mirror of
https://github.com/PorktoberRevolution/ReStocked
synced 2024-09-01 17:34:42 +00:00
1.11 Light updates
This commit is contained in:
38
Source/Restock/ModuleRestockEnhancedLight.cs
Normal file
38
Source/Restock/ModuleRestockEnhancedLight.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Restock
|
||||
{
|
||||
public class ModuleRestockEnhancedLight: PartModule
|
||||
{
|
||||
// Path to the light cookie texture
|
||||
[KSPField]
|
||||
public string cookiePath;
|
||||
|
||||
ModuleLight[] lightModules;
|
||||
Texture2D cookie;
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
}
|
||||
public override void OnStart(StartState state)
|
||||
{
|
||||
base.OnStart(state);
|
||||
lightModules = base.GetComponentsInChildren<ModuleLight>();
|
||||
cookie = GameDatabase.Instance.GetTexture(cookiePath, false);
|
||||
cookie.wrapMode = TextureWrapMode.Clamp;
|
||||
|
||||
if (cookie == null) { this.LogError($"Couldn't find light cookie at {cookiePath}"); return; }
|
||||
|
||||
foreach (ModuleLight ml in lightModules)
|
||||
{
|
||||
foreach (Light l in ml.lights)
|
||||
{
|
||||
l.cookie = cookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user