mixins: fix duplicate spawn events for large gameobjects

This commit is contained in:
Adam
2019-06-06 09:56:03 -04:00
parent 72468f251c
commit 59886b084a

View File

@@ -76,6 +76,9 @@ public abstract class RSTileMixin implements RSTile
@Shadow("clientInstance")
private static RSClient client;
@Inject
private static RSGameObject lastGameObject;
@Inject
private static RSDeque[][][] lastGroundItems = new RSDeque[Constants.MAX_Z][Constants.SCENE_SIZE][Constants.SCENE_SIZE];
@@ -234,12 +237,26 @@ public abstract class RSTileMixin implements RSTile
// Update previous object to current
previousGameObjects[idx] = current;
// Last game object
RSGameObject last = lastGameObject;
// Update last game object
lastGameObject = current;
// Duplicate event, return
if (current == previous)
{
return;
}
if (current != null && current == last)
{
// When >1 tile objects are added to the scene, the same GameObject is added to
// multiple tiles. We keep lastGameObject to prevent duplicate spawn events from
// firing for these objects.
return;
}
// actors, projectiles, and graphics objects are added and removed from the scene each frame as GameObjects,
// so ignore them.
boolean currentInvalid = false, prevInvalid = false;