Add a backawrd moving option for mobile
This commit is contained in:
committed by
Matthias Mailänder
parent
83357af14c
commit
9049ae6f20
@@ -41,6 +41,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
List<CPos> path;
|
List<CPos> path;
|
||||||
CPos? destination;
|
CPos? destination;
|
||||||
|
int startTicks;
|
||||||
|
|
||||||
// For dealing with blockers
|
// For dealing with blockers
|
||||||
bool hasWaited;
|
bool hasWaited;
|
||||||
@@ -111,6 +112,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
protected override void OnFirstRun(Actor self)
|
protected override void OnFirstRun(Actor self)
|
||||||
{
|
{
|
||||||
|
startTicks = self.World.WorldTick;
|
||||||
|
|
||||||
if (evaluateNearestMovableCell && destination.HasValue)
|
if (evaluateNearestMovableCell && destination.HasValue)
|
||||||
{
|
{
|
||||||
var movableDestination = mobile.NearestMoveableCell(destination.Value);
|
var movableDestination = mobile.NearestMoveableCell(destination.Value);
|
||||||
@@ -156,6 +159,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var firstFacing = self.World.Map.FacingBetween(mobile.FromCell, nextCell.Value.Cell, mobile.Facing);
|
var firstFacing = self.World.Map.FacingBetween(mobile.FromCell, nextCell.Value.Cell, mobile.Facing);
|
||||||
|
|
||||||
|
if (mobile.Info.CanMoveBackward && self.World.WorldTick - startTicks < mobile.Info.BackwardDuration && Math.Abs(firstFacing.Angle - mobile.Facing.Angle) > 256)
|
||||||
|
firstFacing = new WAngle(firstFacing.Angle + 512);
|
||||||
|
|
||||||
if (firstFacing != mobile.Facing)
|
if (firstFacing != mobile.Facing)
|
||||||
{
|
{
|
||||||
path.Add(nextCell.Value.Cell);
|
path.Add(nextCell.Value.Cell);
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Display order for the facing slider in the map editor")]
|
[Desc("Display order for the facing slider in the map editor")]
|
||||||
public readonly int EditorFacingDisplayOrder = 3;
|
public readonly int EditorFacingDisplayOrder = 3;
|
||||||
|
|
||||||
|
[Desc("Can move backward if possible")]
|
||||||
|
public readonly bool CanMoveBackward = false;
|
||||||
|
|
||||||
|
[Desc("After how many ticks the actor will turn forward during backoff")]
|
||||||
|
public readonly int BackwardDuration = 40;
|
||||||
|
|
||||||
[ConsumedConditionReference]
|
[ConsumedConditionReference]
|
||||||
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
||||||
public readonly BooleanExpression RequireForceMoveCondition = null;
|
public readonly BooleanExpression RequireForceMoveCondition = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user