예제 #1
0
    // 4.22.16: Currently Order is issued only by user or fleet. Once HQ has arrived at the IFleetExplorable target, 
    // individual ships can still be a long way off trying to get there, so we need to rely on the AutoPilot to manage speed.

    #region ExecuteExploreOrder Support Members

    private void HandleExplorationSuccess(IShipExplorable exploreTgt) {
        D.Log(ShowDebugLog, "{0} successfully completed exploration of {1}.", DebugName, exploreTgt.DebugName);
        exploreTgt.RecordExplorationCompletedBy(Owner);
        Command.HandleOrderOutcome(CurrentOrder.Directive, this, isSuccess: true, target: exploreTgt);
    }
예제 #2
0
 private void AssignShipToExploreItem(ShipItem ship, IShipExplorable item) {
     if (!item.IsExploringAllowedBy(Owner)) {
         D.Error("{0} attempting to assign {1} to illegally explore {2}.", DebugName, ship.DebugName, item.DebugName);
     }
     if (item.IsFullyExploredBy(Owner)) {
         D.Error("{0} attempting to assign {1} to explore {2} which is already explored.", DebugName, ship.DebugName, item.DebugName);
     }
     ShipOrder exploreOrder = new ShipOrder(ShipDirective.Explore, CurrentOrder.Source, toNotifyCmd: true, target: item);
     ship.CurrentOrder = exploreOrder;
 }
예제 #3
0
    /// <summary>
    /// Handles the condition where a ship is no longer available to explore. Returns <c>true</c>
    /// if another ship was assigned to replace this one (not necessarily with the same explore target),
    /// <c>false</c> if no more ships are currently available.
    /// <remarks>Typically this occurs when a ship fails to complete its assigned exploration mission
    /// either because it dies or is so wounded that it needs to repair.</remarks>
    /// </summary>
    /// <param name="unavailableShip">The unavailable ship.</param>
    /// <param name="exploreTgt">The explore target.</param>
    /// <returns></returns>
    private bool HandleShipNoLongerAvailableToExplore(ShipItem unavailableShip, IShipExplorable exploreTgt) {
        bool isExploringSystem = false;
        if (_shipSystemExploreTgtAssignments.ContainsKey(exploreTgt)) {
            isExploringSystem = true;
            if (_shipSystemExploreTgtAssignments.Values.Contains(unavailableShip)) {
                // ship had explore assignment in system so remove it
                var deadShipTgt = _shipSystemExploreTgtAssignments.Single(kvp => kvp.Value == unavailableShip).Key;
                _shipSystemExploreTgtAssignments[deadShipTgt] = null;
            }
        }

        bool isNewShipAssigned;
        IList<ShipItem> ships;
        if (TryGetShips(out ships, availableOnly: true, avoidHQ: true, qty: 1, priorityCats: _desiredExplorationShipCategories)) {
            ShipItem newExploreShip = ships.First();
            if (isExploringSystem) {
                AssignShipToExploreSystemTgt(newExploreShip);
            }
            else {
                AssignShipToExploreItem(newExploreShip, exploreTgt);
            }
            isNewShipAssigned = true;
        }
        else {
            isNewShipAssigned = false;
            D.Warn("{0} found no available ships to explore {1} after {2} became unavailable.", DebugName, exploreTgt.DebugName, unavailableShip.DebugName);
        }
        return isNewShipAssigned;
    }
예제 #4
0
 /// <summary>
 /// Handles the situation where the provided ship has either successfully explored the
 /// provided target in the system, or the exploration of the target failed because the
 /// target is dead. Returns <c>true</c> if a new exploration target was assigned to the
 /// ship, <c>false</c> otherwise. If the ship received no new assignment, it has been
 /// instructed to gather at a nearby assembly station.
 /// </summary>
 /// <param name="ship">The ship.</param>
 /// <param name="exploreTgt">The explore TGT.</param>
 /// <returns></returns>
 private bool HandleSystemTargetExploredOrDead(ShipItem ship, IShipExplorable exploreTgt) {
     _shipSystemExploreTgtAssignments.Remove(exploreTgt);
     bool isNowAssigned = AssignShipToExploreSystemTgt(ship);
     if (!isNowAssigned) {
         if (ship.IsHQ) {
             // no point in telling HQ to assume station, but with no more explore assignment, it should
             // return to the closest Assembly station so the other ships assume station there
             IFleetExplorable fleetExploreTgt = CurrentOrder.Target as IFleetExplorable;
             var closestLocalAssyStation = GameUtility.GetClosest(Position, fleetExploreTgt.LocalAssemblyStations);
             var speed = Speed.Standard;
             float standoffDistance = Constants.ZeroF;   // AssyStation can't be owned by anyone
             bool isFleetwideMove = false;
             ship.CurrentOrder = new ShipMoveOrder(OrderSource.CmdStaff, closestLocalAssyStation, speed, isFleetwideMove, standoffDistance);
         }
         else {
             ShipOrder assumeStationOrder = new ShipOrder(ShipDirective.AssumeStation, OrderSource.CmdStaff);
             ship.CurrentOrder = assumeStationOrder;
         }
     }
     return isNowAssigned;
 }
예제 #5
0
 private bool IsShipExploreTargetPartOfSystem(IShipExplorable shipExploreTgt) {
     return (shipExploreTgt is IPlanet_Ltd || shipExploreTgt is IStar_Ltd);
 }