public void Awake()
        {
            EvaDebug.DebugLog("Loaded AddonAddModule.");

            var parts = new string[]
            {
                "kerbalEVA",
                "kerbalEVAVintage",
                "kerbalEVAfemale",
                "kerbalEVAfemaleVintage",
                "kerbalEVA_RD_Exp",
                "kerbalEVA_female_Exp",
                "kerbalEVA_RD_Future",
                "kerbalEVA_female_Future",
                "kerbalEVAfemaleFuture",
                "maleEVA",
                "femaleEVA",
            };

            foreach (var part in parts)
            {
                var EVA = new ConfigNode("MODULE");
                EVA.AddValue("name", "EvaModule");
                try
                {
                    PartLoader.getPartInfoByName(part).partPrefab.AddModule(EVA);
                }
                catch { }
            }
        }
Exemplo n.º 2
0
 public static void LoadFunction()
 {
     EvaDebug.ProfileStart();
     LoadFile();
     EvaDebug.ProfileEnd("EvaSettings.Load()");
     isLoaded = true;
 }
Exemplo n.º 3
0
        public void Load(Vessel vessel)
        {
            if (!vessel.isEVA)
            {
                EvaDebug.DebugWarning("Tried loading a non eva.");
                return;
            }

            KerbalEVA currentEVA = vessel.GetComponent <KerbalEVA>();

            if (!Contains(vessel.id))
            {
                EvaContainer container = new EvaContainer(vessel.id);

                //load the vessel here.
                container.Load(currentEVA);
                EvaSettings.LoadEva(container);

                collection.Add(container);
            }
            else
            {
                //Reload
                EvaContainer container = GetEva(vessel.id);

                container.Load(currentEVA);
                EvaSettings.LoadEva(container);
            }
        }
Exemplo n.º 4
0
        public void Unload(Vessel vessel, bool delete)
        {
            if (!vessel.isEVA)
            {
                EvaDebug.DebugWarning("Tried unloading a non eva.");
                return;
            }

            EvaDebug.DebugLog("Unload(" + vessel.name + ")");

            foreach (var item in collection)
            {
                if (item.flightID == vessel.id)
                {
                    if (delete)
                    {
                        item.status = Status.Removed;
                    }

                    //unload the vessel here.
                    item.Unload();
                    EvaSettings.SaveEva(item);


                    EvaDebug.DebugLog("Remove EVA: (" + vessel.name + ")");
                    collection.Remove(item);
                    break;
                }
            }
        }
Exemplo n.º 5
0
        public static void SaveEva(EvaContainer container)
        {
            EvaDebug.DebugWarning("EvaSettings.SaveEva(" + container.Name + ")");

            if (container.status == Status.Removed)
            {
                if (collection.ContainsKey(container.flightID))
                {
                    collection.Remove(container.flightID);
                }
            }
            else
            {
                //The eva was already has a old save.
                if (collection.ContainsKey(container.flightID))
                {
                    //Replace the old save.
                    collection[container.flightID] = container.ToSave();
                }
                else
                {
                    //No save yet. Add it now.
                    collection.Add(container.flightID, container.ToSave());
                }
            }
        }
Exemplo n.º 6
0
 public void onCommandSeatInteraction(KerbalEVA k, bool b)
 {
     EvaDebug.DebugLog("onCommandSeatInteraction()");
     if (!b)
     {
         Load(k.vessel);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Runs when the EVA is killed.
        /// </summary>
        /// <param name="report"></param>

/*
 *      public void OnCrewKilled(EventReport report)
 *      {
 *          EvaDebug.DebugLog("OnCrewKilled()");
 *              KerbalRoster boboo = new KerbalRoster(Game.Modes.SANDBOX);
 *              print(boboo[report.sender].name);
 *              //MonoBehaviour.print(report.origin);
 *              //MonoBehaviour.print(report.origin.vessel);
 *          //Unload(report.origin.vessel, true);
 *      }
 */
        public void VesselDestroyed(Vessel report)
        {
            EvaDebug.DebugLog("VesselDestroyed()");
            if (report.isEVA)
            {
                Unload(report, true);
            }
        }
Exemplo n.º 8
0
        public static void Load()
        {
            EvaDebug.DebugWarning("OnLoad()");
            if (HighLogic.CurrentGame.Parameters.CustomParams <EvaFollowerMiscSettings>().displayLoadingKerbals)
            {
                ScreenMessages.PostScreenMessage("Loading Kerbals...", 3, ScreenMessageStyle.LOWER_CENTER);
            }

            LoadFunction();
        }
Exemplo n.º 9
0
        public static void Load()
        {
            EvaDebug.DebugWarning("OnLoad()");
            if (displayLoadingKerbals)
            {
                ScreenMessages.PostScreenMessage("Loading Kerbals...", 3, ScreenMessageStyle.LOWER_CENTER);
            }

            LoadFunction();
        }
Exemplo n.º 10
0
        public void OnPartUnpack(Part part)
        {
            if (part.vessel.isEVA)
            {
                //save before pack
                EvaDebug.DebugWarning("Unpack: " + part.vessel.name);

                Load(part.vessel);
            }
        }
Exemplo n.º 11
0
        public void OnPartPack(Part part)
        {
            if (part.vessel.isEVA)
            {
                //save before pack
                EvaDebug.DebugWarning("Pack: " + part.vessel.name);

                Unload(part.vessel, false);
            }
        }
Exemplo n.º 12
0
        internal bool Contains(Guid id)
        {
            EvaDebug.DebugLog("Contains()");

            for (int i = 0; i < collection.Count; i++)
            {
                if (collection[i].flightID == id)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 13
0
        public void Start()
        {
            EvaDebug.DebugWarning("EvaOrderController.Start()");

            //save config.
            //EvaSettings.SaveConfiguration();
            EvaSettings.LoadConfiguration();

            if (EvaSettings.displayDebugLines)
            {
                InitializeDebugLine();
            }

            InitializeCursor();
        }
Exemplo n.º 14
0
        public void Load(KerbalEVA eva)
        {
            //Load KerbalEVA.
            this.eva = eva;
            loaded   = true;

            //Set Name
            this.Name = eva.name;

            //module on last.
            EvaModule module = (EvaModule)eva.GetComponent(typeof(EvaModule));

            module.Load(this);

            EvaDebug.DebugWarning("EvaContainer.Load(" + eva.name + ")");
        }
Exemplo n.º 15
0
        public void OnDestroy()
        {
            EvaDebug.DebugWarning("EvaController.OnDestroy()");


            GameEvents.onPartPack.Remove(OnPartPack);
            GameEvents.onPartUnpack.Remove(OnPartUnpack);

            GameEvents.onCrewOnEva.Remove(OnCrewOnEva);
            GameEvents.onCrewBoardVessel.Remove(OnCrewBoardVessel);
//            GameEvents.onCrewKilled.Remove(OnCrewKilled);
            GameEvents.onVesselWillDestroy.Add(VesselDestroyed);

            GameEvents.onGameStateSave.Remove(OnSave);
            GameEvents.onFlightReady.Remove(onFlightReadyCallback);
        }
Exemplo n.º 16
0
        public static void Save()
        {
            if (isLoaded)
            {
                EvaDebug.DebugWarning("OnSave()");

                if (displayLoadingKerbals)
                {
                    ScreenMessages.PostScreenMessage("Saving Kerbals...", 3, ScreenMessageStyle.LOWER_CENTER);
                }

                SaveFunction();

                isLoaded = false;
            }
        }
Exemplo n.º 17
0
        public static void SaveConfiguration()
        {
            EvaDebug.DebugWarning("SaveConfiguration()");

            ConfigNode node = new ConfigNode();
            ConfigNode data = new ConfigNode();

            data.AddValue("selectMouseButton", selectMouseButton);
            data.AddValue("dispatchMouseButton", dispatchMouseButton);
            data.AddValue("selectKeyButton", selectKeyButton);
            data.AddValue("dispatchKeyButton", dispatchKeyButton);

            node.AddNode(NODENAME, data);

            Debug.Log("Saving to: " + ConfigFileName);
            node.Save(ConfigFileName);
        }
Exemplo n.º 18
0
        public void Start()
        {
            EvaDebug.DebugWarning("EvaController.Start()");
            //initialize the singleton.
            instance = this;

            GameEvents.onPartPack.Add(OnPartPack);
            GameEvents.onPartUnpack.Add(OnPartUnpack);

            GameEvents.onCrewOnEva.Add(OnCrewOnEva);
            GameEvents.onCrewBoardVessel.Add(OnCrewBoardVessel);
//            GameEvents.onCrewKilled.Add(OnCrewKilled);
            GameEvents.onVesselWillDestroy.Add(VesselDestroyed);

            GameEvents.onGameStateSave.Add(OnSave);
            GameEvents.onFlightReady.Add(onFlightReadyCallback);
        }
Exemplo n.º 19
0
        public static void LoadConfiguration()
        {
            if (FileExcist("Config.cfg"))
            {
                KSP.IO.TextReader tr    = KSP.IO.TextReader.CreateForType <EvaSettings>("Config.cfg");
                string[]          lines = tr.ReadToEnd().Split('\n');

                foreach (var line in lines)
                {
                    string[] parts = line.Split('=');

                    try
                    {
                        if (parts.Length > 1)
                        {
                            string name  = parts[0].Trim();
                            string value = parts[1].Trim();

                            switch (name)
                            {
                            case "ShowDebugLines": { displayDebugLinesSetting = bool.Parse(value); } break;

                            case "ShowLoadingKerbals": { displayLoadingKerbals = bool.Parse(value); } break;

                            case "EnableHelmetToggle": { displayToggleHelmet = bool.Parse(value); } break;

                            case "SelectMouseButton": { selectMouseButton = int.Parse(value); } break;

                            case "DispatchMouseButton": { dispatchMouseButton = int.Parse(value); } break;

                            case "SelectKey": { selectKeyButton = value; } break;

                            case "DispatchKey": { dispatchKeyButton = value; } break;

                            case "TargetVesselBySelection": { targetVesselBySelection = bool.Parse(value); } break;
                            }
                        }
                    }
                    catch
                    {
                        EvaDebug.DebugWarning("[EFX] Config loading error ");
                    }
                }
                displayDebugLines = displayDebugLinesSetting;
            }
        }
Exemplo n.º 20
0
        internal void FromSave(string evaSettings)
        {
            EvaTokenReader reader = new EvaTokenReader(evaSettings);

            try
            {
                string sflightID  = reader.NextTokenEnd(',');
                string sName      = reader.NextTokenEnd(',');
                string mode       = reader.NextTokenEnd(',');
                string status     = reader.NextTokenEnd(',');
                string selected   = reader.NextTokenEnd(',');
                string showHelmet = reader.NextTokenEnd(',');

                string formation = reader.NextToken('(', ')'); reader.Consume();
                string patrol    = reader.NextToken('(', ')'); reader.Consume();
                string order     = reader.NextToken('(', ')'); reader.Consume();
                string wanderer  = reader.NextToken('(', ')');

                this.Name       = sName;
                this.mode       = (Mode)Enum.Parse(typeof(Mode), mode);
                this.status     = (Status)Enum.Parse(typeof(Status), status);
                this.selected   = bool.Parse(selected);
                this.showHelmet = bool.Parse(showHelmet);


                this.formation.FromSave(formation);
                this.patrol.FromSave(patrol);
                this.order.FromSave(order);
                this.wanderer.FromSave(wanderer);

                EvaDebug.DebugLog("Loaded: " + mode);
                EvaDebug.DebugLog("name: " + sName);
                EvaDebug.DebugLog("status: " + status);
                EvaDebug.DebugLog("selected: " + selected);

                if (this.showHelmet == false)
                {
                    eva.ShowHelmet(this.showHelmet);
                }
            }
            catch
            {
                throw new Exception("[EFX] FromSave Failed.");
            }
        }
Exemplo n.º 21
0
        public static void LoadEva(EvaContainer container)
        {
            EvaDebug.DebugWarning("EvaSettings.LoadEva(" + container.Name + ")");

            //The eva was already has a old save.
            //Load it.
            if (collection.ContainsKey(container.flightID))
            {
                //string evaString = collection[container.flightID];
                //EvaDebug.DebugWarning(evaString);

                container.FromSave(collection[container.flightID]);
            }
            else
            {
                //No save yet.
            }
        }
Exemplo n.º 22
0
        public void Awake()
        {
            EvaDebug.DebugLog("Loaded AddonAddModule.");

            ConfigNode EVA = new ConfigNode("MODULE");

            EVA.AddValue("name", "EvaModule");

            try
            {
                PartLoader.getPartInfoByName("kerbalEVA").partPrefab.AddModule(EVA);
            }
            catch {
            }

            EVA = new ConfigNode("MODULE");
            EVA.AddValue("name", "EvaModule");

            try {
                PartLoader.getPartInfoByName("kerbalEVAfemale").partPrefab.AddModule(EVA);
            } catch {
            }
        }
Exemplo n.º 23
0
        private static void LoadFile()
        {
            string fileName = String.Format("Evas-{0}.txt", HighLogic.CurrentGame.Title);

            if (FileExcist(fileName))
            {
                KSP.IO.TextReader tr = KSP.IO.TextReader.CreateForType <EvaSettings>(fileName);

                string file = tr.ReadToEnd();
                tr.Close();

                EvaTokenReader reader = new EvaTokenReader(file);

                EvaDebug.DebugLog("Size KeySize: " + collection.Count);

                //read every eva.
                while (!reader.EOF)
                {
                    //Load all the eva's in the list.
                    LoadEva(reader.NextToken('[', ']'));
                }
            }
        }
Exemplo n.º 24
0
        public void Update()
        {
            if (!FlightGlobals.ready || PauseMenu.isOpen)
            {
                return;
            }

            // Replace this with a check to see if GUI is hidden
            if (Input.GetKeyDown(KeyCode.F2) && EvaSettings.displayDebugLinesSetting)
            {
                EvaSettings.displayDebugLines = !EvaSettings.displayDebugLines;
                foreach (EvaContainer container in EvaController.instance.collection)
                {
                    container.togglePatrolLines();
                }
            }

            if (Input.GetKeyDown(KeyCode.B))
            {
                foreach (EvaContainer container in EvaController.instance.collection)
                {
                    container.EVA.PackToggle();
                }
            }

            try
            {
                foreach (EvaContainer eva in EvaController.instance.collection.ToArray())
                {
                    if (eva == null)
                    {
                        //is this possible ?
                        EvaDebug.DebugWarning("eva == null");
                        continue;
                    }

                    //skip unloaded vessels
                    if (!eva.Loaded)
                    {
                        continue;
                    }

                    //Turn the lights on when dark.
                    //Skip for now, too buggy..
                    //eva.UpdateLamps();

                    if (eva.mode == Mode.None)
                    {
                        //Nothing to do here.
                        continue;
                    }

                    //Recover from ragdoll, if possible.
                    if (eva.IsRagDoll)
                    {
                        eva.RecoverFromRagdoll();
                        continue;
                    }

                    Vector3d move = -eva.Position;

                    //Get next Action, Formation or Patrol
                    Vector3d target = eva.GetNextTarget();

                    // Path Finding
                    //todo: check if the target is occopied.
                    move += target;

                    double sqrDist = move.sqrMagnitude;
                    float  speed   = TimeWarp.deltaTime;

                    if (eva.OnALadder)
                    {
                        eva.ReleaseLadder();
                    }

                    #region Break Free Code

                    if (eva.IsActive)
                    {
                        Mode mode = eva.mode;

                        if (Input.GetKeyDown(KeyCode.W))
                        {
                            mode = EvaFollower.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.S))
                        {
                            mode = EvaFollower.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.A))
                        {
                            mode = EvaFollower.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.D))
                        {
                            mode = EvaFollower.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.Q))
                        {
                            mode = EvaFollower.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.E))
                        {
                            mode = EvaFollower.Mode.None;
                        }

                        if (mode == Mode.None)
                        {
                            //break free!
                            eva.mode = mode;
                            continue;
                        }
                    }
                    #endregion

                    //Animation Logic
                    eva.UpdateAnimations(sqrDist, ref speed);

                    move.Normalize();

                    //Distance Logic
                    eva.CheckDistance(move, speed, sqrDist);

                    //Reset Animation Mode Events
                    eva.CheckModeIsNone();
                }
            }
            catch (Exception exp)
            {
                EvaDebug.DebugWarning("[EFX] EvaLogic: " + exp.Message + ":" + exp.ToString());
            }
        }
Exemplo n.º 25
0
 public void OnDestroy()
 {
     EvaDebug.DebugWarning("EvaLogic.OnDestroy()");
 }
Exemplo n.º 26
0
 public void Start()
 {
     EvaDebug.DebugWarning("EvaLogic.Start()");
 }
Exemplo n.º 27
0
 /// <summary>
 /// Runs when the EVA goes onboard a vessel.
 /// </summary>
 /// <param name="e"></param>
 public void OnCrewBoardVessel(GameEvents.FromToAction <Part, Part> e)
 {
     //remove kerbal
     EvaDebug.DebugLog("OnCrewBoardVessel()");
     Unload(e.from.vessel, true);
 }
Exemplo n.º 28
0
 public static void SaveFunction()
 {
     EvaDebug.ProfileStart();
     SaveFile();
     EvaDebug.ProfileEnd("EvaSettings.Save()");
 }
Exemplo n.º 29
0
 /// <summary>
 /// Load the list
 /// </summary>
 private void onFlightReadyCallback()
 {
     //Load the eva list.
     EvaDebug.DebugLog("onFlightReadyCallback()");
     EvaSettings.Load();
 }
Exemplo n.º 30
0
 public void Unload()
 {
     EvaDebug.DebugWarning("EvaContainer.Unload(" + eva.name + ")");
     loaded = false;
 }