moved the rest of the mine crap into mod dll
This commit is contained in:
60
OpenRa.Mods.RA/Mine.cs
Normal file
60
OpenRa.Mods.RA/Mine.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Effects;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
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; }
|
||||
}
|
||||
|
||||
class MineImmuneInfo : StatelessTraitInfo<MineImmune> { }
|
||||
class MineImmune { }
|
||||
}
|
||||
Reference in New Issue
Block a user