Fix AI crashing when trying to make parachuted harvester search map for resources while mid-air
This commit is contained in:
@@ -833,6 +833,10 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var para = harvester.TraitOrDefault<Parachutable>();
|
||||||
|
if (para != null && para.IsInAir)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Tell the idle harvester to quit slacking:
|
// Tell the idle harvester to quit slacking:
|
||||||
var newSafeResourcePatch = FindNextResource(harvester, harv);
|
var newSafeResourcePatch = FindNextResource(harvester, harv);
|
||||||
BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(harvester, newSafeResourcePatch));
|
BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(harvester, newSafeResourcePatch));
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
positionable = self.Trait<IPositionable>();
|
positionable = self.Trait<IPositionable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsInAir { get; private set; }
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
{
|
{
|
||||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
@@ -66,12 +68,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyParachute.OnParachute(Actor self)
|
void INotifyParachute.OnParachute(Actor self)
|
||||||
{
|
{
|
||||||
|
IsInAir = true;
|
||||||
|
|
||||||
if (conditionManager != null && parachutingToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.ParachutingCondition))
|
if (conditionManager != null && parachutingToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.ParachutingCondition))
|
||||||
parachutingToken = conditionManager.GrantCondition(self, info.ParachutingCondition);
|
parachutingToken = conditionManager.GrantCondition(self, info.ParachutingCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyParachute.OnLanded(Actor self, Actor ignore)
|
void INotifyParachute.OnLanded(Actor self, Actor ignore)
|
||||||
{
|
{
|
||||||
|
IsInAir = false;
|
||||||
|
|
||||||
if (parachutingToken != ConditionManager.InvalidConditionToken)
|
if (parachutingToken != ConditionManager.InvalidConditionToken)
|
||||||
parachutingToken = conditionManager.RevokeCondition(self, parachutingToken);
|
parachutingToken = conditionManager.RevokeCondition(self, parachutingToken);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user