Skip to content

Commit

Permalink
api(mixins): More object methods exposed
Browse files Browse the repository at this point in the history
  • Loading branch information
Owain94 committed Sep 25, 2021
1 parent 910ff6c commit d657990
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 6 deletions.
5 changes: 5 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public interface Node
*/
Node getPrevious();

/**
* Unlink.
*/
void unlink();

/**
* Gets the hash value of the node.
*
Expand Down
50 changes: 50 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,56 @@ public interface Scene
*/
void removeGameObject(GameObject gameObject);

/**
* Remove a game object from the scene
* @param plane
* @param x
* @param y
*/
void removeGameObject(int plane, int x, int y);

/**
* Remove a game object from the scene
* @param wallObject
*/
void removeWallObject(WallObject wallObject);

/**
* Remove a wall object from the scene
* @param plane
* @param x
* @param y
*/
void removeWallObject(int plane, int x, int y);

/**
* Remove a decorative object from the scene
* @param decorativeObject
*/
void removeDecorativeObject(DecorativeObject decorativeObject);

/**
* Remove a decorative object from the scene
* @param plane
* @param x
* @param y
*/
void removeDecorativeObject(int plane, int x, int y);

/**
* Remove a ground object from the scene
* @param groundObject
*/
void removeGroundObject(GroundObject groundObject);

/**
* Remove a ground object from the scene
* @param plane
* @param x
* @param y
*/
void removeGroundObject(int plane, int x, int y);

void generateHouses();

void setRoofRemovalMode(int flags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
import static net.runelite.api.Constants.ROOF_FLAG_DESTINATION;
import static net.runelite.api.Constants.ROOF_FLAG_HOVERED;
import static net.runelite.api.Constants.ROOF_FLAG_POSITION;
import net.runelite.api.DecorativeObject;
import net.runelite.api.GroundObject;
import net.runelite.api.Perspective;
import net.runelite.api.SceneTileModel;
import net.runelite.api.SceneTilePaint;
import net.runelite.api.Tile;
import net.runelite.api.WallObject;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.hooks.DrawCallbacks;
Expand Down Expand Up @@ -1240,4 +1243,61 @@ public void setTileShapes(byte[][][] tileShapes)
{
rl$tileShapes = tileShapes;
}

@Inject
@Override
public void removeWallObject(WallObject wallObject)
{
final Tile[][][] tiles = getTiles();

for (int y = 0; y < 104; ++y)
{
for (int x = 0; x < 104; ++x)
{
Tile tile = tiles[client.getPlane()][x][y];
if (tile != null && tile.getWallObject() == wallObject)
{
tile.setWallObject(null);
}
}
}
}

@Inject
@Override
public void removeDecorativeObject(DecorativeObject decorativeObject)
{
final Tile[][][] tiles = getTiles();

for (int y = 0; y < 104; ++y)
{
for (int x = 0; x < 104; ++x)
{
Tile tile = tiles[client.getPlane()][x][y];
if (tile != null && tile.getDecorativeObject() == decorativeObject)
{
tile.setDecorativeObject(null);
}
}
}
}

@Inject
@Override
public void removeGroundObject(GroundObject groundObject)
{
final Tile[][][] tiles = getTiles();

for (int y = 0; y < 104; ++y)
{
for (int x = 0; x < 104; ++x)
{
Tile tile = tiles[client.getPlane()][x][y];
if (tile != null && tile.getGroundObject() == groundObject)
{
tile.setGroundObject(null);
}
}
}
}
}
21 changes: 21 additions & 0 deletions runescape-api/src/main/java/net/runelite/rs/api/RSScene.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package net.runelite.rs.api;

import net.runelite.api.DecorativeObject;
import net.runelite.api.GameObject;
import net.runelite.api.GroundObject;
import net.runelite.api.Scene;
import net.runelite.api.Tile;
import net.runelite.api.WallObject;
import net.runelite.mapping.Import;

public interface RSScene extends Scene
Expand Down Expand Up @@ -56,6 +59,24 @@ public interface RSScene extends Scene
@Import("removeGameObject")
void removeGameObject(GameObject gameObject);

@Import("removeGameObject")
void removeGameObject(int plane, int x, int y);

void removeWallObject(WallObject wallObject);

@Import("removeBoundaryObject")
void removeWallObject(int plane, int x, int y);

void removeDecorativeObject(DecorativeObject decorativeObject);

@Import("removeWallDecoration")
void removeDecorativeObject(int plane, int x, int y);

void removeGroundObject(GroundObject groundObject);

@Import("removeFloorDecoration")
void removeGroundObject(int plane, int x, int y);

byte[][][] getUnderlayIds();
void setUnderlayIds(byte[][][] underlayIds);

Expand Down
9 changes: 6 additions & 3 deletions runescape-client/src/main/java/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,8 @@ public void removeGroundItemPile(int var1, int var2, int var3) {
@ObfuscatedSignature(
descriptor = "(III)Lhn;"
)
public BoundaryObject method4155(int var1, int var2, int var3) {
@Export("getBoundaryObject")
public BoundaryObject getBoundaryObject(int var1, int var2, int var3) {
Tile var4 = this.tiles[var1][var2][var3];
return var4 == null ? null : var4.boundaryObject;
}
Expand All @@ -730,7 +731,8 @@ public BoundaryObject method4155(int var1, int var2, int var3) {
@ObfuscatedSignature(
descriptor = "(III)Lhh;"
)
public WallDecoration method4156(int var1, int var2, int var3) {
@Export("getWallDecoration")
public WallDecoration getWallDecoration(int var1, int var2, int var3) {
Tile var4 = this.tiles[var1][var2][var3];
return var4 == null ? null : var4.wallDecoration;
}
Expand All @@ -739,7 +741,8 @@ public WallDecoration method4156(int var1, int var2, int var3) {
@ObfuscatedSignature(
descriptor = "(III)Lhj;"
)
public GameObject method4180(int var1, int var2, int var3) {
@Export("getGameObject")
public GameObject getGameObject(int var1, int var2, int var3) {
Tile var4 = this.tiles[var1][var2][var3];
if (var4 == null) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions runescape-client/src/main/java/ScriptFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static final void method1086(class240 var0) {
var9 = Client.field549[var7];
if (var3 >= 0 && var4 >= 0 && var3 < 103 && var4 < 103) {
if (var9 == 0) {
BoundaryObject var33 = CollisionMap.scene.method4155(class391.Client_plane, var3, var4);
BoundaryObject var33 = CollisionMap.scene.getBoundaryObject(class391.Client_plane, var3, var4);
if (var33 != null) {
var11 = HealthBarDefinition.Entity_unpackID(var33.tag);
if (var7 == 2) {
Expand All @@ -425,7 +425,7 @@ static final void method1086(class240 var0) {
}

if (var9 == 1) {
WallDecoration var43 = CollisionMap.scene.method4156(class391.Client_plane, var3, var4);
WallDecoration var43 = CollisionMap.scene.getWallDecoration(class391.Client_plane, var3, var4);
if (var43 != null) {
var11 = HealthBarDefinition.Entity_unpackID(var43.tag);
if (var7 != 4 && var7 != 5) {
Expand All @@ -444,7 +444,7 @@ static final void method1086(class240 var0) {
}

if (var9 == 2) {
GameObject var44 = CollisionMap.scene.method4180(class391.Client_plane, var3, var4);
GameObject var44 = CollisionMap.scene.getGameObject(class391.Client_plane, var3, var4);
if (var7 == 11) {
var7 = 10;
}
Expand Down

0 comments on commit d657990

Please sign in to comment.