Add World parameter to Target.FromCell.
This commit is contained in:
@@ -31,7 +31,7 @@ namespace OpenRA.Orders
|
||||
var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
|
||||
.Where(a => a.Info.Traits.Contains<ITargetableInfo>())
|
||||
.WithHighestSelectionPriority();
|
||||
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(xy);
|
||||
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(world, xy);
|
||||
}
|
||||
|
||||
var orders = world.Selection.Actors
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Orders
|
||||
var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
|
||||
.Where(a => a.Info.Traits.Contains<ITargetableInfo>())
|
||||
.WithHighestSelectionPriority();
|
||||
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(xy);
|
||||
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(world, xy);
|
||||
}
|
||||
|
||||
var orders = world.Selection.Actors
|
||||
|
||||
@@ -28,12 +28,12 @@ namespace OpenRA.Traits
|
||||
int generation;
|
||||
|
||||
public static Target FromPos(WPos p) { return new Target { pos = p, type = TargetType.Terrain }; }
|
||||
public static Target FromCell(CPos c) { return new Target { pos = c.CenterPosition, type = TargetType.Terrain }; }
|
||||
public static Target FromCell(World w, CPos c) { return new Target { pos = c.CenterPosition, type = TargetType.Terrain }; }
|
||||
public static Target FromOrder(World w, Order o)
|
||||
{
|
||||
return o.TargetActor != null
|
||||
? FromActor(o.TargetActor)
|
||||
: FromCell(o.TargetLocation);
|
||||
: FromCell(w, o.TargetLocation);
|
||||
}
|
||||
|
||||
public static Target FromActor(Actor a)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Effects
|
||||
this.firedBy = firedBy;
|
||||
this.weapon = weapon;
|
||||
this.palette = palette;
|
||||
target = Target.FromCell(location);
|
||||
target = Target.FromCell(world, location);
|
||||
anim = new Animation(world, effect);
|
||||
anim.PlayThen("idle", () => Finish(world));
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc
|
||||
new FacingInit(64)
|
||||
});
|
||||
|
||||
a.QueueActivity(new Fly(a, Target.FromCell(self.Location + new CVec(9, 0))));
|
||||
a.QueueActivity(new Fly(a, Target.FromCell(w, self.Location + new CVec(9, 0))));
|
||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||
a.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Cnc
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Country.Race);
|
||||
}));
|
||||
|
||||
a.QueueActivity(new Fly(a, Target.FromCell(endPos)));
|
||||
a.QueueActivity(new Fly(a, Target.FromCell(w, endPos)));
|
||||
a.QueueActivity(new RemoveSelf());
|
||||
});
|
||||
|
||||
|
||||
@@ -114,13 +114,13 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (harv.LastOrderLocation == null)
|
||||
harv.LastOrderLocation = path[0];
|
||||
|
||||
self.SetTargetLine(Target.FromCell(path[0]), Color.Red, false);
|
||||
self.SetTargetLine(Target.FromCell(self.World, path[0]), Color.Red, false);
|
||||
return Util.SequenceActivities(mobile.MoveTo(path[0], 1), new HarvestResource(), new FindResources());
|
||||
}
|
||||
|
||||
public override IEnumerable<Target> GetTargets(Actor self)
|
||||
{
|
||||
yield return Target.FromCell(self.Location);
|
||||
yield return Target.FromCell(self.World, self.Location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
actor.CancelActivity();
|
||||
pos.SetVisualPosition(actor, spawn);
|
||||
actor.QueueActivity(move.MoveIntoWorld(actor, exitCell.Value));
|
||||
actor.SetTargetLine(Target.FromCell(exitCell.Value), Color.Green, false);
|
||||
actor.SetTargetLine(Target.FromCell(w, exitCell.Value), Color.Green, false);
|
||||
});
|
||||
|
||||
if (!unloadAll || cargo.IsEmpty(self))
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
if (order.OrderString == "Move")
|
||||
{
|
||||
var cell = self.World.Map.Clamp(order.TargetLocation);
|
||||
var t = Target.FromCell(cell);
|
||||
var t = Target.FromCell(self.World, cell);
|
||||
|
||||
self.SetTargetLine(t, Color.Green);
|
||||
self.CancelActivity();
|
||||
@@ -161,8 +161,8 @@ namespace OpenRA.Mods.RA.Air
|
||||
return (d * 1024 * 8) / (int)distSq;
|
||||
}
|
||||
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(self, Target.FromCell(cell)); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(self, Target.FromCell(cell)); }
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(self, Target.FromCell(self.World, cell)); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return new HeliFly(self, target, WRange.Zero, range); }
|
||||
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return new HeliFly(self, target, minRange, maxRange); }
|
||||
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new Follow(self, target, minRange, maxRange); }
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell)
|
||||
{
|
||||
return new HeliFly(self, Target.FromCell(cell));
|
||||
return new HeliFly(self, Target.FromCell(self.World, cell));
|
||||
}
|
||||
|
||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos)
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
UnReserve();
|
||||
|
||||
var cell = self.World.Map.Clamp(order.TargetLocation);
|
||||
var t = Target.FromCell(cell);
|
||||
var t = Target.FromCell(self.World, cell);
|
||||
self.SetTargetLine(t, Color.Green);
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Fly(self, t));
|
||||
@@ -101,14 +101,14 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return Util.SequenceActivities(new Fly(self, Target.FromCell(cell)), new FlyCircle()); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(cell)), new FlyCircle()); }
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle()); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(self.World, cell)), new FlyCircle()); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return Util.SequenceActivities(new Fly(self, target, WRange.Zero, range), new FlyCircle()); }
|
||||
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle()); }
|
||||
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new FlyFollow(self, target, minRange, maxRange); }
|
||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell) { return new Fly(self, Target.FromCell(cell)); }
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell) { return new Fly(self, Target.FromCell(self.World, cell)); }
|
||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace OpenRA.Mods.RA
|
||||
if (negativeDamage)
|
||||
return false;
|
||||
|
||||
if (!ab.HasAnyValidWeapons(Target.FromCell(location)))
|
||||
if (!ab.HasAnyValidWeapons(Target.FromCell(self.World, location)))
|
||||
return false;
|
||||
|
||||
if (modifiers.HasModifier(TargetModifiers.ForceAttack))
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA
|
||||
OnExitedAttackRange(self);
|
||||
}
|
||||
|
||||
public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
|
||||
public void SetTarget(World w, WPos pos) { target = Target.FromPos(pos); }
|
||||
|
||||
public void RemovedFromWorld(Actor self)
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
|
||||
if (order.OrderString == "AttackMove")
|
||||
{
|
||||
TargetLocation = move.NearestMoveableCell(order.TargetLocation);
|
||||
self.SetTargetLine(Target.FromCell(TargetLocation.Value), Color.Red);
|
||||
self.SetTargetLine(Target.FromCell(self.World, TargetLocation.Value), Color.Red);
|
||||
Activate(self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new FlyAttack(Target.FromCell(p)));
|
||||
plane.QueueActivity(new FlyAttack(Target.FromCell(w, p)));
|
||||
plane.Trait<ParaDrop>().SetLZ(p);
|
||||
plane.Trait<Cargo>().Load(plane, crate);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var moveTo = harv.LastHarvestedCell ?? (deliveryLoc + new CVec(0, 4));
|
||||
self.QueueActivity(mobile.MoveTo(moveTo, 1));
|
||||
self.SetTargetLine(Target.FromCell(moveTo), Color.Gray, false);
|
||||
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false);
|
||||
|
||||
var territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
||||
if (territory != null) territory.ClaimResource(self, moveTo);
|
||||
@@ -194,7 +194,7 @@ namespace OpenRA.Mods.RA
|
||||
var cell = self.Location;
|
||||
var moveTo = mobile.NearestMoveableCell(cell, 2, 5);
|
||||
self.QueueActivity(mobile.MoveTo(moveTo, 0));
|
||||
self.SetTargetLine(Target.FromCell(moveTo), Color.Gray, false);
|
||||
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false);
|
||||
|
||||
// Find more resources but not at this location:
|
||||
self.QueueActivity(new FindResources(cell));
|
||||
@@ -299,7 +299,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
self.QueueActivity(mobile.MoveTo(loc, 0));
|
||||
self.SetTargetLine(Target.FromCell(loc), Color.Red);
|
||||
self.SetTargetLine(Target.FromCell(self.World, loc), Color.Red);
|
||||
|
||||
LastOrderLocation = loc;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ namespace OpenRA.Mods.RA
|
||||
return;
|
||||
|
||||
self.QueueActivity(mobile.MoveTo(loc.Value, 0));
|
||||
self.SetTargetLine(Target.FromCell(loc.Value), Color.Red);
|
||||
self.SetTargetLine(Target.FromCell(self.World, loc.Value), Color.Red);
|
||||
|
||||
LastOrderLocation = loc;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
self.QueueActivity(new Move(currentLocation, 8));
|
||||
|
||||
self.SetTargetLine(Target.FromCell(currentLocation), Color.Green);
|
||||
self.SetTargetLine(Target.FromCell(self.World, currentLocation), Color.Green);
|
||||
}
|
||||
|
||||
protected void PerformMove(Actor self, CPos targetLocation, bool queued)
|
||||
@@ -542,7 +542,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
if (moveTo.HasValue)
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.SetTargetLine(Target.FromCell(moveTo.Value), Color.Green, false);
|
||||
self.SetTargetLine(Target.FromCell(self.World, moveTo.Value), Color.Green, false);
|
||||
self.QueueActivity(new Move(moveTo.Value, 0));
|
||||
|
||||
Log.Write("debug", "OnNudge #{0} from {1} to {2}",
|
||||
|
||||
@@ -251,9 +251,9 @@ namespace OpenRA.Mods.RA.Move
|
||||
public override IEnumerable<Target> GetTargets(Actor self)
|
||||
{
|
||||
if (path != null)
|
||||
return Enumerable.Reverse(path).Select(c => Target.FromCell(c));
|
||||
return Enumerable.Reverse(path).Select(c => Target.FromCell(self.World, c));
|
||||
if (destination != null)
|
||||
return new Target[] { Target.FromCell(destination.Value) };
|
||||
return new Target[] { Target.FromCell(self.World, destination.Value) };
|
||||
return Target.None;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA
|
||||
var initialFacing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, fi.GetInitialFacing()) : exitinfo.Facing;
|
||||
|
||||
var exitLocation = rp.Value != null ? rp.Value.rallyPoint : exit;
|
||||
var target = Target.FromCell(exitLocation);
|
||||
var target = Target.FromCell(self.World, exitLocation);
|
||||
var nearEnough = rp.Value != null ? WRange.FromCells(rp.Value.nearEnough) : WRange.Zero;
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
@@ -87,7 +87,6 @@ namespace OpenRA.Mods.RA
|
||||
if (exitinfo.MoveIntoWorld)
|
||||
{
|
||||
newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit));
|
||||
|
||||
newUnit.QueueActivity(new AttackMove.AttackMoveActivity(
|
||||
newUnit, move.MoveWithinRange(target, nearEnough)));
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.RA
|
||||
if (rp != null)
|
||||
self.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
self.SetTargetLine(Target.FromCell(rp.rallyPoint), Color.Green);
|
||||
self.SetTargetLine(Target.FromCell(self.World, rp.rallyPoint), Color.Green);
|
||||
self.QueueActivity(movement.MoveTo(rp.rallyPoint, order.TargetActor));
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[LuaGlobal]
|
||||
public void FlyAttackCell(Actor actor, CPos location)
|
||||
{
|
||||
actor.QueueActivity(new FlyAttack(Target.FromCell(location)));
|
||||
actor.QueueActivity(new FlyAttack(Target.FromCell(actor.World, location)));
|
||||
}
|
||||
|
||||
[LuaGlobal]
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public void Paradrop(CPos cell)
|
||||
{
|
||||
paradrop.SetLZ(cell);
|
||||
self.QueueActivity(new FlyAttack(Target.FromCell(cell)));
|
||||
self.QueueActivity(new FlyAttack(Target.FromCell(self.World, cell)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
|
||||
var attack = a.Trait<AttackBomber>();
|
||||
attack.SetTarget(target + targetOffset);
|
||||
attack.SetTarget(w, target + targetOffset);
|
||||
attack.OnEnteredAttackRange += onEnterRange;
|
||||
attack.OnExitedAttackRange += onExitRange;
|
||||
attack.OnRemovedFromWorld += onExitRange;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new Fly(plane, Target.FromCell(order.TargetLocation)));
|
||||
plane.QueueActivity(new Fly(plane, Target.FromCell(self.World, order.TargetLocation)));
|
||||
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
|
||||
{
|
||||
var camera = w.CreateActor("camera", new TypeDictionary
|
||||
|
||||
Reference in New Issue
Block a user