use of net.runelite.api.events.GroundObjectSpawned in project runelite by runelite.
the class RegionTileManager method simulateObjectSpawns.
/**
* Simulate object spawns for EventBus subscriber
* @param subscriber EventBus subscriber
*/
public void simulateObjectSpawns(Object subscriber) {
eventBus.register(subscriber);
forEachTile((tile) -> {
Optional.ofNullable(tile.getWallObject()).ifPresent(object -> {
final WallObjectSpawned objectSpawned = new WallObjectSpawned();
objectSpawned.setTile(tile);
objectSpawned.setWallObject(object);
eventBus.post(objectSpawned);
});
Optional.ofNullable(tile.getDecorativeObject()).ifPresent(object -> {
final DecorativeObjectSpawned objectSpawned = new DecorativeObjectSpawned();
objectSpawned.setTile(tile);
objectSpawned.setDecorativeObject(object);
eventBus.post(objectSpawned);
});
Optional.ofNullable(tile.getGroundObject()).ifPresent(object -> {
final GroundObjectSpawned objectSpawned = new GroundObjectSpawned();
objectSpawned.setTile(tile);
objectSpawned.setGroundObject(object);
eventBus.post(objectSpawned);
});
Arrays.stream(tile.getGameObjects()).filter(Objects::nonNull).forEach(object -> {
final GameObjectSpawned objectSpawned = new GameObjectSpawned();
objectSpawned.setTile(tile);
objectSpawned.setGameObject(object);
eventBus.post(objectSpawned);
});
});
eventBus.unregister(subscriber);
}
use of net.runelite.api.events.GroundObjectSpawned in project runelite by runelite.
the class RSTileMixin method groundObjectChanged.
@FieldHook("groundObject")
@Inject
public void groundObjectChanged(int idx) {
GroundObject previous = previousGroundObject;
GroundObject current = getGroundObject();
previousGroundObject = current;
if (current == null && previous != null) {
GroundObjectDespawned groundObjectDespawned = new GroundObjectDespawned();
groundObjectDespawned.setTile(this);
groundObjectDespawned.setGroundObject(previous);
eventBus.post(groundObjectDespawned);
} else if (current != null && previous == null) {
GroundObjectSpawned groundObjectSpawned = new GroundObjectSpawned();
groundObjectSpawned.setTile(this);
groundObjectSpawned.setGroundObject(current);
eventBus.post(groundObjectSpawned);
} else if (current != null && previous != null) {
GroundObjectChanged groundObjectChanged = new GroundObjectChanged();
groundObjectChanged.setTile(this);
groundObjectChanged.setPrevious(previous);
groundObjectChanged.setGroundObject(current);
eventBus.post(groundObjectChanged);
}
}
Aggregations