From 5eaa99827d7c3273a59739b02051867302677236 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 6 Oct 2019 16:14:06 +0100 Subject: [PATCH] Suppress MoveIntoWorldInit for map-placed Mobile actors. --- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 3 +++ OpenRA.Mods.Common/Traits/Mobile.cs | 7 ++++--- OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs | 1 + OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 12d897558b..697b86d6cb 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -251,6 +251,9 @@ namespace OpenRA.Mods.Common.Traits SetPosition(self, init.Get()); Facing = init.Contains() ? init.Get() : Info.InitialFacing; + + // SkipMoveIntoWorldInit is deliberately ignored for Aircraft + // MoveIntoWorld must run for aircraft for map-placed actors to be associated with their airfields moveIntoWorldDelay = init.Contains() ? init.Get() : 0; } diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 8b3a722bc7..46046c6df7 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits { readonly Actor self; readonly Lazy> speedModifiers; - readonly int moveIntoWorldDelay; + readonly int? moveIntoWorldDelay; #region IMove CurrentMovementTypes MovementType movementTypes; @@ -243,7 +243,8 @@ namespace OpenRA.Mods.Common.Traits if (init.Contains()) SetVisualPosition(self, init.Get()); - moveIntoWorldDelay = init.Contains() ? init.Get() : 0; + if (!init.Contains()) + moveIntoWorldDelay = init.Contains() ? init.Get() : 0; } protected override void Created(Actor self) @@ -898,7 +899,7 @@ namespace OpenRA.Mods.Common.Traits Activity ICreationActivity.GetCreationActivity() { - return MoveIntoWorld(self, moveIntoWorldDelay); + return moveIntoWorldDelay.HasValue ? MoveIntoWorld(self, moveIntoWorldDelay.Value) : null; } class MoveOrderTargeter : IOrderTargeter diff --git a/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs b/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs index 8aea1cd7aa..7abb1c0333 100644 --- a/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs +++ b/OpenRA.Mods.Common/Traits/World/SpawnMPUnits.cs @@ -90,6 +90,7 @@ namespace OpenRA.Mods.Common.Traits new LocationInit(sp + unitGroup.BaseActorOffset), new OwnerInit(p), new SkipMakeAnimsInit(), + new SkipMoveIntoWorldInit(), new FacingInit(unitGroup.BaseActorFacing < 0 ? w.SharedRandom.Next(256) : unitGroup.BaseActorFacing), }); } diff --git a/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs b/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs index ca95ed5ff9..5f47e4e95b 100644 --- a/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs +++ b/OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs @@ -41,6 +41,7 @@ namespace OpenRA.Mods.Common.Traits var initDict = actorReference.InitDict; initDict.Add(new SkipMakeAnimsInit()); + initDict.Add(new SkipMoveIntoWorldInit()); initDict.Add(new SpawnedByMapInit(kv.Key)); if (PreventMapSpawn(world, actorReference, preventMapSpawns)) @@ -63,6 +64,7 @@ namespace OpenRA.Mods.Common.Traits } public class SkipMakeAnimsInit : IActorInit, ISuppressInitExport { } + public class SkipMoveIntoWorldInit : IActorInit, ISuppressInitExport { } public class SpawnedByMapInit : IActorInit, ISuppressInitExport { public readonly string Name;