Refactor BurstDelay to BurstDelays

Allowing to set custom per-burst delays.
This commit is contained in:
reaperrr
2017-07-16 15:03:40 +02:00
parent 4ce2e82ff0
commit 834a40b18d
3 changed files with 17 additions and 3 deletions

View File

@@ -69,8 +69,9 @@ namespace OpenRA.GameRules
[Desc("What types of targets are unaffected.", "Overrules ValidTargets.")]
public readonly HashSet<string> InvalidTargets = new HashSet<string>();
[Desc("Delay in ticks between firing shots from the same ammo magazine.")]
public readonly int BurstDelay = 5;
[Desc("Delay in ticks between firing shots from the same ammo magazine. If one entry, it will be used for all bursts.",
"If multiple entries, their number needs to match Burst - 1.")]
public readonly int[] BurstDelays = { 5 };
[Desc("The minimum range the weapon can fire.")]
public readonly WDist MinRange = WDist.Zero;

View File

@@ -92,6 +92,9 @@ namespace OpenRA.Mods.Common.Traits
WeaponInfo.Range.Length,
ai.TraitInfos<IRangeModifierInfo>().Select(m => m.GetRangeModifierDefault())));
if (WeaponInfo.Burst > 1 && WeaponInfo.BurstDelays.Length > 1 && (WeaponInfo.BurstDelays.Length != WeaponInfo.Burst - 1))
throw new YamlException("Weapon '{0}' has an invalid number of BurstDelays, must be single entry or Burst - 1.".F(weaponToLower));
base.RulesetLoaded(rules, ai);
}
}
@@ -311,7 +314,12 @@ namespace OpenRA.Mods.Common.Traits
protected virtual void UpdateBurst(Actor self, Target target)
{
if (--Burst > 0)
FireDelay = Weapon.BurstDelay;
{
if (Weapon.BurstDelays.Length == 1)
FireDelay = Weapon.BurstDelays[0];
else
FireDelay = Weapon.BurstDelays[Weapon.Burst - (Burst + 1)];
}
else
{
var modifiers = reloadModifiers.ToArray();

View File

@@ -1092,6 +1092,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
// Rename BurstDelay to BurstDelays
if (engineVersion < 20170818)
if (node.Key == "BurstDelay")
node.Key = "BurstDelays";
UpgradeWeaponRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}