Add Orientation getter to IFacing.

This commit is contained in:
Paul Chote
2020-06-05 20:17:32 +01:00
committed by tovl
parent c7ba359688
commit 43717a89b5
6 changed files with 39 additions and 11 deletions

View File

@@ -69,9 +69,7 @@ namespace OpenRA
{ {
get get
{ {
// TODO: Support non-zero pitch/roll in IFacing (IOrientation?) return facing != null ? facing.Orientation : WRot.Zero;
var facingValue = facing != null ? facing.Facing : WAngle.Zero;
return new WRot(WAngle.Zero, WAngle.Zero, facingValue);
} }
} }

View File

@@ -319,6 +319,7 @@ namespace OpenRA.Traits
{ {
WAngle TurnSpeed { get; } WAngle TurnSpeed { get; }
WAngle Facing { get; set; } WAngle Facing { get; set; }
WRot Orientation { get; }
} }
public interface IFacingInfo : ITraitInfoInterface { int GetInitialFacing(); } public interface IFacingInfo : ITraitInfoInterface { int GetInitialFacing(); }

View File

@@ -64,8 +64,16 @@ namespace OpenRA.Mods.Cnc.Traits
IEnumerable<int> speedModifiers; IEnumerable<int> speedModifiers;
INotifyVisualPositionChanged[] notifyVisualPositionChanged; INotifyVisualPositionChanged[] notifyVisualPositionChanged;
WRot orientation;
[Sync] [Sync]
public WAngle Facing { get; set; } public WAngle Facing
{
get { return orientation.Yaw; }
set { orientation = orientation.WithYaw(value); }
}
public WRot Orientation { get { return orientation; } }
[Sync] [Sync]
public WPos CenterPosition { get; private set; } public WPos CenterPosition { get; private set; }

View File

@@ -208,8 +208,16 @@ namespace OpenRA.Mods.Common.Traits
INotifyVisualPositionChanged[] notifyVisualPositionChanged; INotifyVisualPositionChanged[] notifyVisualPositionChanged;
IOverrideAircraftLanding overrideAircraftLanding; IOverrideAircraftLanding overrideAircraftLanding;
WRot orientation;
[Sync] [Sync]
public WAngle Facing { get; set; } public WAngle Facing
{
get { return orientation.Yaw; }
set { orientation = orientation.WithYaw(value); }
}
public WRot Orientation { get { return orientation; } }
[Sync] [Sync]
public WPos CenterPosition { get; private set; } public WPos CenterPosition { get; private set; }

View File

@@ -68,8 +68,16 @@ namespace OpenRA.Mods.Common.Traits
[Sync] [Sync]
public WPos CenterPosition { get; private set; } public WPos CenterPosition { get; private set; }
WRot orientation;
[Sync] [Sync]
public WAngle Facing { get; set; } public WAngle Facing
{
get { return orientation.Yaw; }
set { orientation = orientation.WithYaw(value); }
}
public WRot Orientation { get { return orientation; } }
public WAngle TurnSpeed { get { return WAngle.Zero; } } public WAngle TurnSpeed { get { return WAngle.Zero; } }

View File

@@ -195,10 +195,12 @@ namespace OpenRA.Mods.Common.Traits
} }
#endregion #endregion
WAngle oldFacing, facing; WAngle oldFacing;
WRot orientation;
WPos oldPos; WPos oldPos;
CPos fromCell, toCell; CPos fromCell, toCell;
public SubCell FromSubCell, ToSubCell; public SubCell FromSubCell, ToSubCell;
INotifyCustomLayerChanged[] notifyCustomLayerChanged; INotifyCustomLayerChanged[] notifyCustomLayerChanged;
INotifyVisualPositionChanged[] notifyVisualPositionChanged; INotifyVisualPositionChanged[] notifyVisualPositionChanged;
INotifyMoving[] notifyMoving; INotifyMoving[] notifyMoving;
@@ -216,13 +218,16 @@ namespace OpenRA.Mods.Common.Traits
} }
#region IFacing #region IFacing
[Sync] [Sync]
public WAngle Facing public WAngle Facing
{ {
get { return facing; } get { return orientation.Yaw; }
set { facing = value; } set { orientation = orientation.WithYaw(value); }
} }
public WRot Orientation { get { return orientation; } }
public WAngle TurnSpeed { get { return new WAngle(4 * Info.TurnSpeed); } } public WAngle TurnSpeed { get { return new WAngle(4 * Info.TurnSpeed); } }
#endregion #endregion
@@ -858,12 +863,12 @@ namespace OpenRA.Mods.Common.Traits
void IActorPreviewInitModifier.ModifyActorPreviewInit(Actor self, TypeDictionary inits) void IActorPreviewInitModifier.ModifyActorPreviewInit(Actor self, TypeDictionary inits)
{ {
if (!inits.Contains<DynamicFacingInit>() && !inits.Contains<FacingInit>()) if (!inits.Contains<DynamicFacingInit>() && !inits.Contains<FacingInit>())
inits.Add(new DynamicFacingInit(() => facing.Facing)); inits.Add(new DynamicFacingInit(() => Facing.Facing));
} }
void IDeathActorInitModifier.ModifyDeathActorInit(Actor self, TypeDictionary init) void IDeathActorInitModifier.ModifyDeathActorInit(Actor self, TypeDictionary init)
{ {
init.Add(new FacingInit(facing.Facing)); init.Add(new FacingInit(Facing.Facing));
// Allows the husk to drag to its final position // Allows the husk to drag to its final position
if (CanEnterCell(self.Location, self, BlockedByActor.Stationary)) if (CanEnterCell(self.Location, self, BlockedByActor.Stationary))