Make Aircraft PausableConditional
Note: This commit only does the minimum changes to implement PausableConditional, there are no logic changes yet (like disabling movement on PauseOnCondition).
This commit is contained in:
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// turnSpeed -> divide into 256 to get the number of ticks per complete rotation
|
// turnSpeed -> divide into 256 to get the number of ticks per complete rotation
|
||||||
// speed -> multiply to get distance travelled per rotation (circumference)
|
// speed -> multiply to get distance travelled per rotation (circumference)
|
||||||
// 45 -> divide by 2*pi to get the turn radius: 45==256/(2*pi), with some extra leeway
|
// 45 -> divide by 2*pi to get the turn radius: 45==256/(2*pi), with some extra leeway
|
||||||
return 45 * speed / turnSpeed;
|
return turnSpeed > 0 ? 45 * speed / turnSpeed : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
LeaveMap,
|
LeaveMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AircraftInfo : ITraitInfo, IPositionableInfo, IFacingInfo, IMoveInfo, ICruiseAltitudeInfo,
|
public class AircraftInfo : PausableConditionalTraitInfo, IPositionableInfo, IFacingInfo, IMoveInfo, ICruiseAltitudeInfo,
|
||||||
IActorPreviewInitInfo, IEditorActorOptions, IObservesVariablesInfo
|
IActorPreviewInitInfo, IEditorActorOptions
|
||||||
{
|
{
|
||||||
[Desc("Behavior when aircraft becomes idle. Options are Land, ReturnToBase, LeaveMap, and None.",
|
[Desc("Behavior when aircraft becomes idle. Options are Land, ReturnToBase, LeaveMap, and None.",
|
||||||
"'Land' will behave like 'None' (hover or circle) if a suitable landing site is not available.")]
|
"'Land' will behave like 'None' (hover or circle) if a suitable landing site is not available.")]
|
||||||
@@ -139,20 +139,20 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
||||||
public readonly BooleanExpression RequireForceMoveCondition = null;
|
public readonly BooleanExpression RequireForceMoveCondition = null;
|
||||||
|
|
||||||
|
[Desc("Condition when this aircraft should land as soon as possible and refuse to take off. ",
|
||||||
|
"This only applies while the aircraft is above terrain which is listed in LandableTerrainTypes.")]
|
||||||
|
public readonly BooleanExpression LandOnCondition;
|
||||||
|
|
||||||
public int GetInitialFacing() { return InitialFacing; }
|
public int GetInitialFacing() { return InitialFacing; }
|
||||||
public WDist GetCruiseAltitude() { return CruiseAltitude; }
|
public WDist GetCruiseAltitude() { return CruiseAltitude; }
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init) { return new Aircraft(init, this); }
|
public override object Create(ActorInitializer init) { return new Aircraft(init, this); }
|
||||||
|
|
||||||
IEnumerable<object> IActorPreviewInitInfo.ActorPreviewInits(ActorInfo ai, ActorPreviewType type)
|
IEnumerable<object> IActorPreviewInitInfo.ActorPreviewInits(ActorInfo ai, ActorPreviewType type)
|
||||||
{
|
{
|
||||||
yield return new FacingInit(PreviewFacing);
|
yield return new FacingInit(PreviewFacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Condition when this aircraft should land as soon as possible and refuse to take off. ",
|
|
||||||
"This only applies while the aircraft is above terrain which is listed in LandableTerrainTypes.")]
|
|
||||||
public readonly BooleanExpression LandOnCondition;
|
|
||||||
|
|
||||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any) { return new ReadOnlyDictionary<CPos, SubCell>(); }
|
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any) { return new ReadOnlyDictionary<CPos, SubCell>(); }
|
||||||
|
|
||||||
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
||||||
@@ -189,13 +189,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Aircraft : ITick, ISync, IFacing, IPositionable, IMove, IIssueOrder, IResolveOrder, IOrderVoice, IDeathActorInitModifier,
|
public class Aircraft : PausableConditionalTrait<AircraftInfo>, ITick, ISync, IFacing, IPositionable, IMove,
|
||||||
INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyActorDisposing, INotifyBecomingIdle,
|
INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyActorDisposing, INotifyBecomingIdle, ICreationActivity,
|
||||||
IActorPreviewInitModifier, IIssueDeployOrder, IObservesVariables, ICreationActivity
|
IActorPreviewInitModifier, IDeathActorInitModifier, IIssueDeployOrder, IIssueOrder, IResolveOrder, IOrderVoice
|
||||||
{
|
{
|
||||||
static readonly Pair<CPos, SubCell>[] NoCells = { };
|
static readonly Pair<CPos, SubCell>[] NoCells = { };
|
||||||
|
|
||||||
public readonly AircraftInfo Info;
|
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
Repairable repairable;
|
Repairable repairable;
|
||||||
@@ -241,8 +240,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
bool? landNow;
|
bool? landNow;
|
||||||
|
|
||||||
public Aircraft(ActorInitializer init, AircraftInfo info)
|
public Aircraft(ActorInitializer init, AircraftInfo info)
|
||||||
|
: base(info)
|
||||||
{
|
{
|
||||||
Info = info;
|
|
||||||
self = init.Self;
|
self = init.Self;
|
||||||
|
|
||||||
if (init.Contains<LocationInit>())
|
if (init.Contains<LocationInit>())
|
||||||
@@ -278,8 +277,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IEnumerable<VariableObserver> GetVariableObservers()
|
public override IEnumerable<VariableObserver> GetVariableObservers()
|
||||||
{
|
{
|
||||||
|
foreach (var observer in base.GetVariableObservers())
|
||||||
|
yield return observer;
|
||||||
|
|
||||||
if (Info.LandOnCondition != null)
|
if (Info.LandOnCondition != null)
|
||||||
yield return new VariableObserver(ForceLandConditionChanged, Info.LandOnCondition.Variables);
|
yield return new VariableObserver(ForceLandConditionChanged, Info.LandOnCondition.Variables);
|
||||||
|
|
||||||
@@ -297,12 +299,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
requireForceMove = Info.RequireForceMoveCondition.Evaluate(conditions);
|
requireForceMove = Info.RequireForceMoveCondition.Evaluate(conditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
|
||||||
Created(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Created(Actor self)
|
|
||||||
{
|
{
|
||||||
repairable = self.TraitOrDefault<Repairable>();
|
repairable = self.TraitOrDefault<Repairable>();
|
||||||
rearmable = self.TraitOrDefault<Rearmable>();
|
rearmable = self.TraitOrDefault<Rearmable>();
|
||||||
@@ -312,6 +309,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
notifyMoving = self.TraitsImplementing<INotifyMoving>().ToArray();
|
notifyMoving = self.TraitsImplementing<INotifyMoving>().ToArray();
|
||||||
positionOffsets = self.TraitsImplementing<IAircraftCenterPositionOffset>().ToArray();
|
positionOffsets = self.TraitsImplementing<IAircraftCenterPositionOffset>().ToArray();
|
||||||
overrideAircraftLanding = self.TraitOrDefault<IOverrideAircraftLanding>();
|
overrideAircraftLanding = self.TraitOrDefault<IOverrideAircraftLanding>();
|
||||||
|
|
||||||
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
|
|||||||
Reference in New Issue
Block a user