Prevent multiple Transforms from triggering in the same tick.
This leads to actor duplication.
This commit is contained in:
@@ -42,6 +42,7 @@ namespace OpenRA
|
|||||||
public Player Owner { get; internal set; }
|
public Player Owner { get; internal set; }
|
||||||
|
|
||||||
public bool IsInWorld { get; internal set; }
|
public bool IsInWorld { get; internal set; }
|
||||||
|
public bool WillDispose { get; private set; }
|
||||||
public bool Disposed { get; private set; }
|
public bool Disposed { get; private set; }
|
||||||
|
|
||||||
public Activity CurrentActivity { get; private set; }
|
public Activity CurrentActivity { get; private set; }
|
||||||
@@ -284,6 +285,9 @@ namespace OpenRA
|
|||||||
if (CurrentActivity != null)
|
if (CurrentActivity != null)
|
||||||
CurrentActivity.RootActivity.OnActorDisposeOuter(this);
|
CurrentActivity.RootActivity.OnActorDisposeOuter(this);
|
||||||
|
|
||||||
|
// Allow traits/activities to prevent a race condition when they depend on disposing the actor (e.g. Transforms)
|
||||||
|
WillDispose = true;
|
||||||
|
|
||||||
World.AddFrameEndTask(w =>
|
World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
if (Disposed)
|
if (Disposed)
|
||||||
|
|||||||
@@ -204,6 +204,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (self.WillDispose)
|
||||||
|
return;
|
||||||
|
|
||||||
if (triggered)
|
if (triggered)
|
||||||
health.InflictDamage(self, chronosphere, new Damage(info.Damage, info.DamageTypes), true);
|
health.InflictDamage(self, chronosphere, new Damage(info.Damage, info.DamageTypes), true);
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
if (self.IsDead)
|
if (self.IsDead || self.WillDispose)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
||||||
|
|||||||
Reference in New Issue
Block a user