Search in sources :

Example 1 with WallObjectSpawned

use of net.runelite.api.events.WallObjectSpawned 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);
}
Also used : GroundObjectSpawned(net.runelite.api.events.GroundObjectSpawned) GameObjectSpawned(net.runelite.api.events.GameObjectSpawned) DecorativeObjectSpawned(net.runelite.api.events.DecorativeObjectSpawned) WallObjectSpawned(net.runelite.api.events.WallObjectSpawned)

Example 2 with WallObjectSpawned

use of net.runelite.api.events.WallObjectSpawned in project runelite by runelite.

the class RSTileMixin method wallObjectChanged.

@FieldHook("wallObject")
@Inject
public void wallObjectChanged(int idx) {
    WallObject previous = previousWallObject;
    WallObject current = getWallObject();
    previousWallObject = current;
    if (current == null && previous != null) {
        WallObjectDespawned wallObjectDespawned = new WallObjectDespawned();
        wallObjectDespawned.setTile(this);
        wallObjectDespawned.setWallObject(previous);
        eventBus.post(wallObjectDespawned);
    } else if (current != null && previous == null) {
        WallObjectSpawned wallObjectSpawned = new WallObjectSpawned();
        wallObjectSpawned.setTile(this);
        wallObjectSpawned.setWallObject(current);
        eventBus.post(wallObjectSpawned);
    } else if (current != null && previous != null) {
        WallObjectChanged wallObjectChanged = new WallObjectChanged();
        wallObjectChanged.setTile(this);
        wallObjectChanged.setPrevious(previous);
        wallObjectChanged.setWallObject(current);
        eventBus.post(wallObjectChanged);
    }
}
Also used : WallObject(net.runelite.api.WallObject) WallObjectDespawned(net.runelite.api.events.WallObjectDespawned) WallObjectChanged(net.runelite.api.events.WallObjectChanged) WallObjectSpawned(net.runelite.api.events.WallObjectSpawned) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Aggregations

WallObjectSpawned (net.runelite.api.events.WallObjectSpawned)2 WallObject (net.runelite.api.WallObject)1 DecorativeObjectSpawned (net.runelite.api.events.DecorativeObjectSpawned)1 GameObjectSpawned (net.runelite.api.events.GameObjectSpawned)1 GroundObjectSpawned (net.runelite.api.events.GroundObjectSpawned)1 WallObjectChanged (net.runelite.api.events.WallObjectChanged)1 WallObjectDespawned (net.runelite.api.events.WallObjectDespawned)1 FieldHook (net.runelite.api.mixins.FieldHook)1 Inject (net.runelite.api.mixins.Inject)1