Cleaned up DamageWarhead
Reordered methods and fixed access modifiers. Also removed unused using statements from warheads.
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
|||||||
@@ -38,26 +38,6 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
return base.IsValidAgainst(victim, firedBy);
|
return base.IsValidAgainst(victim, firedBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int DamageVersus(Actor victim, HitShape shape, WarheadArgs args)
|
|
||||||
{
|
|
||||||
// If no Versus values are defined, DamageVersus would return 100 anyway, so we might as well do that early.
|
|
||||||
if (Versus.Count == 0)
|
|
||||||
return 100;
|
|
||||||
|
|
||||||
var armor = victim.TraitsImplementing<Armor>()
|
|
||||||
.Where(a => !a.IsTraitDisabled && a.Info.Type != null && Versus.ContainsKey(a.Info.Type) &&
|
|
||||||
(shape.Info.ArmorTypes.IsEmpty || shape.Info.ArmorTypes.Contains(a.Info.Type)))
|
|
||||||
.Select(a => Versus[a.Info.Type]);
|
|
||||||
|
|
||||||
return Util.ApplyPercentageModifiers(100, armor);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void InflictDamage(Actor victim, Actor firedBy, HitShape shape, WarheadArgs args)
|
|
||||||
{
|
|
||||||
var damage = Util.ApplyPercentageModifiers(Damage, args.DamageModifiers.Append(DamageVersus(victim, shape, args)));
|
|
||||||
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DoImpact(Target target, WarheadArgs args)
|
public override void DoImpact(Target target, WarheadArgs args)
|
||||||
{
|
{
|
||||||
var firedBy = args.SourceActor;
|
var firedBy = args.SourceActor;
|
||||||
@@ -83,6 +63,26 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
DoImpact(target.CenterPosition, firedBy, args);
|
DoImpact(target.CenterPosition, firedBy, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void DoImpact(WPos pos, Actor firedBy, WarheadArgs args);
|
protected virtual int DamageVersus(Actor victim, HitShape shape, WarheadArgs args)
|
||||||
|
{
|
||||||
|
// If no Versus values are defined, DamageVersus would return 100 anyway, so we might as well do that early.
|
||||||
|
if (Versus.Count == 0)
|
||||||
|
return 100;
|
||||||
|
|
||||||
|
var armor = victim.TraitsImplementing<Armor>()
|
||||||
|
.Where(a => !a.IsTraitDisabled && a.Info.Type != null && Versus.ContainsKey(a.Info.Type) &&
|
||||||
|
(shape.Info.ArmorTypes.IsEmpty || shape.Info.ArmorTypes.Contains(a.Info.Type)))
|
||||||
|
.Select(a => Versus[a.Info.Type]);
|
||||||
|
|
||||||
|
return Util.ApplyPercentageModifiers(100, armor);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void InflictDamage(Actor victim, Actor firedBy, HitShape shape, WarheadArgs args)
|
||||||
|
{
|
||||||
|
var damage = Util.ApplyPercentageModifiers(Damage, args.DamageModifiers.Append(DamageVersus(victim, shape, args)));
|
||||||
|
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void DoImpact(WPos pos, Actor firedBy, WarheadArgs args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Warheads
|
namespace OpenRA.Mods.Common.Warheads
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -44,7 +43,7 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
Range = Exts.MakeArray(Falloff.Length, i => i * Spread);
|
Range = Exts.MakeArray(Falloff.Length, i => i * Spread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public 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)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -23,7 +22,7 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
[Desc("Damage will be applied to actors in this area. A value of zero means only targeted actor will be damaged.")]
|
[Desc("Damage will be applied to actors in this area. A value of zero means only targeted actor will be damaged.")]
|
||||||
public readonly WDist Spread = WDist.Zero;
|
public readonly WDist Spread = WDist.Zero;
|
||||||
|
|
||||||
public override void DoImpact(WPos pos, Actor firedBy, WarheadArgs args)
|
protected override void DoImpact(WPos pos, Actor firedBy, WarheadArgs args)
|
||||||
{
|
{
|
||||||
if (Spread == WDist.Zero)
|
if (Spread == WDist.Zero)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.Common.Warheads;
|
using OpenRA.Mods.Common.Warheads;
|
||||||
using OpenRA.Mods.D2k.Traits;
|
using OpenRA.Mods.D2k.Traits;
|
||||||
|
|||||||
Reference in New Issue
Block a user