Made all projectile and warhead fields readonly
This came up while working on the new documentation generation and comparing the results to ORAIDE's own code parser.
This commit is contained in:
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
|
|
||||||
[Desc("Scan radius for actors with projectile-blocking trait. If set to a negative value (default), it will automatically scale",
|
[Desc("Scan radius for actors with projectile-blocking trait. If set to a negative value (default), it will automatically scale",
|
||||||
"to the blocker with the largest health shape. Only set custom values if you know what you're doing.")]
|
"to the blocker with the largest health shape. Only set custom values if you know what you're doing.")]
|
||||||
public WDist BlockerScanRadius = new WDist(-1);
|
public readonly WDist BlockerScanRadius = new WDist(-1);
|
||||||
|
|
||||||
public IProjectile Create(ProjectileArgs args) { return new InstantHit(this, args); }
|
public IProjectile Create(ProjectileArgs args) { return new InstantHit(this, args); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,13 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
public readonly int[] Falloff = { 100, 37, 14, 5, 0 };
|
public readonly int[] Falloff = { 100, 37, 14, 5, 0 };
|
||||||
|
|
||||||
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
|
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
|
||||||
public WDist[] Range = null;
|
public readonly WDist[] Range = null;
|
||||||
|
|
||||||
[Desc("Controls the way damage is calculated. Possible values are 'HitShape', 'ClosestTargetablePosition' and 'CenterPosition'.")]
|
[Desc("Controls the way damage is calculated. Possible values are 'HitShape', 'ClosestTargetablePosition' and 'CenterPosition'.")]
|
||||||
public readonly DamageCalculationType DamageCalculationType = DamageCalculationType.HitShape;
|
public readonly DamageCalculationType DamageCalculationType = DamageCalculationType.HitShape;
|
||||||
|
|
||||||
|
WDist[] effectiveRange;
|
||||||
|
|
||||||
void IRulesetLoaded<WeaponInfo>.RulesetLoaded(Ruleset rules, WeaponInfo info)
|
void IRulesetLoaded<WeaponInfo>.RulesetLoaded(Ruleset rules, WeaponInfo info)
|
||||||
{
|
{
|
||||||
if (Range != null)
|
if (Range != null)
|
||||||
@@ -42,18 +44,20 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
for (var i = 0; i < Range.Length - 1; i++)
|
for (var i = 0; i < Range.Length - 1; i++)
|
||||||
if (Range[i] > Range[i + 1])
|
if (Range[i] > Range[i + 1])
|
||||||
throw new YamlException("Range values must be specified in an increasing order.");
|
throw new YamlException("Range values must be specified in an increasing order.");
|
||||||
|
|
||||||
|
effectiveRange = Range;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Range = Exts.MakeArray(Falloff.Length, i => i * Spread);
|
effectiveRange = Exts.MakeArray(Falloff.Length, i => i * Spread);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DoImpact(WPos pos, Actor firedBy, WarheadArgs args)
|
protected override void DoImpact(WPos pos, Actor firedBy, WarheadArgs args)
|
||||||
{
|
{
|
||||||
var debugVis = firedBy.World.WorldActor.TraitOrDefault<DebugVisualizations>();
|
var debugVis = firedBy.World.WorldActor.TraitOrDefault<DebugVisualizations>();
|
||||||
if (debugVis != null && debugVis.CombatGeometry)
|
if (debugVis != null && debugVis.CombatGeometry)
|
||||||
firedBy.World.WorldActor.Trait<WarheadDebugOverlay>().AddImpact(pos, Range, DebugOverlayColor);
|
firedBy.World.WorldActor.Trait<WarheadDebugOverlay>().AddImpact(pos, effectiveRange, DebugOverlayColor);
|
||||||
|
|
||||||
foreach (var victim in firedBy.World.FindActorsOnCircle(pos, Range[Range.Length - 1]))
|
foreach (var victim in firedBy.World.FindActorsOnCircle(pos, effectiveRange[effectiveRange.Length - 1]))
|
||||||
{
|
{
|
||||||
if (!IsValidAgainst(victim, firedBy))
|
if (!IsValidAgainst(victim, firedBy))
|
||||||
continue;
|
continue;
|
||||||
@@ -82,7 +86,7 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The range to target is more than the range the warhead covers, so GetDamageFalloff() is going to give us 0 and we're going to do 0 damage anyway, so bail early.
|
// The range to target is more than the range the warhead covers, so GetDamageFalloff() is going to give us 0 and we're going to do 0 damage anyway, so bail early.
|
||||||
if (falloffDistance > Range[Range.Length - 1].Length)
|
if (falloffDistance > effectiveRange[effectiveRange.Length - 1].Length)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var localModifiers = args.DamageModifiers.Append(GetDamageFalloff(falloffDistance));
|
var localModifiers = args.DamageModifiers.Append(GetDamageFalloff(falloffDistance));
|
||||||
@@ -109,10 +113,10 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
|
|
||||||
int GetDamageFalloff(int distance)
|
int GetDamageFalloff(int distance)
|
||||||
{
|
{
|
||||||
var inner = Range[0].Length;
|
var inner = effectiveRange[0].Length;
|
||||||
for (var i = 1; i < Range.Length; i++)
|
for (var i = 1; i < effectiveRange.Length; i++)
|
||||||
{
|
{
|
||||||
var outer = Range[i].Length;
|
var outer = effectiveRange[i].Length;
|
||||||
if (outer > distance)
|
if (outer > distance)
|
||||||
return int2.Lerp(Falloff[i - 1], Falloff[i], distance - inner, outer - inner);
|
return int2.Lerp(Falloff[i - 1], Falloff[i], distance - inner, outer - inner);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user