Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse GPSDotEffect for the lifetime of the actor. #16222

Merged
merged 1 commit into from Feb 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions OpenRA.Mods.Cnc/Traits/GpsDot.cs
Expand Up @@ -28,7 +28,7 @@ class GpsDotInfo : ITraitInfo
public object Create(ActorInitializer init) { return new GpsDot(this); }
}

class GpsDot : INotifyAddedToWorld, INotifyRemovedFromWorld
class GpsDot : INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld
{
readonly GpsDotInfo info;
GpsDotEffect effect;
Expand All @@ -38,9 +38,13 @@ public GpsDot(GpsDotInfo info)
this.info = info;
}

void INotifyAddedToWorld.AddedToWorld(Actor self)
void INotifyCreated.Created(Actor self)
{
effect = new GpsDotEffect(self, info);
}

void INotifyAddedToWorld.AddedToWorld(Actor self)
{
self.World.AddFrameEndTask(w => w.Add(effect));
}

Expand Down