Add ValidStances checks to BlocksProjectiles and Gate.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
@@ -18,6 +19,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly WDist Height = WDist.FromCells(1);
|
||||
|
||||
[Desc("Determines what projectiles to block based on their allegiance to the wall owner.")]
|
||||
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new BlocksProjectiles(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -28,6 +32,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
WDist IBlocksProjectiles.BlockingHeight => Info.Height;
|
||||
|
||||
PlayerRelationship IBlocksProjectiles.ValidRelationships { get { return Info.ValidRelationships; } }
|
||||
|
||||
public static bool AnyBlockingActorAt(World world, WPos pos)
|
||||
{
|
||||
var dat = world.Map.DistanceAboveTerrain(pos);
|
||||
@@ -38,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.Any(Exts.IsTraitEnabled));
|
||||
}
|
||||
|
||||
public static bool AnyBlockingActorsBetween(World world, WPos start, WPos end, WDist width, out WPos hit)
|
||||
public static bool AnyBlockingActorsBetween(World world, Player owner, WPos start, WPos end, WDist width, out WPos hit)
|
||||
{
|
||||
var actors = world.FindBlockingActorsOnLine(start, end, width);
|
||||
var length = (end - start).Length;
|
||||
@@ -46,7 +52,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var a in actors)
|
||||
{
|
||||
var blockers = a.TraitsImplementing<IBlocksProjectiles>()
|
||||
.Where(Exts.IsTraitEnabled).ToList();
|
||||
.Where(Exts.IsTraitEnabled).Where(t => t.ValidRelationships.HasRelationship(a.Owner.RelationshipWith(owner)))
|
||||
.ToList();
|
||||
|
||||
if (!blockers.Any())
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user