diff --git a/OpenRA.Mods.RA/Immobile.cs b/OpenRA.Mods.RA/Immobile.cs index 424395b6c7..8fa3d6a8c1 100644 --- a/OpenRA.Mods.RA/Immobile.cs +++ b/OpenRA.Mods.RA/Immobile.cs @@ -16,20 +16,27 @@ namespace OpenRA.Mods.RA { class ImmobileInfo : ITraitInfo, IOccupySpaceInfo { - public object Create(ActorInitializer init) { return new Immobile(init); } + public readonly bool OccupiesSpace = true; + public object Create(ActorInitializer init) { return new Immobile(init, this); } } class Immobile : IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld { [Sync] readonly CPos location; + readonly IEnumerable> occupied; - public Immobile(ActorInitializer init) + public Immobile(ActorInitializer init, ImmobileInfo info) { this.location = init.Get(); + + if (info.OccupiesSpace) + occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) }; + else + occupied = new Pair[0]; } public CPos TopLeft { get { return location; } } - public IEnumerable> OccupiedCells() { yield break; } + public IEnumerable> OccupiedCells() { return occupied; } public WPos CenterPosition { get { return location.CenterPosition; } } public void AddedToWorld(Actor self) diff --git a/OpenRA.Mods.RA/Mine.cs b/OpenRA.Mods.RA/Mine.cs index 4e7f24d662..04651e95db 100644 --- a/OpenRA.Mods.RA/Mine.cs +++ b/OpenRA.Mods.RA/Mine.cs @@ -25,17 +25,15 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new Mine(init, this); } } - class Mine : ICrushable, IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld + class Mine : ICrushable { readonly Actor self; readonly MineInfo info; - [Sync] readonly CPos location; public Mine(ActorInitializer init, MineInfo info) { this.self = init.self; this.info = info; - this.location = init.Get(); } public void WarnCrush(Actor crusher) {} @@ -56,25 +54,6 @@ namespace OpenRA.Mods.RA { return info.CrushClasses.Intersect(crushClasses).Any(); } - - public CPos TopLeft { get { return location; } } - - public IEnumerable> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); } - public WPos CenterPosition { get { return location.CenterPosition; } } - - public void AddedToWorld(Actor self) - { - self.World.ActorMap.AddInfluence(self, this); - self.World.ActorMap.AddPosition(self, this); - self.World.ScreenMap.Add(self); - } - - public void RemovedFromWorld(Actor self) - { - self.World.ActorMap.RemoveInfluence(self, this); - self.World.ActorMap.RemovePosition(self, this); - self.World.ScreenMap.Remove(self); - } } /* tag trait for stuff that shouldnt trigger mines */ diff --git a/OpenRA.Utility/UpgradeRules.cs b/OpenRA.Utility/UpgradeRules.cs index 33770fd3d1..2202893a53 100644 --- a/OpenRA.Utility/UpgradeRules.cs +++ b/OpenRA.Utility/UpgradeRules.cs @@ -163,6 +163,17 @@ namespace OpenRA.Utility node.Key = "RenderDisguise"; } + // IOccupySpace was removed from Mine + if (engineVersion < 20140320) + { + if (depth == 0 && node.Value.Nodes.Any(n => n.Key == "Mine")) + node.Value.Nodes.Add(new MiniYamlNode("Immobile", new MiniYaml("", new List() { new MiniYamlNode("OccupiesSpace", "true") }))); + else + foreach (var i in nodes.Where(n => n.Key == "Immobile")) + if (!i.Value.Nodes.Any(n => n.Key == "OccupiesSpace")) + i.Value.Nodes.Add(new MiniYamlNode("OccupiesSpace", "false")); + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/cnc/rules/system-actors.yaml b/mods/cnc/rules/system-actors.yaml index 27a1412a54..9b4fe0aeb8 100644 --- a/mods/cnc/rules/system-actors.yaml +++ b/mods/cnc/rules/system-actors.yaml @@ -32,16 +32,19 @@ CRATE: mpspawn: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: waypoint: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: CAMERA: Immobile: + OccupiesSpace: false Health: HP: 1000 RevealsShroud: diff --git a/mods/d2k/rules/system-actors.yaml b/mods/d2k/rules/system-actors.yaml index 4542a03daa..4ee97c7222 100644 --- a/mods/d2k/rules/system-actors.yaml +++ b/mods/d2k/rules/system-actors.yaml @@ -86,11 +86,13 @@ CRATE: mpspawn: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: waypoint: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: diff --git a/mods/ra/rules/system-actors.yaml b/mods/ra/rules/system-actors.yaml index 572fcbd3d6..4a71b389bb 100644 --- a/mods/ra/rules/system-actors.yaml +++ b/mods/ra/rules/system-actors.yaml @@ -23,6 +23,8 @@ MINP: TargetableUnit: TargetTypes: Ground BodyOrientation: + Immobile: + OccupiesSpace: true MINV: Mine: @@ -49,6 +51,8 @@ MINV: TargetableUnit: TargetTypes: Ground BodyOrientation: + Immobile: + OccupiesSpace: true CRATE: Tooltip: @@ -122,6 +126,7 @@ CRATE: CAMERA: Immobile: + OccupiesSpace: false Health: HP: 1000 RevealsShroud: @@ -134,6 +139,7 @@ CAMERA: FLARE: Immobile: + OccupiesSpace: false Health: HP: 1000 RevealsShroud: @@ -170,11 +176,13 @@ powerproxy.sonarpulse: mpspawn: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: waypoint: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: diff --git a/mods/ts/rules/system-actors.yaml b/mods/ts/rules/system-actors.yaml index 638c103e1a..a2dfd32804 100644 --- a/mods/ts/rules/system-actors.yaml +++ b/mods/ts/rules/system-actors.yaml @@ -1,10 +1,12 @@ mpspawn: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: waypoint: Immobile: + OccupiesSpace: false RenderEditorOnly: BodyOrientation: