split ITeleportable off as a base interface from IMove; Crate no longer pretends to be moveable.
This commit is contained in:
@@ -121,7 +121,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
if (order.OrderString == "Move")
|
if (order.OrderString == "Move")
|
||||||
{
|
{
|
||||||
if (self.traits.GetOrDefault<IMove>().CanEnterCell(order.TargetLocation))
|
if (CanEnterCell(order.TargetLocation))
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
|
|||||||
@@ -99,13 +99,18 @@ namespace OpenRA.Traits
|
|||||||
public interface IPaletteModifier { void AdjustPalette(Bitmap b); }
|
public interface IPaletteModifier { void AdjustPalette(Bitmap b); }
|
||||||
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }
|
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }
|
||||||
public interface ITags { IEnumerable<TagType> GetTags(); }
|
public interface ITags { IEnumerable<TagType> GetTags(); }
|
||||||
public interface IMove
|
|
||||||
|
public interface ITeleportable /* crap name! */
|
||||||
{
|
{
|
||||||
bool CanEnterCell(int2 location);
|
bool CanEnterCell(int2 location);
|
||||||
|
void SetPosition(Actor self, int2 cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IMove : ITeleportable
|
||||||
|
{
|
||||||
float MovementCostForCell(Actor self, int2 cell);
|
float MovementCostForCell(Actor self, int2 cell);
|
||||||
float MovementSpeedForCell(Actor self, int2 cell);
|
float MovementSpeedForCell(Actor self, int2 cell);
|
||||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||||
void SetPosition(Actor self, int2 cell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IOffsetCenterLocation { float2 CenterOffset { get; } }
|
public interface IOffsetCenterLocation { float2 CenterOffset { get; } }
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ namespace OpenRA.Mods.RA
|
|||||||
class CrateInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
|
class CrateInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
|
||||||
{
|
{
|
||||||
public readonly int Lifetime = 5; // Seconds
|
public readonly int Lifetime = 5; // Seconds
|
||||||
public readonly string[] TerrainTypes = {};
|
public readonly string[] TerrainTypes = { };
|
||||||
public object Create(ActorInitializer init) { return new Crate(init, this); }
|
public object Create(ActorInitializer init) { return new Crate(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// IMove is required for paradrop
|
// ITeleportable is required for paradrop
|
||||||
class Crate : ITick, IOccupySpace, IMove
|
class Crate : ITick, IOccupySpace, ITeleportable
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
[Sync]
|
[Sync]
|
||||||
@@ -81,30 +81,23 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (++ticks >= self.Info.Traits.Get<CrateInfo>().Lifetime * 25)
|
if (++ticks >= self.Info.Traits.Get<CrateInfo>().Lifetime * 25)
|
||||||
self.World.AddFrameEndTask(w => w.Remove(self));
|
self.World.AddFrameEndTask(w => w.Remove(self));
|
||||||
|
|
||||||
var seq = self.World.GetTerrainInfo(cell).IsWater ? "water" : "idle";
|
var seq = self.World.GetTerrainInfo(cell).IsWater ? "water" : "idle";
|
||||||
if (seq != self.traits.Get<RenderSimple>().anim.CurrentSequence.Name)
|
if (seq != self.traits.Get<RenderSimple>().anim.CurrentSequence.Name)
|
||||||
self.traits.Get<RenderSimple>().anim.PlayRepeating(seq);
|
self.traits.Get<RenderSimple>().anim.PlayRepeating(seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 TopLeft {get { return Location; }}
|
public int2 TopLeft { get { return Location; } }
|
||||||
int2[] noCells = new int2[] { };
|
int2[] noCells = new int2[] { };
|
||||||
public IEnumerable<int2> OccupiedCells() { return noCells; }
|
public IEnumerable<int2> OccupiedCells() { return noCells; }
|
||||||
|
|
||||||
public bool CanEnterCell(int2 cell) { return MovementCostForCell(self, cell) < float.PositiveInfinity; }
|
public bool CanEnterCell(int2 cell)
|
||||||
|
|
||||||
public float MovementCostForCell(Actor self, int2 cell)
|
|
||||||
{
|
{
|
||||||
if (!self.World.Map.IsInMap(cell.X,cell.Y))
|
if (!self.World.Map.IsInMap(cell.X, cell.Y)) return false;
|
||||||
return float.PositiveInfinity;
|
|
||||||
|
|
||||||
var type = self.World.GetTerrainType(cell);
|
var type = self.World.GetTerrainType(cell);
|
||||||
return Info.TerrainTypes.Contains(type) ? 0f : float.PositiveInfinity;
|
return Info.TerrainTypes.Contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float MovementSpeedForCell(Actor self, int2 cell) { return 1; }
|
|
||||||
public IEnumerable<float2> GetCurrentPath(Actor self) { return new float2[] {}; }
|
|
||||||
|
|
||||||
public void SetPosition(Actor self, int2 cell)
|
public void SetPosition(Actor self, int2 cell)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
var loc = Traits.Util.CellContaining(location);
|
var loc = Traits.Util.CellContaining(location);
|
||||||
cargo.CancelActivity();
|
cargo.CancelActivity();
|
||||||
|
|
||||||
var mobile = cargo.traits.WithInterface<IMove>().FirstOrDefault();
|
var mobile = cargo.traits.GetOrDefault<ITeleportable>();
|
||||||
|
|
||||||
if (mobile != null)
|
if (mobile != null)
|
||||||
mobile.SetPosition(cargo, loc);
|
mobile.SetPosition(cargo, loc);
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSuitableCell(Actor self, int2 p)
|
bool IsSuitableCell(Actor actorToDrop, int2 p)
|
||||||
{
|
{
|
||||||
return self.traits.WithInterface<IMove>().FirstOrDefault().CanEnterCell(p);
|
return actorToDrop.traits.Get<ITeleportable>().CanEnterCell(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinishedDropping(Actor self)
|
void FinishedDropping(Actor self)
|
||||||
|
|||||||
Reference in New Issue
Block a user