diff --git a/OpenRA.Game/Activities/Activity.cs b/OpenRA.Game/Activities/Activity.cs index dba148f940..124db71267 100644 --- a/OpenRA.Game/Activities/Activity.cs +++ b/OpenRA.Game/Activities/Activity.cs @@ -46,7 +46,7 @@ namespace OpenRA.Activities { public static IEnumerable GetTargetQueue(this Actor self) { - return self.GetCurrentActivity() + return self.CurrentActivity .Iterate(u => u.NextActivity) .TakeWhile(u => u != null) .SelectMany(u => u.GetTargets(self)); diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index ef5a6e6d7f..17cb712691 100644 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -43,7 +43,7 @@ namespace OpenRA public bool IsInWorld { get; internal set; } public bool Disposed { get; private set; } - Activity currentActivity; + public Activity CurrentActivity { get; private set; } public Group Group; public int Generation; @@ -54,7 +54,7 @@ namespace OpenRA public IOccupySpace OccupiesSpace { get; private set; } public ITargetable[] Targetables { get; private set; } - public bool IsIdle { get { return currentActivity == null; } } + public bool IsIdle { get { return CurrentActivity == null; } } public bool IsDead { get { return Disposed || (health != null && health.IsDead); } } public CPos Location { get { return OccupiesSpace.TopLeft; } } @@ -161,7 +161,7 @@ namespace OpenRA public void Tick() { var wasIdle = IsIdle; - currentActivity = ActivityUtils.RunActivity(this, currentActivity); + CurrentActivity = ActivityUtils.RunActivity(this, CurrentActivity); if (!wasIdle && IsIdle) foreach (var n in TraitsImplementing()) @@ -200,21 +200,16 @@ namespace OpenRA public void QueueActivity(Activity nextActivity) { - if (currentActivity == null) - currentActivity = nextActivity; + if (CurrentActivity == null) + CurrentActivity = nextActivity; else - currentActivity.Queue(nextActivity); + CurrentActivity.Queue(nextActivity); } public void CancelActivity() { - if (currentActivity != null) - currentActivity.Cancel(this); - } - - public Activity GetCurrentActivity() - { - return currentActivity; + if (CurrentActivity != null) + CurrentActivity.Cancel(this); } public override int GetHashCode() diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 443a887fb0..9338d9bb72 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -794,8 +794,7 @@ namespace OpenRA.Mods.Common.AI if (!harvester.IsIdle) { - var act = harvester.GetCurrentActivity(); - + var act = harvester.CurrentActivity; if (act.NextActivity == null || act.NextActivity.GetType() != typeof(FindResources)) continue; } diff --git a/OpenRA.Mods.Common/AI/States/AirStates.cs b/OpenRA.Mods.Common/AI/States/AirStates.cs index ad6abe6119..0a14e6f347 100644 --- a/OpenRA.Mods.Common/AI/States/AirStates.cs +++ b/OpenRA.Mods.Common/AI/States/AirStates.cs @@ -125,10 +125,10 @@ namespace OpenRA.Mods.Common.AI protected static bool IsRearm(Actor a) { - var activity = a.GetCurrentActivity(); - if (activity == null) + if (a.IsIdle) return false; + var activity = a.CurrentActivity; var type = activity.GetType(); if (type == typeof(Rearm) || type == typeof(ResupplyAircraft)) return true; diff --git a/OpenRA.Mods.Common/AI/States/StateBase.cs b/OpenRA.Mods.Common/AI/States/StateBase.cs index 2f2e03c79a..9bd180b170 100644 --- a/OpenRA.Mods.Common/AI/States/StateBase.cs +++ b/OpenRA.Mods.Common/AI/States/StateBase.cs @@ -44,15 +44,16 @@ namespace OpenRA.Mods.Common.AI if (a.IsIdle) return false; - var type = a.GetCurrentActivity().GetType(); + var activity = a.CurrentActivity; + var type = activity.GetType(); if (type == typeof(Attack) || type == typeof(FlyAttack)) return true; - var next = a.GetCurrentActivity().NextActivity; + var next = activity.NextActivity; if (next == null) return false; - var nextType = a.GetCurrentActivity().NextActivity.GetType(); + var nextType = next.GetType(); if (nextType == typeof(Attack) || nextType == typeof(FlyAttack)) return true; diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index 5d4ba7be23..d2753d5df2 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -237,7 +237,7 @@ namespace OpenRA.Mods.Common.Traits void INotifyBlockingMove.OnNotifyBlockingMove(Actor self, Actor blocking) { // I'm blocking someone else from moving to my location: - var act = self.GetCurrentActivity(); + var act = self.CurrentActivity; // If I'm just waiting around then get out of the way: if (act is Wait) diff --git a/OpenRA.Mods.Common/Traits/Render/RenderDebugState.cs b/OpenRA.Mods.Common/Traits/Render/RenderDebugState.cs index 6c6ed11f0a..4d23372052 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderDebugState.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderDebugState.cs @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits.Render yield return new TextRenderable(font, self.CenterPosition - offset, 0, color, tagString); // Get the actor's activity. - var activity = self.GetCurrentActivity(); + var activity = self.CurrentActivity; if (activity != null) { var activityName = activity.GetType().ToString().Split('.').Last(); diff --git a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs index 557bf06173..c8b5043ba4 100644 --- a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs +++ b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs @@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits.Render if (!self.IsInWorld || self.IsDead) yield break; - var activity = self.GetCurrentActivity(); + var activity = self.CurrentActivity; if (activity != null) { var targets = activity.GetTargets(self);