better fix for chrono bug
This commit is contained in:
@@ -40,13 +40,13 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't be used in synced code
|
// Can't be used in synced code, except with ignoreVis.
|
||||||
public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation)
|
public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation, bool ignoreVis)
|
||||||
{
|
{
|
||||||
// Todo: Allow enemy units to be chronoshifted into bad terrain to kill them
|
// Todo: Allow enemy units to be chronoshifted into bad terrain to kill them
|
||||||
return self.HasTrait<ITeleportable>() &&
|
return self.HasTrait<ITeleportable>() &&
|
||||||
self.Trait<ITeleportable>().CanEnterCell(targetLocation) &&
|
self.Trait<ITeleportable>().CanEnterCell(targetLocation) &&
|
||||||
(self.World.LocalShroud.IsExplored(targetLocation));
|
(ignoreVis || self.World.LocalShroud.IsExplored(targetLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere)
|
public virtual bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Scripting
|
|||||||
var target = kv.First;
|
var target = kv.First;
|
||||||
var targetCell = kv.Second;
|
var targetCell = kv.Second;
|
||||||
var cs = target.Trait<Chronoshiftable>();
|
var cs = target.Trait<Chronoshiftable>();
|
||||||
if (cs.CanChronoshiftTo(target, targetCell))
|
if (cs.CanChronoshiftTo(target, targetCell, true))
|
||||||
target.Trait<Chronoshiftable>().Teleport(target,
|
target.Trait<Chronoshiftable>().Teleport(target,
|
||||||
targetCell,
|
targetCell,
|
||||||
duration,
|
duration,
|
||||||
|
|||||||
@@ -51,11 +51,9 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var cs = target.Trait<Chronoshiftable>();
|
var cs = target.Trait<Chronoshiftable>();
|
||||||
var targetCell = target.Location + order.TargetLocation - order.ExtraLocation;
|
var targetCell = target.Location + order.TargetLocation - order.ExtraLocation;
|
||||||
// TODO: CanChronoshiftTo() can't be used in synced code, but not checking this here
|
|
||||||
// leaves it open to exploitation.
|
|
||||||
// if (cs.CanChronoshiftTo(target, targetCell)) ...
|
|
||||||
|
|
||||||
var cpi = Info as ChronoshiftPowerInfo;
|
var cpi = Info as ChronoshiftPowerInfo;
|
||||||
|
|
||||||
|
if (cs.CanChronoshiftTo(target, targetCell, true))
|
||||||
cs.Teleport(target, targetCell,
|
cs.Teleport(target, targetCell,
|
||||||
cpi.Duration * 25, cpi.KillCargo, self);
|
cpi.Duration * 25, cpi.KillCargo, self);
|
||||||
}
|
}
|
||||||
@@ -217,7 +215,7 @@ namespace OpenRA.Mods.RA
|
|||||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||||
{
|
{
|
||||||
var targetCell = unit.Location + xy - sourceLocation;
|
var targetCell = unit.Location + xy - sourceLocation;
|
||||||
var canEnter = unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell);
|
var canEnter = unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell, false);
|
||||||
var tile = canEnter ? validTile : invalidTile;
|
var tile = canEnter ? validTile : invalidTile;
|
||||||
tile.DrawAt( wr, Game.CellSize * targetCell, "terrain" );
|
tile.DrawAt( wr, Game.CellSize * targetCell, "terrain" );
|
||||||
}
|
}
|
||||||
@@ -229,7 +227,7 @@ namespace OpenRA.Mods.RA
|
|||||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||||
{
|
{
|
||||||
var targetCell = unit.Location + xy - sourceLocation;
|
var targetCell = unit.Location + xy - sourceLocation;
|
||||||
if (unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell))
|
if (unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell, false))
|
||||||
{
|
{
|
||||||
canTeleport = true;
|
canTeleport = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user