closes #3091 Have Helis take off after repair/rearm
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -34,11 +35,17 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
if (--remainingTicks == 0)
|
||||
{
|
||||
if (!limitedAmmo.GiveAmmo()) return NextActivity;
|
||||
|
||||
var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location)
|
||||
.FirstOrDefault(a => a.HasTrait<RenderBuilding>());
|
||||
|
||||
if (!limitedAmmo.GiveAmmo())
|
||||
{
|
||||
var helicopter = self.TraitOrDefault<Helicopter>();
|
||||
if (helicopter != null)
|
||||
return helicopter.TakeOff(hostBuilding);
|
||||
else return NextActivity;
|
||||
}
|
||||
|
||||
if (hostBuilding != null)
|
||||
hostBuilding.Trait<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -30,7 +31,13 @@ namespace OpenRA.Mods.RA.Activities
|
||||
health = self.TraitOrDefault<Health>();
|
||||
if (health == null) return NextActivity;
|
||||
if (health.DamageState == DamageState.Undamaged)
|
||||
{
|
||||
var helicopter = self.TraitOrDefault<Helicopter>();
|
||||
if (helicopter != null)
|
||||
return helicopter.TakeOff(host);
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
if (remainingTicks == 0)
|
||||
{
|
||||
@@ -44,6 +51,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
remainingTicks = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
self.InflictDamage(self, -hpToRepair, null);
|
||||
|
||||
if (host != null)
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
return info.LandableTerrainTypes.Contains(type);
|
||||
}
|
||||
|
||||
public IEnumerable<Activity> GetResupplyActivities(Actor a)
|
||||
public virtual IEnumerable<Activity> GetResupplyActivities(Actor a)
|
||||
{
|
||||
var name = a.Info.Name;
|
||||
if (info.RearmBuildings.Contains(name))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
@@ -114,6 +115,12 @@ namespace OpenRA.Mods.RA.Air
|
||||
firstTick = false;
|
||||
if (!self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
|
||||
ReserveSpawnBuilding();
|
||||
|
||||
var afld = GetActorBelow();
|
||||
if (afld == null)
|
||||
return;
|
||||
|
||||
self.QueueActivity(TakeOff(afld));
|
||||
}
|
||||
|
||||
// Repulsion only applies when we're flying!
|
||||
@@ -170,5 +177,31 @@ namespace OpenRA.Mods.RA.Air
|
||||
// TODO: Ignore repulsion when moving
|
||||
return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new HeliFly(self, Target.FromPos(toPos)));
|
||||
}
|
||||
|
||||
public override IEnumerable<Activity> GetResupplyActivities(Actor a)
|
||||
{
|
||||
foreach (var b in base.GetResupplyActivities(a))
|
||||
yield return b;
|
||||
}
|
||||
|
||||
public Activity TakeOff(Actor a)
|
||||
{
|
||||
self.CancelActivity();
|
||||
if (Reservation != null)
|
||||
{
|
||||
Reservation.Dispose();
|
||||
Reservation = null;
|
||||
}
|
||||
|
||||
if (a != null)
|
||||
{
|
||||
if (a.HasTrait<RallyPoint>())
|
||||
return new HeliFly(self, Target.FromCell(a.Trait<RallyPoint>().rallyPoint));
|
||||
|
||||
return new HeliFly(self, Target.FromPos(a.CenterPosition));
|
||||
}
|
||||
|
||||
return new HeliFly(self, Target.FromPos(self.CenterPosition));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -928,6 +928,7 @@ HPAD:
|
||||
SpawnOffset: 0,-256,0
|
||||
ExitCell: 0,0
|
||||
MoveIntoWorld: false
|
||||
RallyPoint:
|
||||
Production:
|
||||
Produces: Helicopter
|
||||
Reservable:
|
||||
|
||||
Reference in New Issue
Block a user