Reuse GPSDotEffect for the lifetime of the actor.
This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user