Remove duplication between Immobile and Mine.
This commit is contained in:
@@ -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<Pair<CPos, SubCell>> occupied;
|
||||
|
||||
public Immobile(ActorInitializer init)
|
||||
public Immobile(ActorInitializer init, ImmobileInfo info)
|
||||
{
|
||||
this.location = init.Get<LocationInit, CPos>();
|
||||
|
||||
if (info.OccupiesSpace)
|
||||
occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) };
|
||||
else
|
||||
occupied = new Pair<CPos, SubCell>[0];
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return location; } }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield break; }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupied; }
|
||||
public WPos CenterPosition { get { return location.CenterPosition; } }
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
|
||||
@@ -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<LocationInit,CPos>();
|
||||
}
|
||||
|
||||
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<Pair<CPos, SubCell>> 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 */
|
||||
|
||||
@@ -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<MiniYamlNode>() { 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -86,11 +86,13 @@ CRATE:
|
||||
|
||||
mpspawn:
|
||||
Immobile:
|
||||
OccupiesSpace: false
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
waypoint:
|
||||
Immobile:
|
||||
OccupiesSpace: false
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
mpspawn:
|
||||
Immobile:
|
||||
OccupiesSpace: false
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
waypoint:
|
||||
Immobile:
|
||||
OccupiesSpace: false
|
||||
RenderEditorOnly:
|
||||
BodyOrientation:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user