moved the rest of the mine crap into mod dll
This commit is contained in:
@@ -4,7 +4,7 @@ using OpenRa.Traits;
|
|||||||
|
|
||||||
namespace OpenRa.Effects
|
namespace OpenRa.Effects
|
||||||
{
|
{
|
||||||
class Explosion : IEffect
|
public class Explosion : IEffect
|
||||||
{
|
{
|
||||||
Animation anim;
|
Animation anim;
|
||||||
int2 pos;
|
int2 pos;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
class AftermathInfo
|
public class AftermathInfo
|
||||||
{
|
{
|
||||||
public readonly int MTankDistance = 0;
|
public readonly int MTankDistance = 0;
|
||||||
public readonly float QuakeUnitDamage = 0f;
|
public readonly float QuakeUnitDamage = 0f;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
class GeneralInfo
|
public class GeneralInfo
|
||||||
{
|
{
|
||||||
/* Crates */
|
/* Crates */
|
||||||
public readonly int CrateMinimum = 0;
|
public readonly int CrateMinimum = 0;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using System.Collections;
|
|||||||
|
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
class InfoLoader<T> : IEnumerable<KeyValuePair<string, T>>
|
public class InfoLoader<T> : IEnumerable<KeyValuePair<string, T>>
|
||||||
{
|
{
|
||||||
readonly Dictionary<string, T> infos = new Dictionary<string, T>();
|
readonly Dictionary<string, T> infos = new Dictionary<string, T>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
class ProjectileInfo
|
public class ProjectileInfo
|
||||||
{
|
{
|
||||||
public readonly bool AA = false;
|
public readonly bool AA = false;
|
||||||
public readonly bool AG = true;
|
public readonly bool AG = true;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using OpenRa.GameRules;
|
|||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
static class Rules
|
public static class Rules
|
||||||
{
|
{
|
||||||
public static IniFile AllRules;
|
public static IniFile AllRules;
|
||||||
public static Dictionary<string, List<string>> Categories = new Dictionary<string, List<string>>();
|
public static Dictionary<string, List<string>> Categories = new Dictionary<string, List<string>>();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using OpenRa.Traits;
|
|||||||
|
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
class TechTree
|
public class TechTree
|
||||||
{
|
{
|
||||||
readonly Cache<string, List<NewUnitInfo>> producesIndex = new Cache<string, List<NewUnitInfo>>(x => new List<NewUnitInfo>());
|
readonly Cache<string, List<NewUnitInfo>> producesIndex = new Cache<string, List<NewUnitInfo>>(x => new List<NewUnitInfo>());
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using IjwFramework.Collections;
|
|||||||
|
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
class VoiceInfo
|
public class VoiceInfo
|
||||||
{
|
{
|
||||||
public readonly string[] SovietVariants = { ".aud" };
|
public readonly string[] SovietVariants = { ".aud" };
|
||||||
public readonly string[] AlliedVariants = { ".aud" };
|
public readonly string[] AlliedVariants = { ".aud" };
|
||||||
@@ -30,4 +30,29 @@ namespace OpenRa.GameRules
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class VoicePool
|
||||||
|
{
|
||||||
|
readonly string[] clips;
|
||||||
|
readonly List<string> liveclips = new List<string>();
|
||||||
|
|
||||||
|
public VoicePool(params string[] clips)
|
||||||
|
{
|
||||||
|
this.clips = clips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetNext()
|
||||||
|
{
|
||||||
|
if (liveclips.Count == 0)
|
||||||
|
liveclips.AddRange(clips);
|
||||||
|
|
||||||
|
if (liveclips.Count == 0)
|
||||||
|
return null; /* avoid crashing if there's no clips at all */
|
||||||
|
|
||||||
|
var i = Game.CosmeticRandom.Next(liveclips.Count);
|
||||||
|
var s = liveclips[i];
|
||||||
|
liveclips.RemoveAt(i);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace OpenRa.GameRules
|
namespace OpenRa.GameRules
|
||||||
{
|
{
|
||||||
class WeaponInfo
|
public class WeaponInfo
|
||||||
{
|
{
|
||||||
public readonly string Anim = null;
|
public readonly string Anim = null;
|
||||||
public readonly int Burst = 1;
|
public readonly int Burst = 1;
|
||||||
|
|||||||
@@ -288,7 +288,6 @@
|
|||||||
<Compile Include="Graphics\Viewport.cs" />
|
<Compile Include="Graphics\Viewport.cs" />
|
||||||
<Compile Include="UnitInfluenceMap.cs" />
|
<Compile Include="UnitInfluenceMap.cs" />
|
||||||
<Compile Include="Orders\UnitOrderGenerator.cs" />
|
<Compile Include="Orders\UnitOrderGenerator.cs" />
|
||||||
<Compile Include="VoicePool.cs" />
|
|
||||||
<Compile Include="World.cs" />
|
<Compile Include="World.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -4,51 +4,5 @@ using OpenRa.Effects;
|
|||||||
|
|
||||||
namespace OpenRa.Traits
|
namespace OpenRa.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; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
namespace OpenRa.Traits
|
namespace OpenRa.Traits
|
||||||
{
|
{
|
||||||
class MineImmuneInfo : StatelessTraitInfo<MineImmune> { }
|
|
||||||
class MineImmune { }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,19 +32,19 @@ namespace OpenRa.Traits
|
|||||||
}
|
}
|
||||||
public interface IOccupySpace { IEnumerable<int2> OccupiedCells(); }
|
public interface IOccupySpace { IEnumerable<int2> OccupiedCells(); }
|
||||||
interface INotifyAttack { void Attacking(Actor self); }
|
interface INotifyAttack { void Attacking(Actor self); }
|
||||||
interface IRenderModifier { IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r); }
|
public interface IRenderModifier { IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r); }
|
||||||
interface IDamageModifier { float GetDamageModifier(); }
|
public interface IDamageModifier { float GetDamageModifier(); }
|
||||||
interface ISpeedModifier { float GetSpeedModifier(); }
|
public interface ISpeedModifier { float GetSpeedModifier(); }
|
||||||
interface IPaletteModifier { void AdjustPalette(Bitmap b); }
|
public interface IPaletteModifier { void AdjustPalette(Bitmap b); }
|
||||||
interface IPips { IEnumerable<PipType> GetPips(Actor self); }
|
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }
|
||||||
interface ITags { IEnumerable<TagType> GetTags(); }
|
public interface ITags { IEnumerable<TagType> GetTags(); }
|
||||||
interface IMovement
|
public interface IMovement
|
||||||
{
|
{
|
||||||
UnitMovementType GetMovementType();
|
UnitMovementType GetMovementType();
|
||||||
bool CanEnterCell(int2 location);
|
bool CanEnterCell(int2 location);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ICrushable
|
public interface ICrushable
|
||||||
{
|
{
|
||||||
void OnCrush(Actor crusher);
|
void OnCrush(Actor crusher);
|
||||||
bool IsCrushableBy(UnitMovementType umt, Player player);
|
bool IsCrushableBy(UnitMovementType umt, Player player);
|
||||||
@@ -75,7 +75,7 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public interface ITraitInfo { object Create(Actor self); }
|
public interface ITraitInfo { object Create(Actor self); }
|
||||||
|
|
||||||
class StatelessTraitInfo<T> : ITraitInfo
|
public class StatelessTraitInfo<T> : ITraitInfo
|
||||||
where T : new()
|
where T : new()
|
||||||
{
|
{
|
||||||
static Lazy<T> Instance = Lazy.New(() => new T());
|
static Lazy<T> Instance = Lazy.New(() => new T());
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OpenRa
|
|
||||||
{
|
|
||||||
class VoicePool
|
|
||||||
{
|
|
||||||
readonly string[] clips;
|
|
||||||
readonly List<string> liveclips = new List<string>();
|
|
||||||
|
|
||||||
public VoicePool(params string[] clips)
|
|
||||||
{
|
|
||||||
this.clips = clips;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetNext()
|
|
||||||
{
|
|
||||||
if (liveclips.Count == 0)
|
|
||||||
liveclips.AddRange(clips);
|
|
||||||
|
|
||||||
if (liveclips.Count == 0)
|
|
||||||
return null; /* avoid crashing if there's no clips at all */
|
|
||||||
|
|
||||||
var i = Game.CosmeticRandom.Next(liveclips.Count);
|
|
||||||
var s = liveclips[i];
|
|
||||||
liveclips.RemoveAt(i);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 { }
|
||||||
|
}
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Mine.cs" />
|
||||||
<Compile Include="Minelayer.cs" />
|
<Compile Include="Minelayer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user