-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
225 additions
and
10 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"VERSION": | ||
{ | ||
"MAJOR":1, | ||
"MINOR":88, | ||
"MINOR":89, | ||
"PATCH":2 | ||
}, | ||
"KSP_VERSION_MIN": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ | |
"VERSION": | ||
{ | ||
"MAJOR":1, | ||
"MINOR":88, | ||
"PATCH":2 | ||
"MINOR":90, | ||
"PATCH":0 | ||
}, | ||
"KSP_VERSION_MIN": | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.