use of net.runelite.api.events.GameObjectChanged in project runelite by runelite.
the class RSTileMixin method gameObjectsChanged.
@FieldHook("objects")
@Inject
public void gameObjectsChanged(int idx) {
if (// this happens from the field assignment
idx == -1) {
return;
}
if (previousGameObjects == null) {
previousGameObjects = new GameObject[5];
}
// Previous game object
GameObject previous = previousGameObjects[idx];
// GameObject that was changed.
RSGameObject current = (RSGameObject) getGameObjects()[idx];
// Last game object
GameObject last = lastGameObject;
// Update last game object
lastGameObject = current;
// Update previous object to current
previousGameObjects[idx] = current;
// Duplicate event, return
if (current != null && current.equals(last)) {
return;
}
// Characters seem to generate a constant stream of new GameObjects
if (current == null || !(current.getRenderable() instanceof Actor)) {
if (current == null && previous != null) {
GameObjectDespawned gameObjectDespawned = new GameObjectDespawned();
gameObjectDespawned.setTile(this);
gameObjectDespawned.setGameObject(previous);
eventBus.post(gameObjectDespawned);
} else if (current != null && previous == null) {
GameObjectSpawned gameObjectSpawned = new GameObjectSpawned();
gameObjectSpawned.setTile(this);
gameObjectSpawned.setGameObject(current);
eventBus.post(gameObjectSpawned);
} else if (current != null && previous != null) {
GameObjectChanged gameObjectsChanged = new GameObjectChanged();
gameObjectsChanged.setTile(this);
gameObjectsChanged.setPrevious(previous);
gameObjectsChanged.setGameObject(current);
eventBus.post(gameObjectsChanged);
}
}
}
Aggregations