Make the ICrushable interface a bit more sane, plus correct defaults for infantry

This commit is contained in:
Paul Chote
2009-12-23 02:55:37 -08:00
parent 77f56405b8
commit eae88e7774
3 changed files with 6 additions and 19 deletions

View File

@@ -243,9 +243,7 @@ namespace OpenRa.Game
{
return a != null &&
a.traits.WithInterface<ICrushable>()
.Any(c => c.CrushableBy(umt) &&
((c.IsCrushableByEnemy() && a.Owner != Game.LocalPlayer) ||
(c.IsCrushableByFriend() && a.Owner == Game.LocalPlayer)));
.Any(c => c.IsCrushableBy(umt, a.Owner));
}
public static bool IsWater(int2 a)

View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits
{
@@ -13,24 +13,15 @@ namespace OpenRa.Game.Traits
this.self = self;
}
public bool IsCrushableByFriend()
{
// HACK: should be false
return true;
}
public bool IsCrushableByEnemy()
{
// HACK: should be based off crushable tag
return true;
}
public void OnCrush(Actor crusher)
{
self.InflictDamage(crusher, self.Health, Rules.WarheadInfo["Crush"]);
}
public bool CrushableBy(UnitMovementType umt)
public bool IsCrushableBy(UnitMovementType umt, Player player)
{
if (player == Game.LocalPlayer) return false;
if (!(self.Info as InfantryInfo).Crushable) return false;
switch (umt)
{
case UnitMovementType.Track: return true;

View File

@@ -61,9 +61,7 @@ namespace OpenRa.Game.Traits
interface ICrushable
{
bool IsCrushableByFriend();
bool IsCrushableByEnemy();
void OnCrush(Actor crusher);
bool CrushableBy(UnitMovementType umt);
bool IsCrushableBy(UnitMovementType umt, Player player);
}
}