planes return to base after attacking

This commit is contained in:
Chris Forbes
2009-12-29 19:47:08 +13:00
parent a5d8dc5861
commit 8a71bf36c3
5 changed files with 31 additions and 5 deletions

View File

@@ -7,14 +7,37 @@ namespace OpenRa.Game.Traits.Activities
{
class ReturnToBase : IActivity
{
// todo: defer decision-making until we are first scheduled!
public IActivity NextActivity { get; set; }
bool isCanceled;
readonly float2 w1, w2, w3; /* tangent points to turn circles */
readonly float2 landPoint;
public ReturnToBase(Actor self, float2 landPos)
public ReturnToBase(Actor self)
: this( self, null ) {}
Actor ChooseAirfield(Actor self)
{
// todo: handle reservations
var airfield = Game.world.Actors
.Where(a => a.Info == Rules.UnitInfo["AFLD"]
&& a.Owner == self.Owner)
.FirstOrDefault();
if (airfield == null)
throw new NotImplementedException("nowhere to land; what to do?");
return airfield;
}
public ReturnToBase(Actor self, Actor dest)
{
if (dest == null)
dest = ChooseAirfield(self);
var landPos = dest.CenterLocation;
var unit = self.traits.Get<Unit>();
var speed = .2f * Util.GetEffectiveSpeed(self);
var approachStart = landPos - new float2(unit.Altitude * speed, 0);