Prevent throwing duplacite events for GameObject
Store last gameObject as static variable in tile mixin and in case new event is exactly same as last one in game object spawned, do not proceed. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -58,6 +58,9 @@ public abstract class RSTileMixin implements RSTile
|
|||||||
@Shadow("clientInstance")
|
@Shadow("clientInstance")
|
||||||
private static RSClient client;
|
private static RSClient client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private static GameObject lastGameObject;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private WallObject previousWallObject;
|
private WallObject previousWallObject;
|
||||||
|
|
||||||
@@ -208,12 +211,25 @@ public abstract class RSTileMixin implements RSTile
|
|||||||
|
|
||||||
// Previous game object
|
// Previous game object
|
||||||
GameObject previous = previousGameObjects[idx];
|
GameObject previous = previousGameObjects[idx];
|
||||||
|
|
||||||
// GameObject that was changed.
|
// GameObject that was changed.
|
||||||
RSGameObject current = (RSGameObject) getGameObjects()[idx];
|
RSGameObject current = (RSGameObject) getGameObjects()[idx];
|
||||||
|
|
||||||
|
// Last game object
|
||||||
|
GameObject last = lastGameObject;
|
||||||
|
|
||||||
|
// Update last game object
|
||||||
|
lastGameObject = current;
|
||||||
|
|
||||||
// Update previous object to current
|
// Update previous object to current
|
||||||
previousGameObjects[idx] = current;
|
previousGameObjects[idx] = current;
|
||||||
|
|
||||||
|
// Duplicate event, return
|
||||||
|
if (current != null && current.equals(last))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Characters seem to generate a constant stream of new GameObjects
|
// Characters seem to generate a constant stream of new GameObjects
|
||||||
if (current == null || !(current.getRenderable() instanceof Actor))
|
if (current == null || !(current.getRenderable() instanceof Actor))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user