Example #1
0
        // Triggered by creating a new vessel. Apparantelly we create a new mission. However, decoupling also create the new mission. Unfortunatelly, we cannot find the name here.
        // Events
        private void on_create(Vessel ves)
        {
            // This event should be called only if we have a new mission
            KDebug.Log("on_create", KDebug.Type.CREATE);

            Mission M = new Mission(ves); // Possible new mission (ves is check for null)
            if (M.missionApproved) // Mission was created
            {
                KDebug.Log("on_create approved", KDebug.Type.CREATE);
                int CM = ves.FindPartModulesImplementing<ModuleCommand>().Count();

                KDebug.Log("Command Modules: " + CM.ToString(), KDebug.Type.CREATE); // should wotk!

                //Entry E = new Entry();
                if(ves.situation == Vessel.Situations.PRELAUNCH)
                {
                    KDebug.Log("create " + M.get_name(), KDebug.Type.CREATE);

                    this.add_mission(M);
                    add_event(Entry.Situations.CREATE, ves, M.get_name());
                    //E.add(Entry.Situations.CREATE, M.get_name(), (double)0);
                }
                else if (CM > 0) // Additional check to exclude debrees
                {
                    KDebug.Log("detached " + M.get_name(), KDebug.Type.CREATE);

                    // TODO
                    // Find the command module and name the mission by command module (if we cannot find how to name it wihtout commant module)
                    // Let's find the command module

                    Part P = ves.FindPartModulesImplementing<ModuleCommand>().Last().part;

                    this.add_mission(M);
                    M.rename(P.partInfo.title);
                    //add_event(Entry.Situations.DETACHED, ves, M.get_name());

                    add_event(Entry.Situations.DETACHED, ves, P.partInfo.title);

                    //E.add(Entry.Situations.DETACHED, M.get_name(), (double)0);
                    // To collect the name of the mission we probably need to listed Rename event
                }
                else
                {
                    return;
                }
                // M.add_entry( E ); // I'm not sue I need this

            }
        }
Example #2
0
 // Create a new mission by Mission object. Used to crate and load mission.
 private void add_mission(Mission M)
 {
     KDebug.Log("Add mission from Report by Mission: " + M.get_name(), KDebug.Type.CREATE);
     if(!this.is_missionId_exists(M))
         this.missions.Add(M);
     else
     {
         KDebug.Log("Mission already exists: " + M.get_name(), KDebug.Type.CREATE);
     }
 }