New crush code, now with less bs
This commit is contained in:
@@ -44,8 +44,6 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return NextActivity;
|
||||
}
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||
if (unit.Altitude != info.CruiseAltitude)
|
||||
{
|
||||
|
||||
@@ -28,22 +28,24 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class MineInfo : ITraitInfo
|
||||
{
|
||||
public readonly UnitMovementType[] TriggeredBy = { };
|
||||
public readonly string[] CrushClasses = { };
|
||||
public readonly string Weapon = "ATMine";
|
||||
public readonly bool AvoidFriendly = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new Mine(init); }
|
||||
public object Create(ActorInitializer init) { return new Mine(init, this); }
|
||||
}
|
||||
|
||||
class Mine : ICrushable, IOccupySpace
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly MineInfo info;
|
||||
[Sync]
|
||||
readonly int2 location;
|
||||
|
||||
public Mine(ActorInitializer init)
|
||||
public Mine(ActorInitializer init, MineInfo info)
|
||||
{
|
||||
this.self = init.self;
|
||||
this.info = info;
|
||||
this.location = init.location;
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||
}
|
||||
@@ -57,17 +59,10 @@ namespace OpenRA.Mods.RA
|
||||
Combat.DoExplosion(self, info.Weapon, crusher.CenterLocation.ToInt2(), 0);
|
||||
self.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
|
||||
public bool IsPathableCrush(UnitMovementType umt, Player player)
|
||||
{
|
||||
return !self.Info.Traits.Get<MineInfo>().AvoidFriendly || (player != self.Owner);
|
||||
}
|
||||
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
return self.Info.Traits.Get<MineInfo>().TriggeredBy.Contains(umt);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Re-implement friendly-mine avoidance using a Hazard
|
||||
public IEnumerable<string> CrushClasses { get { return info.CrushClasses; } }
|
||||
|
||||
public int2 TopLeft { get { return location; } }
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return TopLeft; }
|
||||
|
||||
@@ -27,30 +27,24 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class WallInfo : ITraitInfo
|
||||
{
|
||||
public readonly UnitMovementType[] CrushableBy = { };
|
||||
public readonly string[] CrushClasses = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new Wall(init.self); }
|
||||
public object Create(ActorInitializer init) { return new Wall(init.self, this); }
|
||||
}
|
||||
|
||||
public class Wall : ICrushable, IBlocksBullets
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
public Wall(Actor self)
|
||||
readonly WallInfo info;
|
||||
|
||||
public Wall(Actor self, WallInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
this.info = info;
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, self.traits.Get<Building>());
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<string> CrushClasses { get { return info.CrushClasses; } }
|
||||
public void OnCrush(Actor crusher) { self.InflictDamage(crusher, self.Health, null); }
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
return self.Info.Traits.Get<WallInfo>().CrushableBy.Contains(umt);
|
||||
}
|
||||
|
||||
public bool IsPathableCrush(UnitMovementType umt, Player player)
|
||||
{
|
||||
return IsCrushableBy(umt, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user