mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Global override for selectability and kill part on detach
This commit is contained in:
parent
5db788ed37
commit
4cdfac8ccd
Binary file not shown.
@ -1,4 +1,7 @@
|
|||||||
CONFORMALDECALS {
|
CONFORMALDECALS {
|
||||||
|
decalLayer = 31
|
||||||
|
selectableInFlight = false
|
||||||
|
|
||||||
SHADERBLACKLIST {
|
SHADERBLACKLIST {
|
||||||
shader = DepthMask
|
shader = DepthMask
|
||||||
shader = KSP/Alpha/Cutoff
|
shader = KSP/Alpha/Cutoff
|
||||||
|
@ -7,10 +7,14 @@ namespace ConformalDecals {
|
|||||||
private static Texture2D _blankNormal;
|
private static Texture2D _blankNormal;
|
||||||
private static List<string> _shaderBlacklist;
|
private static List<string> _shaderBlacklist;
|
||||||
private static int _decalLayer = 31;
|
private static int _decalLayer = 31;
|
||||||
|
private static bool _selectableInFlight = false;
|
||||||
|
|
||||||
public static Texture2D BlankNormal => _blankNormal;
|
public static Texture2D BlankNormal => _blankNormal;
|
||||||
|
|
||||||
public static int DecalLayer => _decalLayer;
|
public static int DecalLayer => _decalLayer;
|
||||||
|
|
||||||
|
public static bool SelectableInFlight => _selectableInFlight;
|
||||||
|
|
||||||
public static bool IsBlacklisted(Shader shader) {
|
public static bool IsBlacklisted(Shader shader) {
|
||||||
return IsBlacklisted(shader.name);
|
return IsBlacklisted(shader.name);
|
||||||
}
|
}
|
||||||
@ -26,6 +30,7 @@ namespace ConformalDecals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ParseUtil.ParseIntIndirect(ref _decalLayer, node, "decalLayer");
|
ParseUtil.ParseIntIndirect(ref _decalLayer, node, "decalLayer");
|
||||||
|
ParseUtil.ParseBoolIndirect(ref _selectableInFlight, node, "selectableInFlight");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,13 +237,7 @@ namespace ConformalDecals {
|
|||||||
public override void OnStart(StartState state) {
|
public override void OnStart(StartState state) {
|
||||||
this.Log("Starting module");
|
this.Log("Starting module");
|
||||||
|
|
||||||
// handle tweakables
|
|
||||||
if (HighLogic.LoadedSceneIsEditor) {
|
|
||||||
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
|
|
||||||
GameEvents.onVariantApplied.Add(OnVariantApplied);
|
|
||||||
|
|
||||||
UpdateTweakables();
|
|
||||||
}
|
|
||||||
|
|
||||||
materialProperties.RenderQueue = DecalQueue;
|
materialProperties.RenderQueue = DecalQueue;
|
||||||
|
|
||||||
@ -261,19 +255,39 @@ namespace ConformalDecals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle tweakables
|
||||||
|
if (HighLogic.LoadedSceneIsEditor) {
|
||||||
|
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
|
||||||
|
GameEvents.onVariantApplied.Add(OnVariantApplied);
|
||||||
|
|
||||||
|
UpdateTweakables();
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle flight events
|
||||||
if (HighLogic.LoadedSceneIsFlight) {
|
if (HighLogic.LoadedSceneIsFlight) {
|
||||||
|
GameEvents.onPartWillDie.Add(OnPartWillDie);
|
||||||
|
|
||||||
Part.layerMask |= 1 << DecalConfig.DecalLayer;
|
Part.layerMask |= 1 << DecalConfig.DecalLayer;
|
||||||
decalColliderTransform.gameObject.layer = DecalConfig.DecalLayer;
|
decalColliderTransform.gameObject.layer = DecalConfig.DecalLayer;
|
||||||
if (!selectableInFlight) {
|
|
||||||
|
if (!selectableInFlight || !DecalConfig.SelectableInFlight) {
|
||||||
decalColliderTransform.GetComponent<Collider>().enabled = false;
|
decalColliderTransform.GetComponent<Collider>().enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (part.parent == null) part.explode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnDestroy() {
|
public virtual void OnDestroy() {
|
||||||
// remove GameEvents
|
// remove GameEvents
|
||||||
|
if (HighLogic.LoadedSceneIsEditor) {
|
||||||
GameEvents.onEditorPartEvent.Remove(OnEditorEvent);
|
GameEvents.onEditorPartEvent.Remove(OnEditorEvent);
|
||||||
GameEvents.onVariantApplied.Remove(OnVariantApplied);
|
GameEvents.onVariantApplied.Remove(OnVariantApplied);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HighLogic.LoadedSceneIsFlight) {
|
||||||
|
GameEvents.onPartWillDie.Remove(OnPartWillDie);
|
||||||
|
}
|
||||||
|
|
||||||
// remove from preCull delegate
|
// remove from preCull delegate
|
||||||
Camera.onPreCull -= Render;
|
Camera.onPreCull -= Render;
|
||||||
@ -332,6 +346,13 @@ namespace ConformalDecals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void OnPartWillDie(Part willDie) {
|
||||||
|
if (willDie == part.parent) {
|
||||||
|
this.Log("Parent part about to be destroyed! Killing decal part.");
|
||||||
|
part.Die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void OnAttach() {
|
protected void OnAttach() {
|
||||||
if (part.parent == null) {
|
if (part.parent == null) {
|
||||||
this.LogError("Attach function called but part has no parent!");
|
this.LogError("Attach function called but part has no parent!");
|
||||||
|
Loading…
Reference in New Issue
Block a user