Skip to content

Commit

Permalink
fix some dumbness in Production/ITeleportable
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisforbes committed Jan 2, 2011
1 parent 7b5a8cf commit 2048900
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions OpenRA.Game/Traits/TraitsInterfaces.cs
Expand Up @@ -122,6 +122,7 @@ public interface ITeleportable : IHasLocation /* crap name! */
bool CanEnterCell(int2 location);
void SetPosition(Actor self, int2 cell);
void SetPxPosition(Actor self, int2 px);
void AdjustPxPosition(Actor self, int2 px); /* works like SetPxPosition, but visual only */
}

public interface IMove : ITeleportable
Expand Down
2 changes: 2 additions & 0 deletions OpenRA.Mods.RA/Air/Aircraft.cs
Expand Up @@ -69,6 +69,8 @@ public void SetPxPosition( Actor self, int2 px )
SubPxPosition = px * 1024;
}

public void AdjustPxPosition(Actor self, int2 px) { SetPxPosition(self, px); }

public bool AircraftCanEnter(Actor a)
{
if( self.Owner != a.Owner ) return false;
Expand Down
2 changes: 2 additions & 0 deletions OpenRA.Mods.RA/Crate.cs
Expand Up @@ -89,6 +89,8 @@ public void SetPxPosition( Actor self, int2 px )
SetPosition( self, Util.CellContaining( px ) );
}

public void AdjustPxPosition(Actor self, int2 px) { SetPxPosition(self, px); }

public bool CanEnterCell(int2 cell)
{
if (!self.World.Map.IsInMap(cell.X, cell.Y)) return false;
Expand Down
5 changes: 5 additions & 0 deletions OpenRA.Mods.RA/Move/Mobile.cs
Expand Up @@ -185,6 +185,11 @@ public void SetPxPosition(Actor self, int2 px)
FinishedMoving(self);
}

public void AdjustPxPosition(Actor self, int2 px) /* visual hack only */
{
PxPosition = px;
}

public IEnumerable<IOrderTargeter> Orders { get { yield return new MoveOrderTargeter(Info); } }

// Note: Returns a valid order even if the unit can't move to the target
Expand Down
6 changes: 3 additions & 3 deletions OpenRA.Mods.RA/Production.cs
Expand Up @@ -57,7 +57,7 @@ public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo)
// Set the physical position of the unit as the exit cell
teleportable.SetPosition(newUnit,exit);
var to = Util.CenterOfCell(exit);
teleportable.SetPxPosition(newUnit, spawn);
teleportable.AdjustPxPosition(newUnit, spawn);
if (facing != null)
facing.Facing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, facing.Facing) : exitinfo.Facing;
self.World.Add(newUnit);
Expand All @@ -84,15 +84,15 @@ static int2 MoveToRallyPoint(Actor self, Actor newUnit, int2 exitLocation)
if (rp == null)
return exitLocation;

var mobile = self.TraitOrDefault<Mobile>();
var mobile = newUnit.TraitOrDefault<Mobile>();
if (mobile != null)
{
newUnit.QueueActivity(mobile.MoveTo(rp.rallyPoint, 1));
return rp.rallyPoint;
}

// todo: don't talk about HeliFly here.
var helicopter = self.TraitOrDefault<Helicopter>();
var helicopter = newUnit.TraitOrDefault<Helicopter>();
if (helicopter != null)
{
newUnit.QueueActivity(new HeliFly(Util.CenterOfCell(rp.rallyPoint)));
Expand Down

0 comments on commit 2048900

Please sign in to comment.