You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace ConformalDecals {
|
|
public class ModuleConformalDecal : PartModule {
|
|
[KSPField] public string decalPreviewTransform = "";
|
|
|
|
public void OnStart(StartState state) {
|
|
if ((state & StartState.Editor) != 0) {
|
|
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
|
|
}
|
|
else {
|
|
Attach();
|
|
}
|
|
}
|
|
|
|
public void OnEditorEvent(ConstructionEventType eventType, Part eventPart) {
|
|
if (eventPart != this.part) return;
|
|
switch (eventType) {
|
|
case ConstructionEventType.PartAttached:
|
|
Attach();
|
|
break;
|
|
case ConstructionEventType.PartDetached:
|
|
Detach();
|
|
break;
|
|
case ConstructionEventType.PartOffsetting:
|
|
case ConstructionEventType.PartRotated:
|
|
case ConstructionEventType.PartDragging:
|
|
Project();
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
public void Attach() {
|
|
if (part.parent == null) {
|
|
this.LogError("Attach function called but part has no parent!");
|
|
return;
|
|
}
|
|
|
|
Camera.onPreCull += Render;
|
|
}
|
|
|
|
public void Detach() {
|
|
if (part.parent != null) {
|
|
this.LogError("Detach function called but part still has parent!");
|
|
return;
|
|
}
|
|
|
|
Camera.onPreCull -= Render;
|
|
}
|
|
|
|
public void OnDisable() {
|
|
Camera.onPreCull -= Render;
|
|
}
|
|
|
|
public void Project() { }
|
|
|
|
public void Render(Camera camera) { }
|
|
}
|
|
} |