Add turret-linking support to HitShape
Allows to link a HitShape to the position and facing of a turret.
This commit is contained in:
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
|
||||
// If the impact position is within any HitShape, we have a direct hit
|
||||
var activeShapes = victim.TraitsImplementing<HitShape>().Where(Exts.IsTraitEnabled);
|
||||
var directHit = activeShapes.Any(i => i.Info.Type.DistanceFromEdge(pos, victim).Length <= 0);
|
||||
var directHit = activeShapes.Any(i => i.DistanceFromEdge(victim, pos).Length <= 0);
|
||||
|
||||
// If the warhead landed outside the actor's hit-shape(s), we need to skip the rest so it won't be considered an invalidHit
|
||||
if (!directHit)
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
return;
|
||||
|
||||
var closestActiveShape = victim.TraitsImplementing<HitShape>().Where(Exts.IsTraitEnabled)
|
||||
.MinByOrDefault(t => t.Info.Type.DistanceFromEdge(victim.CenterPosition, victim));
|
||||
.MinByOrDefault(t => t.DistanceFromEdge(victim, victim.CenterPosition));
|
||||
|
||||
// Cannot be damaged without an active HitShape
|
||||
if (closestActiveShape == null)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
|
||||
var closestActiveShape = victim.TraitsImplementing<HitShape>()
|
||||
.Where(Exts.IsTraitEnabled)
|
||||
.Select(s => Pair.New(s, s.Info.Type.DistanceFromEdge(pos, victim)))
|
||||
.Select(s => Pair.New(s, s.DistanceFromEdge(victim, pos)))
|
||||
.MinByOrDefault(s => s.Second);
|
||||
|
||||
// Cannot be damaged without an active HitShape
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
|
||||
var closestActiveShape = victim.TraitsImplementing<HitShape>()
|
||||
.Where(Exts.IsTraitEnabled)
|
||||
.Select(s => Pair.New(s, s.Info.Type.DistanceFromEdge(pos, victim)))
|
||||
.Select(s => Pair.New(s, s.DistanceFromEdge(victim, pos)))
|
||||
.MinByOrDefault(s => s.Second);
|
||||
|
||||
// Cannot be damaged without an active HitShape or if HitShape is outside Spread
|
||||
|
||||
Reference in New Issue
Block a user