Beispiel #1
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);
            }
        }
Beispiel #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());
                }
            }
        }
Beispiel #3
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;
                }
            }
        }
Beispiel #4
0
        public void Start()
        {
            OrXchaseDebug.DebugWarning("OrXchaseOrderController.Start()");

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

            //InitializeCursor();
        }
Beispiel #5
0
        public void OnPartUnpack(Part part)
        {
            if (part.vessel.isEVA)
            {
                //save before pack
                OrXchaseDebug.DebugWarning("Unpack: " + part.vessel.name);

                Load(part.vessel);
            }
        }
Beispiel #6
0
        public void OnPartPack(Part part)
        {
            if (part.vessel.isEVA)
            {
                //save before pack
                OrXchaseDebug.DebugWarning("Pack: " + part.vessel.name);

                Unload(part.vessel, false);
            }
        }
Beispiel #7
0
        public static void Load()
        {
            OrXchaseDebug.DebugWarning("OnLoad()");
            if (displayLoadingKerbals)
            {
                ScreenMessages.PostScreenMessage("Loading Kerbals...", 3, ScreenMessageStyle.LOWER_CENTER);
            }

            LoadFunction();
        }
Beispiel #8
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);
        }
Beispiel #9
0
        public static void Save()
        {
            if (isLoaded)
            {
                OrXchaseDebug.DebugWarning("OnSave()");

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

                SaveFunction();

                isLoaded = false;
            }
        }
Beispiel #10
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 + ")");
        }
Beispiel #11
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);
        }
Beispiel #12
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;
            }
        }
Beispiel #13
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.
            }
        }
Beispiel #14
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());
            }
        }
Beispiel #15
0
 public static void ProfileEnd(string name)
 {
     EndTimer();
     OrXchaseDebug.DebugWarning(string.Format("Profile: {0}: {1}mSalt", name, Elapsed));
 }
Beispiel #16
0
 public void Unload()
 {
     OrXchaseDebug.DebugWarning("OrXchaseContainer.Unload(" + eva.name + ")");
     loaded = false;
 }
Beispiel #17
0
 public void OnDestroy()
 {
     OrXchaseDebug.DebugWarning("OrXchaseLogic.OnDestroy()");
 }
Beispiel #18
0
 public void OnDestroy()
 {
     OrXchaseDebug.DebugWarning("OrXchaseOrderController.OnDestroy()");
 }
Beispiel #19
0
 public void Start()
 {
     OrXchaseDebug.DebugWarning("OrXchaseLogic.Start()");
 }