Make Range WDist for all traits with circular ranges.

This commit is contained in:
atlimit8
2015-09-07 13:07:35 -05:00
parent d77839bb3d
commit de7f5a4288
34 changed files with 85 additions and 76 deletions

View File

@@ -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)

View File

@@ -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));

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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); }
}

View File

@@ -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)));
}

View File

@@ -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 { }

View File

@@ -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; } }

View File

@@ -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 { }

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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";

View File

@@ -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);
}
}

View File

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

View File

@@ -223,7 +223,7 @@
Upgrades: hospitalheal
Prerequisites: hosp
DetectCloaked:
Range: 1
Range: 1c0
DeathSounds@NORMAL:
DeathTypes: DefaultDeath, BulletDeath, SmallExplosionDeath, ExplosionDeath
DeathSounds@BURNED:
@@ -448,7 +448,7 @@
Notification: BuildingLost
ShakeOnDeath:
Guardable:
Range: 3
Range: 3c0
Tooltip:
GenericName: Structure
FrozenUnderFog:

View File

@@ -64,7 +64,7 @@ FACT:
ProductionType: Defence.Nod
BaseProvider:
Cooldown: 75
Range: 14
Range: 14c0
WithBuildingPlacedAnimation:
Power:
Amount: 0
@@ -471,7 +471,7 @@ HQ:
ProvidesRadar:
RenderDetectionCircle:
DetectCloaked:
Range: 5
Range: 5c0
AirstrikePower:
Prerequisites: ~techlevel.superweapons
Icon: airstrike
@@ -557,7 +557,7 @@ EYE:
ProvidesRadar:
RenderDetectionCircle:
DetectCloaked:
Range: 5
Range: 5c0
IonCannonPower:
Prerequisites: ~techlevel.superweapons
Icon: ioncannon
@@ -662,7 +662,7 @@ GUN:
WithMuzzleFlash:
-WithDeathAnimation:
DetectCloaked:
Range: 3
Range: 3c0
Power:
Amount: -20
@@ -746,7 +746,7 @@ OBLI:
InitialChargeDelay: 50
-EmitInfantryOnSell:
DetectCloaked:
Range: 5
Range: 5c0
Power:
Amount: -150
@@ -778,7 +778,7 @@ GTWR:
BodyOrientation:
QuantizedFacings: 8
DetectCloaked:
Range: 3
Range: 3c0
WithMuzzleFlash:
Turreted:
ROT: 255
@@ -830,7 +830,7 @@ ATWR:
BodyOrientation:
QuantizedFacings: 8
DetectCloaked:
Range: 5
Range: 5c0
Power:
Amount: -40

View File

@@ -276,7 +276,7 @@
Sellable:
SellSounds: BUILD1.WAV
Guardable:
Range: 3
Range: 3c0
WithCrumbleOverlay:
Demolishable:
DamagedWithoutFoundation:

View File

@@ -403,7 +403,7 @@ outpost:
Range: 10c0
ProvidesRadar:
DetectCloaked:
Range: 6
Range: 6c0
RenderDetectionCircle:
RenderSprites:
Image: outpost.harkonnen
@@ -558,7 +558,7 @@ medium_gun_turret:
LocalOffset: 512,0,432
MuzzleSequence: muzzle
DetectCloaked:
Range: 5
Range: 5c0
Power:
Amount: -20
SelectionDecorations:
@@ -601,7 +601,7 @@ large_gun_turret:
CanPowerDown:
DisabledOverlay:
DetectCloaked:
Range: 6
Range: 6c0
Power:
Amount: -30
SelectionDecorations:
@@ -772,7 +772,7 @@ palace:
corrino: palace.corrino
RenderDetectionCircle:
DetectCloaked:
Range: 4
Range: 4c0
Power:
Amount: -50
ProvidesPrerequisite@nuke:

View File

@@ -570,7 +570,7 @@ Rules:
Produces: Defense, Infantry, Soldier, Dog
-Sellable:
BaseProvider:
Range: 12
Range: 12c0
Power:
Amount: 0
FTUR:

View File

@@ -633,7 +633,7 @@ Rules:
MISS:
ProximityCapturable:
MustBeClear: true
Range: 9
Range: 9c0
CaptorTypes: Ship,Vehicle,Tank,Infantry
StrategicPoint:
Critical: false

View File

@@ -652,7 +652,7 @@ Rules:
JEEP:
Explodes:
JamsRadar:
Range: 10
Range: 10c0
YAK:
Buildable:
Prerequisites: ~disabled

View File

@@ -827,7 +827,7 @@ Rules:
Production:
Produces: Building, Infantry, Soldier, Dog
BaseProvider:
Range: 16
Range: 16c0
Power:
Amount: 0
WEAP:

View File

@@ -414,7 +414,7 @@
Types: Building
GivesBounty:
Guardable:
Range: 3
Range: 3c0
FrozenUnderFog:
GpsRemoveFrozenActor:
Tooltip:

View File

@@ -39,7 +39,7 @@ DOG:
StandSequences: stand
IgnoresDisguise:
DetectCloaked:
Range: 5
Range: 5c0
Voiced:
VoiceSet: DogVoice
-TakeCover:
@@ -222,7 +222,7 @@ SPY:
UpgradeMinEnabledLevel: 1
IgnoresDisguise:
DetectCloaked:
Range: 5
Range: 5c0
Armament:
Weapon: SilencedPPK
AttackFrontal:
@@ -527,7 +527,7 @@ SNIPER:
UncloakOnMove: true
IsPlayerPalette: true
DetectCloaked:
Range: 6
Range: 6c0
-MustBeDestroyed:
ProducibleWithLevel:
Prerequisites: barracks.upgraded

View File

@@ -129,7 +129,7 @@ CAMERA:
ProximityCaptor:
Types: Camera
DetectCloaked:
Range: 10
Range: 10c0
BodyOrientation:
QuantizedFacings: 1
WithSpriteBody:
@@ -157,7 +157,7 @@ SONAR:
ProximityCaptor:
Types: Sonar
DetectCloaked:
Range: 10
Range: 10c0
CloakTypes: Underwater
FLARE:

View File

@@ -46,7 +46,7 @@ SS:
InitialStance: ReturnFire
DetectCloaked:
CloakTypes: Underwater
Range: 4
Range: 4c0
RenderDetectionCircle:
Explodes:
Weapon: UnitExplodeSubmarine
@@ -101,7 +101,7 @@ MSUB:
InitialStance: ReturnFire
DetectCloaked:
CloakTypes: Underwater
Range: 4
Range: 4c0
RenderDetectionCircle:
Explodes:
Weapon: UnitExplodeSubmarine
@@ -151,7 +151,7 @@ DD:
AutoTarget:
DetectCloaked:
CloakTypes: Underwater
Range: 4
Range: 4c0
RenderDetectionCircle:
CA:
@@ -279,6 +279,6 @@ PT:
AutoTarget:
DetectCloaked:
CloakTypes: Underwater
Range: 4
Range: 4c0
RenderDetectionCircle:

View File

@@ -412,7 +412,7 @@ TSLA:
Power:
Amount: -100
DetectCloaked:
Range: 8
Range: 8c0
ProvidesPrerequisite@buildingname:
AGUN:
@@ -460,7 +460,7 @@ AGUN:
Power:
Amount: -50
DetectCloaked:
Range: 6
Range: 6c0
DOME:
Inherits: ^Building
@@ -491,7 +491,7 @@ DOME:
ProvidesRadar:
InfiltrateForExploration:
DetectCloaked:
Range: 10
Range: 10c0
RenderDetectionCircle:
Power:
Amount: -40
@@ -538,7 +538,7 @@ PBOX:
Power:
Amount: -15
DetectCloaked:
Range: 6
Range: 6c0
HBOX:
Inherits: ^Defense
@@ -574,7 +574,7 @@ HBOX:
InitialUnits: e1
-EmitInfantryOnSell:
DetectCloaked:
Range: 6
Range: 6c0
RenderRangeCircle:
FallbackRange: 6c0
AttackGarrisoned:
@@ -620,7 +620,7 @@ GUN:
Power:
Amount: -40
DetectCloaked:
Range: 7
Range: 7c0
FTUR:
Inherits: ^Defense
@@ -655,7 +655,7 @@ FTUR:
Power:
Amount: -20
DetectCloaked:
Range: 6
Range: 6c0
ProvidesPrerequisite@buildingname:
SAM:
@@ -698,7 +698,7 @@ SAM:
Power:
Amount: -40
DetectCloaked:
Range: 5
Range: 5c0
ATEK:
Inherits: ^Building
@@ -895,7 +895,7 @@ FACT:
ProductionType: Defense
Color: 138,138,138
BaseProvider:
Range: 16
Range: 16c0
WithBuildingPlacedAnimation:
Power:
Amount: 0

View File

@@ -414,7 +414,7 @@ MNLY.AP:
Ammo: 5
RearmSound: minelay1.aud
DetectCloaked:
Range: 5
Range: 5c0
CloakTypes: Mine
RenderDetectionCircle:
Explodes:
@@ -449,7 +449,7 @@ MNLY.AT:
Ammo: 5
RearmSound: minelay1.aud
DetectCloaked:
Range: 5
Range: 5c0
CloakTypes: Mine
RenderDetectionCircle:
Explodes:
@@ -532,13 +532,13 @@ MRJ:
Sequence: spinner
Offset: -256,0,256
JamsRadar:
Range: 15
Range: 15c0
JamsMissiles:
Range: 4
Range: 4c0
AlliedMissiles: False
RenderJammerCircle:
DetectCloaked:
Range: 6
Range: 6c0
TTNK:
Inherits: ^Tank
@@ -742,7 +742,7 @@ STNK:
UncloakSound: appear1.aud
IsPlayerPalette: true
DetectCloaked:
Range: 6
Range: 6c0
-MustBeDestroyed:
ProducibleWithLevel:
Prerequisites: vehicles.upgraded

View File

@@ -96,7 +96,7 @@
ShakeOnDeath:
AcceptsSupplies:
Guardable:
Range: 3
Range: 3c0
Demolishable:
Cloak@CLOAKGENERATOR:
UpgradeTypes: cloakgenerator
@@ -624,7 +624,7 @@
RevealsShroud:
Range: 6c0
DetectCloaked:
Range: 5
Range: 5c0
^DeployedVehicle:
Inherits@1: ^GainsExperience

View File

@@ -281,7 +281,7 @@ GARADR:
ProvidesRadar:
InfiltrateForExploration:
DetectCloaked:
Range: 10
Range: 10c0
RenderDetectionCircle:
RevealsShroud:
Range: 10c0

View File

@@ -41,7 +41,7 @@ CAMERA:
Range: 10c0
Type: CenterPosition
DetectCloaked:
Range: 10
Range: 10c0
CRATE:
Inherits: ^Crate

View File

@@ -236,7 +236,7 @@ NARADR:
ProvidesRadar:
InfiltrateForExploration:
DetectCloaked:
Range: 10
Range: 10c0
RenderDetectionCircle:
RevealsShroud:
Range: 10c0

View File

@@ -46,7 +46,7 @@ NALASR:
RevealsShroud:
Range: 5c0
DetectCloaked:
Range: 3
Range: 3c0
Turreted:
ROT: 10
InitialFacing: 300

View File

@@ -22,7 +22,7 @@ GADPSA:
-RenderRangeCircle:
RenderDetectionCircle:
DetectCloaked:
Range: 6
Range: 6c0
NAPULS:
Inherits: ^Defense