Add conversions and helpers for world coordinates.

This commit is contained in:
Paul Chote
2013-03-12 05:52:30 +13:00
parent 724ea88c3b
commit 9e4bab07e5
5 changed files with 89 additions and 2 deletions

View File

@@ -28,6 +28,8 @@ namespace OpenRA
Lazy<IOccupySpace> occupySpace;
IHasLocation HasLocation;
Lazy<IMove> Move;
Lazy<IFacing> Facing;
public Cached<Rectangle> Bounds;
public Cached<Rectangle> ExtendedBounds;
@@ -44,7 +46,26 @@ namespace OpenRA
return HasLocation.PxPosition;
}
}
public WPos CenterPosition
{
get
{
var altitude = Move.Value != null ? Move.Value.Altitude : 0;
return CenterLocation.ToWPos(altitude);
}
}
public WRot Orientation
{
get
{
// TODO: Support non-zero pitch/roll in IFacing (IOrientation?)
var facing = Facing.Value != null ? Facing.Value.Facing : 0;
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
}
}
public Shroud.ActorVisibility Sight;
[Sync] public Player Owner;
@@ -74,6 +95,7 @@ namespace OpenRA
}
Move = Lazy.New(() => TraitOrDefault<IMove>());
Facing = Lazy.New(() => TraitOrDefault<IFacing>());
Size = Lazy.New(() =>
{