AT and AP mine traits
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user