Fix a crash when RallyPoint creates RallyPointIndicator
This commit is contained in:
committed by
Matthias Mailänder
parent
0c32fca6c0
commit
628cc837ef
@@ -58,16 +58,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RallyPoint : IIssueOrder, IResolveOrder, INotifyOwnerChanged, INotifyCreated
|
public class RallyPoint : IIssueOrder, IResolveOrder, INotifyOwnerChanged, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||||
{
|
{
|
||||||
const string OrderID = "SetRallyPoint";
|
const string OrderID = "SetRallyPoint";
|
||||||
|
const uint ForceSet = 1;
|
||||||
|
|
||||||
public List<CPos> Path;
|
public List<CPos> Path;
|
||||||
|
|
||||||
public RallyPointInfo Info;
|
public RallyPointInfo Info;
|
||||||
public string PaletteName { get; private set; }
|
public string PaletteName { get; private set; }
|
||||||
|
RallyPointIndicator effect;
|
||||||
const uint ForceSet = 1;
|
|
||||||
|
|
||||||
public void ResetPath(Actor self)
|
public void ResetPath(Actor self)
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
{
|
{
|
||||||
self.World.Add(new RallyPointIndicator(self, this));
|
effect = new RallyPointIndicator(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
@@ -138,6 +138,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return order.OrderString == OrderID && order.ExtraData == ForceSet;
|
return order.OrderString == OrderID && order.ExtraData == ForceSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
|
{
|
||||||
|
self.World.AddFrameEndTask(w => w.Add(effect));
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||||
|
{
|
||||||
|
self.World.AddFrameEndTask(w => w.Remove(effect));
|
||||||
|
}
|
||||||
|
|
||||||
sealed class RallyPointOrderTargeter : IOrderTargeter
|
sealed class RallyPointOrderTargeter : IOrderTargeter
|
||||||
{
|
{
|
||||||
readonly RallyPointInfo info;
|
readonly RallyPointInfo info;
|
||||||
|
|||||||
Reference in New Issue
Block a user