Add DamageTypes to Kill() and make some traits use it.

This commit is contained in:
Mustafa Alperen Seki
2018-02-03 11:07:02 +03:00
committed by reaperrr
parent b620e8107f
commit 5e7e3bb011
17 changed files with 58 additions and 22 deletions

View File

@@ -25,6 +25,9 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly WAngle Angle = WAngle.FromDegrees(20);
[Desc("Types of damage that this trait causes. Leave empty for no damage types.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public override object Create(ActorInitializer init) { return new AttackLeap(init.Self, this); }
}
@@ -51,7 +54,7 @@ namespace OpenRA.Mods.Cnc.Traits
return;
self.CancelActivity();
self.QueueActivity(new Leap(self, target.Actor, a, info.Speed, info.Angle));
self.QueueActivity(new Leap(self, target.Actor, a, info.Speed, info.Angle, info.DamageTypes));
}
}
}

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Mods.Cnc.Activities;
using OpenRA.Mods.Common.Traits;
@@ -22,6 +23,10 @@ namespace OpenRA.Mods.Cnc.Traits
{
[Desc("Should the actor die instead of being teleported?")]
public readonly bool ExplodeInstead = false;
[Desc("Types of damage that this trait causes to self when 'ExplodeInstead' is true. Leave empty for no damage types.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public readonly string ChronoshiftSound = "chrono2.aud";
[Desc("Should the actor return to its previous location after the chronoshift wore out?")]
@@ -95,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Traits
{
// Damage is inflicted by the chronosphere
if (!self.Disposed)
self.InflictDamage(chronosphere, new Damage(int.MaxValue));
self.Kill(chronosphere, info.DamageTypes);
});
return true;
}

View File

@@ -53,6 +53,9 @@ namespace OpenRA.Mods.Cnc.Traits
public WeaponInfo ThumpDamageWeaponInfo { get; private set; }
public WeaponInfo DetonationWeaponInfo { get; private set; }
[Desc("Types of damage that this trait causes to self while self-destructing. Leave empty for no damage types.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public object Create(ActorInitializer init) { return new MadTank(init.Self, this); }
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
@@ -146,7 +149,7 @@ namespace OpenRA.Mods.Cnc.Traits
info.DetonationWeaponInfo.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
}
self.Kill(self);
self.Kill(self, info.DamageTypes);
});
}

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc.Traits
if (mobile != null && !info.DetonateClasses.Overlaps(mobile.Info.Crushes))
return;
self.Kill(crusher);
self.Kill(crusher, mobile != null ? mobile.Info.CrushDamageTypes : new HashSet<string>());
}
bool ICrushable.CrushableBy(Actor self, Actor crusher, HashSet<string> crushClasses)