Add TargetableOffsets to HitShape

And remove ITargetablePositions from Building.
Also, added UseFootprintOffsets to replicate the old Building behavior for easier setup of TargetablePositions for buildings.
This commit is contained in:
reaperrr
2017-05-23 22:51:04 +02:00
parent 7fd0a3aa58
commit 82758a8bef
9 changed files with 63 additions and 19 deletions

View File

@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
public class Building : IOccupySpace, INotifySold, INotifyTransform, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, ITargetablePositions
public class Building : IOccupySpace, INotifySold, INotifyTransform, ISync, INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld
{
public readonly BuildingInfo Info;
public bool BuildComplete { get; private set; }
@@ -143,6 +143,8 @@ namespace OpenRA.Mods.Common.Traits
readonly Actor self;
public readonly bool SkipMakeAnimation;
Pair<CPos, SubCell>[] occupiedCells;
// Shared activity lock: undeploy, sell, capture, etc.
[Sync] public bool Locked = true;
@@ -173,14 +175,8 @@ namespace OpenRA.Mods.Common.Traits
SkipMakeAnimation = init.Contains<SkipMakeAnimsInit>();
}
Pair<CPos, SubCell>[] occupiedCells;
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupiedCells; }
public IEnumerable<WPos> TargetablePositions(Actor self)
{
return OccupiedCells().Select(c => self.World.Map.CenterOfCell(c.First));
}
void INotifyCreated.Created(Actor self)
{
if (SkipMakeAnimation || !self.Info.HasTraitInfo<WithMakeAnimationInfo>())