diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index bd055fffd3..96b0fe5cf7 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -194,7 +194,6 @@ - diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index c8d2feb031..2d59e8808c 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -232,6 +232,30 @@ namespace OpenRA.Traits } } + public enum SubCell { Invalid = int.MinValue, Any = int.MinValue / 2, FullCell = 0, First = 1 } + public interface IActorMap + { + IEnumerable GetActorsAt(CPos a); + IEnumerable GetActorsAt(CPos a, SubCell sub); + bool HasFreeSubCell(CPos cell, bool checkTransient = true); + SubCell FreeSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, bool checkTransient = true); + SubCell FreeSubCell(CPos cell, SubCell preferredSubCell, Func checkIfBlocker); + bool AnyActorsAt(CPos a); + bool AnyActorsAt(CPos a, SubCell sub, bool checkTransient = true); + bool AnyActorsAt(CPos a, SubCell sub, Func withCondition); + void AddInfluence(Actor self, IOccupySpace ios); + void RemoveInfluence(Actor self, IOccupySpace ios); + int AddCellTrigger(CPos[] cells, Action onEntry, Action onExit); + void RemoveCellTrigger(int id); + int AddProximityTrigger(WPos pos, WDist range, WDist vRange, Action onEntry, Action onExit); + void RemoveProximityTrigger(int id); + void UpdateProximityTrigger(int id, WPos newPos, WDist newRange, WDist newVRange); + void AddPosition(Actor a, IOccupySpace ios); + void RemovePosition(Actor a, IOccupySpace ios); + void UpdatePosition(Actor a, IOccupySpace ios); + IEnumerable ActorsInBox(WPos a, WPos b); + } + public interface IRenderModifier { IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r); } public interface ILoadsPalettes { void LoadPalettes(WorldRenderer wr); } public interface ILoadsPlayerPalettes { void LoadPlayerPalettes(WorldRenderer wr, string playerName, HSLColor playerColor, bool replaceExisting); } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 646cb6adcc..a6311b4c10 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -14,7 +14,6 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Effects; using OpenRA.FileFormats; -using OpenRA.GameRules; using OpenRA.Graphics; using OpenRA.Network; using OpenRA.Orders; @@ -107,7 +106,7 @@ namespace OpenRA public readonly Map Map; - public readonly ActorMap ActorMap; + public readonly IActorMap ActorMap; public readonly ScreenMap ScreenMap; public readonly WorldType Type; @@ -159,7 +158,7 @@ namespace OpenRA var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World"; WorldActor = CreateActor(worldActorType, new TypeDictionary()); - ActorMap = WorldActor.Trait(); + ActorMap = WorldActor.Trait(); ScreenMap = WorldActor.Trait(); // Add players diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 770fd27890..e8d165d4c7 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -793,6 +793,7 @@ + diff --git a/OpenRA.Game/Traits/World/ActorMap.cs b/OpenRA.Mods.Common/Traits/World/ActorMap.cs similarity index 99% rename from OpenRA.Game/Traits/World/ActorMap.cs rename to OpenRA.Mods.Common/Traits/World/ActorMap.cs index abeb03d136..5a942a480d 100644 --- a/OpenRA.Game/Traits/World/ActorMap.cs +++ b/OpenRA.Mods.Common/Traits/World/ActorMap.cs @@ -14,11 +14,10 @@ using System.Collections; using System.Collections.Generic; using System.Drawing; using System.Linq; +using OpenRA.Traits; -namespace OpenRA.Traits +namespace OpenRA.Mods.Common.Traits { - public enum SubCell { Invalid = int.MinValue, Any = int.MinValue / 2, FullCell = 0, First = 1 } - public class ActorMapInfo : ITraitInfo { [Desc("Size of partition bins (cells)")] @@ -27,7 +26,7 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new ActorMap(init.World, this); } } - public class ActorMap : ITick + public class ActorMap : IActorMap, ITick { class InfluenceNode {