Add methods to IOccupySpaceInfo.
This commit is contained in:
@@ -158,7 +158,12 @@ namespace OpenRA.Traits
|
||||
|
||||
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
|
||||
|
||||
public interface IOccupySpaceInfo : ITraitInfo { }
|
||||
public interface IOccupySpaceInfo : ITraitInfo
|
||||
{
|
||||
IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any);
|
||||
bool SharesCell { get; }
|
||||
}
|
||||
|
||||
public interface IOccupySpace
|
||||
{
|
||||
WPos CenterPosition { get; }
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public virtual object Create(ActorInitializer init) { return new Aircraft(init, this); }
|
||||
public int GetInitialFacing() { return InitialFacing; }
|
||||
public WRange GetCruiseAltitude() { return CruiseAltitude; }
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any) { return new ReadOnlyDictionary<CPos, SubCell>(); }
|
||||
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
||||
}
|
||||
|
||||
public class Aircraft : IFacing, IPositionable, ISync, INotifyKilled, IIssueOrder, IOrderVoice, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
|
||||
@@ -104,6 +104,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.Any(b => Math.Abs(a.X - b.X) <= Adjacent
|
||||
&& Math.Abs(a.Y - b.Y) <= Adjacent));
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos topLeft, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = FootprintUtils.UnpathableTiles(info.Name, this, topLeft)
|
||||
.ToDictionary(c => c, c => SubCell.FullCell);
|
||||
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
||||
}
|
||||
|
||||
public class Building : IOccupySpace, INotifySold, INotifyTransform, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
|
||||
@@ -28,6 +28,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string CrushClass = "crate";
|
||||
|
||||
public object Create(ActorInitializer init) { return new Crate(init, this); }
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
||||
}
|
||||
|
||||
class Crate : ITick, IPositionable, ICrushable, ISync, INotifyParachuteLanded, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
|
||||
@@ -24,6 +24,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new Husk(init, this); }
|
||||
|
||||
public int GetInitialFacing() { return 128; }
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
||||
}
|
||||
|
||||
public class Husk : IPositionable, IFacing, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisable
|
||||
|
||||
@@ -18,6 +18,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly bool OccupiesSpace = true;
|
||||
public object Create(ActorInitializer init) { return new Immobile(init, this); }
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = OccupiesSpace ? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } } :
|
||||
new Dictionary<CPos, SubCell>();
|
||||
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
||||
}
|
||||
|
||||
class Immobile : IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
|
||||
@@ -295,6 +295,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public int GetInitialFacing() { return InitialFacing; }
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(new Dictionary<CPos, SubCell>() { { location, subCell } });
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell { get { return SharesCell; } }
|
||||
}
|
||||
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
class MineInfo : ITraitInfo, IOccupySpaceInfo
|
||||
class MineInfo : ITraitInfo
|
||||
{
|
||||
public readonly string[] CrushClasses = { };
|
||||
public readonly bool AvoidFriendly = true;
|
||||
|
||||
Reference in New Issue
Block a user