/// <summary> /// Initializes a new instance of the <see cref="FacilityOrder" /> class. /// </summary> /// <param name="directive">The order directive.</param> /// <param name="source">The source of this order.</param> /// <param name="toNotifyCmd">if set to <c>true</c> the facility will notify its Cmd of the outcome.</param> /// <param name="target">The target of this order. Default is null.</param> public FacilityOrder(FacilityDirective directive, OrderSource source, bool toNotifyCmd = false, IUnitAttackable target = null) { if (directive.EqualsAnyOf(DirectivesWithNullTarget)) { D.AssertNull(target, ToString()); } Directive = directive; Source = source; ToNotifyCmd = toNotifyCmd; Target = target; }
private void __ValidateKnowledgeOfOrderTarget(IUnitAttackable target, FacilityDirective directive) { if (directive == FacilityDirective.Disband || directive == FacilityDirective.Refit || directive == FacilityDirective.StopAttack) { // directives aren't yet implemented return; } if (directive == FacilityDirective.Scuttle || directive == FacilityDirective.Repair) { D.AssertNull(target); return; } if (!OwnerAIMgr.HasKnowledgeOf(target as IItem_Ltd)) { D.Error("{0} received {1} order with Target {2} that {3} has no knowledge of.", DebugName, directive.GetValueName(), target.DebugName, Owner.LeaderName); } }
private void UponOrderOutcome(FacilityDirective directive, FacilityItem facility, bool isSuccess, IElementAttackable target, UnitItemOrderFailureCause failCause) { RelayToCurrentState(directive, facility, isSuccess, target, failCause); }
/// <summary> /// Handles the results of the facility's attempt to execute the provided directive. /// </summary> /// <param name="directive">The directive.</param> /// <param name="facility">The facility.</param> /// <param name="isSuccess">if set to <c>true</c> the directive was successfully completed. May still be ongoing.</param> /// <param name="target">The target. Can be null.</param> /// <param name="failCause">The failure cause if not successful.</param> internal void HandleOrderOutcome(FacilityDirective directive, FacilityItem facility, bool isSuccess, IElementAttackable target = null, UnitItemOrderFailureCause failCause = UnitItemOrderFailureCause.None) { UponOrderOutcome(directive, facility, isSuccess, target, failCause); }
protected void ExecuteAttackOrder_UponOrderOutcome(FacilityDirective directive, FacilityItem facility, bool isSuccess, IElementAttackable target, UnitItemOrderFailureCause failCause) { LogEvent(); if (directive != FacilityDirective.Attack) { D.Warn("{0} State {1} erroneously received OrderOutcome callback with {2} {3}.", DebugName, CurrentState.GetValueName(), typeof(FacilityDirective).Name, directive.GetValueName()); return; } // TODO What? It will be common for an attack by a facility to fail for cause unreachable as its target moves out of range... }
/// <summary> /// The Captain uses this method to issue orders. /// </summary> /// <param name="order">The order.</param> /// <param name="retainSuperiorsOrder">if set to <c>true</c> [retain superiors order].</param> /// <param name="target">The target.</param> private void OverrideCurrentOrder(FacilityDirective order, bool retainSuperiorsOrder, IMortalTarget target = null) { // if the captain says to, and the current existing order is from his superior, then record it as a standing order FacilityOrder standingOrder = null; if (retainSuperiorsOrder && CurrentOrder != null) { if (CurrentOrder.Source != OrderSource.ElementCaptain) { // the current order is from the Captain's superior so retain it standingOrder = CurrentOrder; } else if (CurrentOrder.StandingOrder != null) { // the current order is from the Captain, but there is a standing order in it so retain it standingOrder = CurrentOrder.StandingOrder; } } FacilityOrder newOrder = new FacilityOrder(order, OrderSource.ElementCaptain, target) { StandingOrder = standingOrder }; CurrentOrder = newOrder; }