merged ATMine/APMine. differences are now all in traitinfo.
This commit is contained in:
@@ -205,8 +205,7 @@
|
||||
<Compile Include="Traits\Activities\Turn.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\Activities\UnloadCargo.cs" />
|
||||
<Compile Include="Traits\APMine.cs" />
|
||||
<Compile Include="Traits\ATMine.cs" />
|
||||
<Compile Include="Traits\Mine.cs" />
|
||||
<Compile Include="Traits\AttackBase.cs" />
|
||||
<Compile Include="Traits\AttackFrontal.cs" />
|
||||
<Compile Include="Traits\AttackHeli.cs" />
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class APMineInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new APMine(self); }
|
||||
}
|
||||
|
||||
class APMine : ICrushable, IOccupySpace
|
||||
{
|
||||
readonly Actor self;
|
||||
public APMine(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
Game.UnitInfluence.Add(self, this);
|
||||
}
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
if (crusher.traits.Contains<MineImmune>() && crusher.Owner == self.Owner)
|
||||
return;
|
||||
|
||||
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:
|
||||
case UnitMovementType.Wheel:
|
||||
case UnitMovementType.Track:
|
||||
return true;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ATMineInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new ATMine(self); }
|
||||
}
|
||||
|
||||
class ATMine : ICrushable, IOccupySpace
|
||||
{
|
||||
readonly Actor self;
|
||||
public ATMine(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
Game.UnitInfluence.Add(self, this);
|
||||
}
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
if (crusher.traits.Contains<MineImmune>() && crusher.Owner == self.Owner)
|
||||
return;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
||||
}
|
||||
}
|
||||
54
OpenRa.Game/Traits/Mine.cs
Normal file
54
OpenRa.Game/Traits/Mine.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class MineInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Damage = 0;
|
||||
public readonly UnitMovementType[] TriggeredBy = { };
|
||||
public readonly string Warhead = "ATMine";
|
||||
public readonly bool AvoidFriendly = true;
|
||||
|
||||
public object Create(Actor self) { return new Mine(self); }
|
||||
}
|
||||
|
||||
class Mine : ICrushable, IOccupySpace
|
||||
{
|
||||
readonly Actor self;
|
||||
public Mine(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
Game.UnitInfluence.Add(self, this);
|
||||
}
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
if (crusher.traits.Contains<MineImmune>() && crusher.Owner == self.Owner)
|
||||
return;
|
||||
|
||||
var info = self.Info.Traits.Get<MineInfo>();
|
||||
var warhead = Rules.WarheadInfo[info.Warhead];
|
||||
|
||||
Game.world.AddFrameEndTask(_ =>
|
||||
{
|
||||
Game.world.Remove(self);
|
||||
Game.world.Add(new Explosion(self.CenterLocation.ToInt2(), warhead.Explosion, false));
|
||||
crusher.InflictDamage(crusher, info.Damage, warhead);
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsPathableCrush(UnitMovementType umt, Player player)
|
||||
{
|
||||
return !self.Info.Traits.Get<MineInfo>().AvoidFriendly || (player != Game.LocalPlayer);
|
||||
}
|
||||
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
return self.Info.Traits.Get<MineInfo>().TriggeredBy.Contains(umt);
|
||||
}
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user