diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index d8669e748a..50d31c0096 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -318,7 +318,10 @@ namespace OpenRA.Traits } public interface IRenderOverlay { void Render(WorldRenderer wr); } + + [RequireExplicitImplementation] public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); } + [RequireExplicitImplementation] public interface INotifyIdle { void TickIdle(Actor self); } public interface IRenderAboveWorld { void RenderAboveWorld(Actor self, WorldRenderer wr); } diff --git a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs index 5b7b9ba882..ba3a4332ea 100644 --- a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs +++ b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs @@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Scripting return Triggerables(trigger).Count > 0; } - public void TickIdle(Actor self) + void INotifyIdle.TickIdle(Actor self) { if (world.Disposing) return; diff --git a/OpenRA.Mods.Common/Traits/Air/FlyAwayOnIdle.cs b/OpenRA.Mods.Common/Traits/Air/FlyAwayOnIdle.cs index 7d52e0898e..601a98a1a7 100644 --- a/OpenRA.Mods.Common/Traits/Air/FlyAwayOnIdle.cs +++ b/OpenRA.Mods.Common/Traits/Air/FlyAwayOnIdle.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits class FlyAwayOnIdle : INotifyIdle { - public void TickIdle(Actor self) + void INotifyIdle.TickIdle(Actor self) { self.QueueActivity(new FlyOffMap(self)); self.QueueActivity(new RemoveSelf()); diff --git a/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs b/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs index bbc33cb2ef..08cbaaf9f6 100644 --- a/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs +++ b/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits aircraftInfo = self.Info.TraitInfo(); } - public void TickIdle(Actor self) + void INotifyIdle.TickIdle(Actor self) { // We're on the ground, let's stay there. if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude) diff --git a/OpenRA.Mods.Common/Traits/AttackMove.cs b/OpenRA.Mods.Common/Traits/AttackMove.cs index 000453773a..7a997c4e2f 100644 --- a/OpenRA.Mods.Common/Traits/AttackMove.cs +++ b/OpenRA.Mods.Common/Traits/AttackMove.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits self.QueueActivity(new AttackMoveActivity(self, move.MoveTo(TargetLocation.Value, 1))); } - public void TickIdle(Actor self) + void INotifyIdle.TickIdle(Actor self) { // This might cause the actor to be stuck if the target location is unreachable if (TargetLocation.HasValue && self.Location != TargetLocation.Value) diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index 085187ffc1..ed179ee14b 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Traits Attack(self, Aggressor, allowMove); } - public void TickIdle(Actor self) + void INotifyIdle.TickIdle(Actor self) { if (IsTraitDisabled || Stance < UnitStance.Defend) return; diff --git a/OpenRA.Mods.Common/Traits/Wanders.cs b/OpenRA.Mods.Common/Traits/Wanders.cs index 1dad232b2f..a41d69ded2 100644 --- a/OpenRA.Mods.Common/Traits/Wanders.cs +++ b/OpenRA.Mods.Common/Traits/Wanders.cs @@ -57,12 +57,17 @@ namespace OpenRA.Mods.Common.Traits base.Created(self); } - public virtual void OnBecomingIdle(Actor self) + protected virtual void OnBecomingIdle(Actor self) { countdown = self.World.SharedRandom.Next(info.MinMoveDelay, info.MaxMoveDelay); } - public virtual void TickIdle(Actor self) + void INotifyBecomingIdle.OnBecomingIdle(Actor self) + { + OnBecomingIdle(self); + } + + protected virtual void TickIdle(Actor self) { if (IsTraitDisabled) return; @@ -83,6 +88,11 @@ namespace OpenRA.Mods.Common.Traits DoAction(self, targetCell); } + void INotifyIdle.TickIdle(Actor self) + { + TickIdle(self); + } + CPos PickTargetLocation() { var target = self.CenterPosition + new WVec(0, -1024 * effectiveMoveRadius, 0).Rotate(WRot.FromFacing(self.World.SharedRandom.Next(255)));