Make Target fields readonly.
This commit is contained in:
@@ -19,42 +19,68 @@ namespace OpenRA.Traits
|
|||||||
public struct Target
|
public struct Target
|
||||||
{
|
{
|
||||||
public static readonly Target[] None = { };
|
public static readonly Target[] None = { };
|
||||||
public static readonly Target Invalid = new Target { type = TargetType.Invalid };
|
public static readonly Target Invalid = new Target();
|
||||||
|
|
||||||
TargetType type;
|
readonly TargetType type;
|
||||||
Actor actor;
|
readonly Actor actor;
|
||||||
FrozenActor frozen;
|
readonly FrozenActor frozen;
|
||||||
WPos pos;
|
readonly WPos pos;
|
||||||
CPos? cell;
|
readonly CPos? cell;
|
||||||
SubCell? subCell;
|
readonly SubCell? subCell;
|
||||||
int generation;
|
readonly int generation;
|
||||||
|
|
||||||
public static Target FromPos(WPos p) { return new Target { pos = p, type = TargetType.Terrain }; }
|
Target(WPos pos)
|
||||||
public static Target FromCell(World w, CPos c, SubCell subCell = SubCell.FullCell)
|
|
||||||
{
|
{
|
||||||
return new Target
|
type = TargetType.Terrain;
|
||||||
{
|
this.pos = pos;
|
||||||
pos = w.Map.CenterOfSubCell(c, subCell),
|
|
||||||
cell = c,
|
actor = null;
|
||||||
subCell = subCell,
|
frozen = null;
|
||||||
type = TargetType.Terrain
|
cell = null;
|
||||||
};
|
subCell = null;
|
||||||
|
generation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Target FromActor(Actor a)
|
Target(World w, CPos c, SubCell subCell)
|
||||||
{
|
{
|
||||||
if (a == null)
|
type = TargetType.Terrain;
|
||||||
return Invalid;
|
pos = w.Map.CenterOfSubCell(c, subCell);
|
||||||
|
cell = c;
|
||||||
|
this.subCell = subCell;
|
||||||
|
|
||||||
return new Target
|
actor = null;
|
||||||
{
|
frozen = null;
|
||||||
actor = a,
|
generation = 0;
|
||||||
type = TargetType.Actor,
|
|
||||||
generation = a.Generation,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Target FromFrozenActor(FrozenActor a) { return new Target { frozen = a, type = TargetType.FrozenActor }; }
|
Target(Actor a)
|
||||||
|
{
|
||||||
|
type = TargetType.Actor;
|
||||||
|
actor = a;
|
||||||
|
generation = a.Generation;
|
||||||
|
|
||||||
|
pos = WPos.Zero;
|
||||||
|
frozen = null;
|
||||||
|
cell = null;
|
||||||
|
subCell = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Target(FrozenActor fa)
|
||||||
|
{
|
||||||
|
type = TargetType.FrozenActor;
|
||||||
|
frozen = fa;
|
||||||
|
|
||||||
|
pos = WPos.Zero;
|
||||||
|
actor = null;
|
||||||
|
cell = null;
|
||||||
|
subCell = null;
|
||||||
|
generation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Target FromPos(WPos p) { return new Target(p); }
|
||||||
|
public static Target FromCell(World w, CPos c, SubCell subCell = SubCell.FullCell) { return new Target(w, c, subCell); }
|
||||||
|
public static Target FromActor(Actor a) { return a != null ? new Target(a) : Invalid; }
|
||||||
|
public static Target FromFrozenActor(FrozenActor fa) { return new Target(fa); }
|
||||||
|
|
||||||
public Actor Actor { get { return actor; } }
|
public Actor Actor { get { return actor; } }
|
||||||
public FrozenActor FrozenActor { get { return frozen; } }
|
public FrozenActor FrozenActor { get { return frozen; } }
|
||||||
|
|||||||
Reference in New Issue
Block a user