renamed in Mobile.CurrentAction: "Action" -> "Activity"

This commit is contained in:
Bob
2009-10-26 18:57:12 +13:00
parent 20fed17306
commit 384a3ee2e9
4 changed files with 34 additions and 34 deletions

View File

@@ -198,7 +198,7 @@ namespace OpenRa.Game
var unit = new Actor(name, (1/24f * producer.CenterLocation).ToInt2(), player);
var mobile = unit.traits.Get<Mobile>();
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));

View File

@@ -32,7 +32,7 @@ namespace OpenRa.Game
Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false);
var mobile = Unit.traits.Get<Traits.Mobile>();
mobile.Cancel(Unit);
mobile.QueueAction( new Traits.Mobile.MoveTo( Destination ) );
mobile.QueueActivity( new Traits.Mobile.MoveTo( Destination ) );
}
}
}

View File

@@ -37,13 +37,13 @@ namespace OpenRa.Game.Traits
public override void Apply()
{
var mobile = Unit.traits.Get<Mobile>();
mobile.QueueAction( new Mobile.Turn( 96 ) );
mobile.QueueAction( new DeployAction() );
mobile.QueueActivity( new Mobile.Turn( 96 ) );
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 )
{

View File

@@ -16,7 +16,7 @@ namespace OpenRa.Game.Traits
public int facing;
public int Voice = Game.CosmeticRandom.Next(2);
CurrentAction currentAction;
CurrentActivity currentActivity;
public Mobile(Actor self)
{
@@ -24,25 +24,25 @@ namespace OpenRa.Game.Traits
fromCell = toCell;
}
public void QueueAction( CurrentAction nextAction )
public void QueueActivity( CurrentActivity nextActivity )
{
if( currentAction == null )
if( currentActivity == null )
{
currentAction = nextAction;
currentActivity = nextActivity;
return;
}
var act = currentAction;
while( act.NextAction != null )
var act = currentActivity;
while( act.NextActivity != null )
{
act = act.NextAction;
act = act.NextActivity;
}
act.NextAction = nextAction;
act.NextActivity = nextActivity;
}
public void Tick(Actor self)
{
if( currentAction != null )
currentAction.Tick( self, this );
if( currentActivity != null )
currentActivity.Tick( self, this );
else
fromCell = toCell;
}
@@ -59,8 +59,8 @@ namespace OpenRa.Game.Traits
public void Cancel(Actor self)
{
if (currentAction != null)
currentAction.Cancel(self, this);
if (currentActivity != null)
currentActivity.Cancel(self, this);
}
public IEnumerable<int2> OccupiedCells()
@@ -70,23 +70,23 @@ namespace OpenRa.Game.Traits
public UnitMovementType GetMovementType()
{
/* todo: boats, planes */
/* todo: boats */
var vi = self.unitInfo as UnitInfo.VehicleInfo;
if (vi == null) return UnitMovementType.Foot;
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 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;
@@ -99,9 +99,9 @@ namespace OpenRa.Game.Traits
{
if( desiredFacing == mobile.facing )
{
mobile.currentAction = NextAction;
if( NextAction != null )
NextAction.Tick( self, mobile );
mobile.currentActivity = NextActivity;
if( NextActivity != null )
NextActivity.Tick( self, mobile );
return;
}
Util.TickFacing( ref mobile.facing, desiredFacing, self.unitInfo.ROT );
@@ -110,13 +110,13 @@ namespace OpenRa.Game.Traits
public void Cancel( Actor self, Mobile mobile )
{
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;
List<int2> path;
@@ -144,7 +144,7 @@ namespace OpenRa.Game.Traits
if( destination == self.Location )
{
mobile.currentAction = NextAction;
mobile.currentActivity = NextActivity;
return;
}
@@ -160,7 +160,7 @@ namespace OpenRa.Game.Traits
int2 dir = nextCell - mobile.fromCell;
var firstFacing = Util.GetFacing( dir, mobile.facing );
if( firstFacing != mobile.facing )
mobile.currentAction = new Turn( firstFacing ) { NextAction = this };
mobile.currentActivity = new Turn( firstFacing ) { NextActivity = this };
else
{
if (!CanEnterCell(nextCell, self)) return; /* todo: repath, sometimes */
@@ -177,7 +177,7 @@ namespace OpenRa.Game.Traits
Game.UnitInfluence.Update(mobile);
}
mobile.currentAction.Tick( self, mobile );
mobile.currentActivity.Tick( self, mobile );
}
static float2 CenterOfCell( int2 loc )
@@ -296,7 +296,7 @@ namespace OpenRa.Game.Traits
public void Cancel( Actor self, Mobile mobile )
{
path.Clear();
NextAction = null;
NextActivity = null;
}
}
}