diff --git a/Makefile b/Makefile index af9b35d1..36c77f89 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ export PLUGINDIR := ${MODGAMEDATA}/Plugins export APIEXTDATA := ${PLUGINDIR} RESGEN2 := resgen2 -GMCS := gmcs +CSC := csc GIT := git TAR := tar ZIP := zip @@ -24,7 +24,7 @@ all clean install: info: @echo "${MODNAME} Build Information" @echo " resgen2: ${RESGEN2}" - @echo " gmcs: ${GMCS}" + @echo " gmcs: ${CSC}" @echo " git: ${GIT}" @echo " tar: ${TAR}" @echo " zip: ${ZIP}" diff --git a/Source/BuildControl.cs b/Source/BuildControl.cs index 50e2fbcd..c8c0e885 100644 --- a/Source/BuildControl.cs +++ b/Source/BuildControl.cs @@ -50,6 +50,8 @@ public interface IBuilder string Name { get; set; } string LandedAt { get; } string LaunchedFrom { get; } + + uint ID { get; } } public IBuilder builder { get; private set; } @@ -85,6 +87,7 @@ public RMResourceSet craftResources } } public List craftBoM { get; private set; } + public bool craftBoMdirty { get; private set; } public CostReport buildCost { get; private set; } public CostReport builtStuff { get; private set; } public State state { get; private set; } @@ -599,6 +602,11 @@ void RotateLaunchClamps (ShipConstruct ship) for (int j = 0; j < elc.Count; j++) { elc[j].RotateTower (); } + if (elc.Count < 1) { + if (p.Modules["ModuleRestockLaunchClamp"] != null) { + p.SendMessage("RotateTower", SendMessageOptions.DontRequireReceiver); + } + } } } @@ -616,9 +624,9 @@ void EnableExtendingLaunchClamps (ShipConstruct ship) // ReplaceLaunchClamps will not do any replacement because // the module uses a different name. Thus this will pick up // the ReStock module. - var lc = p.FindModulesImplementing (); - for (int j = 0; j < elc.Count; j++) { - lc[j].EnableExtension (); + var lc = p.Modules["ModuleRestockLaunchClamp"]; + if (lc != null) { + (lc as LaunchClamp).EnableExtension (); } } } @@ -725,6 +733,7 @@ public void LoadCraft (string filename, string flagname) } PlaceCraftHull(); state = State.Planning; + craftBoMdirty = true; } public void UnloadCraft () @@ -739,6 +748,7 @@ public bool CreateBoM () { string str; + craftBoMdirty = false; if (craftConfig != null) { craftBoM = new List (); var partCounts = new Dictionary (); @@ -761,6 +771,7 @@ public bool CreateBoM () } return true; } + craftBoM = null; return false; } @@ -818,7 +829,7 @@ internal HashSet CraftParts () return part_set; } - internal void FindVesselResources () + void FindVesselResources () { var craft_parts = CraftParts (); var pad_parts = new HashSet (builder.vessel.parts); @@ -843,6 +854,14 @@ internal void FindVesselResources () } } + IEnumerator WaitAndFindVesselResources () + { + yield return null; + if (builder.vessel != null) { + FindVesselResources (); + } + } + public void Load (ConfigNode node) { if (node.HasValue ("filename")) { @@ -911,7 +930,7 @@ internal void OnStart () } } PlaceCraftHull (); - FindVesselResources (); + (builder as PartModule).StartCoroutine (WaitAndFindVesselResources ()); SetPadMass (); } @@ -1100,7 +1119,7 @@ void onVesselWasModified (Vessel v) if (craftRoot != null && craftRoot.vessel != builder.vessel) { CleanupAfterRelease (); } - FindVesselResources (); + (builder as PartModule).StartCoroutine (WaitAndFindVesselResources ()); } } } diff --git a/Source/DisposablePad/DisposablePad.cs b/Source/DisposablePad/DisposablePad.cs index 9b9d7064..1c92fe8a 100644 --- a/Source/DisposablePad/DisposablePad.cs +++ b/Source/DisposablePad/DisposablePad.cs @@ -106,6 +106,8 @@ public string Name public string LandedAt { get { return ""; } } public string LaunchedFrom { get { return ""; } } + public uint ID { get { return part.flightID; } } + public void PadSelection_start () { } diff --git a/Source/GUI/BuildWindow.cs b/Source/GUI/BuildWindow.cs index 67033771..13f91202 100644 --- a/Source/GUI/BuildWindow.cs +++ b/Source/GUI/BuildWindow.cs @@ -48,6 +48,7 @@ public class ELBuildWindow : MonoBehaviour static Texture2D flagTexture; List launchpads; + ELVesselWorkNet worknet; DropDownList pad_list; ELBuildControl control; @@ -154,10 +155,34 @@ public static void SaveSettings (ConfigNode node) node.AddValue ("link_lfo_sliders", link_lfo_sliders); } + static ELVesselWorkNet FindWorkNet (Vessel v) + { + for (int i = 0; i < v.vesselModules.Count; i++) { + var worknet = v.vesselModules[i] as ELVesselWorkNet; + if (worknet != null) { + return worknet; + } + } + return null; + } + + static ELBuildControl FindControl (Vessel v, uint id) + { + Part part = v[id]; + if (part != null) { + var pad = part.FindModuleImplementing (); + if (pad != null) { + return pad.control; + } + } + return null; + } + void BuildPadList (Vessel v) { launchpads = null; pad_list = null; + worknet = null; if (v.isEVA) { control = null; @@ -167,6 +192,10 @@ void BuildPadList (Vessel v) if (pads.Count < 1) { control = null; } else { + worknet = FindWorkNet (v); + if (worknet != null) { + control = FindControl (v, worknet.selectedPad); + } launchpads = new List (); int control_index = -1; for (int i = 0; i < pads.Count; i++) { @@ -177,6 +206,7 @@ void BuildPadList (Vessel v) } if (control_index < 0) { control_index = 0; + control = pads[0].control; } var pad_names = new List (); for (int ind = 0; ind < launchpads.Count; ind++) { @@ -424,6 +454,7 @@ void Select_Pad (ELBuildControl selected_pad) control.builder.Highlight (false); } control = selected_pad; + worknet.selectedPad = control.builder.ID; pad_list.SelectItem (launchpads.IndexOf (control)); UpdateGUIState (); } @@ -729,6 +760,14 @@ void CloseButton () void WindowGUI (int windowID) { + var e = Event.current; + switch (e.type) { + case EventType.Layout: + if (control.craftBoMdirty) { + control.CreateBoM (); + } + break; + } ELStyles.Init (); SelectPad_start (); diff --git a/Source/LaunchClamp/LaunchClamp.cs b/Source/LaunchClamp/LaunchClamp.cs index 0ae8e27d..bd9891ae 100644 --- a/Source/LaunchClamp/LaunchClamp.cs +++ b/Source/LaunchClamp/LaunchClamp.cs @@ -58,7 +58,7 @@ public class ELExtendingLaunchClamp : PartModule bool can_stretch; bool enableExtension; - FXGroup release_fx; + FXGroup release_fx = null; ConfigurableJoint clampJoint; GameObject []clones; diff --git a/Source/Makefile b/Source/Makefile index 399f500b..8421f515 100644 --- a/Source/Makefile +++ b/Source/Makefile @@ -94,8 +94,8 @@ EL_FILES := \ $e RESGEN2 := resgen2 -GMCS := mcs -GMCSFLAGS := -optimize -warnaserror -debug +CSC := csc +CSCFLAGS := -highentropyva- -noconfig -nostdlib+ -t:library -optimize -warnaserror -debug GIT := git TAR := tar ZIP := zip @@ -109,27 +109,38 @@ version: info: @echo "${MODNAME} Build Information" @echo " resgen2: ${RESGEN2}" - @echo " gmcs: ${GMCS}" - @echo " gmcs flags: ${GMCSFLAGS}" + @echo " csc: ${CSC}" + @echo " csc flags: ${CSCFLAGS}" @echo " git: ${GIT}" @echo " tar: ${TAR}" @echo " zip: ${ZIP}" @echo " KSP Data: ${KSPDIR}" +SYSTEM := \ + -lib:${MANAGED} \ + -r:${MANAGED}/mscorlib.dll \ + -r:${MANAGED}/System.dll \ + -r:${MANAGED}/System.Core.dll + +KSP := \ + -r:Assembly-CSharp.dll \ + -r:Assembly-CSharp-firstpass.dll + +UNITY := \ + -r:UnityEngine.dll \ + -r:UnityEngine.UI.dll \ + -r:UnityEngine.UIModule.dll \ + -r:UnityEngine.IMGUIModule.dll \ + -r:UnityEngine.TextRenderingModule.dll \ + -r:UnityEngine.AnimationModule.dll \ + -r:UnityEngine.CoreModule.dll \ + -r:UnityEngine.PhysicsModule.dll \ + -r:UnityEngine.InputLegacyModule.dll \ + $e + bin/Launchpad.dll: ${EL_FILES} @mkdir -p bin - ${GMCS} ${GMCSFLAGS} -t:library -lib:${MANAGED} \ - -r:Assembly-CSharp,Assembly-CSharp-firstpass \ - -r:UnityEngine \ - -r:UnityEngine.UI \ - -r:UnityEngine.UIModule \ - -r:UnityEngine.IMGUIModule \ - -r:UnityEngine.TextRenderingModule \ - -r:UnityEngine.AnimationModule \ - -r:UnityEngine.CoreModule \ - -r:UnityEngine.PhysicsModule \ - -r:UnityEngine.InputLegacyModule \ - -out:$@ $^ + ${CSC} ${CSCFLAGS} ${SYSTEM} ${KSP} ${UNITY} -out:$@ $^ clean: rm -f ${TARGETS}* assembly/AssemblyInfo.cs bin/${MODNAME}.version diff --git a/Source/Pad/Launchpad.cs b/Source/Pad/Launchpad.cs index 02ae787c..105344fa 100644 --- a/Source/Pad/Launchpad.cs +++ b/Source/Pad/Launchpad.cs @@ -120,6 +120,8 @@ public string Name public string LandedAt { get { return ""; } } public string LaunchedFrom { get { return ""; } } + public uint ID { get { return part.flightID; } } + public void PadSelection_start () { } @@ -334,5 +336,20 @@ public void OnRename () { ELBuildWindow.updateCurrentPads (); } + + void OnCollisionStay (Collision collision) + { + // force any vessels landed on the pad to share the same situation + // works around a bug in KSP that sometimes glitches the landed + // vessel to not-landed + Part p = FlightGlobals.GetPartUpwardsCached (collision.collider.gameObject); + if (p != null) { + if (vessel.LandedOrSplashed) { + p.vessel.Landed = vessel.Landed; + p.vessel.Splashed = vessel.Splashed; + p.vessel.SetLandedAt (vessel.landedAt, null, vessel.displaylandedAt); + } + } + } } } diff --git a/Source/Survey/SurveyStake.cs b/Source/Survey/SurveyStake.cs index c861c15e..32472b48 100644 --- a/Source/Survey/SurveyStake.cs +++ b/Source/Survey/SurveyStake.cs @@ -16,13 +16,9 @@ You should have received a copy of the GNU General Public License . */ using System; -using System.Collections.Generic; -using System.Linq; using UnityEngine; using UnityEngine.UI; -using TMPro; -using KSP.IO; using Highlighting; namespace ExtraplanetaryLaunchpads { @@ -160,7 +156,7 @@ public void OnPartDie () unfocusedRange = 200f, guiName = "")] public void NextUse() { - use = (use + 1) % StakeUses.Count(); + use = (use + 1) % StakeUses.Length; Events["NextUse"].guiName = StakeUses[use]; UpdatePlaque (); ELSurveyTracker.onStakeModified.Fire (this); diff --git a/Source/Survey/SurveyStation.cs b/Source/Survey/SurveyStation.cs index 212b20b2..9f92c8a9 100644 --- a/Source/Survey/SurveyStation.cs +++ b/Source/Survey/SurveyStation.cs @@ -135,6 +135,8 @@ public string LaunchedFrom } } + public uint ID { get { return part.flightID; } } + public bool isBusy { get { diff --git a/Source/Workshop/VesselWorkNet.cs b/Source/Workshop/VesselWorkNet.cs index fda0b36f..c2056853 100644 --- a/Source/Workshop/VesselWorkNet.cs +++ b/Source/Workshop/VesselWorkNet.cs @@ -35,6 +35,9 @@ public class ELVesselWorkNet : VesselModule public double lastUpdate; public double Productivity { get; private set; } + [KSPField (isPersistant = true)] + public uint selectedPad; + public void ForceProductivityUpdate() { forceProductivityUpdate = true; diff --git a/tools/git-version-gen b/tools/git-version-gen index b011bb22..ed87c5b6 100755 --- a/tools/git-version-gen +++ b/tools/git-version-gen @@ -190,10 +190,17 @@ fi v=`echo "$v" |sed "s/^$prefix//"` -# Test whether to append the "-dirty" suffix only if the version +# Test whether to append the branch "-dirty" suffixes only if the version # string we're using came from git. I.e., skip the test if it's "UNKNOWN" # or if it came from .tarball-version. if test -n "$v_from_git"; then + branch=`git branch --show-current` + case "$branch" in + 'master') ;; + *) + v="$v-$branch" + ;; + esac # Don't declare a version "dirty" merely because a time stamp has changed. git update-index --refresh > /dev/null 2>&1