made teleport work

This commit is contained in:
Chris Forbes
2009-12-19 13:28:32 +13:00
parent cdea6b642b
commit 571816b7ac
4 changed files with 16 additions and 28 deletions

View File

@@ -19,26 +19,11 @@ namespace OpenRa.Game.Traits.Activities
public IActivity Tick(Actor self)
{
var unit = self.traits.Get<Unit>();
var mobile = self.traits.Get<Mobile>();
//TODO: Something needs to go here to shift the units position.
// Everything i have tried has caused a crash in UnitInfluenceMap.
//Game.world.AddFrameEndTask(_ =>
//{
Game.UnitInfluence.Remove(self, mobile);
//self.Location = this.destination;
mobile.toCell = this.destination;
Game.UnitInfluence.Add(self, mobile);
//});
return null;
mobile.TeleportTo(self, destination);
return NextActivity;
}
public void Cancel(Actor self){}
public void Cancel(Actor self) { }
}
}

View File

@@ -38,8 +38,8 @@ namespace OpenRa.Game.Traits
if (order.OrderString == "UsePortableChronoshift" && CanEnterCell(order.TargetLocation, self))
{
//self.QueueActivity(new Activities.Teleport(order.TargetLocation));
Sound.Play("chrotnk1.aud");
self.QueueActivity(new Activities.Teleport(order.TargetLocation));
// Sound.Play("chrotnk1.aud");
chronoshiftActive = false;
remainingChargeTime = chargeTime;
}

View File

@@ -28,6 +28,12 @@ namespace OpenRa.Game.Traits
Game.UnitInfluence.Add(self, this);
}
public void TeleportTo(Actor self, int2 xy)
{
fromCell = toCell = xy;
self.CenterLocation = Util.CenterOfCell(fromCell);
}
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (mi.Button == MouseButton.Left) return null;
@@ -52,7 +58,9 @@ namespace OpenRa.Game.Traits
public IEnumerable<int2> OccupiedCells()
{
return new[] { fromCell, toCell };
return (fromCell == toCell)
? new[] { fromCell }
: new[] { fromCell, toCell };
}
public UnitMovementType GetMovementType()