From cc0ad3eacdb8becb9806ce2ddadfc92a11c6a774 Mon Sep 17 00:00:00 2001 From: SirDiazo Date: Sun, 31 Aug 2014 22:05:09 -0600 Subject: [PATCH] Version 1.13d Version 1.13c not released. c: Fix loading of KSP base groups d: Fix spaceplanes coordiantes --- .gitignore | 1 + AGExt/Editor.cs | 70 +++++++++++++++++++++++++++++++++++++++++++++++-- AGExt/Flight.cs | 59 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b9d6bd9..79c1549 100644 --- a/.gitignore +++ b/.gitignore @@ -213,3 +213,4 @@ pip-log.txt #Mr Developer .mr.developer.cfg +us.stackdump diff --git a/AGExt/Editor.cs b/AGExt/Editor.cs index e955ff4..57df657 100644 --- a/AGExt/Editor.cs +++ b/AGExt/Editor.cs @@ -2548,6 +2548,63 @@ public static void EditorLoadFromFile() } } } + + List CustomActions = new List(); + CustomActions.Add(KSPActionGroup.Custom01); //how do you add a range from enum? + CustomActions.Add(KSPActionGroup.Custom02); + CustomActions.Add(KSPActionGroup.Custom03); + CustomActions.Add(KSPActionGroup.Custom04); + CustomActions.Add(KSPActionGroup.Custom05); + CustomActions.Add(KSPActionGroup.Custom06); + CustomActions.Add(KSPActionGroup.Custom07); + CustomActions.Add(KSPActionGroup.Custom08); + CustomActions.Add(KSPActionGroup.Custom09); + CustomActions.Add(KSPActionGroup.Custom10); + + errLine = "16"; + // string AddGroup = ""; + List partAllActions = new List(); //is all vessel actions, copy pasting code + foreach (Part p in EditorLogic.SortedShipList) + { + partAllActions.AddRange(p.Actions); + foreach(PartModule pm in p.Modules) + { + partAllActions.AddRange(pm.Actions); + } + } + + foreach (BaseAction baLoad in partAllActions) + { + foreach (KSPActionGroup agrp in CustomActions) + { + + if ((baLoad.actionGroup & agrp) == agrp) + { + errLine = "17"; + ////AddGroup = AddGroup + '\u2023' + (CustomActions.IndexOf(agrp) + 1).ToString("000") + baLoad.guiName; + //partAGActions2.Add(new AGXAction() { group = CustomActions.IndexOf(agrp) + 1, prt = this.part, ba = baLoad, activated = false }); + AGXAction ToAdd = new AGXAction() { prt = baLoad.listParent.part, ba = baLoad, group = CustomActions.IndexOf(agrp) + 1, activated = false }; + List Checking = new List(); + Checking.AddRange(CurrentVesselActions); + Checking.RemoveAll(p => p.group != ToAdd.group); + + Checking.RemoveAll(p => p.prt != ToAdd.prt); + + Checking.RemoveAll(p => p.ba != ToAdd.ba); + + + + if (Checking.Count == 0) + { + + CurrentVesselActions.Add(ToAdd); + + } + } + } + errLine = "18"; + } + } catch (Exception e) { @@ -2809,8 +2866,16 @@ public static void EditorSaveToFile() partTemp.AddValue("name", p.name); partTemp.AddValue("vesselID", "0"); partTemp.AddValue("relLocX", (p.transform.position - EditorLogic.startPod.transform.position).x); - partTemp.AddValue("relLocY", (p.transform.position - EditorLogic.startPod.transform.position).y); - partTemp.AddValue("relLocZ", (p.transform.position - EditorLogic.startPod.transform.position).z); + if (!inVAB) + { + partTemp.AddValue("relLocZ", ((p.transform.position - EditorLogic.startPod.transform.position).y) * -1f); + partTemp.AddValue("relLocY", (p.transform.position - EditorLogic.startPod.transform.position).z); + } + else + { + partTemp.AddValue("relLocY", (p.transform.position - EditorLogic.startPod.transform.position).y); + partTemp.AddValue("relLocZ", (p.transform.position - EditorLogic.startPod.transform.position).z); + } errLine = "20"; foreach (AGXAction agxAct in thisPartsActions) { @@ -2822,6 +2887,7 @@ public static void EditorSaveToFile() thisVsl.AddNode(partTemp); errLine = "23"; } + // print("part OrgPart "+ p.ConstructID+" " + p.orgPos + " " + p.orgRot); } } catch diff --git a/AGExt/Flight.cs b/AGExt/Flight.cs index 775356b..d5ee55d 100644 --- a/AGExt/Flight.cs +++ b/AGExt/Flight.cs @@ -585,6 +585,65 @@ public void VesselOffRails(Vessel vsl) //load vessels here } } + List CustomActions = new List(); + CustomActions.Add(KSPActionGroup.Custom01); //how do you add a range from enum? + CustomActions.Add(KSPActionGroup.Custom02); + CustomActions.Add(KSPActionGroup.Custom03); + CustomActions.Add(KSPActionGroup.Custom04); + CustomActions.Add(KSPActionGroup.Custom05); + CustomActions.Add(KSPActionGroup.Custom06); + CustomActions.Add(KSPActionGroup.Custom07); + CustomActions.Add(KSPActionGroup.Custom08); + CustomActions.Add(KSPActionGroup.Custom09); + CustomActions.Add(KSPActionGroup.Custom10); + + //errLine = "16"; + // string AddGroup = ""; + List partAllActions = new List(); //is all vessel actions, copy pasting code + foreach (Part p in vsl.parts) + { + partAllActions.AddRange(p.Actions); + foreach (PartModule pm in p.Modules) + { + partAllActions.AddRange(pm.Actions); + } + + // print("part orgpos " + p.ConstructID+ " " + p.orgPos + " " + p.orgRot); + } + + foreach (BaseAction baLoad in partAllActions) + { + foreach (KSPActionGroup agrp in CustomActions) + { + + if ((baLoad.actionGroup & agrp) == agrp) + { + // errLine = "17"; + ////AddGroup = AddGroup + '\u2023' + (CustomActions.IndexOf(agrp) + 1).ToString("000") + baLoad.guiName; + //partAGActions2.Add(new AGXAction() { group = CustomActions.IndexOf(agrp) + 1, prt = this.part, ba = baLoad, activated = false }); + AGXAction ToAdd = new AGXAction() { prt = baLoad.listParent.part, ba = baLoad, group = CustomActions.IndexOf(agrp) + 1, activated = false }; + List Checking = new List(); + Checking.AddRange(AllVesselsActions); + Checking.RemoveAll(p => p.group != ToAdd.group); + + Checking.RemoveAll(p => p.prt != ToAdd.prt); + + Checking.RemoveAll(p => p.ba != ToAdd.ba); + + + + if (Checking.Count == 0) + { + + AllVesselsActions.Add(ToAdd); + + } + } + } + // errLine = "18"; + } + + if (vsl == FlightGlobals.ActiveVessel) { CurrentKeySet = Convert.ToInt32(vslNode.GetValue("currentKeyset"));