Merge pull request #3397 from chrisforbes/target-generations
Target generations
This commit is contained in:
@@ -72,6 +72,7 @@ namespace OpenRA
|
||||
|
||||
Activity currentActivity;
|
||||
public Group Group;
|
||||
public int Generation;
|
||||
|
||||
internal Actor(World world, string name, TypeDictionary initDict )
|
||||
{
|
||||
@@ -272,6 +273,7 @@ namespace OpenRA
|
||||
// momentarily remove from world so the ownership queries don't get confused
|
||||
w.Remove(this);
|
||||
Owner = newOwner;
|
||||
Generation++;
|
||||
w.Add(this);
|
||||
|
||||
foreach (var t in this.TraitsImplementing<INotifyOwnerChanged>())
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace OpenRA.Traits
|
||||
public static Target[] NoTargets = {};
|
||||
|
||||
Actor actor;
|
||||
Player owner;
|
||||
PPos pos;
|
||||
bool valid;
|
||||
int generation;
|
||||
|
||||
public static Target FromActor(Actor a)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
actor = a,
|
||||
valid = (a != null),
|
||||
owner = (a != null) ? a.Owner : null
|
||||
generation = a.Generation,
|
||||
};
|
||||
}
|
||||
public static Target FromPos(PPos p) { return new Target { pos = p, valid = true }; }
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public static readonly Target None = new Target();
|
||||
|
||||
public bool IsValid { get { return valid && (actor == null || (actor.IsInWorld && !actor.IsDead() && actor.Owner == owner)); } }
|
||||
public bool IsValid { get { return valid && (actor == null || (actor.IsInWorld && !actor.IsDead() && actor.Generation == generation)); } }
|
||||
public PPos PxPosition { get { return IsActor ? actor.Trait<IHasLocation>().PxPosition : pos; } }
|
||||
public PPos CenterLocation { get { return PxPosition; } }
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
Sound.Play("chrono2.aud", destination.ToPPos());
|
||||
|
||||
self.Trait<ITeleportable>().SetPosition(self, destination);
|
||||
self.Generation++;
|
||||
|
||||
if (killCargo && self.HasTrait<Cargo>())
|
||||
{
|
||||
@@ -66,6 +67,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
self.Trait<ITeleportable>().SetPosition(self, destination);
|
||||
self.Generation++;
|
||||
return NextActivity;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user