Remove RenderLandingCraft dependency on Mobile.

This commit is contained in:
Paul Chote
2014-03-19 13:43:56 +13:00
parent de735fbd27
commit 2b3e116f74

View File

@@ -14,7 +14,7 @@ using OpenRA.Mods.RA.Move;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
{ {
public class RenderLandingCraftInfo : RenderUnitInfo public class RenderLandingCraftInfo : RenderUnitInfo, Requires<IMoveInfo>
{ {
public readonly string[] OpenTerrainTypes = { "Clear" }; public readonly string[] OpenTerrainTypes = { "Clear" };
public readonly string OpenAnim = "open"; public readonly string OpenAnim = "open";
@@ -25,26 +25,24 @@ namespace OpenRA.Mods.RA.Render
public class RenderLandingCraft : RenderUnit public class RenderLandingCraft : RenderUnit
{ {
readonly RenderLandingCraftInfo info;
readonly Actor self; readonly Actor self;
readonly Cargo cargo; readonly Cargo cargo;
readonly RenderLandingCraftInfo info; readonly IMove move;
bool open; bool open;
public RenderLandingCraft(Actor self, RenderLandingCraftInfo info) public RenderLandingCraft(Actor self, RenderLandingCraftInfo info)
: base(self) : base(self)
{ {
this.info = info;
this.self = self; this.self = self;
cargo = self.Trait<Cargo>(); cargo = self.Trait<Cargo>();
this.info = info; move = self.Trait<IMove>();
} }
public bool ShouldBeOpen() public bool ShouldBeOpen()
{ {
var mobile = self.TraitOrDefault<Mobile>(); if (self.CenterPosition.Z > 0 || move.IsMoving)
if (mobile == null)
return false;
if (self.CenterPosition.Z > 0 || mobile.IsMoving)
return false; return false;
return cargo.CurrentAdjacentCells return cargo.CurrentAdjacentCells