Fix setting MayYieldReservation when there is no reservation
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2016 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, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Activities;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Activities
|
||||||
|
{
|
||||||
|
public class AllowYieldingReservation : Activity
|
||||||
|
{
|
||||||
|
readonly Aircraft aircraft;
|
||||||
|
|
||||||
|
public AllowYieldingReservation(Actor self)
|
||||||
|
{
|
||||||
|
aircraft = self.Trait<Aircraft>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Activity Tick(Actor self)
|
||||||
|
{
|
||||||
|
aircraft.AllowYieldingReservation();
|
||||||
|
return NextActivity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
inner = ActivityUtils.SequenceActivities(
|
inner = ActivityUtils.SequenceActivities(
|
||||||
aircraft.GetResupplyActivities(host)
|
aircraft.GetResupplyActivities(host)
|
||||||
.Append(new CallFunc(() => aircraft.MayYieldReservation = true))
|
.Append(new AllowYieldingReservation(self))
|
||||||
.Append(new WaitFor(() => NextActivity != null || aircraft.ReservedActor == null))
|
.Append(new WaitFor(() => NextActivity != null || aircraft.ReservedActor == null))
|
||||||
.ToArray());
|
.ToArray());
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// HACK: Append NextActivity to TakeOff to avoid moving to the Rallypoint (if NextActivity is non-null).
|
// HACK: Append NextActivity to TakeOff to avoid moving to the Rallypoint (if NextActivity is non-null).
|
||||||
inner = ActivityUtils.SequenceActivities(
|
inner = ActivityUtils.SequenceActivities(
|
||||||
aircraft.GetResupplyActivities(host)
|
aircraft.GetResupplyActivities(host)
|
||||||
.Append(new CallFunc(() => aircraft.MayYieldReservation = true))
|
.Append(new AllowYieldingReservation(self))
|
||||||
.Append(new TakeOff(self)).Append(NextActivity).ToArray());
|
.Append(new TakeOff(self)).Append(NextActivity).ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Activities\Air\AllowYieldingReservation.cs" />
|
||||||
<Compile Include="Activities\Air\FallToEarth.cs" />
|
<Compile Include="Activities\Air\FallToEarth.cs" />
|
||||||
<Compile Include="Activities\Air\Fly.cs" />
|
<Compile Include="Activities\Air\Fly.cs" />
|
||||||
<Compile Include="Activities\Air\FlyAttack.cs" />
|
<Compile Include="Activities\Air\FlyAttack.cs" />
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
|
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
|
||||||
public int TurnSpeed { get { return Info.TurnSpeed; } }
|
public int TurnSpeed { get { return Info.TurnSpeed; } }
|
||||||
public Actor ReservedActor { get; private set; }
|
public Actor ReservedActor { get; private set; }
|
||||||
public bool MayYieldReservation;
|
public bool MayYieldReservation { get; private set; }
|
||||||
|
|
||||||
bool airborne;
|
bool airborne;
|
||||||
bool cruising;
|
bool cruising;
|
||||||
@@ -282,6 +282,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AllowYieldingReservation()
|
||||||
|
{
|
||||||
|
if (reservation == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MayYieldReservation = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void UnReserve()
|
public void UnReserve()
|
||||||
{
|
{
|
||||||
if (reservation == null)
|
if (reservation == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user