Refactor Mobile.TeleportTo -> IMove.SetPosition
This commit is contained in:
@@ -66,9 +66,9 @@ namespace OpenRA.Traits
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||
}
|
||||
|
||||
public void TeleportTo(Actor self, int2 xy)
|
||||
public void SetPosition(Actor self, int2 cell)
|
||||
{
|
||||
SetLocation( xy, xy );
|
||||
SetLocation( cell, cell );
|
||||
self.CenterLocation = Util.CenterOfCell(fromCell);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace OpenRA.Traits
|
||||
UnitMovementType GetMovementType();
|
||||
bool CanEnterCell(int2 location);
|
||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||
void SetPosition(Actor self, int2 cell);
|
||||
}
|
||||
|
||||
public interface IOffsetCenterLocation { float2 CenterOffset { get; } }
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
@@ -66,7 +67,7 @@ namespace OpenRA.Mods.Cnc
|
||||
self.World.AddFrameEndTask(ww =>
|
||||
{
|
||||
ww.Add(actor);
|
||||
actor.traits.Get<Mobile>().TeleportTo(actor, self.Location + unloadOffset);
|
||||
actor.traits.WithInterface<IMove>().FirstOrDefault().SetPosition(actor, self.Location + unloadOffset);
|
||||
newUnit.traits.Get<Unit>().Facing = 192;
|
||||
actor.CancelActivity();
|
||||
actor.QueueActivity(new Move(self.Location + exitOffset, self));
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
using System.Linq;
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class Leap : IActivity
|
||||
@@ -51,7 +52,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
if (t >= 1f)
|
||||
{
|
||||
self.traits.Get<Mobile>().TeleportTo(self, target.Location);
|
||||
self.traits.WithInterface<IMove>().FirstOrDefault().SetPosition(self, target.Location);
|
||||
target.InflictDamage(self, target.Health, null); // kill it
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
@@ -35,8 +36,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
var mobile = self.traits.Get<Mobile>();
|
||||
mobile.TeleportTo(self, destination);
|
||||
self.traits.WithInterface<IMove>().FirstOrDefault().SetPosition(self, destination);
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Add(actor);
|
||||
actor.traits.Get<Mobile>().TeleportTo(actor, self.Location);
|
||||
actor.traits.WithInterface<IMove>().FirstOrDefault().SetPosition(actor, self.Location);
|
||||
actor.CancelActivity();
|
||||
actor.QueueActivity(new Move(exitTile.Value, 0));
|
||||
});
|
||||
|
||||
@@ -49,6 +49,12 @@ namespace OpenRA.Mods.RA
|
||||
get { return Location; }
|
||||
}
|
||||
|
||||
public void SetPosition(Actor self, int2 cell)
|
||||
{
|
||||
Location = cell;
|
||||
self.CenterLocation = Util.CenterOfCell(cell);
|
||||
}
|
||||
|
||||
public bool AircraftCanEnter(Actor self, Actor a)
|
||||
{
|
||||
var aircraft = self.Info.Traits.Get<AircraftInfo>();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -67,8 +68,11 @@ namespace OpenRA.Mods.RA.Effects
|
||||
w.Remove(this);
|
||||
var loc = Traits.Util.CellContaining(location);
|
||||
cargo.CancelActivity();
|
||||
if (cargo.traits.Contains<Mobile>())
|
||||
cargo.traits.Get<Mobile>().TeleportTo(cargo, loc);
|
||||
|
||||
var mobile = cargo.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
|
||||
if (mobile != null)
|
||||
mobile.SetPosition(cargo, loc);
|
||||
else
|
||||
{
|
||||
cargo.CenterLocation = Traits.Util.CenterOfCell(loc);
|
||||
|
||||
Reference in New Issue
Block a user