Search in sources :

Example 1 with DecorativeObjectSpawned

use of net.runelite.api.events.DecorativeObjectSpawned 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 DecorativeObjectSpawned

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

the class RSTileMixin method decorativeObjectChanged.

@FieldHook("decorativeObject")
@Inject
public void decorativeObjectChanged(int idx) {
    DecorativeObject previous = previousDecorativeObject;
    DecorativeObject current = getDecorativeObject();
    previousDecorativeObject = current;
    if (current == null && previous != null) {
        DecorativeObjectDespawned decorativeObjectDespawned = new DecorativeObjectDespawned();
        decorativeObjectDespawned.setTile(this);
        decorativeObjectDespawned.setDecorativeObject(previous);
        eventBus.post(decorativeObjectDespawned);
    } else if (current != null && previous == null) {
        DecorativeObjectSpawned decorativeObjectSpawned = new DecorativeObjectSpawned();
        decorativeObjectSpawned.setTile(this);
        decorativeObjectSpawned.setDecorativeObject(current);
        eventBus.post(decorativeObjectSpawned);
    } else if (current != null && previous != null) {
        DecorativeObjectChanged decorativeObjectChanged = new DecorativeObjectChanged();
        decorativeObjectChanged.setTile(this);
        decorativeObjectChanged.setPrevious(previous);
        decorativeObjectChanged.setDecorativeObject(current);
        eventBus.post(decorativeObjectChanged);
    }
}
Also used : DecorativeObjectDespawned(net.runelite.api.events.DecorativeObjectDespawned) DecorativeObjectChanged(net.runelite.api.events.DecorativeObjectChanged) DecorativeObject(net.runelite.api.DecorativeObject) DecorativeObjectSpawned(net.runelite.api.events.DecorativeObjectSpawned) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Aggregations

DecorativeObjectSpawned (net.runelite.api.events.DecorativeObjectSpawned)2 DecorativeObject (net.runelite.api.DecorativeObject)1 DecorativeObjectChanged (net.runelite.api.events.DecorativeObjectChanged)1 DecorativeObjectDespawned (net.runelite.api.events.DecorativeObjectDespawned)1 GameObjectSpawned (net.runelite.api.events.GameObjectSpawned)1 GroundObjectSpawned (net.runelite.api.events.GroundObjectSpawned)1 WallObjectSpawned (net.runelite.api.events.WallObjectSpawned)1 FieldHook (net.runelite.api.mixins.FieldHook)1 Inject (net.runelite.api.mixins.Inject)1