Exemplo n.º 1
0
        public void Unload(Vessel vessel, bool delete)
        {
            if (!vessel.isEVA)
            {
                OrXchaseDebug.DebugWarning("Tried unloading a non eva.");
                return;
            }

            OrXchaseDebug.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();
                    OrXchaseSettings.SaveEva(item);


                    OrXchaseDebug.DebugLog("Remove EVA: (" + vessel.name + ")");
                    collection.Remove(item);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static void SaveEva(OrXchaseContainer container)
        {
            OrXchaseDebug.DebugWarning("OrXchaseSettings.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.º 3
0
 public static void LoadFunction()
 {
     OrXchaseDebug.ProfileStart();
     LoadFile();
     OrXchaseDebug.ProfileEnd("OrXchaseSettings.Load()");
     isLoaded = true;
 }
Exemplo n.º 4
0
        public void Load(Vessel vessel)
        {
            if (!vessel.isEVA)
            {
                OrXchaseDebug.DebugWarning("Tried loading a non eva.");
                return;
            }

            KerbalEVA OrXEVA     = vessel.GetComponent <KerbalEVA>();
            var       currentEVA = vessel.FindPartModuleImplementing <KerbalEVA>();

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

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

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

                container.Load(currentEVA);
                OrXchaseSettings.LoadEva(container);
            }
        }
Exemplo n.º 5
0
 public void VesselDestroyed(Vessel report)
 {
     OrXchaseDebug.DebugLog("VesselDestroyed()");
     if (report.isEVA)
     {
         Unload(report, true);
     }
 }
Exemplo n.º 6
0
        public static void Load()
        {
            OrXchaseDebug.DebugWarning("OnLoad()");
            if (displayLoadingKerbals)
            {
                ScreenMessages.PostScreenMessage("Loading Kerbals...", 3, ScreenMessageStyle.LOWER_CENTER);
            }

            LoadFunction();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Runs when the EVA is killed.
        /// </summary>
        /// <param name="report"></param>

        public void OnCrewKilled(EventReport report)
        {
            OrXchaseDebug.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);
        }
Exemplo n.º 8
0
        public void OnPartPack(Part part)
        {
            if (part.vessel.isEVA)
            {
                //save before pack
                OrXchaseDebug.DebugWarning("Pack: " + part.vessel.name);

                Unload(part.vessel, false);
            }
        }
Exemplo n.º 9
0
        public void OnPartUnpack(Part part)
        {
            if (part.vessel.isEVA)
            {
                //save before pack
                OrXchaseDebug.DebugWarning("Unpack: " + part.vessel.name);

                Load(part.vessel);
            }
        }
Exemplo n.º 10
0
        public void Start()
        {
            OrXchaseDebug.DebugWarning("OrXchaseOrderController.Start()");

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

            //InitializeCursor();
        }
Exemplo n.º 11
0
        public bool Contains(Guid id)
        {
            OrXchaseDebug.DebugLog("Contains()");

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

            return(false);
        }
        public void Awake()
        {
            OrXchaseDebug.DebugLog("Loaded AddOrXchase.");

            ConfigNode EVA = new ConfigNode("MODULE");

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

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

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

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

            /*
             * EVA = new ConfigNode("MODULE");
             * EVA.AddValue("name", "OrXchaseModule");
             *
             * try
             * {
             *  PartLoader.getPartInfoByName("OrX_OrxBonusBall").partPrefab.AddModule(EVA);
             * }
             * catch
             * {
             *
             * }
             *
             * EVA = new ConfigNode("MODULE");
             * EVA.AddValue("name", "OrXchaseModule");
             *
             * try
             * {
             *  PartLoader.getPartInfoByName("OrX_OrxBonusBall2").partPrefab.AddModule(EVA);
             * }
             * catch
             * {
             *
             * }
             */
        }
Exemplo n.º 13
0
        public static void Save()
        {
            if (isLoaded)
            {
                OrXchaseDebug.DebugWarning("OnSave()");

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

                SaveFunction();

                isLoaded = false;
            }
        }
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.
            OrXchaseModule module = (OrXchaseModule)eva.GetComponent(typeof(OrXchaseModule));

            module.Load(this);

            OrXchaseDebug.DebugWarning("OrXchaseContainer.Load(" + eva.name + ")");
        }
Exemplo n.º 15
0
        public void OnDestroy()
        {
            OrXchaseDebug.DebugWarning("OrXchaseController.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 void Start()
        {
            OrXchaseDebug.DebugWarning("OrXchaseController.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.º 17
0
        public static void LoadConfiguration()
        {
            if (FileExcist("Config.cfg"))
            {
                KSP.IO.TextReader tr    = KSP.IO.TextReader.CreateForType <OrXchaseSettings>("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 "ShowDebugLineSalt": { displayDebugLinesSetting = bool.Parse(value); } break;

                            case "ShowLoadingKerbalSalt": { 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
                    {
                        OrXchaseDebug.DebugWarning("[OrX Chase] Config loading error ");
                    }
                }
                displayDebugLines = displayDebugLinesSetting;
            }
        }
Exemplo n.º 18
0
        public void FromSave(string OrXchaseSettings)
        {
            OrXchaseTokenReader reader = new OrXchaseTokenReader(OrXchaseSettings);

            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);

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

                if (this.showHelmet == false)
                {
                    eva.ShowHelmet(this.showHelmet);
                }
            }
            catch
            {
                throw new Exception("[OrX Chase] FromSave Failed.");
            }
        }
Exemplo n.º 19
0
        public static void LoadEva(OrXchaseContainer container)
        {
            OrXchaseDebug.DebugWarning("OrXchaseSettings.LoadEva(" + container.Name + ")");

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

                container.FromSave(collection[container.flightID]);
            }
            else
            {
                //No save yet.
            }
        }
Exemplo n.º 20
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 <OrXchaseSettings>(fileName);

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

                OrXchaseTokenReader reader = new OrXchaseTokenReader(file);

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

                //read every eva.
                while (!reader.EOF)
                {
                    //Load all the eva's in the list.
                    LoadEva(reader.NextToken('[', ']'));
                }
            }
        }
Exemplo n.º 21
0
 public void Start()
 {
     OrXchaseDebug.DebugWarning("OrXchaseLogic.Start()");
 }
Exemplo n.º 22
0
 /// <summary>
 /// Runs when the kerbal goes on EVA.
 /// </summary>
 /// <param name="e"></param>
 public void OnCrewOnEva(GameEvents.FromToAction <Part, Part> e)
 {
     //add new kerbal
     OrXchaseDebug.DebugLog("OnCrewOnEva()");
     Load(e.to.vessel);
 }
Exemplo n.º 23
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) && OrXchaseSettings.displayDebugLinesSetting)
            {
                OrXchaseSettings.displayDebugLines = !OrXchaseSettings.displayDebugLines;
                foreach (OrXchaseContainer container in OrXchaseController.instance.collection)
                {
                    container.togglePatrolLines();
                }
            }

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

            try
            {
                foreach (OrXchaseContainer eva in OrXchaseController.instance.collection.ToArray())
                {
                    if (eva == null)
                    {
                        //is this possible ?
                        OrXchaseDebug.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 = OrXBDAc.chase.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.S))
                        {
                            mode = OrXBDAc.chase.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.A))
                        {
                            mode = OrXBDAc.chase.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.D))
                        {
                            mode = OrXBDAc.chase.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.Q))
                        {
                            mode = OrXBDAc.chase.Mode.None;
                        }
                        if (Input.GetKeyDown(KeyCode.E))
                        {
                            mode = OrXBDAc.chase.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)
            {
                OrXchaseDebug.DebugWarning("[OrX Chase] OrXchaseLogic: " + exp.Message + ":" + exp.ToString());
            }
        }
Exemplo n.º 24
0
 public static void SaveFunction()
 {
     OrXchaseDebug.ProfileStart();
     SaveFile();
     OrXchaseDebug.ProfileEnd("OrXchaseSettings.Save()");
 }
Exemplo n.º 25
0
 /// <summary>
 /// Load the list
 /// </summary>
 private void onFlightReadyCallback()
 {
     //Load the eva list.
     OrXchaseDebug.DebugLog("onFlightReadyCallback()");
     OrXchaseSettings.Load();
 }
Exemplo n.º 26
0
 public void OnDestroy()
 {
     OrXchaseDebug.DebugWarning("OrXchaseOrderController.OnDestroy()");
 }
Exemplo n.º 27
0
 public void Unload()
 {
     OrXchaseDebug.DebugWarning("OrXchaseContainer.Unload(" + eva.name + ")");
     loaded = false;
 }
Exemplo n.º 28
0
 public void OnDestroy()
 {
     OrXchaseDebug.DebugWarning("OrXchaseLogic.OnDestroy()");
 }
Exemplo n.º 29
0
 public static void ProfileEnd(string name)
 {
     EndTimer();
     OrXchaseDebug.DebugWarning(string.Format("Profile: {0}: {1}mSalt", name, Elapsed));
 }
Exemplo n.º 30
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
     OrXchaseDebug.DebugLog("OnCrewBoardVessel()");
     Unload(e.from.vessel, true);
 }