MissionController.Mission.isDone C# (CSharp) Method

isDone() public method

Checks if the mission is finishable with the vessel
public isDone ( Vessel vessel, GameEvent events ) : bool
vessel Vessel current vessel
events GameEvent
return bool
        public bool isDone(Vessel vessel, GameEvent events)
        {
            if (vessel == null) {
                return false;
            }

            foreach (MissionGoal c in goals) {
                if (!c.isDone (vessel, events) && !c.optional) {
                    return false;
                }
            }
            return true;
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Finishes the given mission with the given vessel.
        /// Rewards the space program with the missions reward.
        /// </summary>
        /// <param name="m">mission</param>
        /// <param name="vessel">vessel</param>
        public void finishMission(Mission m, Vessel vessel, GameEvent events)
        {
            if (!isMissionAlreadyFinished(m, vessel) && m.isDone(vessel, events))
            {
                MissionStatus status = new MissionStatus(m.name, vessel.id.ToString());

                status.repeatable           = m.repeatable;
                status.repeatableSameVessel = m.repeatableSameVessel;

                if (m.passiveMission)
                {
                    status.endOfLife             = Planetarium.GetUniversalTime() + m.lifetime;
                    status.passiveReward         = m.passiveReward;
                    status.lastPassiveRewardTime = Planetarium.GetUniversalTime();
                }

                if (m.clientControlled)
                {
                    status.endOfLife = Planetarium.GetUniversalTime() + m.lifetime;
                }

                status.clientControlled = m.clientControlled;

                currentProgram.add(status);
                reward(m.reward);

                // finish unfinished goals
                foreach (MissionGoal goal in m.goals)
                {
                    finishMissionGoal(goal, vessel, events);
                }

                // If this mission is randomized, we will discard the mission
                if (m.randomized)
                {
                    discardRandomMission(m);
                    m = reloadMission(m, vessel);
                }
            }
        }
All Usage Examples Of MissionController.Mission::isDone