made teleport work
This commit is contained in:
@@ -19,26 +19,11 @@ namespace OpenRa.Game.Traits.Activities
|
|||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
var unit = self.traits.Get<Unit>();
|
|
||||||
var mobile = self.traits.Get<Mobile>();
|
var mobile = self.traits.Get<Mobile>();
|
||||||
|
mobile.TeleportTo(self, destination);
|
||||||
//TODO: Something needs to go here to shift the units position.
|
return NextActivity;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel(Actor self) { }
|
public void Cancel(Actor self) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
if (order.OrderString == "UsePortableChronoshift" && CanEnterCell(order.TargetLocation, self))
|
if (order.OrderString == "UsePortableChronoshift" && CanEnterCell(order.TargetLocation, self))
|
||||||
{
|
{
|
||||||
//self.QueueActivity(new Activities.Teleport(order.TargetLocation));
|
self.QueueActivity(new Activities.Teleport(order.TargetLocation));
|
||||||
Sound.Play("chrotnk1.aud");
|
// Sound.Play("chrotnk1.aud");
|
||||||
chronoshiftActive = false;
|
chronoshiftActive = false;
|
||||||
remainingChargeTime = chargeTime;
|
remainingChargeTime = chargeTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ namespace OpenRa.Game.Traits
|
|||||||
Game.UnitInfluence.Add(self, this);
|
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)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
@@ -52,7 +58,9 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public IEnumerable<int2> OccupiedCells()
|
public IEnumerable<int2> OccupiedCells()
|
||||||
{
|
{
|
||||||
return new[] { fromCell, toCell };
|
return (fromCell == toCell)
|
||||||
|
? new[] { fromCell }
|
||||||
|
: new[] { fromCell, toCell };
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitMovementType GetMovementType()
|
public UnitMovementType GetMovementType()
|
||||||
|
|||||||
@@ -57,13 +57,8 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public void Remove( Actor self, IOccupySpace unit )
|
public void Remove( Actor self, IOccupySpace unit )
|
||||||
{
|
{
|
||||||
var min = int2.Max(new int2(0, 0), self.Location - searchDistance);
|
foreach (var c in unit.OccupiedCells())
|
||||||
var max = int2.Min(new int2(128, 128), self.Location + searchDistance);
|
influence[c.X, c.Y] = null;
|
||||||
|
|
||||||
for (var j = min.Y; j <= max.Y; j++)
|
|
||||||
for (var i = min.X; i <= max.X; i++)
|
|
||||||
if (influence[i, j] == self)
|
|
||||||
influence[i, j] = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(Actor self, IOccupySpace unit)
|
public void Update(Actor self, IOccupySpace unit)
|
||||||
|
|||||||
Reference in New Issue
Block a user