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
|
||||
{
|
||||
name = ModuleRestockDepthMask
|
||||
shaderName = Depth Mask
|
||||
maskTransform = radialintake_mask
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
@ -25,8 +26,8 @@ namespace Restock
|
||||
public int maskRenderQueue = 1999;
|
||||
|
||||
|
||||
// depth mask object transform
|
||||
public Transform maskTransformObject;
|
||||
// depth mask object transforms
|
||||
public Transform[] maskTransformObjects;
|
||||
|
||||
// body object transform
|
||||
public Transform bodyTransformObject;
|
||||
@ -38,7 +39,7 @@ namespace Restock
|
||||
public override void OnStart(StartState state)
|
||||
{
|
||||
base.OnStart(state);
|
||||
UpdatematerialQueue();
|
||||
UpdateAllMaterials();
|
||||
|
||||
// the part variant system is implemented extremely stupidly
|
||||
// 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;
|
||||
|
||||
this.maskTransformObject = base.part.FindModelTransform(maskTransform);
|
||||
if (this.maskTransformObject == null)
|
||||
this.maskTransformObjects = base.part.FindModelTransforms(maskTransform);
|
||||
if (this.maskTransformObjects.Length == 0 || this.maskTransformObjects == null)
|
||||
{
|
||||
this.LogError($"Can't find transform {maskTransform}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bodyTransform == "")
|
||||
if (bodyTransform.Length == 0)
|
||||
{
|
||||
this.bodyTransformObject = base.part.partTransform;
|
||||
}
|
||||
@ -91,34 +92,27 @@ namespace Restock
|
||||
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
|
||||
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;
|
||||
windowRenderer.material.renderQueue = maskRenderQueue;
|
||||
|
||||
var meshRenderers = bodyTransformObject.GetComponentsInChildren<MeshRenderer>(true);
|
||||
var skinnedMeshRenderers = bodyTransformObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
|
||||
foreach (var renderer in meshRenderers)
|
||||
foreach (var renderer in renderers)
|
||||
{
|
||||
if (renderer == windowRenderer) continue;
|
||||
var queue = renderer.material.renderQueue;
|
||||
if (queue <= maskRenderQueue) continue;
|
||||
queue = meshRenderQueue + ((queue - 2000) / 2);
|
||||
renderer.material.renderQueue = queue;
|
||||
}
|
||||
|
||||
foreach (var renderer in skinnedMeshRenderers)
|
||||
foreach (var maskObject in maskTransformObjects)
|
||||
{
|
||||
if (renderer == windowRenderer) continue;
|
||||
var queue = renderer.material.renderQueue;
|
||||
queue = meshRenderQueue + ((queue - 2000) / 2);
|
||||
renderer.material.renderQueue = queue;
|
||||
var renderer = maskObject.GetComponent<Renderer>();
|
||||
renderer.material.shader = depthShader;
|
||||
renderer.material.renderQueue = maskRenderQueue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user