Add IBlocksProjectilesInfo interface

This commit is contained in:
reaperrr
2017-05-04 14:13:05 +02:00
committed by Chris Forbes
parent 0d2d17d2fb
commit d92d9f86fc
3 changed files with 13 additions and 10 deletions

View File

@@ -14,14 +14,8 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[RequireExplicitImplementation]
public interface IBlocksProjectiles
{
WDist BlockingHeight { get; }
}
[Desc("This actor blocks bullets and missiles with 'Blockable' property.")] [Desc("This actor blocks bullets and missiles with 'Blockable' property.")]
public class BlocksProjectilesInfo : ConditionalTraitInfo public class BlocksProjectilesInfo : ConditionalTraitInfo, IBlocksProjectilesInfo
{ {
public readonly WDist Height = WDist.FromCells(1); public readonly WDist Height = WDist.FromCells(1);

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Will open and be passable for actors that appear friendly when there are no enemies in range.")] [Desc("Will open and be passable for actors that appear friendly when there are no enemies in range.")]
public class GateInfo : BuildingInfo public class GateInfo : BuildingInfo, IBlocksProjectilesInfo
{ {
public readonly string OpeningSound = null; public readonly string OpeningSound = null;
public readonly string ClosingSound = null; public readonly string ClosingSound = null;
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int TransitionDelay = 33; public readonly int TransitionDelay = 33;
[Desc("Blocks bullets scaled to open value.")] [Desc("Blocks bullets scaled to open value.")]
public readonly int BlocksProjectilesHeight = 640; public readonly WDist BlocksProjectilesHeight = new WDist(640);
public override object Create(ActorInitializer init) { return new Gate(init, this); } public override object Create(ActorInitializer init) { return new Gate(init, this); }
} }
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
get get
{ {
return new WDist(info.BlocksProjectilesHeight * (OpenPosition - Position) / OpenPosition); return new WDist(info.BlocksProjectilesHeight.Length * (OpenPosition - Position) / OpenPosition);
} }
} }
} }

View File

@@ -38,6 +38,15 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition); IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition);
} }
[RequireExplicitImplementation]
public interface IBlocksProjectiles
{
WDist BlockingHeight { get; }
}
[RequireExplicitImplementation]
public interface IBlocksProjectilesInfo : ITraitInfoInterface { }
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface INotifySold public interface INotifySold
{ {