Make Range WDist for all traits with circular ranges.
This commit is contained in:
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
bool JammedBy(TraitPair<JamsMissiles> tp)
|
||||
{
|
||||
if ((tp.Actor.CenterPosition - pos).HorizontalLengthSquared > tp.Trait.Range * tp.Trait.Range)
|
||||
if ((tp.Actor.CenterPosition - pos).HorizontalLengthSquared > tp.Trait.Range.LengthSquared)
|
||||
return false;
|
||||
|
||||
if (tp.Actor.Owner.Stances[args.SourceActor.Owner] == Stance.Ally && !tp.Trait.AlliedMissiles)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Limits the zone where buildings can be constructed to a radius around this actor.")]
|
||||
public class BaseProviderInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Range = 10;
|
||||
public readonly WDist Range = WDist.FromCells(10);
|
||||
public readonly int Cooldown = 0;
|
||||
public readonly int InitialDelay = 0;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
yield return new RangeCircleRenderable(
|
||||
self.CenterPosition,
|
||||
WDist.FromCells(Info.Range),
|
||||
Info.Range,
|
||||
0,
|
||||
Color.FromArgb(128, Ready() ? Color.White : Color.Red),
|
||||
Color.FromArgb(96, Color.Black));
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Range is counted from the center of the actor, not from each cell.
|
||||
var target = Target.FromPos(bp.Actor.CenterPosition);
|
||||
if (target.IsInRange(center, WDist.FromCells(bp.Trait.Info.Range)))
|
||||
if (target.IsInRange(center, bp.Trait.Info.Range))
|
||||
return bp.Actor;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
return self.World.ActorsWithTrait<DetectCloaked>().Any(a => !a.Trait.IsTraitDisabled && a.Actor.Owner.IsAlliedWith(viewer)
|
||||
&& Info.CloakTypes.Overlaps(a.Trait.Info.CloakTypes)
|
||||
&& (self.CenterPosition - a.Actor.CenterPosition).Length <= WDist.FromCells(a.Trait.Info.Range).Length);
|
||||
&& (self.CenterPosition - a.Actor.CenterPosition).LengthSquared <= a.Trait.Info.Range.LengthSquared);
|
||||
}
|
||||
|
||||
public Color RadarColorOverride(Actor self)
|
||||
|
||||
@@ -18,8 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Specific cloak classifications I can reveal.")]
|
||||
public readonly HashSet<string> CloakTypes = new HashSet<string> { "Cloak" };
|
||||
|
||||
[Desc("Measured in cells.")]
|
||||
public readonly int Range = 5;
|
||||
public readonly WDist Range = WDist.FromCells(5);
|
||||
|
||||
public override object Create(ActorInitializer init) { return new DetectCloaked(this); }
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
self.SetTargetLine(target, Color.Yellow);
|
||||
|
||||
var range = WDist.FromCells(target.Actor.Info.TraitInfo<GuardableInfo>().Range);
|
||||
var range = target.Actor.Info.TraitInfo<GuardableInfo>().Range;
|
||||
self.QueueActivity(false, new AttackMoveActivity(self, self.Trait<IMove>().MoveFollow(self, target, WDist.Zero, range)));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("This unit can be guarded (followed and protected) by a Guard unit.")]
|
||||
public class GuardableInfo : TraitInfo<Guardable>
|
||||
{
|
||||
[Desc("Maximum range that guarding actors will maintain. Measured in cells.")]
|
||||
public readonly int Range = 2;
|
||||
[Desc("Maximum range that guarding actors will maintain.")]
|
||||
public readonly WDist Range = WDist.FromCells(2);
|
||||
}
|
||||
|
||||
public class Guardable { }
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class JamsMissilesInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Range = 0;
|
||||
public readonly WDist Range = WDist.Zero;
|
||||
public readonly bool AlliedMissiles = true;
|
||||
public readonly int Chance = 100;
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly JamsMissilesInfo info;
|
||||
|
||||
// Convert cells to world units
|
||||
public int Range { get { return 1024 * info.Range; } }
|
||||
public WDist Range { get { return info.Range; } }
|
||||
public bool AlliedMissiles { get { return info.AlliedMissiles; } }
|
||||
public int Chance { get { return info.Chance; } }
|
||||
|
||||
|
||||
@@ -27,10 +27,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Check if powered
|
||||
if (self.IsDisabled()) return false;
|
||||
|
||||
var isJammed = self.World.ActorsWithTrait<JamsRadar>().Any(a => a.Actor.Owner.Stances[self.Owner] != Stance.Ally
|
||||
&& (self.Location - a.Actor.Location).Length <= a.Actor.Info.TraitInfo<JamsRadarInfo>().Range);
|
||||
|
||||
return !isJammed;
|
||||
return self.World.ActorsWithTrait<JamsRadar>().All(a => a.Actor.Owner.Stances[self.Owner] == Stance.Ally
|
||||
|| (self.CenterPosition - a.Actor.CenterPosition).HorizontalLengthSquared
|
||||
> a.Actor.Info.TraitInfo<JamsRadarInfo>().Range.LengthSquared);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class JamsRadarInfo : TraitInfo<JamsRadar>
|
||||
{
|
||||
[Desc("Range for jamming.")]
|
||||
public readonly int Range = 0;
|
||||
public readonly WDist Range = WDist.Zero;
|
||||
}
|
||||
|
||||
public class JamsRadar { }
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class ProximityCapturableInfo : ITraitInfo
|
||||
{
|
||||
public readonly bool Permanent = false;
|
||||
public readonly int Range = 5;
|
||||
public readonly WDist Range = WDist.FromCells(5);
|
||||
public readonly bool MustBeClear = false;
|
||||
public readonly HashSet<string> CaptorTypes = new HashSet<string> { "Vehicle", "Tank", "Infantry" };
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IEnumerable<Actor> UnitsInRange()
|
||||
{
|
||||
return Self.World.FindActorsInCircle(Self.CenterPosition, WDist.FromCells(Info.Range))
|
||||
return Self.World.FindActorsInCircle(Self.CenterPosition, Info.Range)
|
||||
.Where(a => a.IsInWorld && a != Self && !a.Disposed && !a.Owner.NonCombatant);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var range = self.TraitsImplementing<DetectCloaked>()
|
||||
.Where(a => !a.IsTraitDisabled)
|
||||
.Select(a => WDist.FromCells(a.Info.Range))
|
||||
.Select(a => a.Info.Range)
|
||||
.Append(WDist.Zero).Max();
|
||||
|
||||
if (range == WDist.Zero)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Duration of the upgrade (in ticks). Set to 0 for a permanent upgrade.")]
|
||||
public readonly int Duration = 0;
|
||||
|
||||
[Desc("Cells")]
|
||||
[Desc("Cells - affects whole cells only")]
|
||||
public readonly int Range = 1;
|
||||
public readonly string GrantUpgradeSound = "ironcur9.aud";
|
||||
|
||||
|
||||
@@ -2126,6 +2126,18 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (engineVersion < 20150910 && Game.ModData.Manifest.Mod.Id == "d2k")
|
||||
node.Key = RenameD2kActors(node.Key);
|
||||
|
||||
// Make Range WDist for all traits with circular ranges.
|
||||
if (engineVersion < 20150917 && depth == 2 && node.Key == "Range")
|
||||
{
|
||||
if (parentKey == "DetectCloaked"
|
||||
|| parentKey == "JamsMissiles"
|
||||
|| parentKey == "JamsRadar"
|
||||
|| parentKey == "Guardable"
|
||||
|| parentKey == "BaseProvider"
|
||||
|| parentKey == "ProximityCapturable")
|
||||
node.Value.Value = node.Value.Value + "c0";
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user