clean up plane cruise altitude crap => yaml
This commit is contained in:
@@ -31,11 +31,11 @@ namespace OpenRA.Traits.Activities
|
|||||||
public Fly(int2 pos) { Pos = Util.CenterOfCell(pos); }
|
public Fly(int2 pos) { Pos = Util.CenterOfCell(pos); }
|
||||||
|
|
||||||
public IActivity NextActivity { get; set; }
|
public IActivity NextActivity { get; set; }
|
||||||
|
|
||||||
const int CruiseAltitude = 20;
|
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||||
|
|
||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
|
|
||||||
var d = Pos - self.CenterLocation;
|
var d = Pos - self.CenterLocation;
|
||||||
@@ -45,14 +45,14 @@ namespace OpenRA.Traits.Activities
|
|||||||
var unit = self.traits.Get<Unit>();
|
var unit = self.traits.Get<Unit>();
|
||||||
|
|
||||||
var desiredFacing = Util.GetFacing(d, unit.Facing);
|
var desiredFacing = Util.GetFacing(d, unit.Facing);
|
||||||
if (unit.Altitude == CruiseAltitude)
|
if (unit.Altitude == cruiseAltitude)
|
||||||
Util.TickFacing(ref unit.Facing, desiredFacing,
|
Util.TickFacing(ref unit.Facing, desiredFacing,
|
||||||
self.Info.Traits.Get<UnitInfo>().ROT);
|
self.Info.Traits.Get<UnitInfo>().ROT);
|
||||||
|
|
||||||
if (unit.Altitude < CruiseAltitude)
|
if (unit.Altitude < cruiseAltitude)
|
||||||
++unit.Altitude;
|
++unit.Altitude;
|
||||||
|
|
||||||
FlyUtil.Fly(self, CruiseAltitude);
|
FlyUtil.Fly(self, cruiseAltitude);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,17 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Traits.Activities;
|
using OpenRA.Traits.Activities;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
class PlaneInfo : ITraitInfo
|
class PlaneInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
public readonly int CruiseAltitude = 20;
|
||||||
|
public readonly string[] RearmBuildings = { "afld" };
|
||||||
|
public readonly string[] RepairBuildings = { "fix" };
|
||||||
|
|
||||||
public object Create(Actor self) { return new Plane(self); }
|
public object Create(Actor self) { return new Plane(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,22 +39,21 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public Plane(Actor self) {}
|
public Plane(Actor self) {}
|
||||||
|
|
||||||
// todo: push into data!
|
static bool PlaneCanEnter(Actor self, Actor a)
|
||||||
static bool PlaneCanEnter(Actor a)
|
|
||||||
{
|
{
|
||||||
if (a.Info.Name == "afld") return true;
|
var plane = self.Info.Traits.Get<PlaneInfo>();
|
||||||
if (a.Info.Name == "fix") return true;
|
return plane.RearmBuildings.Contains(a.Info.Name)
|
||||||
return false;
|
|| plane.RepairBuildings.Contains(a.Info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
if (underCursor == null)
|
if (underCursor == null)
|
||||||
{
|
return new Order("Move", self, xy);
|
||||||
return new Order("Move", self, xy);
|
|
||||||
}
|
if (PlaneCanEnter(self, underCursor)
|
||||||
if (PlaneCanEnter(underCursor)
|
|
||||||
&& underCursor.Owner == self.Owner
|
&& underCursor.Owner == self.Owner
|
||||||
&& !Reservable.IsReserved(underCursor))
|
&& !Reservable.IsReserved(underCursor))
|
||||||
return new Order("Enter", self, underCursor);
|
return new Order("Enter", self, underCursor);
|
||||||
@@ -80,10 +84,13 @@ namespace OpenRA.Traits
|
|||||||
if (res != null)
|
if (res != null)
|
||||||
reservation = res.Reserve(self);
|
reservation = res.Reserve(self);
|
||||||
|
|
||||||
|
var info = self.Info.Traits.Get<PlaneInfo>();
|
||||||
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
|
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
|
||||||
self.QueueActivity(order.TargetActor.Info.Name == "afld"
|
self.QueueActivity(
|
||||||
? (IActivity)new Rearm() : new Repair(true));
|
info.RearmBuildings.Contains(order.TargetActor.Info.Name)
|
||||||
|
? (IActivity)new Rearm() : new Repair(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user