renamed in Mobile.CurrentAction: "Action" -> "Activity"
This commit is contained in:
@@ -198,7 +198,7 @@ namespace OpenRa.Game
|
|||||||
var unit = new Actor(name, (1/24f * producer.CenterLocation).ToInt2(), player);
|
var unit = new Actor(name, (1/24f * producer.CenterLocation).ToInt2(), player);
|
||||||
var mobile = unit.traits.Get<Mobile>();
|
var mobile = unit.traits.Get<Mobile>();
|
||||||
mobile.facing = 128;
|
mobile.facing = 128;
|
||||||
mobile.QueueAction( new Traits.Mobile.MoveTo( unit.Location + new int2( 0, 3 ) ) );
|
mobile.QueueActivity( new Traits.Mobile.MoveTo( unit.Location + new int2( 0, 3 ) ) );
|
||||||
|
|
||||||
world.AddFrameEndTask(_ => world.Add(unit));
|
world.AddFrameEndTask(_ => world.Add(unit));
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRa.Game
|
|||||||
Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false);
|
Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false);
|
||||||
var mobile = Unit.traits.Get<Traits.Mobile>();
|
var mobile = Unit.traits.Get<Traits.Mobile>();
|
||||||
mobile.Cancel(Unit);
|
mobile.Cancel(Unit);
|
||||||
mobile.QueueAction( new Traits.Mobile.MoveTo( Destination ) );
|
mobile.QueueActivity( new Traits.Mobile.MoveTo( Destination ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ namespace OpenRa.Game.Traits
|
|||||||
public override void Apply()
|
public override void Apply()
|
||||||
{
|
{
|
||||||
var mobile = Unit.traits.Get<Mobile>();
|
var mobile = Unit.traits.Get<Mobile>();
|
||||||
mobile.QueueAction( new Mobile.Turn( 96 ) );
|
mobile.QueueActivity( new Mobile.Turn( 96 ) );
|
||||||
mobile.QueueAction( new DeployAction() );
|
mobile.QueueActivity( new DeployAction() );
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeployAction : Mobile.CurrentAction
|
class DeployAction : Mobile.CurrentActivity
|
||||||
{
|
{
|
||||||
public Mobile.CurrentAction NextAction { get; set; }
|
public Mobile.CurrentActivity NextActivity { get; set; }
|
||||||
|
|
||||||
public void Tick( Actor self, Mobile mobile )
|
public void Tick( Actor self, Mobile mobile )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game.Traits
|
|||||||
public int facing;
|
public int facing;
|
||||||
|
|
||||||
public int Voice = Game.CosmeticRandom.Next(2);
|
public int Voice = Game.CosmeticRandom.Next(2);
|
||||||
CurrentAction currentAction;
|
CurrentActivity currentActivity;
|
||||||
|
|
||||||
public Mobile(Actor self)
|
public Mobile(Actor self)
|
||||||
{
|
{
|
||||||
@@ -24,25 +24,25 @@ namespace OpenRa.Game.Traits
|
|||||||
fromCell = toCell;
|
fromCell = toCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QueueAction( CurrentAction nextAction )
|
public void QueueActivity( CurrentActivity nextActivity )
|
||||||
{
|
{
|
||||||
if( currentAction == null )
|
if( currentActivity == null )
|
||||||
{
|
{
|
||||||
currentAction = nextAction;
|
currentActivity = nextActivity;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var act = currentAction;
|
var act = currentActivity;
|
||||||
while( act.NextAction != null )
|
while( act.NextActivity != null )
|
||||||
{
|
{
|
||||||
act = act.NextAction;
|
act = act.NextActivity;
|
||||||
}
|
}
|
||||||
act.NextAction = nextAction;
|
act.NextActivity = nextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if( currentAction != null )
|
if( currentActivity != null )
|
||||||
currentAction.Tick( self, this );
|
currentActivity.Tick( self, this );
|
||||||
else
|
else
|
||||||
fromCell = toCell;
|
fromCell = toCell;
|
||||||
}
|
}
|
||||||
@@ -59,8 +59,8 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public void Cancel(Actor self)
|
public void Cancel(Actor self)
|
||||||
{
|
{
|
||||||
if (currentAction != null)
|
if (currentActivity != null)
|
||||||
currentAction.Cancel(self, this);
|
currentActivity.Cancel(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<int2> OccupiedCells()
|
public IEnumerable<int2> OccupiedCells()
|
||||||
@@ -70,23 +70,23 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public UnitMovementType GetMovementType()
|
public UnitMovementType GetMovementType()
|
||||||
{
|
{
|
||||||
/* todo: boats, planes */
|
/* todo: boats */
|
||||||
|
|
||||||
var vi = self.unitInfo as UnitInfo.VehicleInfo;
|
var vi = self.unitInfo as UnitInfo.VehicleInfo;
|
||||||
if (vi == null) return UnitMovementType.Foot;
|
if (vi == null) return UnitMovementType.Foot;
|
||||||
return vi.Tracked ? UnitMovementType.Track : UnitMovementType.Wheel;
|
return vi.Tracked ? UnitMovementType.Track : UnitMovementType.Wheel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CurrentAction
|
public interface CurrentActivity
|
||||||
{
|
{
|
||||||
CurrentAction NextAction { get; set; }
|
CurrentActivity NextActivity { get; set; }
|
||||||
void Tick( Actor self, Mobile mobile );
|
void Tick( Actor self, Mobile mobile );
|
||||||
void Cancel( Actor self, Mobile mobile );
|
void Cancel( Actor self, Mobile mobile );
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Turn : CurrentAction
|
public class Turn : CurrentActivity
|
||||||
{
|
{
|
||||||
public CurrentAction NextAction { get; set; }
|
public CurrentActivity NextActivity { get; set; }
|
||||||
|
|
||||||
public int desiredFacing;
|
public int desiredFacing;
|
||||||
|
|
||||||
@@ -99,9 +99,9 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
if( desiredFacing == mobile.facing )
|
if( desiredFacing == mobile.facing )
|
||||||
{
|
{
|
||||||
mobile.currentAction = NextAction;
|
mobile.currentActivity = NextActivity;
|
||||||
if( NextAction != null )
|
if( NextActivity != null )
|
||||||
NextAction.Tick( self, mobile );
|
NextActivity.Tick( self, mobile );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Util.TickFacing( ref mobile.facing, desiredFacing, self.unitInfo.ROT );
|
Util.TickFacing( ref mobile.facing, desiredFacing, self.unitInfo.ROT );
|
||||||
@@ -110,13 +110,13 @@ namespace OpenRa.Game.Traits
|
|||||||
public void Cancel( Actor self, Mobile mobile )
|
public void Cancel( Actor self, Mobile mobile )
|
||||||
{
|
{
|
||||||
desiredFacing = mobile.facing;
|
desiredFacing = mobile.facing;
|
||||||
NextAction = null;
|
NextActivity = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MoveTo : CurrentAction
|
public class MoveTo : CurrentActivity
|
||||||
{
|
{
|
||||||
public CurrentAction NextAction { get; set; }
|
public CurrentActivity NextActivity { get; set; }
|
||||||
|
|
||||||
int2 destination;
|
int2 destination;
|
||||||
List<int2> path;
|
List<int2> path;
|
||||||
@@ -144,7 +144,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
if( destination == self.Location )
|
if( destination == self.Location )
|
||||||
{
|
{
|
||||||
mobile.currentAction = NextAction;
|
mobile.currentActivity = NextActivity;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ namespace OpenRa.Game.Traits
|
|||||||
int2 dir = nextCell - mobile.fromCell;
|
int2 dir = nextCell - mobile.fromCell;
|
||||||
var firstFacing = Util.GetFacing( dir, mobile.facing );
|
var firstFacing = Util.GetFacing( dir, mobile.facing );
|
||||||
if( firstFacing != mobile.facing )
|
if( firstFacing != mobile.facing )
|
||||||
mobile.currentAction = new Turn( firstFacing ) { NextAction = this };
|
mobile.currentActivity = new Turn( firstFacing ) { NextActivity = this };
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!CanEnterCell(nextCell, self)) return; /* todo: repath, sometimes */
|
if (!CanEnterCell(nextCell, self)) return; /* todo: repath, sometimes */
|
||||||
@@ -177,7 +177,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
Game.UnitInfluence.Update(mobile);
|
Game.UnitInfluence.Update(mobile);
|
||||||
}
|
}
|
||||||
mobile.currentAction.Tick( self, mobile );
|
mobile.currentActivity.Tick( self, mobile );
|
||||||
}
|
}
|
||||||
|
|
||||||
static float2 CenterOfCell( int2 loc )
|
static float2 CenterOfCell( int2 loc )
|
||||||
@@ -258,7 +258,7 @@ namespace OpenRa.Game.Traits
|
|||||||
var ret = new MoveFirstHalf(
|
var ret = new MoveFirstHalf(
|
||||||
BetweenCells( mobile.fromCell, mobile.toCell ),
|
BetweenCells( mobile.fromCell, mobile.toCell ),
|
||||||
BetweenCells( mobile.toCell, nextCell ),
|
BetweenCells( mobile.toCell, nextCell ),
|
||||||
mobile.facing,
|
mobile.facing,
|
||||||
Util.GetNearestFacing( mobile.facing, Util.GetFacing( nextCell - mobile.toCell, mobile.facing ) ),
|
Util.GetNearestFacing( mobile.facing, Util.GetFacing( nextCell - mobile.toCell, mobile.facing ) ),
|
||||||
moveFraction - moveFractionTotal );
|
moveFraction - moveFractionTotal );
|
||||||
mobile.fromCell = mobile.toCell;
|
mobile.fromCell = mobile.toCell;
|
||||||
@@ -296,7 +296,7 @@ namespace OpenRa.Game.Traits
|
|||||||
public void Cancel( Actor self, Mobile mobile )
|
public void Cancel( Actor self, Mobile mobile )
|
||||||
{
|
{
|
||||||
path.Clear();
|
path.Clear();
|
||||||
NextAction = null;
|
NextActivity = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user