Add death types
This commit is contained in:
committed by
Matthias Mailänder
parent
abec71c42d
commit
4c04d4fa30
@@ -11,6 +11,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -23,6 +24,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("The weapons used for shrapnel.")]
|
||||
public readonly string[] Weapons = [];
|
||||
|
||||
[Desc("What damage type needs to kill the actor to trigger the firing of projectiles? " +
|
||||
"Leave empty to ignore damage types.")]
|
||||
public readonly BitSet<DamageType> DeathTypes = default;
|
||||
|
||||
[Desc("The minimal amount of health loss required to trigger projectiles.")]
|
||||
public readonly int MinimumDamage = 0;
|
||||
|
||||
[Desc("The maximum amount of health loss required to trigger projectiles.")]
|
||||
public readonly int MaximumDamage = int.MaxValue;
|
||||
|
||||
[Desc("The amount of pieces of shrapnel to expel. Two values indicate a range.")]
|
||||
public readonly int[] Pieces = [3, 10];
|
||||
|
||||
@@ -51,11 +62,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public FireProjectilesOnDeath(FireProjectilesOnDeathInfo info)
|
||||
: base(info) { }
|
||||
|
||||
public void Killed(Actor self, AttackInfo attack)
|
||||
void INotifyKilled.Killed(Actor self, AttackInfo attack)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
|
||||
if (!Info.DeathTypes.IsEmpty && !attack.Damage.DamageTypes.Overlaps(Info.DeathTypes))
|
||||
return;
|
||||
|
||||
if (attack.Damage.Value <= Info.MinimumDamage || attack.Damage.Value >= Info.MaximumDamage)
|
||||
return;
|
||||
|
||||
foreach (var wep in Info.WeaponInfos)
|
||||
{
|
||||
var pieces = Util.RandomInRange(self.World.SharedRandom, Info.Pieces);
|
||||
|
||||
Reference in New Issue
Block a user