Fix projecting onto parts using B9PS

This commit is contained in:
Andrew Cassidy 2020-06-29 18:41:46 -07:00
parent d557df49fa
commit 261da9194b
2 changed files with 14 additions and 12 deletions

View File

@ -237,14 +237,23 @@ namespace ConformalDecals {
public override void OnStart(StartState state) { public override void OnStart(StartState state) {
this.Log("Starting module"); this.Log("Starting module");
materialProperties.RenderQueue = DecalQueue; materialProperties.RenderQueue = DecalQueue;
_boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>(); _boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>();
UpdateMaterials(); UpdateMaterials();
// handle tweakables
if (HighLogic.LoadedSceneIsEditor) {
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
GameEvents.onVariantApplied.Add(OnVariantApplied);
UpdateTweakables();
}
}
public override void OnStartFinished(StartState state) {
// handle game events
if (HighLogic.LoadedSceneIsGame) { if (HighLogic.LoadedSceneIsGame) {
// set initial attachment state // set initial attachment state
if (part.parent == null) { if (part.parent == null) {
@ -254,27 +263,20 @@ namespace ConformalDecals {
OnAttach(); OnAttach();
} }
} }
// handle tweakables
if (HighLogic.LoadedSceneIsEditor) {
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
GameEvents.onVariantApplied.Add(OnVariantApplied);
UpdateTweakables();
}
// handle flight events // handle flight events
if (HighLogic.LoadedSceneIsFlight) { if (HighLogic.LoadedSceneIsFlight) {
GameEvents.onPartWillDie.Add(OnPartWillDie); GameEvents.onPartWillDie.Add(OnPartWillDie);
if (part.parent == null) part.explode();
Part.layerMask |= 1 << DecalConfig.DecalLayer; Part.layerMask |= 1 << DecalConfig.DecalLayer;
decalColliderTransform.gameObject.layer = DecalConfig.DecalLayer; decalColliderTransform.gameObject.layer = DecalConfig.DecalLayer;
if (!selectableInFlight || !DecalConfig.SelectableInFlight) { if (!selectableInFlight || !DecalConfig.SelectableInFlight) {
decalColliderTransform.GetComponent<Collider>().enabled = false; decalColliderTransform.GetComponent<Collider>().enabled = false;
_boundsRenderer.enabled = false;
} }
if (part.parent == null) part.explode();
} }
} }