Major refactor, splitting ModuleConformalDecal
parent
5652f0dda1
commit
6a5604911d
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using ConformalDecals.MaterialModifiers;
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public class ModuleConformalDecalFlag : ModuleConformalDecalBase {
|
||||
|
||||
[KSPField]
|
||||
private MaterialTextureProperty _flagTextureProperty;
|
||||
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
base.OnLoad(node);
|
||||
|
||||
_flagTextureProperty = new MaterialTextureProperty("_MainTex", Texture2D.whiteTexture);
|
||||
materialProperties.AddProperty(_flagTextureProperty);
|
||||
}
|
||||
|
||||
public override void OnStart(StartState state) {
|
||||
base.OnStart(state);
|
||||
|
||||
UpdateFlag(EditorLogic.FlagURL != string.Empty ? EditorLogic.FlagURL : HighLogic.CurrentGame.flagURL);
|
||||
GameEvents.onMissionFlagSelect.Add(UpdateFlag);
|
||||
}
|
||||
|
||||
private void UpdateFlag(string flagUrl) {
|
||||
_flagTextureProperty.texture = GameDatabase.Instance.GetTexture(flagUrl, false);
|
||||
|
||||
materialProperties.UpdateMaterials();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using ConformalDecals.MaterialModifiers;
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public class ModuleConformalDecalGeneric : ModuleConformalDecalBase {
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
base.OnLoad(node);
|
||||
|
||||
// add texture nodes
|
||||
foreach (var textureNode in node.GetNodes("TEXTURE")) {
|
||||
materialProperties.AddProperty(new MaterialTextureProperty(textureNode));
|
||||
}
|
||||
|
||||
// add float nodes
|
||||
foreach (var floatNode in node.GetNodes("FLOAT")) {
|
||||
materialProperties.AddProperty(new MaterialFloatProperty(floatNode));
|
||||
}
|
||||
|
||||
// add color nodes
|
||||
foreach (var colorNode in node.GetNodes("COLOR")) {
|
||||
materialProperties.AddProperty(new MaterialColorProperty(colorNode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue