From c983dda0778f7c64f025c717f6db8eb22a184e2c Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 12 Aug 2018 17:22:43 +0200 Subject: [PATCH] Fix husks not updating targetable positions on teleport This should have checked for IPositionableInfo to begin with. Husk already implements IPositionable, so implementing *Info as well makes sense, even if it only serves to exclude it from ITargetablePositions caching for now. --- OpenRA.Game/Actor.cs | 4 ++-- OpenRA.Mods.Common/Traits/Husk.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 43b8a7b9ec..7e9b402620 100644 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -124,9 +124,9 @@ namespace OpenRA world.AddFrameEndTask(w => { // Caching this in a AddFrameEndTask, because trait construction order might cause problems if done directly at creation time. - // All actors that can move should have IMove, if not it's pretty safe to assume the actor is immobile and + // All actors that can move or teleport should have IPositionable, if not it's pretty safe to assume the actor is completely immobile and // all targetable positions can be cached if all ITargetablePositions have no conditional requirements. - if (!Info.HasTraitInfo() && targetablePositions.Any() && targetablePositions.All(tp => tp.AlwaysEnabled)) + if (!Info.HasTraitInfo() && targetablePositions.Any() && targetablePositions.All(tp => tp.AlwaysEnabled)) staticTargetablePositions = targetablePositions.SelectMany(tp => tp.TargetablePositions(this)).ToArray(); }); diff --git a/OpenRA.Mods.Common/Traits/Husk.cs b/OpenRA.Mods.Common/Traits/Husk.cs index 3b97aa3cea..8960b42845 100644 --- a/OpenRA.Mods.Common/Traits/Husk.cs +++ b/OpenRA.Mods.Common/Traits/Husk.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Spawns remains of a husk actor with the correct facing.")] - public class HuskInfo : ITraitInfo, IOccupySpaceInfo, IFacingInfo, IActorPreviewInitInfo + public class HuskInfo : ITraitInfo, IPositionableInfo, IFacingInfo, IActorPreviewInitInfo { public readonly HashSet AllowedTerrain = new HashSet(); @@ -41,6 +41,13 @@ namespace OpenRA.Mods.Common.Traits } bool IOccupySpaceInfo.SharesCell { get { return false; } } + + public bool CanEnterCell(World world, Actor self, CPos cell, Actor ignoreActor = null, bool checkTransientActors = true) + { + // IPositionable*Info*.CanEnterCell is only ever used for things like exiting production facilities, + // all places relevant for husks check IPositionable.CanEnterCell instead, so we can safely set this to true. + return true; + } } public class Husk : IPositionable, IFacing, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld,