Skip to content

Commit

Permalink
Merge pull request #83 from BobPalmer/DEVELOP
Browse files Browse the repository at this point in the history
2017.01.04 release
  • Loading branch information
BobPalmer authored Jan 5, 2017
2 parents 7aba970 + e8473c3 commit 12b2cc5
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 47 deletions.
4 changes: 4 additions & 0 deletions FOR_RELEASE/GameData/000_USITools/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.8.8 - 2017.01.01
-------------------
Dependency Updates

0.8.7 - (KSP 1.2.2)
-------------------
Updates for KSP 1.2.2
Expand Down
Binary file modified FOR_RELEASE/GameData/000_USITools/USITools.dll
Binary file not shown.
Binary file modified FOR_RELEASE/GameData/000_USITools/USITools.dll.mdb
Binary file not shown.
Binary file modified FOR_RELEASE/GameData/000_USITools/USITools.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion FOR_RELEASE/GameData/000_USITools/USITools.version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"VERSION":{
"MAJOR":0,
"MINOR":8,
"PATCH":7,
"PATCH":8,
"BUILD":0
},
"KSP_VERSION":{
Expand Down
File renamed without changes.
33 changes: 10 additions & 23 deletions USITools/USITools/Logistics/USI_ModuleDemolition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public class USI_ModuleDemolition : PartModule
unfocusedRange = 5f)]
public void ScrapPart()
{
if (!CheckCrew())
return;

_demoParts = new List<Part>();
if (part.parent != null)
{
Expand All @@ -42,8 +39,6 @@ public void ScrapPart()
unfocusedRange = 5f)]
public void ScrapSection()
{
if (!CheckCrew())
return;
_demoParts = new List<Part>();

if (part.parent != null)
Expand All @@ -61,8 +56,6 @@ public void ScrapSection()
unfocusedRange = 5f)]
public void ScrapVessel()
{
if (!CheckCrew())
return;
_demoParts = new List<Part>();
foreach (var p in vessel.parts)
{
Expand All @@ -87,31 +80,25 @@ private void AddRecursiveParts(Part part, List<Part> list)
}
}

private bool CheckCrew()
{
var kerbal = FlightGlobals.ActiveVessel.rootPart.protoModuleCrew[0];
if (kerbal.experienceTrait.Title != "Engineer")
{
ScreenMessages.PostScreenMessage("Only Engineers can disassemble parts!", 5f,
ScreenMessageStyle.UPPER_CENTER);
return false;
}
return true;
}

private List<String> _blackList = new List<string> { "PotatoRoid", "UsiExplorationRock" };
private void DestroyParts()
{
if (_demoParts == null)
return;
foreach (var part in _demoParts)
{
var res = PartResourceLibrary.Instance.GetDefinition(ResourceName);
double resAmount = part.mass / res.density * Efficiency;
if (!_blackList.Contains(part.partName))
{
var res = PartResourceLibrary.Instance.GetDefinition(ResourceName);
double resAmount = part.mass/res.density*Efficiency;
ScreenMessages.PostScreenMessage(
String.Format("You disassemble the {0} into {1:0.00} units of {2}", part.partInfo.title,
resAmount, ResourceName), 5f, ScreenMessageStyle.UPPER_CENTER);
PushResources(ResourceName, resAmount);
}
part.decouple();
part.explode();

ScreenMessages.PostScreenMessage(String.Format("You disassemble the {0} into {1:0.00} units of {2}", part.partInfo.title, resAmount, ResourceName), 5f, ScreenMessageStyle.UPPER_CENTER);
PushResources(ResourceName, resAmount);
}
}

Expand Down
21 changes: 10 additions & 11 deletions USITools/USITools/Logistics/USI_ModuleRecycleablePart.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace KolonyTools
{
public class USI_ModuleRecycleablePart : PartModule
{
//Another super hacky module.
private List<String> _blackList = new List<string> { "PotatoRoid", "UsiExplorationRock" };

[KSPField]
public float EVARange = 5f;
Expand All @@ -19,9 +21,6 @@ public class USI_ModuleRecycleablePart : PartModule
[KSPField]
public float Efficiency = 0.8f;

[KSPField]
public bool EngineerOnly = true;

[KSPEvent(active = true, guiActiveUnfocused = true, externalToEVAOnly = true, guiName = "Scrap part",
unfocusedRange = 5f)]
public void ScrapPart()
Expand All @@ -33,17 +32,17 @@ public void ScrapPart()
ScreenMessageStyle.UPPER_CENTER);
return;
}
if (EngineerOnly && kerbal.experienceTrait.Title != "Engineer")
{
ScreenMessages.PostScreenMessage("Only Engineers can disassemble parts!", 5f,
ScreenMessageStyle.UPPER_CENTER);
return;
}

var res = PartResourceLibrary.Instance.GetDefinition(ResourceName);
double resAmount = part.mass / res.density * Efficiency;

ScreenMessages.PostScreenMessage(String.Format("You disassemble the {0} into {1:0.00} units of {2}", part.name, resAmount, ResourceName), 5f, ScreenMessageStyle.UPPER_CENTER);
PushResources(ResourceName, resAmount);
if (!_blackList.Contains(part.partName))
{
ScreenMessages.PostScreenMessage(
String.Format("You disassemble the {0} into {1:0.00} units of {2}", part.name, resAmount,
ResourceName), 5f, ScreenMessageStyle.UPPER_CENTER);
PushResources(ResourceName, resAmount);
}
part.decouple();
part.explode();
}
Expand Down
56 changes: 45 additions & 11 deletions USITools/USITools/USIAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class USIAnimation : PartModule
{
private List<IAnimatedModule> _Modules;
private List<ModuleSwappableConverter> _SwapBays;
private bool _hasBeenInitialized = false;

private void FindModules()
{
Expand All @@ -21,6 +22,15 @@ private void FindModules()
}
}

[KSPField]
public string startEventGUIName = "";

[KSPField]
public string endEventGUIName = "";

[KSPField]
public string actionGUIName = "";


[KSPField] public int CrewCapacity = 0;

Expand Down Expand Up @@ -361,10 +371,12 @@ private void ToggleEvent(string eventName, bool state)
}


public override void OnStart(StartState state)
public void Initialize()
{
try
{
_hasBeenInitialized = true;
UpdatemenuNames();
FindModules();
SetupResourceCosts();
SetupDeployMenus();
Expand All @@ -377,10 +389,26 @@ public override void OnStart(StartState state)
}
catch (Exception ex)
{
print("ERROR IN USIAnimationOnStart - " + ex.Message);
print("ERROR IN USI Animation Initialize - " + ex.Message);
}
}

private void UpdatemenuNames()
{
if (startEventGUIName != "")
{
Events["DeployModule"].guiName = startEventGUIName;
Actions["DeployAction"].guiName = startEventGUIName;
}
if (endEventGUIName != "")
{
Events["RetractModule"].guiName = endEventGUIName;
Actions["RetractAction"].guiName = endEventGUIName;
}
if (actionGUIName != "")
Actions["ToggleAction"].guiName = actionGUIName;
}

private void SetupDeployMenus()
{
if (ResourceCosts != String.Empty)
Expand Down Expand Up @@ -408,6 +436,7 @@ private void DisableModules()
{
_Modules[i].DisableModule();
}
SetControlSurface(false);
}

private void EnableModules()
Expand All @@ -431,20 +460,22 @@ private void EnableModules()
mod.EnableModule();
}
}
SetControlSurface(true);
}

public override void OnLoad(ConfigNode node)
private void SetControlSurface(bool state)
{
try
{
CheckAnimationState();
}
catch (Exception ex)
{
print("ERROR IN USIAnimationOnLoad - " + ex.Message);
}
var mcs = part.FindModuleImplementing<ModuleControlSurface>();
if (mcs == null)
return;

mcs.ignorePitch = !state;
mcs.ignoreRoll = !state;
mcs.ignoreYaw = !state;
mcs.isEnabled = state;
}


private void CheckAnimationState()
{
if (part.protoModuleCrew.Count > 0)
Expand Down Expand Up @@ -517,6 +548,9 @@ private void CompressResourceCapacity()

public void FixedUpdate()
{
if(!_hasBeenInitialized)
Initialize();

if (!HighLogic.LoadedSceneIsFlight)
return;

Expand Down
2 changes: 1 addition & 1 deletion USITools/USITools/USITools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<Compile Include="AquaticModules\ModuleAquaticRCS.cs" />
<Compile Include="AquaticModules\ModuleAquaticSAS.cs" />
<Compile Include="AquaticModules\ModuleBallast.cs" />
<Compile Include="Class1.cs" />
<Compile Include="FloaterModule.cs" />
<Compile Include="LifeBoat.cs" />
<Compile Include="ConverterPart.cs" />
<Compile Include="IEfficiencyBonusConsumer.cs" />
Expand Down

0 comments on commit 12b2cc5

Please sign in to comment.