Remove duplication between Immobile and Mine.
This commit is contained in:
@@ -16,20 +16,27 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class ImmobileInfo : ITraitInfo, IOccupySpaceInfo
|
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
|
class Immobile : IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||||
{
|
{
|
||||||
[Sync] readonly CPos location;
|
[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>();
|
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 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 WPos CenterPosition { get { return location.CenterPosition; } }
|
||||||
|
|
||||||
public void AddedToWorld(Actor self)
|
public void AddedToWorld(Actor self)
|
||||||
|
|||||||
@@ -25,17 +25,15 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new Mine(init, this); }
|
public object Create(ActorInitializer init) { return new Mine(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class Mine : ICrushable, IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld
|
class Mine : ICrushable
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly MineInfo info;
|
readonly MineInfo info;
|
||||||
[Sync] readonly CPos location;
|
|
||||||
|
|
||||||
public Mine(ActorInitializer init, MineInfo info)
|
public Mine(ActorInitializer init, MineInfo info)
|
||||||
{
|
{
|
||||||
this.self = init.self;
|
this.self = init.self;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.location = init.Get<LocationInit,CPos>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WarnCrush(Actor crusher) {}
|
public void WarnCrush(Actor crusher) {}
|
||||||
@@ -56,25 +54,6 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
return info.CrushClasses.Intersect(crushClasses).Any();
|
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 */
|
/* tag trait for stuff that shouldnt trigger mines */
|
||||||
|
|||||||
@@ -163,6 +163,17 @@ namespace OpenRA.Utility
|
|||||||
node.Key = "RenderDisguise";
|
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);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,16 +32,19 @@ CRATE:
|
|||||||
|
|
||||||
mpspawn:
|
mpspawn:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
waypoint:
|
waypoint:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
CAMERA:
|
CAMERA:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
Health:
|
Health:
|
||||||
HP: 1000
|
HP: 1000
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
|
|||||||
@@ -86,11 +86,13 @@ CRATE:
|
|||||||
|
|
||||||
mpspawn:
|
mpspawn:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
waypoint:
|
waypoint:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ MINP:
|
|||||||
TargetableUnit:
|
TargetableUnit:
|
||||||
TargetTypes: Ground
|
TargetTypes: Ground
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
Immobile:
|
||||||
|
OccupiesSpace: true
|
||||||
|
|
||||||
MINV:
|
MINV:
|
||||||
Mine:
|
Mine:
|
||||||
@@ -49,6 +51,8 @@ MINV:
|
|||||||
TargetableUnit:
|
TargetableUnit:
|
||||||
TargetTypes: Ground
|
TargetTypes: Ground
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
Immobile:
|
||||||
|
OccupiesSpace: true
|
||||||
|
|
||||||
CRATE:
|
CRATE:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
@@ -122,6 +126,7 @@ CRATE:
|
|||||||
|
|
||||||
CAMERA:
|
CAMERA:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
Health:
|
Health:
|
||||||
HP: 1000
|
HP: 1000
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
@@ -134,6 +139,7 @@ CAMERA:
|
|||||||
|
|
||||||
FLARE:
|
FLARE:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
Health:
|
Health:
|
||||||
HP: 1000
|
HP: 1000
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
@@ -170,11 +176,13 @@ powerproxy.sonarpulse:
|
|||||||
|
|
||||||
mpspawn:
|
mpspawn:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
waypoint:
|
waypoint:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
mpspawn:
|
mpspawn:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
waypoint:
|
waypoint:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
OccupiesSpace: false
|
||||||
RenderEditorOnly:
|
RenderEditorOnly:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user