mirror of
https://github.com/PorktoberRevolution/ReStocked
synced 2024-09-01 17:34:42 +00:00
Merge branch 'negative-space' into develop
This commit is contained in:
commit
4ac9b1d69a
@ -1 +1 @@
|
|||||||
Subproject commit 923c301f3286243fdbdc2955f6e407aadab6f2b4
|
Subproject commit e07a544f43258f6ca20819fe598739a6366d9548
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -129,6 +129,7 @@
|
|||||||
MODULE
|
MODULE
|
||||||
{
|
{
|
||||||
name = ModuleRestockDepthMask
|
name = ModuleRestockDepthMask
|
||||||
|
shaderName = Depth Mask
|
||||||
maskTransform = radialintake_mask
|
maskTransform = radialintake_mask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
@ -25,8 +26,8 @@ namespace Restock
|
|||||||
public int maskRenderQueue = 1999;
|
public int maskRenderQueue = 1999;
|
||||||
|
|
||||||
|
|
||||||
// depth mask object transform
|
// depth mask object transforms
|
||||||
public Transform maskTransformObject;
|
public Transform[] maskTransformObjects;
|
||||||
|
|
||||||
// body object transform
|
// body object transform
|
||||||
public Transform bodyTransformObject;
|
public Transform bodyTransformObject;
|
||||||
@ -38,7 +39,7 @@ namespace Restock
|
|||||||
public override void OnStart(StartState state)
|
public override void OnStart(StartState state)
|
||||||
{
|
{
|
||||||
base.OnStart(state);
|
base.OnStart(state);
|
||||||
UpdatematerialQueue();
|
UpdateAllMaterials();
|
||||||
|
|
||||||
// the part variant system is implemented extremely stupidly
|
// the part variant system is implemented extremely stupidly
|
||||||
// so we have to make this whole module more complicated as a result
|
// so we have to make this whole module more complicated as a result
|
||||||
@ -58,14 +59,14 @@ namespace Restock
|
|||||||
|
|
||||||
if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) return;
|
if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) return;
|
||||||
|
|
||||||
this.maskTransformObject = base.part.FindModelTransform(maskTransform);
|
this.maskTransformObjects = base.part.FindModelTransforms(maskTransform);
|
||||||
if (this.maskTransformObject == null)
|
if (this.maskTransformObjects.Length == 0 || this.maskTransformObjects == null)
|
||||||
{
|
{
|
||||||
this.LogError($"Can't find transform {maskTransform}");
|
this.LogError($"Can't find transform {maskTransform}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bodyTransform == "")
|
if (bodyTransform.Length == 0)
|
||||||
{
|
{
|
||||||
this.bodyTransformObject = base.part.partTransform;
|
this.bodyTransformObject = base.part.partTransform;
|
||||||
}
|
}
|
||||||
@ -91,34 +92,27 @@ namespace Restock
|
|||||||
public void OnVariantApplied(Part appliedPart, PartVariant variant)
|
public void OnVariantApplied(Part appliedPart, PartVariant variant)
|
||||||
{
|
{
|
||||||
// I dont know why changing part variants resets all the materials to their as-loaded state, but it does
|
// I dont know why changing part variants resets all the materials to their as-loaded state, but it does
|
||||||
if (appliedPart == this.part) UpdatematerialQueue();
|
if (appliedPart == this.part) UpdateAllMaterials();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void UpdatematerialQueue()
|
private void UpdateAllMaterials()
|
||||||
{
|
{
|
||||||
var windowRenderer = maskTransformObject.GetComponent<MeshRenderer>();
|
var renderers = bodyTransformObject.GetComponentsInChildren<Renderer>(true);
|
||||||
|
|
||||||
windowRenderer.material.shader = depthShader;
|
foreach (var renderer in renderers)
|
||||||
windowRenderer.material.renderQueue = maskRenderQueue;
|
|
||||||
|
|
||||||
var meshRenderers = bodyTransformObject.GetComponentsInChildren<MeshRenderer>(true);
|
|
||||||
var skinnedMeshRenderers = bodyTransformObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
|
||||||
|
|
||||||
foreach (var renderer in meshRenderers)
|
|
||||||
{
|
{
|
||||||
if (renderer == windowRenderer) continue;
|
|
||||||
var queue = renderer.material.renderQueue;
|
var queue = renderer.material.renderQueue;
|
||||||
|
if (queue <= maskRenderQueue) continue;
|
||||||
queue = meshRenderQueue + ((queue - 2000) / 2);
|
queue = meshRenderQueue + ((queue - 2000) / 2);
|
||||||
renderer.material.renderQueue = queue;
|
renderer.material.renderQueue = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var renderer in skinnedMeshRenderers)
|
foreach (var maskObject in maskTransformObjects)
|
||||||
{
|
{
|
||||||
if (renderer == windowRenderer) continue;
|
var renderer = maskObject.GetComponent<Renderer>();
|
||||||
var queue = renderer.material.renderQueue;
|
renderer.material.shader = depthShader;
|
||||||
queue = meshRenderQueue + ((queue - 2000) / 2);
|
renderer.material.renderQueue = maskRenderQueue;
|
||||||
renderer.material.renderQueue = queue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user