AT and AP mine traits
This commit is contained in:
@@ -239,6 +239,14 @@ namespace OpenRa.Game
|
||||
{
|
||||
return IsActorCrushableByMovementType(a, b.traits.WithInterface<IMovement>().FirstOrDefault().GetMovementType());
|
||||
}
|
||||
|
||||
public static bool IsActorPathableToCrush(Actor a, UnitMovementType umt)
|
||||
{
|
||||
return a != null &&
|
||||
a.traits.WithInterface<ICrushable>()
|
||||
.Any(c => c.IsPathableCrush(umt, a.Owner));
|
||||
}
|
||||
|
||||
public static bool IsActorCrushableByMovementType(Actor a, UnitMovementType umt)
|
||||
{
|
||||
return a != null &&
|
||||
|
||||
@@ -162,6 +162,8 @@
|
||||
<Compile Include="Traits\Activities\Move.cs" />
|
||||
<Compile Include="Traits\Activities\Follow.cs" />
|
||||
<Compile Include="Traits\Activities\Turn.cs" />
|
||||
<Compile Include="Traits\APMine.cs" />
|
||||
<Compile Include="Traits\ATMine.cs" />
|
||||
<Compile Include="Traits\AttackBase.cs" />
|
||||
<Compile Include="Traits\AttackInfo.cs" />
|
||||
<Compile Include="Traits\AttackTurreted.cs" />
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRa.Game
|
||||
}
|
||||
|
||||
// Replicate real-ra behavior of not being able to enter a cell if there is a mixture of crushable and uncrushable units
|
||||
if (checkForBlocked && (Game.UnitInfluence.GetUnitsAt(newHere).Any(a => !Game.IsActorCrushableByMovementType(a, umt))))
|
||||
if (checkForBlocked && (Game.UnitInfluence.GetUnitsAt(newHere).Any(a => !Game.IsActorPathableToCrush(a, umt))))
|
||||
continue;
|
||||
|
||||
if (customBlock != null && customBlock(newHere))
|
||||
|
||||
41
OpenRa.Game/Traits/APMine.cs
Normal file
41
OpenRa.Game/Traits/APMine.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Effects;
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class APMine : ICrushable
|
||||
{
|
||||
readonly Actor self;
|
||||
public APMine(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
Game.world.AddFrameEndTask(_ =>
|
||||
{
|
||||
Game.world.Remove(self);
|
||||
Game.world.Add(new Explosion(self.CenterLocation.ToInt2(), 5, false));
|
||||
crusher.InflictDamage(crusher, Rules.General.APMineDamage, Rules.WarheadInfo["APMine"]);
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsPathableCrush(UnitMovementType umt, Player player)
|
||||
{
|
||||
return (player != Game.LocalPlayer); // Units should avoid friendly mines
|
||||
}
|
||||
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
// Mines should explode indiscriminantly of player
|
||||
switch (umt)
|
||||
{
|
||||
case UnitMovementType.Foot: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
OpenRa.Game/Traits/ATMine.cs
Normal file
43
OpenRa.Game/Traits/ATMine.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ATMine : ICrushable
|
||||
{
|
||||
readonly Actor self;
|
||||
public ATMine(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
Game.world.AddFrameEndTask(_ =>
|
||||
{
|
||||
Game.world.Remove(self);
|
||||
Game.world.Add(new Explosion(self.CenterLocation.ToInt2(), 3, false));
|
||||
crusher.InflictDamage(crusher, Rules.General.AVMineDamage, Rules.WarheadInfo["ATMine"]);
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsPathableCrush(UnitMovementType umt, Player player)
|
||||
{
|
||||
return (player != Game.LocalPlayer); // Units should avoid friendly mines
|
||||
}
|
||||
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
// Mines should explode indiscriminantly of player
|
||||
switch (umt)
|
||||
{
|
||||
case UnitMovementType.Wheel:
|
||||
case UnitMovementType.Track: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,12 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
self.InflictDamage(crusher, self.Health, Rules.WarheadInfo["Crush"]);
|
||||
}
|
||||
|
||||
|
||||
public bool IsPathableCrush(UnitMovementType umt, Player player)
|
||||
{
|
||||
return IsCrushableBy(umt, player);
|
||||
}
|
||||
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
if (player == Game.LocalPlayer) return false;
|
||||
|
||||
@@ -63,5 +63,6 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
void OnCrush(Actor crusher);
|
||||
bool IsCrushableBy(UnitMovementType umt, Player player);
|
||||
bool IsPathableCrush(UnitMovementType umt, Player player);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user