Merge pull request #5470 from Kanar/AirfieldRP

Closes #5592
This commit is contained in:
Matthias Mailänder
2014-06-14 11:03:17 +02:00
8 changed files with 55 additions and 52 deletions

View File

@@ -39,21 +39,7 @@ namespace OpenRA.Mods.RA.Activities
.FirstOrDefault(a => a.HasTrait<RenderBuilding>());
if (!limitedAmmo.GiveAmmo())
{
var helicopter = self.TraitOrDefault<Helicopter>();
if (helicopter != null)
{
if (helicopter.Info.RepairBuildings.Contains(hostBuilding.Info.Name) && self.HasTrait<Health>())
{
if (self.Trait<Health>().DamageState != DamageState.Undamaged)
return NextActivity;
}
return helicopter.TakeOff(hostBuilding);
}
return NextActivity;
}
if (hostBuilding != null)
hostBuilding.Trait<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");

View File

@@ -31,22 +31,9 @@ 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)
{
if (helicopter.Info.RearmBuildings.Contains(host.Info.Name) && self.HasTrait<LimitedAmmo>())
{
if (self.Trait<LimitedAmmo>().FullAmmo() == false)
return NextActivity;
}
return helicopter.TakeOff(host);
}
return NextActivity;
}
if (remainingTicks == 0)
{

View File

@@ -87,6 +87,7 @@ namespace OpenRA.Mods.RA.Air
self.QueueActivity(new Turn(Info.InitialFacing));
self.QueueActivity(new HeliLand(false));
self.QueueActivity(new ResupplyAircraft());
self.QueueActivity(new TakeOff());
}
}
@@ -116,11 +117,11 @@ namespace OpenRA.Mods.RA.Air
if (!self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
ReserveSpawnBuilding();
var afld = GetActorBelow();
if (afld == null)
var host = GetActorBelow();
if (host == null)
return;
self.QueueActivity(TakeOff(afld));
self.QueueActivity(new TakeOff());
}
// Repulsion only applies when we're flying!
@@ -183,25 +184,5 @@ namespace OpenRA.Mods.RA.Air
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));
}
}
}

View File

@@ -43,6 +43,12 @@ namespace OpenRA.Mods.RA.Air
firstTick = false;
if (!self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
ReserveSpawnBuilding();
var host = GetActorBelow();
if (host == null)
return;
self.QueueActivity(new TakeOff());
}
}
@@ -86,6 +92,7 @@ namespace OpenRA.Mods.RA.Air
self.SetTargetLine(Target.FromActor(airfield), Color.Green);
self.QueueActivity(new ReturnToBase(self, airfield));
self.QueueActivity(new ResupplyAircraft());
self.QueueActivity(new TakeOff());
}
else
{

View File

@@ -0,0 +1,40 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Air
{
public class TakeOff : Activity
{
public override Activity Tick(Actor self)
{
var aircraft = self.Trait<Aircraft>();
self.CancelActivity();
var reservation = aircraft.Reservation;
if (reservation != null)
{
reservation.Dispose();
reservation = null;
}
var host = aircraft.GetActorBelow();
var hasHost = host != null;
var rp = hasHost ? host.TraitOrDefault<RallyPoint>() : null;
var destination = rp != null ? rp.rallyPoint :
(hasHost ? host.CenterPosition.ToCPos() : self.CenterPosition.ToCPos());
return new AttackMove.AttackMoveActivity(self, self.Trait<IMove>().MoveTo(destination, 1));
}
}
}

View File

@@ -94,6 +94,7 @@
<ItemGroup>
<Compile Include="Activities\CaptureActor.cs" />
<Compile Include="Activities\Hunt.cs" />
<Compile Include="Air\TakeOff.cs" />
<Compile Include="AI\AttackOrFleeFuzzy.cs" />
<Compile Include="AI\BaseBuilder.cs" />
<Compile Include="AI\HackyAI.cs" />

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.RA
}
}
newUnit.SetTargetLine(target, Color.Green, false);
newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false);
if (!self.IsDead())
foreach (var t in self.TraitsImplementing<INotifyProduction>())

View File

@@ -968,6 +968,7 @@ AFLD:
ExitCell: 1,1
Facing: 192
MoveIntoWorld: false
RallyPoint:
Production:
Produces: Plane
Reservable: