Reimplement demolition lock using conditions.

This commit is contained in:
Paul Chote
2018-10-27 17:09:30 +00:00
committed by abcdefg30
parent 0901a7d9de
commit 18b84750aa
25 changed files with 239 additions and 71 deletions

View File

@@ -40,8 +40,6 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new EjectOnDeath(init.Self, this); }
}
public interface IPreventsEjectOnDeath { bool PreventsEjectOnDeath(Actor self); }
public class EjectOnDeath : ConditionalTrait<EjectOnDeathInfo>, INotifyKilled
{
public EjectOnDeath(Actor self, EjectOnDeathInfo info)
@@ -52,10 +50,6 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled || self.Owner.WinState == WinState.Lost || !self.World.Map.Contains(self.Location))
return;
foreach (var condition in self.TraitsImplementing<IPreventsEjectOnDeath>())
if (condition.PreventsEjectOnDeath(self))
return;
var r = self.World.SharedRandom.Next(1, 100);
if (r <= 100 - Info.SuccessRate)