Properly remove worms from the world

This commit is contained in:
penev92
2015-03-05 22:22:08 +02:00
parent 58ab28206f
commit 4a5b3b59ed
2 changed files with 4 additions and 5 deletions

View File

@@ -75,6 +75,9 @@ namespace OpenRA.Mods.Common.Traits
|| self.Owner.Stances[actor.Actor.Owner] != Stance.Enemy)
continue;
if (actor.Actor.IsDead || !actor.Actor.IsInWorld)
continue;
// The actor is not currently visible
if (!self.Owner.Shroud.IsVisible(actor.Actor))
continue;

View File

@@ -115,11 +115,7 @@ namespace OpenRA.Mods.D2k.Activities
if (self.World.SharedRandom.Next() % 100 <= sandworm.Info.ChanceToDisappear)
{
self.CancelActivity();
self.World.AddFrameEndTask(w => w.Remove(self));
var wormManager = self.World.WorldActor.TraitOrDefault<WormManager>();
if (wormManager != null)
wormManager.DecreaseWormCount();
self.World.AddFrameEndTask(w => self.Kill(self));
}
else
renderUnit.DefaultAnimation.ReplaceAnim("idle");