Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
taniwha committed Sep 20, 2020
2 parents 78e8826 + a510e99 commit 6a88192
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 31 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PLUGINDIR := ${MODGAMEDATA}/Plugins
export APIEXTDATA := ${PLUGINDIR}

RESGEN2 := resgen2
GMCS := gmcs
CSC := csc
GIT := git
TAR := tar
ZIP := zip
Expand All @@ -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}"
Expand Down
31 changes: 25 additions & 6 deletions Source/BuildControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -85,6 +87,7 @@ public RMResourceSet craftResources
}
}
public List<string> 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; }
Expand Down Expand Up @@ -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);
}
}
}
}

Expand All @@ -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<LaunchClamp> ();
for (int j = 0; j < elc.Count; j++) {
lc[j].EnableExtension ();
var lc = p.Modules["ModuleRestockLaunchClamp"];
if (lc != null) {
(lc as LaunchClamp).EnableExtension ();
}
}
}
Expand Down Expand Up @@ -725,6 +733,7 @@ public void LoadCraft (string filename, string flagname)
}
PlaceCraftHull();
state = State.Planning;
craftBoMdirty = true;
}

public void UnloadCraft ()
Expand All @@ -739,6 +748,7 @@ public bool CreateBoM ()
{
string str;

craftBoMdirty = false;
if (craftConfig != null) {
craftBoM = new List<string> ();
var partCounts = new Dictionary<string, int> ();
Expand All @@ -761,6 +771,7 @@ public bool CreateBoM ()
}
return true;
}
craftBoM = null;
return false;
}

Expand Down Expand Up @@ -818,7 +829,7 @@ internal HashSet<Part> CraftParts ()
return part_set;
}

internal void FindVesselResources ()
void FindVesselResources ()
{
var craft_parts = CraftParts ();
var pad_parts = new HashSet<Part> (builder.vessel.parts);
Expand All @@ -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")) {
Expand Down Expand Up @@ -911,7 +930,7 @@ internal void OnStart ()
}
}
PlaceCraftHull ();
FindVesselResources ();
(builder as PartModule).StartCoroutine (WaitAndFindVesselResources ());
SetPadMass ();
}

Expand Down Expand Up @@ -1100,7 +1119,7 @@ void onVesselWasModified (Vessel v)
if (craftRoot != null && craftRoot.vessel != builder.vessel) {
CleanupAfterRelease ();
}
FindVesselResources ();
(builder as PartModule).StartCoroutine (WaitAndFindVesselResources ());
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/DisposablePad/DisposablePad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
}
Expand Down
39 changes: 39 additions & 0 deletions Source/GUI/BuildWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class ELBuildWindow : MonoBehaviour
static Texture2D flagTexture;

List<ELBuildControl> launchpads;
ELVesselWorkNet worknet;
DropDownList pad_list;
ELBuildControl control;

Expand Down Expand Up @@ -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<ELBuildControl.IBuilder> ();
if (pad != null) {
return pad.control;
}
}
return null;
}

void BuildPadList (Vessel v)
{
launchpads = null;
pad_list = null;
worknet = null;

if (v.isEVA) {
control = null;
Expand All @@ -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<ELBuildControl> ();
int control_index = -1;
for (int i = 0; i < pads.Count; i++) {
Expand All @@ -177,6 +206,7 @@ void BuildPadList (Vessel v)
}
if (control_index < 0) {
control_index = 0;
control = pads[0].control;
}
var pad_names = new List<string> ();
for (int ind = 0; ind < launchpads.Count; ind++) {
Expand Down Expand Up @@ -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 ();
}
Expand Down Expand Up @@ -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 ();
Expand Down
2 changes: 1 addition & 1 deletion Source/LaunchClamp/LaunchClamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class ELExtendingLaunchClamp : PartModule
bool can_stretch;
bool enableExtension;

FXGroup release_fx;
FXGroup release_fx = null;
ConfigurableJoint clampJoint;

GameObject []clones;
Expand Down
43 changes: 27 additions & 16 deletions Source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions Source/Pad/Launchpad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
}
Expand Down Expand Up @@ -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);
}
}
}
}
}
6 changes: 1 addition & 5 deletions Source/Survey/SurveyStake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ You should have received a copy of the GNU General Public License
<http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

using KSP.IO;
using Highlighting;

namespace ExtraplanetaryLaunchpads {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Source/Survey/SurveyStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public string LaunchedFrom
}
}

public uint ID { get { return part.flightID; } }

public bool isBusy
{
get {
Expand Down
3 changes: 3 additions & 0 deletions Source/Workshop/VesselWorkNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion tools/git-version-gen
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6a88192

Please sign in to comment.