void Attacking_EnterState() {
     LogEvent();
     _attackTarget = CurrentOrder.Target as IMortalTarget;
     _attackTarget.onTargetDeathOneShot += OnTargetDeath;
     var elementAttackOrder = new FacilityOrder(FacilityDirective.Attack, OrderSource.UnitCommand, _attackTarget);
     Elements.ForAll(e => (e as FacilityModel).CurrentOrder = elementAttackOrder);
 }
Exemple #2
0
    private void InitiateRepair(bool retainSuperiorsOrderOnRepairCompletion) {
        D.AssertNotEqual(FacilityState.Repairing, CurrentState);
        D.Assert(!_debugSettings.DisableRepair);
        D.Assert(Data.Health < Constants.OneHundredPercent);

        FacilityOrder repairOrder = new FacilityOrder(FacilityDirective.Repair, OrderSource.Captain);
        OverrideCurrentOrder(repairOrder, retainSuperiorsOrderOnRepairCompletion);
    }
Exemple #3
0
 /// <summary>
 /// The Captain uses this method to issue orders.
 /// </summary>
 /// <param name="captainsOverrideOrder">The captains override order.</param>
 /// <param name="retainSuperiorsOrder">if set to <c>true</c> [retain superiors order].</param>
 private void OverrideCurrentOrder(FacilityOrder captainsOverrideOrder, bool retainSuperiorsOrder) {
     D.AssertEqual(OrderSource.Captain, captainsOverrideOrder.Source, captainsOverrideOrder.ToString());
     D.AssertNull(captainsOverrideOrder.StandingOrder, captainsOverrideOrder.ToString());
     D.Assert(!captainsOverrideOrder.ToNotifyCmd, captainsOverrideOrder.ToString());
     // 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.Captain) {
             // the current order is from the Captain's superior so retain it
             standingOrder = CurrentOrder;
         }
         else {
             // the current order is from the Captain, so its standing order, if any, should be retained
             standingOrder = CurrentOrder.StandingOrder;
         }
     }
     captainsOverrideOrder.StandingOrder = standingOrder;
     CurrentOrder = captainsOverrideOrder;
 }
    protected void ExecuteAttackOrder_EnterState() {
        LogEvent();

        var elementAttackOrder = new FacilityOrder(FacilityDirective.Attack, CurrentOrder.Source, toNotifyCmd: true, target: _fsmTgt);
        Elements.ForAll(e => (e as FacilityItem).CurrentOrder = elementAttackOrder);
    }
 /// <summary>
 /// Kills all remaining elements of the Unit along with this Command. All Elements are ordered 
 /// to Scuttle (assume Dead state) which results in the Command assuming its own Dead state.
 /// </summary>
 private void ScuttleUnit() {
     var elementScuttleOrder = new FacilityOrder(FacilityDirective.Scuttle, OrderSource.CmdStaff);
     Elements.ForAll(e => (e as FacilityItem).CurrentOrder = elementScuttleOrder);
 }
 /// <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;
 }