rename WRange to WDist

This commit is contained in:
Matthias Mailänder
2015-07-06 16:35:15 +02:00
parent 54e1cf866c
commit 7447e0bf93
100 changed files with 244 additions and 244 deletions

View File

@@ -243,10 +243,10 @@ namespace OpenRA
return InvalidValueAction(value, fieldType, fieldName); return InvalidValueAction(value, fieldType, fieldName);
} }
else if (fieldType == typeof(WRange)) else if (fieldType == typeof(WDist))
{ {
WRange res; WDist res;
if (WRange.TryParse(value, out res)) if (WDist.TryParse(value, out res))
return res; return res;
return InvalidValueAction(value, fieldType, fieldName); return InvalidValueAction(value, fieldType, fieldName);
@@ -258,8 +258,8 @@ namespace OpenRA
var parts = value.Split(','); var parts = value.Split(',');
if (parts.Length == 3) if (parts.Length == 3)
{ {
WRange rx, ry, rz; WDist rx, ry, rz;
if (WRange.TryParse(parts[0], out rx) && WRange.TryParse(parts[1], out ry) && WRange.TryParse(parts[2], out rz)) if (WDist.TryParse(parts[0], out rx) && WDist.TryParse(parts[1], out ry) && WDist.TryParse(parts[2], out rz))
return new WVec(rx, ry, rz); return new WVec(rx, ry, rz);
} }
} }
@@ -279,8 +279,8 @@ namespace OpenRA
for (var i = 0; i < vecs.Length; ++i) for (var i = 0; i < vecs.Length; ++i)
{ {
WRange rx, ry, rz; WDist rx, ry, rz;
if (WRange.TryParse(parts[3 * i], out rx) && WRange.TryParse(parts[3 * i + 1], out ry) && WRange.TryParse(parts[3 * i + 2], out rz)) if (WDist.TryParse(parts[3 * i], out rx) && WDist.TryParse(parts[3 * i + 1], out ry) && WDist.TryParse(parts[3 * i + 2], out rz))
vecs[i] = new WVec(rx, ry, rz); vecs[i] = new WVec(rx, ry, rz);
} }
@@ -296,8 +296,8 @@ namespace OpenRA
var parts = value.Split(','); var parts = value.Split(',');
if (parts.Length == 3) if (parts.Length == 3)
{ {
WRange rx, ry, rz; WDist rx, ry, rz;
if (WRange.TryParse(parts[0], out rx) && WRange.TryParse(parts[1], out ry) && WRange.TryParse(parts[2], out rz)) if (WDist.TryParse(parts[0], out rx) && WDist.TryParse(parts[1], out ry) && WDist.TryParse(parts[2], out rz))
return new WPos(rx, ry, rz); return new WPos(rx, ry, rz);
} }
} }

View File

@@ -33,7 +33,7 @@ namespace OpenRA.GameRules
public sealed class WeaponInfo public sealed class WeaponInfo
{ {
[Desc("The maximum range the weapon can fire.")] [Desc("The maximum range the weapon can fire.")]
public readonly WRange Range = WRange.Zero; public readonly WDist Range = WDist.Zero;
[Desc("The sound played when the weapon is fired.")] [Desc("The sound played when the weapon is fired.")]
public readonly string[] Report = null; public readonly string[] Report = null;
@@ -56,7 +56,7 @@ namespace OpenRA.GameRules
public readonly int BurstDelay = 5; public readonly int BurstDelay = 5;
[Desc("The minimum range the weapon can fire.")] [Desc("The minimum range the weapon can fire.")]
public readonly WRange MinRange = WRange.Zero; public readonly WDist MinRange = WDist.Zero;
[FieldLoader.LoadUsing("LoadProjectile")] [FieldLoader.LoadUsing("LoadProjectile")]
public readonly IProjectileInfo Projectile; public readonly IProjectileInfo Projectile;

View File

@@ -194,7 +194,7 @@ namespace OpenRA.Graphics
new SelectionBarsRenderable(unit).Render(this); new SelectionBarsRenderable(unit).Render(this);
} }
public void DrawRangeCircle(WPos pos, WRange range, Color c) public void DrawRangeCircle(WPos pos, WDist range, Color c)
{ {
var offset = new WVec(range.Range, 0, 0); var offset = new WVec(range.Range, 0, 0);
for (var i = 0; i < 32; i++) for (var i = 0; i < 32; i++)

View File

@@ -841,13 +841,13 @@ namespace OpenRA
return new MPos(x, y).ToCPos(this); return new MPos(x, y).ToCPos(this);
} }
public WRange DistanceToEdge(WPos pos, WVec dir) public WDist DistanceToEdge(WPos pos, WVec dir)
{ {
var tl = CenterOfCell(CellsInsideBounds.TopLeft) - new WVec(512, 512, 0); var tl = CenterOfCell(CellsInsideBounds.TopLeft) - new WVec(512, 512, 0);
var br = CenterOfCell(CellsInsideBounds.BottomRight) + new WVec(511, 511, 0); var br = CenterOfCell(CellsInsideBounds.BottomRight) + new WVec(511, 511, 0);
var x = dir.X == 0 ? int.MaxValue : ((dir.X < 0 ? tl.X : br.X) - pos.X) / dir.X; var x = dir.X == 0 ? int.MaxValue : ((dir.X < 0 ? tl.X : br.X) - pos.X) / dir.X;
var y = dir.Y == 0 ? int.MaxValue : ((dir.Y < 0 ? tl.Y : br.Y) - pos.Y) / dir.Y; var y = dir.Y == 0 ? int.MaxValue : ((dir.Y < 0 ? tl.Y : br.Y) - pos.Y) / dir.Y;
return new WRange(Math.Min(x, y) * dir.Length); return new WDist(Math.Min(x, y) * dir.Length);
} }
static readonly CVec[][] TilesByDistance = InitTilesByDistance(MaxTilesInCircleRange); static readonly CVec[][] TilesByDistance = InitTilesByDistance(MaxTilesInCircleRange);

View File

@@ -305,8 +305,8 @@
<Compile Include="CPos.cs" /> <Compile Include="CPos.cs" />
<Compile Include="CVec.cs" /> <Compile Include="CVec.cs" />
<Compile Include="WAngle.cs" /> <Compile Include="WAngle.cs" />
<Compile Include="WDist.cs" />
<Compile Include="WPos.cs" /> <Compile Include="WPos.cs" />
<Compile Include="WRange.cs" />
<Compile Include="WRot.cs" /> <Compile Include="WRot.cs" />
<Compile Include="WVec.cs" /> <Compile Include="WVec.cs" />
<Compile Include="Primitives\TypeDictionary.cs" /> <Compile Include="Primitives\TypeDictionary.cs" />

2
OpenRA.Game/Sync.cs Executable file → Normal file
View File

@@ -36,7 +36,7 @@ namespace OpenRA
{ typeof(int2), ((Func<int2, int>)HashInt2).Method }, { typeof(int2), ((Func<int2, int>)HashInt2).Method },
{ typeof(CPos), ((Func<CPos, int>)HashCPos).Method }, { typeof(CPos), ((Func<CPos, int>)HashCPos).Method },
{ typeof(CVec), ((Func<CVec, int>)HashCVec).Method }, { typeof(CVec), ((Func<CVec, int>)HashCVec).Method },
{ typeof(WRange), ((Func<WRange, int>)Hash<WRange>).Method }, { typeof(WDist), ((Func<WDist, int>)Hash<WDist>).Method },
{ typeof(WPos), ((Func<WPos, int>)Hash<WPos>).Method }, { typeof(WPos), ((Func<WPos, int>)Hash<WPos>).Method },
{ typeof(WVec), ((Func<WVec, int>)Hash<WVec>).Method }, { typeof(WVec), ((Func<WVec, int>)Hash<WVec>).Method },
{ typeof(WAngle), ((Func<WAngle, int>)Hash<WAngle>).Method }, { typeof(WAngle), ((Func<WAngle, int>)Hash<WAngle>).Method },

2
OpenRA.Game/Traits/Health.cs Executable file → Normal file
View File

@@ -18,7 +18,7 @@ namespace OpenRA.Traits
public readonly int HP = 0; public readonly int HP = 0;
[Desc("Physical size of the unit used for damage calculations. Impacts within this radius apply full damage.")] [Desc("Physical size of the unit used for damage calculations. Impacts within this radius apply full damage.")]
public readonly WRange Radius = new WRange(426); public readonly WDist Radius = new WDist(426);
[Desc("Trigger interfaces such as AnnounceOnKill?")] [Desc("Trigger interfaces such as AnnounceOnKill?")]
public readonly bool NotifyAppliedDamage = true; public readonly bool NotifyAppliedDamage = true;

View File

@@ -140,7 +140,7 @@ namespace OpenRA.Traits
} }
} }
public bool IsInRange(WPos origin, WRange range) public bool IsInRange(WPos origin, WDist range)
{ {
if (Type == TargetType.Invalid) if (Type == TargetType.Invalid)
return false; return false;

View File

@@ -234,9 +234,9 @@ namespace OpenRA.Traits
{ {
Activity MoveTo(CPos cell, int nearEnough); Activity MoveTo(CPos cell, int nearEnough);
Activity MoveTo(CPos cell, Actor ignoredActor); Activity MoveTo(CPos cell, Actor ignoredActor);
Activity MoveWithinRange(Target target, WRange range); Activity MoveWithinRange(Target target, WDist range);
Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange); Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange);
Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange); Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange);
Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any); Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any);
Activity MoveToTarget(Actor self, Target target); Activity MoveToTarget(Actor self, Target target);
Activity MoveIntoTarget(Actor self, Target target); Activity MoveIntoTarget(Actor self, Target target);

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Traits
{ {
public readonly int Id; public readonly int Id;
public WPos Position { get; private set; } public WPos Position { get; private set; }
public WRange Range { get; private set; } public WDist Range { get; private set; }
public WPos TopLeft { get; private set; } public WPos TopLeft { get; private set; }
public WPos BottomRight { get; private set; } public WPos BottomRight { get; private set; }
@@ -102,7 +102,7 @@ namespace OpenRA.Traits
IEnumerable<Actor> currentActors = Enumerable.Empty<Actor>(); IEnumerable<Actor> currentActors = Enumerable.Empty<Actor>();
public ProximityTrigger(int id, WPos pos, WRange range, Action<Actor> onActorEntered, Action<Actor> onActorExited) public ProximityTrigger(int id, WPos pos, WDist range, Action<Actor> onActorEntered, Action<Actor> onActorExited)
{ {
Id = id; Id = id;
@@ -112,12 +112,12 @@ namespace OpenRA.Traits
Update(pos, range); Update(pos, range);
} }
public void Update(WPos newPos, WRange newRange) public void Update(WPos newPos, WDist newRange)
{ {
Position = newPos; Position = newPos;
Range = newRange; Range = newRange;
var offset = new WVec(newRange, newRange, WRange.Zero); var offset = new WVec(newRange, newRange, WDist.Zero);
TopLeft = newPos - offset; TopLeft = newPos - offset;
BottomRight = newPos + offset; BottomRight = newPos + offset;
@@ -130,7 +130,7 @@ namespace OpenRA.Traits
return; return;
var oldActors = currentActors; var oldActors = currentActors;
var delta = new WVec(Range, Range, WRange.Zero); var delta = new WVec(Range, Range, WDist.Zero);
currentActors = am.ActorsInBox(Position - delta, Position + delta) currentActors = am.ActorsInBox(Position - delta, Position + delta)
.Where(a => (a.CenterPosition - Position).HorizontalLengthSquared < Range.RangeSquared) .Where(a => (a.CenterPosition - Position).HorizontalLengthSquared < Range.RangeSquared)
.ToList(); .ToList();
@@ -407,7 +407,7 @@ namespace OpenRA.Traits
} }
} }
public int AddProximityTrigger(WPos pos, WRange range, Action<Actor> onEntry, Action<Actor> onExit) public int AddProximityTrigger(WPos pos, WDist range, Action<Actor> onEntry, Action<Actor> onExit)
{ {
var id = nextTriggerId++; var id = nextTriggerId++;
var t = new ProximityTrigger(id, pos, range, onEntry, onExit); var t = new ProximityTrigger(id, pos, range, onEntry, onExit);
@@ -431,7 +431,7 @@ namespace OpenRA.Traits
t.Dispose(); t.Dispose();
} }
public void UpdateProximityTrigger(int id, WPos newPos, WRange newRange) public void UpdateProximityTrigger(int id, WPos newPos, WDist newRange)
{ {
ProximityTrigger t; ProximityTrigger t;
if (!proximityTriggers.TryGetValue(id, out t)) if (!proximityTriggers.TryGetValue(id, out t))

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Traits
Hash += 1; Hash += 1;
} }
public static IEnumerable<CPos> CellsInRange(Map map, WPos pos, WRange range) public static IEnumerable<CPos> CellsInRange(Map map, WPos pos, WDist range)
{ {
var r = (range.Range + 1023) / 1024; var r = (range.Range + 1023) / 1024;
var limit = range.RangeSquared; var limit = range.RangeSquared;
@@ -83,7 +83,7 @@ namespace OpenRA.Traits
yield return c; yield return c;
} }
public static IEnumerable<CPos> CellsInRange(Map map, CPos cell, WRange range) public static IEnumerable<CPos> CellsInRange(Map map, CPos cell, WDist range)
{ {
return CellsInRange(map, map.CenterOfCell(cell), range); return CellsInRange(map, map.CenterOfCell(cell), range);
} }

View File

@@ -20,43 +20,43 @@ namespace OpenRA
/// <summary> /// <summary>
/// 1d world distance - 1024 units = 1 cell. /// 1d world distance - 1024 units = 1 cell.
/// </summary> /// </summary>
public struct WRange : IComparable, IComparable<WRange>, IEquatable<WRange>, IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding public struct WDist : IComparable, IComparable<WDist>, IEquatable<WDist>, IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding
{ {
public readonly int Range; public readonly int Range;
public long RangeSquared { get { return (long)Range * (long)Range; } } public long RangeSquared { get { return (long)Range * (long)Range; } }
public WRange(int r) { Range = r; } public WDist(int r) { Range = r; }
public static readonly WRange Zero = new WRange(0); public static readonly WDist Zero = new WDist(0);
public static WRange FromCells(int cells) { return new WRange(1024 * cells); } public static WDist FromCells(int cells) { return new WDist(1024 * cells); }
public static WRange operator +(WRange a, WRange b) { return new WRange(a.Range + b.Range); } public static WDist operator +(WDist a, WDist b) { return new WDist(a.Range + b.Range); }
public static WRange operator -(WRange a, WRange b) { return new WRange(a.Range - b.Range); } public static WDist operator -(WDist a, WDist b) { return new WDist(a.Range - b.Range); }
public static WRange operator -(WRange a) { return new WRange(-a.Range); } public static WDist operator -(WDist a) { return new WDist(-a.Range); }
public static WRange operator /(WRange a, int b) { return new WRange(a.Range / b); } public static WDist operator /(WDist a, int b) { return new WDist(a.Range / b); }
public static WRange operator *(WRange a, int b) { return new WRange(a.Range * b); } public static WDist operator *(WDist a, int b) { return new WDist(a.Range * b); }
public static WRange operator *(int a, WRange b) { return new WRange(a * b.Range); } public static WDist operator *(int a, WDist b) { return new WDist(a * b.Range); }
public static bool operator <(WRange a, WRange b) { return a.Range < b.Range; } public static bool operator <(WDist a, WDist b) { return a.Range < b.Range; }
public static bool operator >(WRange a, WRange b) { return a.Range > b.Range; } public static bool operator >(WDist a, WDist b) { return a.Range > b.Range; }
public static bool operator <=(WRange a, WRange b) { return a.Range <= b.Range; } public static bool operator <=(WDist a, WDist b) { return a.Range <= b.Range; }
public static bool operator >=(WRange a, WRange b) { return a.Range >= b.Range; } public static bool operator >=(WDist a, WDist b) { return a.Range >= b.Range; }
public static bool operator ==(WRange me, WRange other) { return me.Range == other.Range; } public static bool operator ==(WDist me, WDist other) { return me.Range == other.Range; }
public static bool operator !=(WRange me, WRange other) { return !(me == other); } public static bool operator !=(WDist me, WDist other) { return !(me == other); }
// Sampled a N-sample probability density function in the range [-1024..1024] // Sampled a N-sample probability density function in the range [-1024..1024]
// 1 sample produces a rectangular probability // 1 sample produces a rectangular probability
// 2 samples produces a triangular probability // 2 samples produces a triangular probability
// ... // ...
// N samples approximates a true gaussian // N samples approximates a true gaussian
public static WRange FromPDF(MersenneTwister r, int samples) public static WDist FromPDF(MersenneTwister r, int samples)
{ {
return new WRange(Exts.MakeArray(samples, _ => r.Next(-1024, 1024)) return new WDist(Exts.MakeArray(samples, _ => r.Next(-1024, 1024))
.Sum() / samples); .Sum() / samples);
} }
public static bool TryParse(string s, out WRange result) public static bool TryParse(string s, out WDist result)
{ {
result = WRange.Zero; result = WDist.Zero;
if (string.IsNullOrEmpty(s)) if (string.IsNullOrEmpty(s))
return false; return false;
@@ -84,32 +84,32 @@ namespace OpenRA
if (cell < 0) if (cell < 0)
subcell = -subcell; subcell = -subcell;
result = new WRange(1024 * cell + subcell); result = new WDist(1024 * cell + subcell);
return true; return true;
} }
public override int GetHashCode() { return Range.GetHashCode(); } public override int GetHashCode() { return Range.GetHashCode(); }
public bool Equals(WRange other) { return other == this; } public bool Equals(WDist other) { return other == this; }
public override bool Equals(object obj) { return obj is WRange && Equals((WRange)obj); } public override bool Equals(object obj) { return obj is WDist && Equals((WDist)obj); }
public int CompareTo(object obj) public int CompareTo(object obj)
{ {
if (!(obj is WRange)) if (!(obj is WDist))
return 1; return 1;
return Range.CompareTo(((WRange)obj).Range); return Range.CompareTo(((WDist)obj).Range);
} }
public int CompareTo(WRange other) { return Range.CompareTo(other.Range); } public int CompareTo(WDist other) { return Range.CompareTo(other.Range); }
public override string ToString() { return Range.ToString(); } public override string ToString() { return Range.ToString(); }
#region Scripting interface #region Scripting interface
public LuaValue Add(LuaRuntime runtime, LuaValue left, LuaValue right) public LuaValue Add(LuaRuntime runtime, LuaValue left, LuaValue right)
{ {
WRange a; WDist a;
WRange b; WDist b;
if (!left.TryGetClrValue<WRange>(out a) || !right.TryGetClrValue<WRange>(out b)) if (!left.TryGetClrValue<WDist>(out a) || !right.TryGetClrValue<WDist>(out b))
throw new LuaException("Attempted to call WRange.Add(WRange, WRange) with invalid arguments."); throw new LuaException("Attempted to call WRange.Add(WRange, WRange) with invalid arguments.");
return new LuaCustomClrObject(a + b); return new LuaCustomClrObject(a + b);
@@ -117,9 +117,9 @@ namespace OpenRA
public LuaValue Subtract(LuaRuntime runtime, LuaValue left, LuaValue right) public LuaValue Subtract(LuaRuntime runtime, LuaValue left, LuaValue right)
{ {
WRange a; WDist a;
WRange b; WDist b;
if (!left.TryGetClrValue<WRange>(out a) || !right.TryGetClrValue<WRange>(out b)) if (!left.TryGetClrValue<WDist>(out a) || !right.TryGetClrValue<WDist>(out b))
throw new LuaException("Attempted to call WRange.Subtract(WRange, WRange) with invalid arguments."); throw new LuaException("Attempted to call WRange.Subtract(WRange, WRange) with invalid arguments.");
return new LuaCustomClrObject(a - b); return new LuaCustomClrObject(a - b);
@@ -127,9 +127,9 @@ namespace OpenRA
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right) public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{ {
WRange a; WDist a;
WRange b; WDist b;
if (!left.TryGetClrValue<WRange>(out a) || !right.TryGetClrValue<WRange>(out b)) if (!left.TryGetClrValue<WDist>(out a) || !right.TryGetClrValue<WDist>(out b))
throw new LuaException("Attempted to call WRange.Equals(WRange, WRange) with invalid arguments."); throw new LuaException("Attempted to call WRange.Equals(WRange, WRange) with invalid arguments.");
return a == b; return a == b;

View File

@@ -22,7 +22,7 @@ namespace OpenRA
public readonly int X, Y, Z; public readonly int X, Y, Z;
public WPos(int x, int y, int z) { X = x; Y = y; Z = z; } public WPos(int x, int y, int z) { X = x; Y = y; Z = z; }
public WPos(WRange x, WRange y, WRange z) { X = x.Range; Y = y.Range; Z = z.Range; } public WPos(WDist x, WDist y, WDist z) { X = x.Range; Y = y.Range; Z = z.Range; }
public static readonly WPos Zero = new WPos(0, 0, 0); public static readonly WPos Zero = new WPos(0, 0, 0);

View File

@@ -21,7 +21,7 @@ namespace OpenRA
public readonly int X, Y, Z; public readonly int X, Y, Z;
public WVec(int x, int y, int z) { X = x; Y = y; Z = z; } public WVec(int x, int y, int z) { X = x; Y = y; Z = z; }
public WVec(WRange x, WRange y, WRange z) { X = x.Range; Y = y.Range; Z = z.Range; } public WVec(WDist x, WDist y, WDist z) { X = x.Range; Y = y.Range; Z = z.Range; }
public static readonly WVec Zero = new WVec(0, 0, 0); public static readonly WVec Zero = new WVec(0, 0, 0);
@@ -76,7 +76,7 @@ namespace OpenRA
// N samples approximates a true gaussian // N samples approximates a true gaussian
public static WVec FromPDF(MersenneTwister r, int samples) public static WVec FromPDF(MersenneTwister r, int samples)
{ {
return new WVec(WRange.FromPDF(r, samples), WRange.FromPDF(r, samples), WRange.Zero); return new WVec(WDist.FromPDF(r, samples), WDist.FromPDF(r, samples), WDist.Zero);
} }
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); } public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); }

View File

@@ -30,12 +30,12 @@ namespace OpenRA
return actors.MinByOrDefault(a => (a.CenterPosition - pos).LengthSquared); return actors.MinByOrDefault(a => (a.CenterPosition - pos).LengthSquared);
} }
public static IEnumerable<Actor> FindActorsInCircle(this World world, WPos origin, WRange r) public static IEnumerable<Actor> FindActorsInCircle(this World world, WPos origin, WDist r)
{ {
using (new PerfSample("FindUnitsInCircle")) using (new PerfSample("FindUnitsInCircle"))
{ {
// Target ranges are calculated in 2D, so ignore height differences // Target ranges are calculated in 2D, so ignore height differences
var vec = new WVec(r, r, WRange.Zero); var vec = new WVec(r, r, WDist.Zero);
return world.ActorMap.ActorsInBox(origin - vec, origin + vec).Where( return world.ActorMap.ActorsInBox(origin - vec, origin + vec).Where(
a => (a.CenterPosition - origin).HorizontalLengthSquared <= r.RangeSquared); a => (a.CenterPosition - origin).HorizontalLengthSquared <= r.RangeSquared);
} }

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Cnc.Traits
var altitude = self.World.Map.Rules.Actors[actorType].Traits.Get<PlaneInfo>().CruiseAltitude; var altitude = self.World.Map.Rules.Actors[actorType].Traits.Get<PlaneInfo>().CruiseAltitude;
var actor = w.CreateActor(actorType, new TypeDictionary var actor = w.CreateActor(actorType, new TypeDictionary
{ {
new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)), new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WDist.Zero, WDist.Zero, altitude)),
new OwnerInit(owner), new OwnerInit(owner),
new FacingInit(64) new FacingInit(64)
}); });

View File

@@ -485,7 +485,7 @@ namespace OpenRA.Mods.Common.AI
return allEnemyUnits.ClosestTo(pos); return allEnemyUnits.ClosestTo(pos);
} }
internal Actor FindClosestEnemy(WPos pos, WRange radius) internal Actor FindClosestEnemy(WPos pos, WDist radius)
{ {
var enemyUnits = World.FindActorsInCircle(pos, radius) var enemyUnits = World.FindActorsInCircle(pos, radius)
.Where(unit => Player.Stances[unit.Owner] == Stance.Enemy && .Where(unit => Player.Stances[unit.Owner] == Stance.Enemy &&
@@ -643,7 +643,7 @@ namespace OpenRA.Mods.Common.AI
foreach (var b in allEnemyBaseBuilder) foreach (var b in allEnemyBaseBuilder)
{ {
var enemies = World.FindActorsInCircle(b.CenterPosition, WRange.FromCells(Info.RushAttackScanRadius)) var enemies = World.FindActorsInCircle(b.CenterPosition, WDist.FromCells(Info.RushAttackScanRadius))
.Where(unit => Player.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait<AttackBase>()).ToList(); .Where(unit => Player.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait<AttackBase>()).ToList();
if (rushFuzzy.CanAttack(ownUnits, enemies)) if (rushFuzzy.CanAttack(ownUnits, enemies))
@@ -672,7 +672,7 @@ namespace OpenRA.Mods.Common.AI
if (!protectSq.IsValid) if (!protectSq.IsValid)
{ {
var ownUnits = World.FindActorsInCircle(World.Map.CenterOfCell(GetRandomBaseCenter()), WRange.FromCells(Info.ProtectUnitScanRadius)) var ownUnits = World.FindActorsInCircle(World.Map.CenterOfCell(GetRandomBaseCenter()), WDist.FromCells(Info.ProtectUnitScanRadius))
.Where(unit => unit.Owner == Player && !unit.HasTrait<Building>() .Where(unit => unit.Owner == Player && !unit.HasTrait<Building>()
&& unit.HasTrait<AttackBase>()); && unit.HasTrait<AttackBase>());

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.AI
protected static bool NearToPosSafely(Squad owner, WPos loc, out Actor detectedEnemyTarget) protected static bool NearToPosSafely(Squad owner, WPos loc, out Actor detectedEnemyTarget)
{ {
detectedEnemyTarget = null; detectedEnemyTarget = null;
var unitsAroundPos = owner.World.FindActorsInCircle(loc, WRange.FromCells(DangerRadius)) var unitsAroundPos = owner.World.FindActorsInCircle(loc, WDist.FromCells(DangerRadius))
.Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList(); .Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList();
if (!unitsAroundPos.Any()) if (!unitsAroundPos.Any())

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.AI
owner.TargetActor = t; owner.TargetActor = t;
} }
var enemyUnits = owner.World.FindActorsInCircle(owner.TargetActor.CenterPosition, WRange.FromCells(10)) var enemyUnits = owner.World.FindActorsInCircle(owner.TargetActor.CenterPosition, WDist.FromCells(10))
.Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList(); .Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList();
if (enemyUnits.Any()) if (enemyUnits.Any())
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.AI
var leader = owner.Units.ClosestTo(owner.TargetActor.CenterPosition); var leader = owner.Units.ClosestTo(owner.TargetActor.CenterPosition);
if (leader == null) if (leader == null)
return; return;
var ownUnits = owner.World.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(owner.Units.Count) / 3) var ownUnits = owner.World.FindActorsInCircle(leader.CenterPosition, WDist.FromCells(owner.Units.Count) / 3)
.Where(a => a.Owner == owner.Units.FirstOrDefault().Owner && owner.Units.Contains(a)).ToHashSet(); .Where(a => a.Owner == owner.Units.FirstOrDefault().Owner && owner.Units.Contains(a)).ToHashSet();
if (ownUnits.Count < owner.Units.Count) if (ownUnits.Count < owner.Units.Count)
{ {
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.AI
} }
else else
{ {
var enemies = owner.World.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(12)) var enemies = owner.World.FindActorsInCircle(leader.CenterPosition, WDist.FromCells(12))
.Where(a1 => !a1.Disposed && !a1.IsDead); .Where(a1 => !a1.Disposed && !a1.IsDead);
var enemynearby = enemies.Where(a1 => a1.HasTrait<ITargetable>() && leader.Owner.Stances[a1.Owner] == Stance.Enemy); var enemynearby = enemies.Where(a1 => a1.HasTrait<ITargetable>() && leader.Owner.Stances[a1.Owner] == Stance.Enemy);
var target = enemynearby.ClosestTo(leader.CenterPosition); var target = enemynearby.ClosestTo(leader.CenterPosition);

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.AI
if (!owner.IsTargetValid) if (!owner.IsTargetValid)
{ {
owner.TargetActor = owner.Bot.FindClosestEnemy(owner.CenterPosition, WRange.FromCells(8)); owner.TargetActor = owner.Bot.FindClosestEnemy(owner.CenterPosition, WDist.FromCells(8));
if (owner.TargetActor == null) if (owner.TargetActor == null)
{ {

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.AI
return false; return false;
var u = squad.Units.Random(squad.Random); var u = squad.Units.Random(squad.Random);
var units = squad.World.FindActorsInCircle(u.CenterPosition, WRange.FromCells(DangerRadius)).ToList(); var units = squad.World.FindActorsInCircle(u.CenterPosition, WDist.FromCells(DangerRadius)).ToList();
var ownBaseBuildingAround = units.Where(unit => unit.Owner == squad.Bot.Player && unit.HasTrait<Building>()); var ownBaseBuildingAround = units.Where(unit => unit.Owner == squad.Bot.Player && unit.HasTrait<Building>());
if (ownBaseBuildingAround.Any()) if (ownBaseBuildingAround.Any())
return false; return false;

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.AI
foreach (var consideration in Considerations) foreach (var consideration in Considerations)
{ {
var radiusToUse = new WRange(consideration.CheckRadius.Range); var radiusToUse = new WDist(consideration.CheckRadius.Range);
var checkActors = world.FindActorsInCircle(pos, radiusToUse); var checkActors = world.FindActorsInCircle(pos, radiusToUse);
foreach (var scrutinized in checkActors) foreach (var scrutinized in checkActors)
@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.AI
public readonly DecisionMetric TargetMetric = DecisionMetric.None; public readonly DecisionMetric TargetMetric = DecisionMetric.None;
[Desc("What is the check radius of this decision?")] [Desc("What is the check radius of this decision?")]
public readonly WRange CheckRadius = WRange.FromCells(5); public readonly WDist CheckRadius = WDist.FromCells(5);
public Consideration(MiniYaml yaml) public Consideration(MiniYaml yaml)
{ {

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Activities
} }
var move = info.Moves ? aircraft.FlyStep(aircraft.Facing) : WVec.Zero; var move = info.Moves ? aircraft.FlyStep(aircraft.Facing) : WVec.Zero;
move -= new WVec(WRange.Zero, WRange.Zero, info.Velocity); move -= new WVec(WDist.Zero, WDist.Zero, info.Velocity);
aircraft.SetPosition(self, aircraft.CenterPosition + move); aircraft.SetPosition(self, aircraft.CenterPosition + move);
return this; return this;

View File

@@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly Plane plane; readonly Plane plane;
readonly Target target; readonly Target target;
readonly WRange maxRange; readonly WDist maxRange;
readonly WRange minRange; readonly WDist minRange;
public Fly(Actor self, Target t) public Fly(Actor self, Target t)
{ {
@@ -28,14 +28,14 @@ namespace OpenRA.Mods.Common.Activities
target = t; target = t;
} }
public Fly(Actor self, Target t, WRange minRange, WRange maxRange) public Fly(Actor self, Target t, WDist minRange, WDist maxRange)
: this(self, t) : this(self, t)
{ {
this.maxRange = maxRange; this.maxRange = maxRange;
this.minRange = minRange; this.minRange = minRange;
} }
public static void FlyToward(Actor self, Plane plane, int desiredFacing, WRange desiredAltitude) public static void FlyToward(Actor self, Plane plane, int desiredFacing, WDist desiredAltitude)
{ {
var move = plane.FlyStep(plane.Facing); var move = plane.FlyStep(plane.Facing);
var altitude = plane.CenterPosition.Z; var altitude = plane.CenterPosition.Z;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Activities
public class FlyCircle : Activity public class FlyCircle : Activity
{ {
readonly Plane plane; readonly Plane plane;
readonly WRange cruiseAltitude; readonly WDist cruiseAltitude;
public FlyCircle(Actor self) public FlyCircle(Actor self)
{ {

View File

@@ -18,10 +18,10 @@ namespace OpenRA.Mods.Common.Activities
{ {
Target target; Target target;
Plane plane; Plane plane;
WRange minRange; WDist minRange;
WRange maxRange; WDist maxRange;
public FlyFollow(Actor self, Target target, WRange minRange, WRange maxRange) public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange)
{ {
this.target = target; this.target = target;
plane = self.Trait<Plane>(); plane = self.Trait<Plane>();

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Activities
public class FlyTimed : Activity public class FlyTimed : Activity
{ {
readonly Plane plane; readonly Plane plane;
readonly WRange cruiseAltitude; readonly WDist cruiseAltitude;
int remainingTicks; int remainingTicks;
public FlyTimed(int ticks, Actor self) public FlyTimed(int ticks, Actor self)

View File

@@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly Helicopter helicopter; readonly Helicopter helicopter;
readonly Target target; readonly Target target;
readonly WRange maxRange; readonly WDist maxRange;
readonly WRange minRange; readonly WDist minRange;
public HeliFly(Actor self, Target t) public HeliFly(Actor self, Target t)
{ {
@@ -28,14 +28,14 @@ namespace OpenRA.Mods.Common.Activities
target = t; target = t;
} }
public HeliFly(Actor self, Target t, WRange minRange, WRange maxRange) public HeliFly(Actor self, Target t, WDist minRange, WDist maxRange)
: this(self, t) : this(self, t)
{ {
this.maxRange = maxRange; this.maxRange = maxRange;
this.minRange = minRange; this.minRange = minRange;
} }
public static bool AdjustAltitude(Actor self, Helicopter helicopter, WRange targetAltitude) public static bool AdjustAltitude(Actor self, Helicopter helicopter, WDist targetAltitude)
{ {
var altitude = helicopter.CenterPosition.Z; var altitude = helicopter.CenterPosition.Z;
if (altitude == targetAltitude.Range) if (altitude == targetAltitude.Range)

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Activities
public class HeliLand : Activity public class HeliLand : Activity
{ {
readonly Helicopter helicopter; readonly Helicopter helicopter;
readonly WRange landAltitude; readonly WDist landAltitude;
bool requireSpace; bool requireSpace;
public HeliLand(Actor self, bool requireSpace) public HeliLand(Actor self, bool requireSpace)

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Activities
} }
var desiredFacing = Util.GetFacing(d, plane.Facing); var desiredFacing = Util.GetFacing(d, plane.Facing);
Fly.FlyToward(self, plane, desiredFacing, WRange.Zero); Fly.FlyToward(self, plane, desiredFacing, WDist.Zero);
return this; return this;
} }

View File

@@ -21,11 +21,11 @@ namespace OpenRA.Mods.Common.Activities
readonly AttackBase attack; readonly AttackBase attack;
readonly IMove move; readonly IMove move;
readonly IFacing facing; readonly IFacing facing;
readonly WRange minRange; readonly WDist minRange;
readonly WRange maxRange; readonly WDist maxRange;
readonly IPositionable positionable; readonly IPositionable positionable;
public Attack(Actor self, Target target, WRange minRange, WRange maxRange, bool allowMovement) public Attack(Actor self, Target target, WDist minRange, WDist maxRange, bool allowMovement)
{ {
Target = target; Target = target;
this.minRange = minRange; this.minRange = minRange;

View File

@@ -52,9 +52,9 @@ namespace OpenRA.Mods.Common.Activities
protected virtual void OnInside(Actor self) { } protected virtual void OnInside(Actor self) { }
protected bool TryGetAlternateTargetInCircle( protected bool TryGetAlternateTargetInCircle(
Actor self, WRange radius, Action<Target> update, Func<Actor, bool> primaryFilter, Func<Actor, bool>[] preferenceFilters = null) Actor self, WDist radius, Action<Target> update, Func<Actor, bool> primaryFilter, Func<Actor, bool>[] preferenceFilters = null)
{ {
var diff = new WVec(radius, radius, WRange.Zero); var diff = new WVec(radius, radius, WDist.Zero);
var candidates = self.World.ActorMap.ActorsInBox(self.CenterPosition - diff, self.CenterPosition + diff) var candidates = self.World.ActorMap.ActorsInBox(self.CenterPosition - diff, self.CenterPosition + diff)
.Where(primaryFilter).Select(a => new { Actor = a, Ls = (self.CenterPosition - a.CenterPosition).HorizontalLengthSquared }) .Where(primaryFilter).Select(a => new { Actor = a, Ls = (self.CenterPosition - a.CenterPosition).HorizontalLengthSquared })
.Where(p => p.Ls <= radius.RangeSquared).OrderBy(p => p.Ls).Select(p => p.Actor); .Where(p => p.Ls <= radius.RangeSquared).OrderBy(p => p.Ls).Select(p => p.Actor);

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
public class Heal : Attack public class Heal : Attack
{ {
public Heal(Actor self, Target target, WRange minRange, WRange maxRange, bool allowMovement) public Heal(Actor self, Target target, WDist minRange, WDist maxRange, bool allowMovement)
: base(self, target, minRange, maxRange, allowMovement) { } : base(self, target, minRange, maxRange, allowMovement) { }
protected override Activity InnerTick(Actor self, AttackBase attack) protected override Activity InnerTick(Actor self, AttackBase attack)

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Activities
return this; return this;
return Util.SequenceActivities( return Util.SequenceActivities(
new AttackMoveActivity(self, new Move(self, target.Location, WRange.FromCells(2))), new AttackMoveActivity(self, new Move(self, target.Location, WDist.FromCells(2))),
new Wait(25), new Wait(25),
this); this);
} }

View File

@@ -16,11 +16,11 @@ namespace OpenRA.Mods.Common.Activities
public class Follow : Activity public class Follow : Activity
{ {
readonly Target target; readonly Target target;
readonly WRange minRange; readonly WDist minRange;
readonly WRange maxRange; readonly WDist maxRange;
readonly IMove move; readonly IMove move;
public Follow(Actor self, Target target, WRange minRange, WRange maxRange) public Follow(Actor self, Target target, WDist minRange, WDist maxRange)
{ {
this.target = target; this.target = target;
this.minRange = minRange; this.minRange = minRange;

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Activities
readonly Mobile mobile; readonly Mobile mobile;
readonly IDisableMove[] moveDisablers; readonly IDisableMove[] moveDisablers;
readonly WRange nearEnough; readonly WDist nearEnough;
readonly Func<List<CPos>> getPath; readonly Func<List<CPos>> getPath;
readonly Actor ignoredActor; readonly Actor ignoredActor;
@@ -50,14 +50,14 @@ namespace OpenRA.Mods.Common.Activities
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.ToCell, destination, false) PathSearch.FromPoint(self.World, mobile.Info, self, mobile.ToCell, destination, false)
.WithoutLaneBias()); .WithoutLaneBias());
this.destination = destination; this.destination = destination;
this.nearEnough = WRange.Zero; this.nearEnough = WDist.Zero;
} }
// HACK: for legacy code // HACK: for legacy code
public Move(Actor self, CPos destination, int nearEnough) public Move(Actor self, CPos destination, int nearEnough)
: this(self, destination, WRange.FromCells(nearEnough)) { } : this(self, destination, WDist.FromCells(nearEnough)) { }
public Move(Actor self, CPos destination, WRange nearEnough) public Move(Actor self, CPos destination, WDist nearEnough)
{ {
mobile = self.Trait<Mobile>(); mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray(); moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities
this.nearEnough = nearEnough; this.nearEnough = nearEnough;
} }
public Move(Actor self, CPos destination, SubCell subCell, WRange nearEnough) public Move(Actor self, CPos destination, SubCell subCell, WDist nearEnough)
{ {
mobile = self.Trait<Mobile>(); mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray(); moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
@@ -90,11 +90,11 @@ namespace OpenRA.Mods.Common.Activities
.WithIgnoredActor(ignoredActor)); .WithIgnoredActor(ignoredActor));
this.destination = destination; this.destination = destination;
this.nearEnough = WRange.Zero; this.nearEnough = WDist.Zero;
this.ignoredActor = ignoredActor; this.ignoredActor = ignoredActor;
} }
public Move(Actor self, Target target, WRange range) public Move(Actor self, Target target, WDist range)
{ {
mobile = self.Trait<Mobile>(); mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray(); moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Common.Activities
this.getPath = getPath; this.getPath = getPath;
destination = null; destination = null;
nearEnough = WRange.Zero; nearEnough = WDist.Zero;
} }
static int HashList<T>(List<T> xs) static int HashList<T>(List<T> xs)

View File

@@ -18,10 +18,10 @@ namespace OpenRA.Mods.Common.Activities
{ {
public class MoveWithinRange : MoveAdjacentTo public class MoveWithinRange : MoveAdjacentTo
{ {
readonly WRange maxRange; readonly WDist maxRange;
readonly WRange minRange; readonly WDist minRange;
public MoveWithinRange(Actor self, Target target, WRange minRange, WRange maxRange) public MoveWithinRange(Actor self, Target target, WDist minRange, WDist maxRange)
: base(self, target) : base(self, target)
{ {
this.minRange = minRange; this.minRange = minRange;

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common
{ {
// Move within sight range of the frozen actor // Move within sight range of the frozen actor
var sight = self.TraitOrDefault<RevealsShroud>(); var sight = self.TraitOrDefault<RevealsShroud>();
var range = sight != null ? sight.Range : WRange.FromCells(2); var range = sight != null ? sight.Range : WDist.FromCells(2);
self.QueueActivity(move.MoveWithinRange(Target.FromPos(frozen.CenterPosition), range)); self.QueueActivity(move.MoveWithinRange(Target.FromPos(frozen.CenterPosition), range));
} }

View File

@@ -23,9 +23,9 @@ namespace OpenRA.Mods.Common.Effects
public class BulletInfo : IProjectileInfo public class BulletInfo : IProjectileInfo
{ {
[Desc("Projectile speed in WRange / tick, two values indicate variable velocity.")] [Desc("Projectile speed in WRange / tick, two values indicate variable velocity.")]
public readonly WRange[] Speed = { new WRange(17) }; public readonly WDist[] Speed = { new WDist(17) };
[Desc("Maximum offset at the maximum range.")] [Desc("Maximum offset at the maximum range.")]
public readonly WRange Inaccuracy = WRange.Zero; public readonly WDist Inaccuracy = WDist.Zero;
public readonly string Image = null; public readonly string Image = null;
[SequenceReference("Image")] public readonly string Sequence = "idle"; [SequenceReference("Image")] public readonly string Sequence = "idle";
public readonly string Palette = "effect"; public readonly string Palette = "effect";
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Effects
readonly ProjectileArgs args; readonly ProjectileArgs args;
readonly Animation anim; readonly Animation anim;
[Sync] readonly WAngle angle; [Sync] readonly WAngle angle;
[Sync] readonly WRange speed; [Sync] readonly WDist speed;
ContrailRenderable contrail; ContrailRenderable contrail;
string trailPalette; string trailPalette;
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Effects
angle = info.Angle[0]; angle = info.Angle[0];
if (info.Speed.Length > 1) if (info.Speed.Length > 1)
speed = new WRange(world.SharedRandom.Next(info.Speed[0].Range, info.Speed[1].Range)); speed = new WDist(world.SharedRandom.Next(info.Speed[0].Range, info.Speed[1].Range));
else else
speed = info.Speed[0]; speed = info.Speed[0];

View File

@@ -25,9 +25,9 @@ namespace OpenRA.Mods.Common.Effects
public readonly string OpenSequence = null; public readonly string OpenSequence = null;
public readonly string Palette = "effect"; public readonly string Palette = "effect";
public readonly bool Shadow = false; public readonly bool Shadow = false;
public readonly WRange Velocity = WRange.Zero; public readonly WDist Velocity = WDist.Zero;
[Desc("Value added to velocity every tick.")] [Desc("Value added to velocity every tick.")]
public readonly WRange Acceleration = new WRange(15); public readonly WDist Acceleration = new WDist(15);
public IEffect Create(ProjectileArgs args) { return new GravityBomb(this, args); } public IEffect Create(ProjectileArgs args) { return new GravityBomb(this, args); }
} }
@@ -46,8 +46,8 @@ namespace OpenRA.Mods.Common.Effects
this.info = info; this.info = info;
this.args = args; this.args = args;
pos = args.Source; pos = args.Source;
velocity = new WVec(WRange.Zero, WRange.Zero, -info.Velocity); velocity = new WVec(WDist.Zero, WDist.Zero, -info.Velocity);
acceleration = new WVec(WRange.Zero, WRange.Zero, info.Acceleration); acceleration = new WVec(WDist.Zero, WDist.Zero, info.Acceleration);
anim = new Animation(args.SourceActor.World, info.Image); anim = new Animation(args.SourceActor.World, info.Image);

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Effects
public readonly string Palette = "effect"; public readonly string Palette = "effect";
public readonly bool Shadow = false; public readonly bool Shadow = false;
[Desc("Projectile speed in WRange / tick")] [Desc("Projectile speed in WRange / tick")]
public readonly WRange Speed = new WRange(8); public readonly WDist Speed = new WDist(8);
[Desc("Maximum vertical pitch when changing altitude.")] [Desc("Maximum vertical pitch when changing altitude.")]
public readonly WAngle MaximumPitch = WAngle.FromDegrees(30); public readonly WAngle MaximumPitch = WAngle.FromDegrees(30);
[Desc("How many ticks before this missile is armed and can explode.")] [Desc("How many ticks before this missile is armed and can explode.")]
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Is the missile blocked by actors with BlocksProjectiles: trait.")] [Desc("Is the missile blocked by actors with BlocksProjectiles: trait.")]
public readonly bool Blockable = true; public readonly bool Blockable = true;
[Desc("Maximum offset at the maximum range")] [Desc("Maximum offset at the maximum range")]
public readonly WRange Inaccuracy = WRange.Zero; public readonly WDist Inaccuracy = WDist.Zero;
[Desc("Probability of locking onto and following target.")] [Desc("Probability of locking onto and following target.")]
public readonly int LockOnProbability = 100; public readonly int LockOnProbability = 100;
[Desc("In n/256 per tick.")] [Desc("In n/256 per tick.")]
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Explodes when inside this proximity radius to target.", [Desc("Explodes when inside this proximity radius to target.",
"Note: If this value is lower than the missile speed, this check might", "Note: If this value is lower than the missile speed, this check might",
"not trigger fast enough, causing the missile to fly past the target.")] "not trigger fast enough, causing the missile to fly past the target.")]
public readonly WRange CloseEnough = new WRange(298); public readonly WDist CloseEnough = new WDist(298);
public IEffect Create(ProjectileArgs args) { return new Missile(this, args); } public IEffect Create(ProjectileArgs args) { return new Missile(this, args); }
} }

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Effects
WPos pos; WPos pos;
int ticks; int ticks;
public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WRange velocity, int delay, bool skipAscent, string flashType) public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType)
{ {
this.firedBy = firedBy; this.firedBy = firedBy;
this.weapon = weapon; this.weapon = weapon;
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Effects
this.turn = delay / 2; this.turn = delay / 2;
this.flashType = flashType; this.flashType = flashType;
var offset = new WVec(WRange.Zero, WRange.Zero, velocity * turn); var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);
ascendSource = launchPos; ascendSource = launchPos;
ascendTarget = launchPos + offset; ascendTarget = launchPos + offset;
descendSource = targetPos + offset; descendSource = targetPos + offset;

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Graphics
public class DefaultSpriteSequence : ISpriteSequence public class DefaultSpriteSequence : ISpriteSequence
{ {
static readonly WRange DefaultShadowSpriteZOffset = new WRange(-5); static readonly WDist DefaultShadowSpriteZOffset = new WDist(-5);
readonly Sprite[] sprites; readonly Sprite[] sprites;
readonly bool reverseFacings, transpose; readonly bool reverseFacings, transpose;
@@ -104,8 +104,8 @@ namespace OpenRA.Mods.Common.Graphics
{ {
Start = LoadField<int>(d, "Start", 0); Start = LoadField<int>(d, "Start", 0);
ShadowStart = LoadField<int>(d, "ShadowStart", -1); ShadowStart = LoadField<int>(d, "ShadowStart", -1);
ShadowZOffset = LoadField<WRange>(d, "ShadowZOffset", DefaultShadowSpriteZOffset).Range; ShadowZOffset = LoadField<WDist>(d, "ShadowZOffset", DefaultShadowSpriteZOffset).Range;
ZOffset = LoadField<WRange>(d, "ZOffset", WRange.Zero).Range; ZOffset = LoadField<WDist>(d, "ZOffset", WDist.Zero).Range;
Tick = LoadField<int>(d, "Tick", 40); Tick = LoadField<int>(d, "Tick", 40);
transpose = LoadField<bool>(d, "Transpose", false); transpose = LoadField<bool>(d, "Transpose", false);
Frames = LoadField<int[]>(d, "Frames", null); Frames = LoadField<int[]>(d, "Frames", null);

View File

@@ -16,12 +16,12 @@ namespace OpenRA.Mods.Common.Graphics
public struct RangeCircleRenderable : IRenderable, IFinalizedRenderable public struct RangeCircleRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos centerPosition; readonly WPos centerPosition;
readonly WRange radius; readonly WDist radius;
readonly int zOffset; readonly int zOffset;
readonly Color color; readonly Color color;
readonly Color contrastColor; readonly Color contrastColor;
public RangeCircleRenderable(WPos centerPosition, WRange radius, int zOffset, Color color, Color contrastColor) public RangeCircleRenderable(WPos centerPosition, WDist radius, int zOffset, Color color, Color contrastColor)
{ {
this.centerPosition = centerPosition; this.centerPosition = centerPosition;
this.radius = radius; this.radius = radius;

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Pathfinder
} }
} }
public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, Actor self) public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WDist range, Actor self)
{ {
using (new PerfSample("Pathfinder")) using (new PerfSample("Pathfinder"))
{ {

View File

@@ -65,9 +65,9 @@ namespace OpenRA.Mods.Common.Scripting
public WRangeGlobal(ScriptContext context) : base(context) { } public WRangeGlobal(ScriptContext context) : base(context) { }
[Desc("Create a new WRange.")] [Desc("Create a new WRange.")]
public WRange New(int r) { return new WRange(r); } public WDist New(int r) { return new WDist(r); }
[Desc("Create a new WRange by cell distance")] [Desc("Create a new WRange by cell distance")]
public WRange FromCells(int numCells) { return WRange.FromCells(numCells); } public WDist FromCells(int numCells) { return WDist.FromCells(numCells); }
} }
} }

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Scripting
} }
[Desc("Returns a table of all actors within the requested region, filtered using the specified function.")] [Desc("Returns a table of all actors within the requested region, filtered using the specified function.")]
public Actor[] ActorsInCircle(WPos location, WRange radius, LuaFunction filter = null) public Actor[] ActorsInCircle(WPos location, WDist radius, LuaFunction filter = null)
{ {
var actors = Context.World.FindActorsInCircle(location, radius); var actors = Context.World.FindActorsInCircle(location, radius);

View File

@@ -344,7 +344,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Call a function when an actor enters this range." + [Desc("Call a function when an actor enters this range." +
"Returns the trigger id for later removal using RemoveProximityTrigger(int id)." + "Returns the trigger id for later removal using RemoveProximityTrigger(int id)." +
"The callback function will be called as func(Actor a, int id).")] "The callback function will be called as func(Actor a, int id).")]
public int OnEnteredProximityTrigger(WPos pos, WRange range, LuaFunction func) public int OnEnteredProximityTrigger(WPos pos, WDist range, LuaFunction func)
{ {
var triggerId = 0; var triggerId = 0;
var onEntry = (LuaFunction)func.CopyReference(); var onEntry = (LuaFunction)func.CopyReference();
@@ -370,7 +370,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Call a function when an actor leaves this range." + [Desc("Call a function when an actor leaves this range." +
"Returns the trigger id for later removal using RemoveProximityTrigger(int id)." + "Returns the trigger id for later removal using RemoveProximityTrigger(int id)." +
"The callback function will be called as func(Actor a, int id).")] "The callback function will be called as func(Actor a, int id).")]
public int OnExitedProximityTrigger(WPos pos, WRange range, LuaFunction func) public int OnExitedProximityTrigger(WPos pos, WDist range, LuaFunction func)
{ {
var triggerId = 0; var triggerId = 0;
var onExit = (LuaFunction)func.CopyReference(); var onExit = (LuaFunction)func.CopyReference();

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Scripting
"(in cells) that will be considered close enough to complete the activity.")] "(in cells) that will be considered close enough to complete the activity.")]
public void Move(CPos cell, int closeEnough = 0) public void Move(CPos cell, int closeEnough = 0)
{ {
Self.QueueActivity(new Move(Self, cell, WRange.FromCells(closeEnough))); Self.QueueActivity(new Move(Self, cell, WDist.FromCells(closeEnough)));
} }
[ScriptActorPropertyActivity] [ScriptActorPropertyActivity]

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class AircraftInfo : ITraitInfo, IFacingInfo, IOccupySpaceInfo, ICruiseAltitudeInfo, UsesInit<LocationInit>, UsesInit<FacingInit> public class AircraftInfo : ITraitInfo, IFacingInfo, IOccupySpaceInfo, ICruiseAltitudeInfo, UsesInit<LocationInit>, UsesInit<FacingInit>
{ {
public readonly WRange CruiseAltitude = new WRange(1280); public readonly WDist CruiseAltitude = new WDist(1280);
public readonly WRange IdealSeparation = new WRange(1706); public readonly WDist IdealSeparation = new WDist(1706);
[Desc("Whether the aircraft can be repulsed.")] [Desc("Whether the aircraft can be repulsed.")]
public readonly bool Repulsable = true; public readonly bool Repulsable = true;
[Desc("The speed at which the aircraft is repulsed from other aircraft. Specify -1 for normal movement speed.")] [Desc("The speed at which the aircraft is repulsed from other aircraft. Specify -1 for normal movement speed.")]
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual object Create(ActorInitializer init) { return new Aircraft(init, this); } public virtual object Create(ActorInitializer init) { return new Aircraft(init, this); }
public int GetInitialFacing() { return InitialFacing; } public int GetInitialFacing() { return InitialFacing; }
public WRange GetCruiseAltitude() { return CruiseAltitude; } public WDist GetCruiseAltitude() { return CruiseAltitude; }
[VoiceReference] public readonly string Voice = "Action"; [VoiceReference] public readonly string Voice = "Action";

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool Spins = true; public readonly bool Spins = true;
public readonly bool Moves = false; public readonly bool Moves = false;
public readonly WRange Velocity = new WRange(43); public readonly WDist Velocity = new WDist(43);
public object Create(ActorInitializer init) { return new FallsToEarth(init.Self, this); } public object Create(ActorInitializer init) { return new FallsToEarth(init.Self, this); }
} }

View File

@@ -25,10 +25,10 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Allow the helicopter turn before landing.")] [Desc("Allow the helicopter turn before landing.")]
public readonly bool TurnToLand = false; public readonly bool TurnToLand = false;
public readonly WRange LandAltitude = WRange.Zero; public readonly WDist LandAltitude = WDist.Zero;
[Desc("How fast the helicopter ascends or descends.")] [Desc("How fast the helicopter ascends or descends.")]
public readonly WRange AltitudeVelocity = new WRange(43); public readonly WDist AltitudeVelocity = new WDist(43);
public override object Create(ActorInitializer init) { return new Helicopter(init, this); } public override object Create(ActorInitializer init) { return new Helicopter(init, this); }
} }
@@ -145,9 +145,9 @@ namespace OpenRA.Mods.Common.Traits
public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(self, Target.FromCell(self.World, cell)); } public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(self, Target.FromCell(self.World, cell)); } public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
public Activity MoveWithinRange(Target target, WRange range) { return new HeliFly(self, target, WRange.Zero, range); } public Activity MoveWithinRange(Target target, WDist range) { return new HeliFly(self, target, WDist.Zero, range); }
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return new HeliFly(self, target, minRange, maxRange); } public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange) { return new HeliFly(self, target, minRange, maxRange); }
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new Follow(self, target, minRange, maxRange); } public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange) { return new Follow(self, target, minRange, maxRange); }
public CPos NearestMoveableCell(CPos cell) { return cell; } public CPos NearestMoveableCell(CPos cell) { return cell; }
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)

View File

@@ -128,13 +128,13 @@ namespace OpenRA.Mods.Common.Traits
public Activity MoveTo(CPos cell, int nearEnough) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle(self)); } public Activity MoveTo(CPos cell, int nearEnough) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle(self)); }
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle(self)); } public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle(self)); }
public Activity MoveWithinRange(Target target, WRange range) { return Util.SequenceActivities(new Fly(self, target, WRange.Zero, range), new FlyCircle(self)); } public Activity MoveWithinRange(Target target, WDist range) { return Util.SequenceActivities(new Fly(self, target, WDist.Zero, range), new FlyCircle(self)); }
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange)
{ {
return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle(self)); return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle(self));
} }
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new FlyFollow(self, target, minRange, maxRange); } public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange) { return new FlyFollow(self, target, minRange, maxRange); }
public CPos NearestMoveableCell(CPos cell) { return cell; } public CPos NearestMoveableCell(CPos cell) { return cell; }
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return new Fly(self, Target.FromCell(self.World, cell)); } public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return new Fly(self, Target.FromCell(self.World, cell)); }
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos)));
} }
public Activity MoveToTarget(Actor self, Target target) { return new Fly(self, target, WRange.FromCells(3), WRange.FromCells(5)); } public Activity MoveToTarget(Actor self, Target target) { return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5)); }
public Activity MoveIntoTarget(Actor self, Target target) { return new Land(self, target); } public Activity MoveIntoTarget(Actor self, Target target) { return new Land(self, target); }
} }
} }

View File

@@ -48,10 +48,10 @@ namespace OpenRA.Mods.Common.Traits
public readonly WAngle[] LocalYaw = { }; public readonly WAngle[] LocalYaw = { };
[Desc("Move the turret backwards when firing.")] [Desc("Move the turret backwards when firing.")]
public readonly WRange Recoil = WRange.Zero; public readonly WDist Recoil = WDist.Zero;
[Desc("Recoil recovery per-frame")] [Desc("Recoil recovery per-frame")]
public readonly WRange RecoilRecovery = new WRange(9); public readonly WDist RecoilRecovery = new WDist(9);
[Desc("Muzzle flash sequence to render")] [Desc("Muzzle flash sequence to render")]
public readonly string MuzzleSequence = null; public readonly string MuzzleSequence = null;
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
Lazy<AmmoPool> ammoPool; Lazy<AmmoPool> ammoPool;
List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>(); List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>();
public WRange Recoil; public WDist Recoil;
public int FireDelay { get; private set; } public int FireDelay { get; private set; }
public int Burst { get; private set; } public int Burst { get; private set; }
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits
if (FireDelay > 0) if (FireDelay > 0)
--FireDelay; --FireDelay;
Recoil = new WRange(Math.Max(0, Recoil.Range - Info.RecoilRecovery.Range)); Recoil = new WDist(Math.Max(0, Recoil.Range - Info.RecoilRecovery.Range));
for (var i = 0; i < delayedActions.Count; i++) for (var i = 0; i < delayedActions.Count; i++)
{ {
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits
if (!target.IsInRange(self.CenterPosition, Weapon.Range)) if (!target.IsInRange(self.CenterPosition, Weapon.Range))
return null; return null;
if (Weapon.MinRange != WRange.Zero && target.IsInRange(self.CenterPosition, Weapon.MinRange)) if (Weapon.MinRange != WDist.Zero && target.IsInRange(self.CenterPosition, Weapon.MinRange))
return null; return null;
if (!Weapon.IsValidAgainst(target, self.World, self)) if (!Weapon.IsValidAgainst(target, self.World, self))
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.Common.Traits
public WVec MuzzleOffset(Actor self, Barrel b) public WVec MuzzleOffset(Actor self, Barrel b)
{ {
var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation); var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
var localOffset = b.Offset + new WVec(-Recoil, WRange.Zero, WRange.Zero); var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);
if (turret.Value != null) if (turret.Value != null)
{ {
var turretOrientation = coords.Value.QuantizeOrientation(self, turret.Value.LocalOrientation(self)); var turretOrientation = coords.Value.QuantizeOrientation(self, turret.Value.LocalOrientation(self));

View File

@@ -162,23 +162,23 @@ namespace OpenRA.Mods.Common.Traits
return Armaments.Any(a => a.Weapon.IsValidAgainst(t, self.World, self)); return Armaments.Any(a => a.Weapon.IsValidAgainst(t, self.World, self));
} }
public WRange GetMinimumRange() public WDist GetMinimumRange()
{ {
if (IsTraitDisabled) if (IsTraitDisabled)
return WRange.Zero; return WDist.Zero;
return Armaments.Where(a => !a.IsTraitDisabled) return Armaments.Where(a => !a.IsTraitDisabled)
.Select(a => a.Weapon.MinRange).Min(); .Select(a => a.Weapon.MinRange).Min();
} }
public WRange GetMaximumRange() public WDist GetMaximumRange()
{ {
if (IsTraitDisabled) if (IsTraitDisabled)
return WRange.Zero; return WDist.Zero;
return Armaments.Where(a => !a.IsTraitDisabled) return Armaments.Where(a => !a.IsTraitDisabled)
.Select(a => a.Weapon.Range) .Select(a => a.Weapon.Range)
.Append(WRange.Zero).Max(); .Append(WDist.Zero).Max();
} }
public Armament ChooseArmamentForTarget(Target t) { return Armaments.FirstOrDefault(a => a.Weapon.IsValidAgainst(t, self.World, self)); } public Armament ChooseArmamentForTarget(Target t) { return Armaments.FirstOrDefault(a => a.Weapon.IsValidAgainst(t, self.World, self)); }

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
|| (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.Traits.Contains<IMove>()); || (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.Traits.Contains<IMove>());
// Try and sit at least one cell closer than the max range to give some leeway if the target starts moving. // Try and sit at least one cell closer than the max range to give some leeway if the target starts moving.
var maxRange = targetIsMobile ? new WRange(Math.Max(weapon.Weapon.MinRange.Range, weapon.Weapon.Range.Range - 1024)) var maxRange = targetIsMobile ? new WDist(Math.Max(weapon.Weapon.MinRange.Range, weapon.Weapon.Range.Range - 1024))
: weapon.Weapon.Range; : weapon.Weapon.Range;
attack.Target = target; attack.Target = target;

View File

@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
if (nextScanTime <= 0) if (nextScanTime <= 0)
{ {
var range = info.ScanRadius > 0 ? WRange.FromCells(info.ScanRadius) : attack.GetMaximumRange(); var range = info.ScanRadius > 0 ? WDist.FromCells(info.ScanRadius) : attack.GetMaximumRange();
if (self.IsIdle || currentTarget == null || !Target.FromActor(currentTarget).IsInRange(self.CenterPosition, range)) if (self.IsIdle || currentTarget == null || !Target.FromActor(currentTarget).IsInRange(self.CenterPosition, range))
return ChooseTarget(self, range); return ChooseTarget(self, range);
} }
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Traits
attack.AttackTarget(target, false, info.AllowMovement && Stance != UnitStance.Defend); attack.AttackTarget(target, false, info.AllowMovement && Stance != UnitStance.Defend);
} }
Actor ChooseTarget(Actor self, WRange range) Actor ChooseTarget(Actor self, WDist range)
{ {
nextScanTime = self.World.SharedRandom.Next(info.MinimumScanTimeInterval, info.MaximumScanTimeInterval); nextScanTime = self.World.SharedRandom.Next(info.MinimumScanTimeInterval, info.MaximumScanTimeInterval);
var inRange = self.World.FindActorsInCircle(self.CenterPosition, range); var inRange = self.World.FindActorsInCircle(self.CenterPosition, range);

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(
self.CenterPosition, self.CenterPosition,
WRange.FromCells(Info.Range), WDist.FromCells(Info.Range),
0, 0,
Color.FromArgb(128, Ready() ? Color.White : Color.Red), Color.FromArgb(128, Ready() ? Color.White : Color.Red),
Color.FromArgb(96, Color.Black)); Color.FromArgb(96, Color.Black));

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
// Range is counted from the center of the actor, not from each cell. // Range is counted from the center of the actor, not from each cell.
var target = Target.FromPos(bp.Actor.CenterPosition); var target = Target.FromPos(bp.Actor.CenterPosition);
if (target.IsInRange(center, WRange.FromCells(bp.Trait.Info.Range))) if (target.IsInRange(center, WDist.FromCells(bp.Trait.Info.Range)))
return bp.Actor; return bp.Actor;
} }

View File

@@ -125,7 +125,7 @@ namespace OpenRA.Mods.Common.Traits
return self.World.ActorsWithTrait<DetectCloaked>().Any(a => !a.Trait.IsTraitDisabled && a.Actor.Owner.IsAlliedWith(viewer) return self.World.ActorsWithTrait<DetectCloaked>().Any(a => !a.Trait.IsTraitDisabled && a.Actor.Owner.IsAlliedWith(viewer)
&& Info.CloakTypes.Intersect(a.Trait.Info.CloakTypes).Any() && Info.CloakTypes.Intersect(a.Trait.Info.CloakTypes).Any()
&& (self.CenterPosition - a.Actor.CenterPosition).Length <= WRange.FromCells(a.Trait.Info.Range).Range); && (self.CenterPosition - a.Actor.CenterPosition).Length <= WDist.FromCells(a.Trait.Info.Range).Range);
} }
public Color RadarColorOverride(Actor self) public Color RadarColorOverride(Actor self)

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Duration = 0; public readonly int Duration = 0;
[Desc("The range to search for extra collectors in.", "Extra collectors will also be granted the crate action.")] [Desc("The range to search for extra collectors in.", "Extra collectors will also be granted the crate action.")]
public readonly WRange Range = new WRange(3); public readonly WDist Range = new WDist(3);
[Desc("The maximum number of extra collectors to grant the crate action to.", "-1 = no limit")] [Desc("The maximum number of extra collectors to grant the crate action to.", "-1 = no limit")]
public readonly int MaxExtraCollectors = 4; public readonly int MaxExtraCollectors = 4;

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int Levels = 1; public readonly int Levels = 1;
[Desc("The range to search for extra collectors in.", "Extra collectors will also be granted the crate action.")] [Desc("The range to search for extra collectors in.", "Extra collectors will also be granted the crate action.")]
public readonly WRange Range = new WRange(3); public readonly WDist Range = new WDist(3);
[Desc("The maximum number of extra collectors to grant the crate action to.")] [Desc("The maximum number of extra collectors to grant the crate action to.")]
public readonly int MaxExtraCollectors = 4; public readonly int MaxExtraCollectors = 4;

View File

@@ -49,8 +49,8 @@ namespace OpenRA.Mods.Common.Traits
{ {
self.SetTargetLine(target, Color.Yellow); self.SetTargetLine(target, Color.Yellow);
var range = WRange.FromCells(target.Actor.Info.Traits.Get<GuardableInfo>().Range); var range = WDist.FromCells(target.Actor.Info.Traits.Get<GuardableInfo>().Range);
self.QueueActivity(false, new AttackMoveActivity(self, self.Trait<IMove>().MoveFollow(self, target, WRange.Zero, range))); self.QueueActivity(false, new AttackMoveActivity(self, self.Trait<IMove>().MoveFollow(self, target, WDist.Zero, range)));
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)

View File

@@ -717,9 +717,9 @@ namespace OpenRA.Mods.Common.Traits
public Activity ScriptedMove(CPos cell) { return new Move(self, cell); } public Activity ScriptedMove(CPos cell) { return new Move(self, cell); }
public Activity MoveTo(CPos cell, int nearEnough) { return new Move(self, cell, nearEnough); } public Activity MoveTo(CPos cell, int nearEnough) { return new Move(self, cell, nearEnough); }
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new Move(self, cell, ignoredActor); } public Activity MoveTo(CPos cell, Actor ignoredActor) { return new Move(self, cell, ignoredActor); }
public Activity MoveWithinRange(Target target, WRange range) { return new MoveWithinRange(self, target, WRange.Zero, range); } public Activity MoveWithinRange(Target target, WDist range) { return new MoveWithinRange(self, target, WDist.Zero, range); }
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return new MoveWithinRange(self, target, minRange, maxRange); } public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange) { return new MoveWithinRange(self, target, minRange, maxRange); }
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new Follow(self, target, minRange, maxRange); } public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange) { return new Follow(self, target, minRange, maxRange); }
public Activity MoveTo(Func<List<CPos>> pathFunc) { return new Move(self, pathFunc); } public Activity MoveTo(Func<List<CPos>> pathFunc) { return new Move(self, pathFunc); }
public void OnNotifyBlockingMove(Actor self, Actor blocking) public void OnNotifyBlockingMove(Actor self, Actor blocking)

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
public class ParaDropInfo : ITraitInfo, Requires<CargoInfo> public class ParaDropInfo : ITraitInfo, Requires<CargoInfo>
{ {
[Desc("Distance around the drop-point to unload troops.")] [Desc("Distance around the drop-point to unload troops.")]
public readonly WRange DropRange = WRange.FromCells(4); public readonly WDist DropRange = WDist.FromCells(4);
[Desc("Sound to play when dropping.")] [Desc("Sound to play when dropping.")]
public readonly string ChuteSound = "chute1.aud"; public readonly string ChuteSound = "chute1.aud";

View File

@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int MaxAlternateTransportAttempts = 1; public readonly int MaxAlternateTransportAttempts = 1;
[Desc("Range from self for looking for an alternate transport (default: 5.5 cells).")] [Desc("Range from self for looking for an alternate transport (default: 5.5 cells).")]
public readonly WRange AlternateTransportScanRange = WRange.FromCells(11) / 2; public readonly WDist AlternateTransportScanRange = WDist.FromCells(11) / 2;
[Desc("Upgrade types to grant to transport.")] [Desc("Upgrade types to grant to transport.")]
public readonly string[] GrantUpgrades = { }; public readonly string[] GrantUpgrades = { };

View File

@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<Actor> UnitsInRange() IEnumerable<Actor> UnitsInRange()
{ {
return Self.World.FindActorsInCircle(Self.CenterPosition, WRange.FromCells(Info.Range)) return Self.World.FindActorsInCircle(Self.CenterPosition, WDist.FromCells(Info.Range))
.Where(a => a.IsInWorld && a != Self && !a.Disposed && !a.Owner.NonCombatant); .Where(a => a.IsInWorld && a != Self && !a.Disposed && !a.Owner.NonCombatant);
} }

View File

@@ -35,10 +35,10 @@ namespace OpenRA.Mods.Common.Traits
var range = self.TraitsImplementing<DetectCloaked>() var range = self.TraitsImplementing<DetectCloaked>()
.Where(a => !a.IsTraitDisabled) .Where(a => !a.IsTraitDisabled)
.Select(a => WRange.FromCells(a.Info.Range)) .Select(a => WDist.FromCells(a.Info.Range))
.Append(WRange.Zero).Max(); .Append(WDist.Zero).Max();
if (range == WRange.Zero) if (range == WDist.Zero)
yield break; yield break;
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string RangeCircleType = null; public readonly string RangeCircleType = null;
[Desc("Range to draw if no armaments are available")] [Desc("Range to draw if no armaments are available")]
public readonly WRange FallbackRange = WRange.Zero; public readonly WDist FallbackRange = WDist.Zero;
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition) public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
{ {
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
if (armaments.Any()) if (armaments.Any())
range = armaments.Select(a => w.Map.Rules.Weapons[a.Weapon.ToLowerInvariant()].Range).Max(); range = armaments.Select(a => w.Map.Rules.Weapons[a.Weapon.ToLowerInvariant()].Range).Max();
if (range == WRange.Zero) if (range == WDist.Zero)
yield break; yield break;
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
yield break; yield break;
var range = attack.GetMaximumRange(); var range = attack.GetMaximumRange();
if (range == WRange.Zero) if (range == WDist.Zero)
yield break; yield break;
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(

View File

@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
WVec BarrelOffset() WVec BarrelOffset()
{ {
var localOffset = info.LocalOffset + new WVec(-armament.Recoil, WRange.Zero, WRange.Zero); var localOffset = info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero);
var turretOffset = turreted != null ? turreted.Position(self) : WVec.Zero; var turretOffset = turreted != null ? turreted.Position(self) : WVec.Zero;
var turretOrientation = turreted != null ? turreted.LocalOrientation(self) : WRot.Zero; var turretOrientation = turreted != null ? turreted.LocalOrientation(self) : WRot.Zero;

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly Color Color = Color.FromArgb(128, Color.White); public readonly Color Color = Color.FromArgb(128, Color.White);
[Desc("Range of the circle")] [Desc("Range of the circle")]
public readonly WRange Range = WRange.Zero; public readonly WDist Range = WDist.Zero;
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition) public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
{ {

View File

@@ -91,8 +91,8 @@ namespace OpenRA.Mods.Common.Traits
if (!Info.Recoils) if (!Info.Recoils)
return t.Position(self); return t.Position(self);
var recoil = arms.Aggregate(WRange.Zero, (a, b) => a + b.Recoil); var recoil = arms.Aggregate(WDist.Zero, (a, b) => a + b.Recoil);
var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero); var localOffset = new WVec(-recoil, WDist.Zero, WDist.Zero);
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation); var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self)); var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self));
return t.Position(self) + body.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation)); return t.Position(self) + body.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation));

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
WVec BarrelOffset() WVec BarrelOffset()
{ {
var localOffset = info.LocalOffset + new WVec(-armament.Recoil, WRange.Zero, WRange.Zero); var localOffset = info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero);
var turretOffset = turreted != null ? turreted.Position(self) : WVec.Zero; var turretOffset = turreted != null ? turreted.Position(self) : WVec.Zero;
var turretOrientation = turreted != null ? turreted.LocalOrientation(self) : WRot.Zero; var turretOrientation = turreted != null ? turreted.LocalOrientation(self) : WRot.Zero;

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
var target = Target.FromOrder(self.World, order); var target = Target.FromOrder(self.World, order);
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(movement.MoveWithinRange(target, new WRange(1024 * info.CloseEnough))); self.QueueActivity(movement.MoveWithinRange(target, new WDist(1024 * info.CloseEnough)));
self.QueueActivity(new Repair(order.TargetActor)); self.QueueActivity(new Repair(order.TargetActor));
self.SetTargetLine(target, Color.Green, false); self.SetTargetLine(target, Color.Green, false);

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class RevealsShroudInfo : ITraitInfo public class RevealsShroudInfo : ITraitInfo
{ {
public readonly WRange Range = WRange.Zero; public readonly WDist Range = WDist.Zero;
[Desc("Possible values are CenterPosition (measure range from the center) and ", [Desc("Possible values are CenterPosition (measure range from the center) and ",
"Footprint (measure range from the footprint)")] "Footprint (measure range from the footprint)")]
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
var map = self.World.Map; var map = self.World.Map;
var range = Range; var range = Range;
if (range == WRange.Zero) if (range == WDist.Zero)
return NoCells; return NoCells;
if (info.Type == VisibilityType.Footprint) if (info.Type == VisibilityType.Footprint)
@@ -101,6 +101,6 @@ namespace OpenRA.Mods.Common.Traits
removeCellsFromPlayerShroud(p); removeCellsFromPlayerShroud(p);
} }
public WRange Range { get { return cachedDisabled ? WRange.Zero : info.Range; } } public WDist Range { get { return cachedDisabled ? WDist.Zero : info.Range; } }
} }
} }

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly WVec SquadOffset = new WVec(-1536, 1536, 0); public readonly WVec SquadOffset = new WVec(-1536, 1536, 0);
public readonly int QuantizedFacings = 32; public readonly int QuantizedFacings = 32;
public readonly WRange Cordon = new WRange(5120); public readonly WDist Cordon = new WDist(5120);
[ActorReference] [ActorReference]
[Desc("Actor to spawn when the aircraft start attacking")] [Desc("Actor to spawn when the aircraft start attacking")]
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int CameraRemoveDelay = 25; public readonly int CameraRemoveDelay = 25;
[Desc("Weapon range offset to apply during the beacon clock calculation")] [Desc("Weapon range offset to apply during the beacon clock calculation")]
public readonly WRange BeaconDistanceOffset = WRange.FromCells(6); public readonly WDist BeaconDistanceOffset = WDist.FromCells(6);
public override object Create(ActorInitializer init) { return new AirstrikePower(init.Self, this); } public override object Create(ActorInitializer init) { return new AirstrikePower(init.Self, this); }
} }

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int FlightDelay = 400; public readonly int FlightDelay = 400;
[Desc("Visual ascent velocity in WRange / tick")] [Desc("Visual ascent velocity in WRange / tick")]
public readonly WRange FlightVelocity = new WRange(512); public readonly WDist FlightVelocity = new WDist(512);
[Desc("Descend immediately on the target, with half the FlightDelay")] [Desc("Descend immediately on the target, with half the FlightDelay")]
public readonly bool SkipAscent = false; public readonly bool SkipAscent = false;

View File

@@ -21,10 +21,10 @@ namespace OpenRA.Mods.Common.Traits
public readonly WVec Offset = WVec.Zero; public readonly WVec Offset = WVec.Zero;
[Desc("Minimum distance to throw the particle")] [Desc("Minimum distance to throw the particle")]
public readonly WRange MinThrowRange = new WRange(256); public readonly WDist MinThrowRange = new WDist(256);
[Desc("Maximum distance to throw the particle")] [Desc("Maximum distance to throw the particle")]
public readonly WRange MaxThrowRange = new WRange(768); public readonly WDist MaxThrowRange = new WDist(768);
[Desc("Minimum angle to throw the particle")] [Desc("Minimum angle to throw the particle")]
public readonly WAngle MinThrowAngle = WAngle.FromDegrees(30); public readonly WAngle MinThrowAngle = WAngle.FromDegrees(30);
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
length = (finalPos - initialPos).Length / info.Velocity; length = (finalPos - initialPos).Length / info.Velocity;
// Facing rotation // Facing rotation
rotation = WRange.FromPDF(Game.CosmeticRandom, 2).Range * info.ROT / 1024; rotation = WDist.FromPDF(Game.CosmeticRandom, 2).Range * info.ROT / 1024;
var anim = new Animation(init.World, rs.GetImage(self), () => (int)facing); var anim = new Animation(init.World, rs.GetImage(self), () => (int)facing);
anim.PlayRepeating(info.Anim); anim.PlayRepeating(info.Anim);

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string[] Upgrades = { }; public readonly string[] Upgrades = { };
[Desc("The range to search for actors to upgrade.")] [Desc("The range to search for actors to upgrade.")]
public readonly WRange Range = WRange.FromCells(3); public readonly WDist Range = WDist.FromCells(3);
[Desc("What diplomatic stances are affected.")] [Desc("What diplomatic stances are affected.")]
public readonly Stance ValidStances = Stance.Ally; public readonly Stance ValidStances = Stance.Ally;
@@ -44,8 +44,8 @@ namespace OpenRA.Mods.Common.Traits
int proximityTrigger; int proximityTrigger;
WPos cachedPosition; WPos cachedPosition;
WRange cachedRange; WDist cachedRange;
WRange desiredRange; WDist desiredRange;
bool cachedDisabled = true; bool cachedDisabled = true;
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
if (cachedDisabled != disabled) if (cachedDisabled != disabled)
{ {
Sound.Play(disabled ? info.DisableSound : info.EnableSound, self.CenterPosition); Sound.Play(disabled ? info.DisableSound : info.EnableSound, self.CenterPosition);
desiredRange = disabled ? WRange.Zero : info.Range; desiredRange = disabled ? WDist.Zero : info.Range;
cachedDisabled = disabled; cachedDisabled = disabled;
} }

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int QuantizedFacings = 32; public readonly int QuantizedFacings = 32;
[Desc("Spawn and remove the plane this far outside the map.")] [Desc("Spawn and remove the plane this far outside the map.")]
public readonly WRange Cordon = new WRange(5120); public readonly WDist Cordon = new WDist(5120);
public object Create(ActorInitializer init) { return new CrateSpawner(this, init.Self); } public object Create(ActorInitializer init) { return new CrateSpawner(this, init.Self); }
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class MPStartLocationsInfo : ITraitInfo public class MPStartLocationsInfo : ITraitInfo
{ {
public readonly WRange InitialExploreRange = WRange.FromCells(5); public readonly WDist InitialExploreRange = WDist.FromCells(5);
public virtual object Create(ActorInitializer init) { return new MPStartLocations(this); } public virtual object Create(ActorInitializer init) { return new MPStartLocations(this); }
} }

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
/// <returns>A path from start to target</returns> /// <returns>A path from start to target</returns>
List<CPos> FindUnitPath(CPos source, CPos target, Actor self); List<CPos> FindUnitPath(CPos source, CPos target, Actor self);
List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, Actor self); List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WDist range, Actor self);
/// <summary> /// <summary>
/// Calculates a path given a search specification /// Calculates a path given a search specification
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
return pb; return pb;
} }
public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WRange range, Actor self) public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WDist range, Actor self)
{ {
var mi = self.Info.Traits.Get<MobileInfo>(); var mi = self.Info.Traits.Get<MobileInfo>();
var targetCell = world.Map.CellContaining(target); var targetCell = world.Map.CellContaining(target);

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
public interface INotifyChat { bool OnChat(string from, string message); } public interface INotifyChat { bool OnChat(string from, string message); }
public interface INotifyParachuteLanded { void OnLanded(); } public interface INotifyParachuteLanded { void OnLanded(); }
public interface IRenderActorPreviewInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); } public interface IRenderActorPreviewInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }
public interface ICruiseAltitudeInfo { WRange GetCruiseAltitude(); } public interface ICruiseAltitudeInfo { WDist GetCruiseAltitude(); }
public interface IUpgradable public interface IUpgradable
{ {
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits
public interface ICallForTransport public interface ICallForTransport
{ {
WRange MinimumDistance { get; } WDist MinimumDistance { get; }
bool WantsTransport { get; set; } bool WantsTransport { get; set; }
void MovementCancelled(Actor self); void MovementCancelled(Actor self);
void RequestTransport(CPos destination, Activity afterLandActivity); void RequestTransport(CPos destination, Activity afterLandActivity);

View File

@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
if (t == typeof(WPos)) if (t == typeof(WPos))
return "3D World Position"; return "3D World Position";
if (t == typeof(WRange)) if (t == typeof(WDist))
return "1D World Range"; return "1D World Range";
if (t == typeof(WVec)) if (t == typeof(WVec))

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Warheads
[Desc("Duration of the upgrade (in ticks). Set to 0 for a permanent upgrade.")] [Desc("Duration of the upgrade (in ticks). Set to 0 for a permanent upgrade.")]
public readonly int Duration = 0; public readonly int Duration = 0;
public readonly WRange Range = WRange.FromCells(1); public readonly WDist Range = WDist.FromCells(1);
// TODO: This can be removed after the legacy and redundant 0% = not targetable // TODO: This can be removed after the legacy and redundant 0% = not targetable
// assumption has been removed from the yaml definitions // assumption has been removed from the yaml definitions

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Warheads
public class HealthPercentageDamageWarhead : DamageWarhead public class HealthPercentageDamageWarhead : DamageWarhead
{ {
[Desc("Size of the area. Damage will be applied to this area.", "If two spreads are defined, the area of effect is a ring, where the second value is the inner radius.")] [Desc("Size of the area. Damage will be applied to this area.", "If two spreads are defined, the area of effect is a ring, where the second value is the inner radius.")]
public readonly WRange[] Spread = { new WRange(43) }; public readonly WDist[] Spread = { new WDist(43) };
public override void DoImpact(WPos pos, Actor firedBy, IEnumerable<int> damageModifiers) public override void DoImpact(WPos pos, Actor firedBy, IEnumerable<int> damageModifiers)
{ {

View File

@@ -17,13 +17,13 @@ namespace OpenRA.Mods.Common.Warheads
public class SpreadDamageWarhead : DamageWarhead public class SpreadDamageWarhead : DamageWarhead
{ {
[Desc("Range between falloff steps.")] [Desc("Range between falloff steps.")]
public readonly WRange Spread = new WRange(43); public readonly WDist Spread = new WDist(43);
[Desc("Damage percentage at each range step")] [Desc("Damage percentage at each range step")]
public readonly int[] Falloff = { 100, 37, 14, 5, 2, 1, 0 }; public readonly int[] Falloff = { 100, 37, 14, 5, 2, 1, 0 };
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")] [Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
public WRange[] Range = null; public WDist[] Range = null;
public void InitializeRange() public void InitializeRange()
{ {

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.D2k.Activities
{ {
case State.Intercept: case State.Intercept:
state = State.LockCarryable; state = State.LockCarryable;
return Util.SequenceActivities(movement.MoveWithinRange(Target.FromActor(cargo), WRange.FromCells(4)), this); return Util.SequenceActivities(movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4)), this);
case State.LockCarryable: case State.LockCarryable:
// Last check // Last check

View File

@@ -23,10 +23,10 @@ namespace OpenRA.Mods.D2k.Traits
public readonly int[] Falloff = { 100, 100, 25, 11, 6, 4, 3, 2, 1, 0 }; public readonly int[] Falloff = { 100, 100, 25, 11, 6, 4, 3, 2, 1, 0 };
[Desc("Range between falloff steps.")] [Desc("Range between falloff steps.")]
public readonly WRange Spread = new WRange(3072); public readonly WDist Spread = new WDist(3072);
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")] [Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
public WRange[] Range = null; public WDist[] Range = null;
public override object Create(ActorInitializer init) { return new AttractsWorms(init, this); } public override object Create(ActorInitializer init) { return new AttractsWorms(init, this); }
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.D2k.Traits
public class CarryableInfo : ITraitInfo public class CarryableInfo : ITraitInfo
{ {
[Desc("Required distance away from destination before requesting a pickup. Default is 6 cells.")] [Desc("Required distance away from destination before requesting a pickup. Default is 6 cells.")]
public WRange MinDistance = WRange.FromCells(6); public WDist MinDistance = WDist.FromCells(6);
public object Create(ActorInitializer init) { return new Carryable(init.Self, this); } public object Create(ActorInitializer init) { return new Carryable(init.Self, this); }
} }
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.D2k.Traits
public void MovingToResources(Actor self, CPos targetCell, Activity next) { RequestTransport(targetCell, next); } public void MovingToResources(Actor self, CPos targetCell, Activity next) { RequestTransport(targetCell, next); }
public void MovingToRefinery(Actor self, CPos targetCell, Activity next) { RequestTransport(targetCell, next); } public void MovingToRefinery(Actor self, CPos targetCell, Activity next) { RequestTransport(targetCell, next); }
public WRange MinimumDistance { get { return info.MinDistance; } } public WDist MinimumDistance { get { return info.MinDistance; } }
public void RequestTransport(CPos destination, Activity afterLandActivity) public void RequestTransport(CPos destination, Activity afterLandActivity)
{ {

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.D2k.Traits
public class Carryall : INotifyBecomingIdle, INotifyKilled, ISync, IRender, INotifyActorDisposing public class Carryall : INotifyBecomingIdle, INotifyKilled, ISync, IRender, INotifyActorDisposing
{ {
readonly Actor self; readonly Actor self;
readonly WRange carryHeight; readonly WDist carryHeight;
readonly CarryallInfo info; readonly CarryallInfo info;
// The actor we are currently carrying. // The actor we are currently carrying.

View File

@@ -21,10 +21,10 @@ namespace OpenRA.Mods.D2k.Traits
public readonly int TargetRescanInterval = 32; public readonly int TargetRescanInterval = 32;
[Desc("The radius in which the worm \"searches\" for targets.")] [Desc("The radius in which the worm \"searches\" for targets.")]
public readonly WRange MaxSearchRadius = WRange.FromCells(27); public readonly WDist MaxSearchRadius = WDist.FromCells(27);
[Desc("The range at which the worm launches an attack regardless of noise levels.")] [Desc("The range at which the worm launches an attack regardless of noise levels.")]
public readonly WRange IgnoreNoiseAttackRange = WRange.FromCells(3); public readonly WDist IgnoreNoiseAttackRange = WDist.FromCells(3);
[Desc("The chance this actor has of disappearing after it attacks (in %).")] [Desc("The chance this actor has of disappearing after it attacks (in %).")]
public readonly int ChanceToDisappear = 80; public readonly int ChanceToDisappear = 80;
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.D2k.Traits
if (IsMovingTowardTarget) if (IsMovingTowardTarget)
return; return;
self.QueueActivity(mobile.Value.MoveWithinRange(Target.FromCell(self.World, targetCell, SubCell.Any), WRange.FromCells(1))); self.QueueActivity(mobile.Value.MoveWithinRange(Target.FromCell(self.World, targetCell, SubCell.Any), WDist.FromCells(1)));
} }
public void Tick(Actor self) public void Tick(Actor self)

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.D2k.Traits
[WeaponReference] [WeaponReference]
public string[] Weapons = { }; public string[] Weapons = { };
public int[] Pieces = { 3, 10 }; public int[] Pieces = { 3, 10 };
public WRange[] Range = { WRange.FromCells(2), WRange.FromCells(5) }; public WDist[] Range = { WDist.FromCells(2), WDist.FromCells(5) };
public object Create(ActorInitializer actor) { return new ThrowsShrapnel(this); } public object Create(ActorInitializer actor) { return new ThrowsShrapnel(this); }
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.D2k.Warheads
[Desc("Duration of the owner change (in ticks). Set to 0 to make it permanent.")] [Desc("Duration of the owner change (in ticks). Set to 0 to make it permanent.")]
public readonly int Duration = 0; public readonly int Duration = 0;
public readonly WRange Range = WRange.FromCells(1); public readonly WDist Range = WDist.FromCells(1);
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{ {

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Activities
int ticks; int ticks;
WAngle angle; WAngle angle;
public Leap(Actor self, Actor target, WeaponInfo weapon, WRange speed, WAngle angle) public Leap(Actor self, Actor target, WeaponInfo weapon, WDist speed, WAngle angle)
{ {
var targetMobile = target.TraitOrDefault<Mobile>(); var targetMobile = target.TraitOrDefault<Mobile>();
if (targetMobile == null) if (targetMobile == null)

View File

@@ -107,8 +107,8 @@ namespace OpenRA.Mods.RA.Graphics
var renderables = new List<IFinalizedRenderable>(); var renderables = new List<IFinalizedRenderable>();
if (Game.CosmeticRandom.Next(2) != 0) if (Game.CosmeticRandom.Next(2) != 0)
{ {
var p1 = from + (1 / 3f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm; var p1 = from + (1 / 3f) * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm;
var p2 = from + (2 / 3f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm; var p2 = from + (2 / 3f) * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm;
renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal)); renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal));
renderables.AddRange(DrawZap(wr, p1, p2, s, out p2, pal)); renderables.AddRange(DrawZap(wr, p1, p2, s, out p2, pal));
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.RA.Graphics
} }
else else
{ {
var p1 = from + (1 / 2f) * dist + WRange.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm; var p1 = from + (1 / 2f) * dist + WDist.FromPDF(Game.CosmeticRandom, 2).Range * dist.Length / 4096 * norm;
renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal)); renderables.AddRange(DrawZap(wr, from, p1, s, out p1, pal));
renderables.AddRange(DrawZap(wr, p1, to, s, out z, pal)); renderables.AddRange(DrawZap(wr, p1, to, s, out z, pal));

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Traits
class AttackLeapInfo : AttackFrontalInfo class AttackLeapInfo : AttackFrontalInfo
{ {
[Desc("Leap speed (in units/tick).")] [Desc("Leap speed (in units/tick).")]
public readonly WRange Speed = new WRange(426); public readonly WDist Speed = new WDist(426);
public readonly WAngle Angle = WAngle.FromDegrees(20); public readonly WAngle Angle = WAngle.FromDegrees(20);
public override object Create(ActorInitializer init) { return new AttackLeap(init.Self, this); } public override object Create(ActorInitializer init) { return new AttackLeap(init.Self, this); }

View File

@@ -198,7 +198,7 @@ namespace OpenRA.Mods.RA.Traits
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(
self.CenterPosition, self.CenterPosition,
WRange.FromCells(self.Trait<PortableChrono>().Info.MaxDistance), WDist.FromCells(self.Trait<PortableChrono>().Info.MaxDistance),
0, 0,
Color.FromArgb(128, Color.LawnGreen), Color.FromArgb(128, Color.LawnGreen),
Color.FromArgb(96, Color.Black)); Color.FromArgb(96, Color.Black));

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(
centerPosition, centerPosition,
WRange.FromCells(jamsMissiles.Range), WDist.FromCells(jamsMissiles.Range),
0, 0,
Color.FromArgb(128, Color.Red), Color.FromArgb(128, Color.Red),
Color.FromArgb(96, Color.Black)); Color.FromArgb(96, Color.Black));
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(
centerPosition, centerPosition,
WRange.FromCells(jamsRadar.Range), WDist.FromCells(jamsRadar.Range),
0, 0,
Color.FromArgb(128, Color.Blue), Color.FromArgb(128, Color.Blue),
Color.FromArgb(96, Color.Black)); Color.FromArgb(96, Color.Black));
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(
self.CenterPosition, self.CenterPosition,
WRange.FromCells(jamsMissiles.Range), WDist.FromCells(jamsMissiles.Range),
0, 0,
Color.FromArgb(128, Color.Red), Color.FromArgb(128, Color.Red),
Color.FromArgb(96, Color.Black)); Color.FromArgb(96, Color.Black));
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
yield return new RangeCircleRenderable( yield return new RangeCircleRenderable(
self.CenterPosition, self.CenterPosition,
WRange.FromCells(jamsRadar.Range), WDist.FromCells(jamsRadar.Range),
0, 0,
Color.FromArgb(128, Color.Blue), Color.FromArgb(128, Color.Blue),
Color.FromArgb(96, Color.Black)); Color.FromArgb(96, Color.Black));

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly int QuantizedFacings = 32; public readonly int QuantizedFacings = 32;
[Desc("Spawn and remove the plane this far outside the map.")] [Desc("Spawn and remove the plane this far outside the map.")]
public readonly WRange Cordon = new WRange(5120); public readonly WDist Cordon = new WDist(5120);
[ActorReference] [ActorReference]
[Desc("Troops to be delivered. They will be distributed between the planes if SquadSize > 1.")] [Desc("Troops to be delivered. They will be distributed between the planes if SquadSize > 1.")]
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly int CameraRemoveDelay = 85; public readonly int CameraRemoveDelay = 85;
[Desc("Weapon range offset to apply during the beacon clock calculation.")] [Desc("Weapon range offset to apply during the beacon clock calculation.")]
public readonly WRange BeaconDistanceOffset = WRange.FromCells(4); public readonly WDist BeaconDistanceOffset = WDist.FromCells(4);
public override object Create(ActorInitializer init) { return new ParatroopersPower(init.Self, this); } public override object Create(ActorInitializer init) { return new ParatroopersPower(init.Self, this); }
} }