Move Shape from Health to new HitShape trait
Renamed Shape to Type
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -88,12 +89,9 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
if (checkTargetType && !IsValidAgainst(victim, firedBy))
|
||||
continue;
|
||||
|
||||
var healthInfo = victim.Info.TraitInfoOrDefault<HealthInfo>();
|
||||
if (healthInfo == null)
|
||||
continue;
|
||||
|
||||
// If the impact position is within any actor's HitShape, we have a direct hit
|
||||
if (healthInfo.Shape.DistanceFromEdge(pos, victim).Length <= 0)
|
||||
// If the impact position is within any HitShape, we have a direct hit
|
||||
var activeShapes = victim.TraitsImplementing<HitShape>().Where(Exts.IsTraitEnabled);
|
||||
if (activeShapes.Any(i => i.Info.Type.DistanceFromEdge(pos, victim).Length <= 0))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
@@ -66,11 +67,17 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
|
||||
foreach (var victim in hitActors)
|
||||
{
|
||||
// Cannot be damaged without a Health trait
|
||||
var healthInfo = victim.Info.TraitInfoOrDefault<HealthInfo>();
|
||||
if (healthInfo == null)
|
||||
continue;
|
||||
|
||||
var distance = healthInfo.Shape.DistanceFromEdge(pos, victim);
|
||||
// Cannot be damaged without an active HitShape
|
||||
var activeShapes = victim.TraitsImplementing<HitShape>().Where(Exts.IsTraitEnabled);
|
||||
if (!activeShapes.Any())
|
||||
continue;
|
||||
|
||||
var distance = activeShapes.Min(t => t.Info.Type.DistanceFromEdge(pos, victim));
|
||||
var localModifiers = damageModifiers.Append(GetDamageFalloff(distance.Length));
|
||||
|
||||
DoImpact(victim, firedBy, localModifiers);
|
||||
|
||||
Reference in New Issue
Block a user