Search in sources :

Example 6 with FieldHook

use of net.runelite.api.mixins.FieldHook 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);
        }
    }
}
Also used : GameObjectSpawned(net.runelite.api.events.GameObjectSpawned) RSGameObject(net.runelite.rs.api.RSGameObject) GameObject(net.runelite.api.GameObject) RSGameObject(net.runelite.rs.api.RSGameObject) Actor(net.runelite.api.Actor) GameObjectDespawned(net.runelite.api.events.GameObjectDespawned) GameObjectChanged(net.runelite.api.events.GameObjectChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 7 with FieldHook

use of net.runelite.api.mixins.FieldHook in project runelite by runelite.

the class RSWidgetMixin method onHiddenChanged.

@FieldHook("isHidden")
@Inject
public void onHiddenChanged(int idx) {
    int id = getId();
    if (id == -1) {
        return;
    }
    Widget parent = getParent();
    // so ignore them
    if (parent != null) {
        if (parent.isHidden()) {
            return;
        }
    } else if (TO_GROUP(id) != client.getWidgetRoot()) {
        return;
    }
    broadcastHidden(isSelfHidden());
}
Also used : Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 8 with FieldHook

use of net.runelite.api.mixins.FieldHook in project runelite by runelite.

the class RSActorMixin method graphicChanged.

@FieldHook("graphic")
@Inject
public void graphicChanged(int idx) {
    GraphicChanged graphicChanged = new GraphicChanged();
    graphicChanged.setActor(this);
    eventBus.post(graphicChanged);
}
Also used : GraphicChanged(net.runelite.api.events.GraphicChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 9 with FieldHook

use of net.runelite.api.mixins.FieldHook in project runelite by runelite.

the class RSClientMixin method draggingWidgetChanged.

@FieldHook("draggingWidget")
@Inject
public static void draggingWidgetChanged(int idx) {
    DraggingWidgetChanged draggingWidgetChanged = new DraggingWidgetChanged();
    draggingWidgetChanged.setDraggingWidget(client.isDraggingWidget());
    eventBus.post(draggingWidgetChanged);
}
Also used : DraggingWidgetChanged(net.runelite.api.events.DraggingWidgetChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 10 with FieldHook

use of net.runelite.api.mixins.FieldHook in project runelite by runelite.

the class RSClientMixin method experiencedChanged.

@FieldHook("skillExperiences")
@Inject
public static void experiencedChanged(int idx) {
    ExperienceChanged experienceChanged = new ExperienceChanged();
    Skill[] possibleSkills = Skill.values();
    // We subtract one here because 'Overall' isn't considered a skill that's updated.
    if (idx < possibleSkills.length - 1) {
        Skill updatedSkill = possibleSkills[idx];
        experienceChanged.setSkill(updatedSkill);
        eventBus.post(experienceChanged);
    }
}
Also used : ExperienceChanged(net.runelite.api.events.ExperienceChanged) Skill(net.runelite.api.Skill) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Aggregations

FieldHook (net.runelite.api.mixins.FieldHook)20 Inject (net.runelite.api.mixins.Inject)20 Skill (net.runelite.api.Skill)2 Actor (net.runelite.api.Actor)1 DecorativeObject (net.runelite.api.DecorativeObject)1 GameObject (net.runelite.api.GameObject)1 GrandExchangeOffer (net.runelite.api.GrandExchangeOffer)1 GroundObject (net.runelite.api.GroundObject)1 MenuAction (net.runelite.api.MenuAction)1 Point (net.runelite.api.Point)1 WallObject (net.runelite.api.WallObject)1 AnimationChanged (net.runelite.api.events.AnimationChanged)1 BoostedLevelChanged (net.runelite.api.events.BoostedLevelChanged)1 DecorativeObjectChanged (net.runelite.api.events.DecorativeObjectChanged)1 DecorativeObjectDespawned (net.runelite.api.events.DecorativeObjectDespawned)1 DecorativeObjectSpawned (net.runelite.api.events.DecorativeObjectSpawned)1 DraggingWidgetChanged (net.runelite.api.events.DraggingWidgetChanged)1 ExperienceChanged (net.runelite.api.events.ExperienceChanged)1 GameObjectChanged (net.runelite.api.events.GameObjectChanged)1 GameObjectDespawned (net.runelite.api.events.GameObjectDespawned)1