Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel-125 committed Mar 9, 2024
1 parent b57122c commit cb742f6
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 10 deletions.
Binary file modified .vs/WildBlueTools/v16/.suo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"VERSION":
{
"MAJOR":1,
"MINOR":88,
"MINOR":89,
"PATCH":2
},
"KSP_VERSION_MIN":
Expand Down
19 changes: 19 additions & 0 deletions GoldStrike/WBIGoldStrikeDrill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ public bool UpdateLode()
return true;
}

protected override void setupHarvester()
{
base.setupHarvester();

//Make sure our lode is up to date
UpdateLode();

if (nearestLode != null && outputDef != null)
{
StringBuilder outputInfo = new StringBuilder();
outputInfo.AppendLine(infoView.ModuleInfo);
outputInfo.AppendLine("<color=white><b--- Prospecting ---</b></color>");
outputInfo.AppendLine("<color=white><b>Resource: </b>" + outputDef.displayName + "</color>");
outputInfo.AppendLine("<color=white><b>Remaining: </b>" + string.Format("{0:n2}", nearestLode.amountRemaining) + "u</color>");

infoView.ModuleInfo = outputInfo.ToString();
}
}

protected void findNearestLode()
{
int planetID;
Expand Down
4 changes: 2 additions & 2 deletions Notes/WildBlueTools.version
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"VERSION":
{
"MAJOR":1,
"MINOR":88,
"PATCH":2
"MINOR":90,
"PATCH":0
},
"KSP_VERSION_MIN":
{
Expand Down
2 changes: 1 addition & 1 deletion Omni/WBIModuleResourceHarvester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public string GetMinedResources()
return infoView.ModuleInfo;
}

protected void setupHarvester()
protected virtual void setupHarvester()
{
if (!HighLogic.LoadedSceneIsFlight)
return;
Expand Down
2 changes: 1 addition & 1 deletion Omni/WBIOmniConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ protected virtual void setupConverterTemplate()
bool.TryParse(currentTemplate.GetValue("requiresOrbiting"), out requiresOrbiting);

//Efficiency
EfficiencyBonus *= BaseEfficiency;
EfficiencyBonus = BaseEfficiency;

//Clear existing lists
inputList.Clear();
Expand Down
130 changes: 130 additions & 0 deletions Parts/WBIModuleBloakingDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP.IO;

namespace WildBlueIndustries
{
[KSPModule("Bloaking Device")]
public class WBIModuleBloakingDevice : PartModule
{
[KSPField()]
public bool debugMode = true;

[KSPField(guiName = "Bloaking Device", isPersistant = true, guiActive = true, guiActiveEditor = false)]
[UI_Toggle(enabledText = "Bloaked!", disabledText = "Un-Bloaked!")]
public bool isBloaking;

[KSPField(guiName = "Bloak Level", isPersistant = true, guiActive = true, guiActiveEditor = false)]
[UI_FloatRange(stepIncrement = 0.5f, maxValue = 100f, minValue = 0.0f)]
public float bloakLevel = 50f;

[KSPField()]
private float prevBloakLevel;

[KSPField()]
private int prevVesselPartCount;

[KSPField()]
private bool wasBloaking;

public override void OnStart(StartState state)
{
base.OnStart(state);
if (!HighLogic.LoadedSceneIsFlight)
return;

// Get the list of parts in the vessel
prevBloakLevel = bloakLevel;
prevVesselPartCount = part.vessel.parts.Count;
wasBloaking = isBloaking;

// Debug UI
Fields["wasBloaking"].guiActive = debugMode;
Fields["prevVesselPartCount"].guiActive = debugMode;
Fields["prevBloakLevel"].guiActive = debugMode;

UpdateOpacity();
}

public void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight)
return;

// Check bloak status change
if (isBloaking != wasBloaking)
{
wasBloaking = isBloaking;
UpdateOpacity();
if (isBloaking)
{
ScreenMessages.PostScreenMessage("Bloaked!", 5.0f, ScreenMessageStyle.UPPER_LEFT);
}
else
{
ScreenMessages.PostScreenMessage("Un-Bloaked!", 5.0f, ScreenMessageStyle.UPPER_LEFT);
}
}

// If we aren't bloaking then return
if (!isBloaking)
{
return;
}

// Check E.C.
if (!ConsumeResources())
{
isBloaking = false;
wasBloaking = false;
UpdateOpacity();
ScreenMessages.PostScreenMessage("Un-Bloaked!", 5.0f, ScreenMessageStyle.UPPER_LEFT);
return;
}

// Check changes in bloak level
if (!bloakLevel.Equals(prevBloakLevel) || part.vessel.parts.Count != prevVesselPartCount)
{
prevVesselPartCount = part.vessel.parts.Count;
prevBloakLevel = bloakLevel;
UpdateOpacity();
}
}

[KSPAction("Toggle Bloak", KSPActionGroup.None)]
public void ToggleLightsAction(KSPActionParam param)
{
isBloaking = !isBloaking;
}

public bool ConsumeResources()
{
string errorStatus = string.Empty;
int count = resHandler.inputResources.Count;
float rateMultiplier = part.vessel.parts.Count * (1 - (bloakLevel / 100.0f));

resHandler.UpdateModuleResourceInputs(ref errorStatus, rateMultiplier, 0.1, true, true);
for (int index = 0; index < count; index++)
{
if (!resHandler.inputResources[index].available)
return false;
}

return true;
}

public void UpdateOpacity()
{
float opacity = isBloaking ? (bloakLevel / 100.0f) : 1.0f;
int count = part.vessel.parts.Count;

foreach (Part vesselPart in part.vessel.parts)
{
vesselPart.SetOpacity(opacity);
}
}
}
}
3 changes: 2 additions & 1 deletion Switchers/WBIResourceSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,8 @@ public float GetModuleMass(float defaultMass, ModifierStagingSituation sit)
{
double test = part.partInfo.partPrefab.mass;
currentMass = part.mass;
return CalculatePartMass(defaultMass);
float moduleMass = CalculatePartMass(defaultMass);
return moduleMass;
}

public ModifierChangeWhen GetModuleMassChangeWhen()
Expand Down
2 changes: 0 additions & 2 deletions Utilities/WBIModuleUpdateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight || harvester == null)
return;

Debug.Log("[WBIModuleUpdateHelper] - FixedUpdate called.");
}
}
}
51 changes: 51 additions & 0 deletions WBIModuleHelmetToggle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP.IO;
using KSP.Localization;

namespace WildBlueIndustries
{
public class WBIModuleHelmetToggle: PartModule
{
public KerbalEVA kerbalEVA;

[KSPEvent(guiActive = true, guiName = "Acting! Toggle Helmet")]
public void ToggleHelmet()
{
bool helmetVisible = kerbalEVA.helmetTransform.gameObject.activeSelf;
helmetVisible = !helmetVisible;

setupSuitMeshes(helmetVisible);

}

public override void OnStart(StartState state)
{
base.OnStart(state);
kerbalEVA = this.part.vessel.FindPartModuleImplementing<KerbalEVA>();
}

void setupSuitMeshes(bool isVisible)
{
Collider collider;

//Toggle helmet
kerbalEVA.helmetTransform.gameObject.SetActive(isVisible);
collider = kerbalEVA.helmetTransform.gameObject.GetComponent<Collider>();
if (collider != null)
collider.enabled = isVisible;

//Toggle neck ring
kerbalEVA.neckRingTransform.gameObject.SetActive(isVisible);
collider = kerbalEVA.neckRingTransform.gameObject.GetComponent<Collider>();
if (collider != null)
collider.enabled = isVisible;

//Fire event
GameEvents.OnHelmetChanged.Fire(kerbalEVA, isVisible, isVisible);
}
}
}
2 changes: 2 additions & 0 deletions WildBlueTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
<Compile Include="Utilities\WBIComponentAdder.cs" />
<Compile Include="Utilities\WBIEngineHeat.cs" />
<Compile Include="Utilities\WBIModuleUpdateHelper.cs" />
<Compile Include="Parts\WBIModuleBloakingDevice.cs" />
<Compile Include="WBIModuleHelmetToggle.cs" />
<Compile Include="Wrappers\KIS\WBIKISInventoryManager.cs" />
<Compile Include="Parts\WBIModuleAsteroidResource.cs" />
<Compile Include="PlayModes\PlayModesWindow.cs" />
Expand Down
18 changes: 16 additions & 2 deletions WildBlueTools.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
# Visual Studio Version 16
VisualStudioVersion = 16.0.33529.622
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WildBlueTools", "WildBlueTools.csproj", "{CC0BDF1A-9641-4628-9F0F-3500DDC99534}"
EndProject
Expand Down Expand Up @@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EVARepairs", "..\EVARepairs
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WildBlueCore", "..\WildBlueCore\source\WildBlueCore\WildBlueCore.csproj", "{7D8D783F-DDA6-4C96-BF65-8905FAB07CB5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepStore", "..\DeepStore\source\DeepStore\DeepStore.csproj", "{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -271,6 +273,18 @@ Global
{7D8D783F-DDA6-4C96-BF65-8905FAB07CB5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7D8D783F-DDA6-4C96-BF65-8905FAB07CB5}.Release|x86.ActiveCfg = Release|Any CPU
{7D8D783F-DDA6-4C96-BF65-8905FAB07CB5}.Release|x86.Build.0 = Release|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Debug|x86.ActiveCfg = Debug|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Debug|x86.Build.0 = Debug|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Release|Any CPU.Build.0 = Release|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Release|x86.ActiveCfg = Release|Any CPU
{CC7FDE93-91D6-4F68-A0ED-A5CBDF94B823}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file modified bin/Debug/Assembly-CSharp-firstpass.dll
Binary file not shown.
Binary file modified bin/Debug/Assembly-CSharp.dll
Binary file not shown.
Binary file modified bin/Debug/Unity.Analytics.DataPrivacy.dll
Binary file not shown.
Binary file modified bin/Debug/UnityEngine.UI.dll
Binary file not shown.
Binary file modified bin/Debug/WildBlueTools.dll
Binary file not shown.
Binary file modified bin/Debug/WildBlueTools.pdb
Binary file not shown.

0 comments on commit cb742f6

Please sign in to comment.