Reuse GPSDotEffect for the lifetime of the actor.

This commit is contained in:
Paul Chote
2019-02-20 18:20:05 +00:00
committed by reaperrr
parent 3b6249323d
commit bf9d06cb12

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Cnc.Traits
public object Create(ActorInitializer init) { return new GpsDot(this); } public object Create(ActorInitializer init) { return new GpsDot(this); }
} }
class GpsDot : INotifyAddedToWorld, INotifyRemovedFromWorld class GpsDot : INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld
{ {
readonly GpsDotInfo info; readonly GpsDotInfo info;
GpsDotEffect effect; GpsDotEffect effect;
@@ -38,9 +38,13 @@ namespace OpenRA.Mods.Cnc.Traits
this.info = info; this.info = info;
} }
void INotifyAddedToWorld.AddedToWorld(Actor self) void INotifyCreated.Created(Actor self)
{ {
effect = new GpsDotEffect(self, info); effect = new GpsDotEffect(self, info);
}
void INotifyAddedToWorld.AddedToWorld(Actor self)
{
self.World.AddFrameEndTask(w => w.Add(effect)); self.World.AddFrameEndTask(w => w.Add(effect));
} }