Convert game thread events to singletons (#794)

* Convert game thread events to singletons

* Fix checkstyle

* Fix copy paste error
This commit is contained in:
Owain van Brakel
2019-06-28 22:11:57 +02:00
committed by James
parent 23f6463024
commit 38d9800d10
102 changed files with 756 additions and 220 deletions

View File

@@ -186,7 +186,7 @@ public abstract class RSActorMixin implements RSActor
@Inject
public void animationChanged(int idx)
{
AnimationChanged animationChange = new AnimationChanged();
AnimationChanged animationChange = AnimationChanged.INSTANCE;
animationChange.setActor(this);
client.getCallbacks().post(animationChange);
}
@@ -195,7 +195,7 @@ public abstract class RSActorMixin implements RSActor
@Inject
public void spotAnimationChanged(int idx)
{
SpotAnimationChanged spotAnimationChanged = new SpotAnimationChanged();
SpotAnimationChanged spotAnimationChanged = SpotAnimationChanged.INSTANCE;
spotAnimationChanged.setActor(this);
client.getCallbacks().post(spotAnimationChanged);
}
@@ -204,7 +204,9 @@ public abstract class RSActorMixin implements RSActor
@Inject
public void interactingChanged(int idx)
{
InteractingChanged interactingChanged = new InteractingChanged(this, getInteracting());
InteractingChanged interactingChanged = InteractingChanged.INSTANCE;
interactingChanged.setSource(this);
interactingChanged.setTarget(getInteracting());
client.getCallbacks().post(interactingChanged);
}
@@ -215,7 +217,10 @@ public abstract class RSActorMixin implements RSActor
String overheadText = getOverheadText();
if (overheadText != null)
{
OverheadTextChanged overheadTextChanged = new OverheadTextChanged(this, overheadText);
OverheadTextChanged overheadTextChanged = OverheadTextChanged.INSTANCE;
overheadTextChanged.setActor(this);
overheadTextChanged.setOverheadText(overheadText);
client.getCallbacks().post(overheadTextChanged);
}
}
@@ -251,7 +256,7 @@ public abstract class RSActorMixin implements RSActor
{
client.getLogger().debug("You died!");
LocalPlayerDeath event = new LocalPlayerDeath();
LocalPlayerDeath event = LocalPlayerDeath.INSTANCE;
client.getCallbacks().post(event);
}
else if (this instanceof RSNPC)
@@ -278,7 +283,7 @@ public abstract class RSActorMixin implements RSActor
public void applyActorHitsplat(int type, int value, int var3, int var4, int gameCycle, int duration)
{
final Hitsplat hitsplat = new Hitsplat(Hitsplat.HitsplatType.fromInteger(type), value, gameCycle + duration);
final HitsplatApplied event = new HitsplatApplied();
final HitsplatApplied event = HitsplatApplied.INSTANCE;
event.setActor(this);
event.setHitsplat(hitsplat);
client.getCallbacks().post(event);