mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
added missing rulesets to bramble dimensions
This commit is contained in:
parent
f13ea1581b
commit
e45dee5e61
@ -1,3 +1,4 @@
|
|||||||
|
using HarmonyLib;
|
||||||
using NewHorizons.Builder.Props;
|
using NewHorizons.Builder.Props;
|
||||||
using NewHorizons.Components.Orbital;
|
using NewHorizons.Components.Orbital;
|
||||||
using NewHorizons.Handlers;
|
using NewHorizons.Handlers;
|
||||||
@ -5,9 +6,130 @@ using NewHorizons.Utility;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Body
|
namespace NewHorizons.Builder.Body
|
||||||
{
|
{
|
||||||
|
[HarmonyPatch]
|
||||||
|
static class Patch
|
||||||
|
{
|
||||||
|
// SkinnedMeshRenderer.SetBlendShapeWeight
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(PlayerFogWarpDetector), nameof(PlayerFogWarpDetector.LateUpdate))]
|
||||||
|
public static bool LateUpdate(PlayerFogWarpDetector __instance)
|
||||||
|
{
|
||||||
|
// if (PlanetaryFogController.GetActiveFogSphere() == null)
|
||||||
|
//{
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
float num = __instance._targetFogFraction;
|
||||||
|
if (PlayerState.IsInsideShip())
|
||||||
|
{
|
||||||
|
num = Mathf.Max(__instance._shipFogDetector.GetTargetFogFraction(), num);
|
||||||
|
}
|
||||||
|
if (num < __instance._fogFraction)
|
||||||
|
{
|
||||||
|
float num2 = (__instance._closestFogWarp.UseFastFogFade() ? 1f : 0.2f);
|
||||||
|
__instance._fogFraction = Mathf.MoveTowards(__instance._fogFraction, num, Time.deltaTime * num2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__instance._fogFraction = num;
|
||||||
|
}
|
||||||
|
if (__instance._targetFogColorWarpVolume != __instance._closestFogWarp)
|
||||||
|
{
|
||||||
|
__instance._targetFogColorWarpVolume = __instance._closestFogWarp;
|
||||||
|
__instance._startColorCrossfadeTime = Time.time;
|
||||||
|
__instance._startCrossfadeColor = __instance._fogColor;
|
||||||
|
}
|
||||||
|
if (__instance._targetFogColorWarpVolume != null)
|
||||||
|
{
|
||||||
|
Color fogColor = __instance._targetFogColorWarpVolume.GetFogColor();
|
||||||
|
if (__instance._fogFraction <= 0f)
|
||||||
|
{
|
||||||
|
__instance._fogColor = fogColor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float t = Mathf.InverseLerp(__instance._startColorCrossfadeTime, __instance._startColorCrossfadeTime + 1f, Time.time);
|
||||||
|
__instance._fogColor = Color.Lerp(__instance._startCrossfadeColor, fogColor, t);
|
||||||
|
}
|
||||||
|
__instance._fogColor = new Color(__instance._fogColor.r, __instance._fogColor.g, __instance._fogColor.b);
|
||||||
|
}
|
||||||
|
if (__instance._playerEffectBubbleController != null)
|
||||||
|
{
|
||||||
|
__instance._playerEffectBubbleController.SetFogFade(__instance._fogFraction, __instance._fogColor);
|
||||||
|
}
|
||||||
|
if (__instance._shipLandingCamEffectBubbleController != null)
|
||||||
|
{
|
||||||
|
__instance._shipLandingCamEffectBubbleController.SetFogFade(__instance._fogFraction, __instance._fogColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FogWarpBubbleController.SetFogFade
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(FogWarpEffectBubbleController), nameof(FogWarpEffectBubbleController.SetFogFade))]
|
||||||
|
public static bool FogWarpBubbleController_SetFogFade(FogWarpEffectBubbleController __instance, float fogAlpha, Color fogColor)
|
||||||
|
{
|
||||||
|
if (__instance._effectBubbleRenderer.sharedMaterial != null)
|
||||||
|
{
|
||||||
|
Color value = fogColor;
|
||||||
|
value.a = fogAlpha;
|
||||||
|
__instance._matPropBlock.SetColor(__instance._propID_Color, value);
|
||||||
|
__instance._effectBubbleRenderer.SetPropertyBlock(__instance._matPropBlock);
|
||||||
|
}
|
||||||
|
__instance._visible = __instance._effectBubbleRenderer.sharedMaterial != null && fogAlpha > 0f;
|
||||||
|
if (__instance._targetCamera == null)
|
||||||
|
{
|
||||||
|
__instance._effectBubbleRenderer.enabled = __instance._visible;
|
||||||
|
Logger.Log($"Setting camera effect renderer to {__instance._visible}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logger.Log($"{__instance.gameObject.transform.GetPath()} _visible: {__instance._visible} set alpha to {fogAlpha} and set color ot {fogColor}");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// note: I would just make this a one line postfix function, but CheckWarpProximity() does extra stuff that we really don't want to run twice
|
||||||
|
// so we have to completely override this function to support scaling ;-;
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(FogWarpDetector), nameof(FogWarpDetector.FixedUpdate))]
|
||||||
|
public static void FixedUpdate(FogWarpDetector __instance)
|
||||||
|
{
|
||||||
|
__instance._targetFogFraction = 0f;
|
||||||
|
__instance._closestFogWarp = null;
|
||||||
|
float num = float.PositiveInfinity;
|
||||||
|
for (int i = 0; i < __instance._warpVolumes.Count; i++)
|
||||||
|
{
|
||||||
|
if (!__instance._warpVolumes[i].IsProbeOnly() || __instance._name == FogWarpDetector.Name.Probe)
|
||||||
|
{
|
||||||
|
FogWarpVolume fogWarpVolume = __instance._warpVolumes[i];
|
||||||
|
float num2 = Mathf.Abs(fogWarpVolume.CheckWarpProximity(__instance));
|
||||||
|
float b = Mathf.Clamp01(1f - Mathf.Abs(num2) / fogWarpVolume.GetFogThickness());
|
||||||
|
__instance._targetFogFraction = Mathf.Max(__instance._targetFogFraction, b);
|
||||||
|
if (num2 < num)
|
||||||
|
{
|
||||||
|
num = num2;
|
||||||
|
__instance._closestFogWarp = fogWarpVolume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: in order to fix fog screen effect for scaling nodes, I need to replace all InnerFogWarpVolume and OuterFogWarpVolume instances with NHInner/OuterFogWarpVolume and on those two classes, implement GetFogThickness(){ return 50*scale; }}
|
||||||
|
// TODO: StreamingHandler.SetUpStreaming() for all FogWarpEffectBubbleController objects
|
||||||
|
// TODO: add the "don't see me" effect
|
||||||
|
|
||||||
|
|
||||||
|
// Patch PlayerFogWarpDetector.LateUpdate to figure out why the screen fog isn't working
|
||||||
|
|
||||||
|
// try FogWarpBubbleController.SetFogFade?
|
||||||
|
|
||||||
public static class BrambleDimensionBuilder
|
public static class BrambleDimensionBuilder
|
||||||
{
|
{
|
||||||
public static readonly float BASE_DIMENSION_RADIUS = 1705f;
|
public static readonly float BASE_DIMENSION_RADIUS = 1705f;
|
||||||
@ -72,6 +194,29 @@ namespace NewHorizons.Builder.Body
|
|||||||
repelVolume.transform.parent = sector.transform;
|
repelVolume.transform.parent = sector.transform;
|
||||||
repelVolume.transform.localPosition = Vector3.zero;
|
repelVolume.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
// Set up rulesets
|
||||||
|
var sectorTriggerVolume = sector.gameObject.GetComponent<OWTriggerVolume>();
|
||||||
|
|
||||||
|
var thrustRuleset = sector.gameObject.AddComponent<ThrustRuleset>();
|
||||||
|
thrustRuleset._attachedBody = owRigidBody;
|
||||||
|
thrustRuleset._triggerVolume = sectorTriggerVolume;
|
||||||
|
thrustRuleset._nerfDuration = 0.5f;
|
||||||
|
thrustRuleset._nerfJetpackBooster = false;
|
||||||
|
thrustRuleset._thrustLimit = 20;
|
||||||
|
|
||||||
|
var effectRuleset = sector.gameObject.AddComponent<EffectRuleset>();
|
||||||
|
effectRuleset._attachedBody = owRigidBody;
|
||||||
|
effectRuleset._triggerVolume = sectorTriggerVolume;
|
||||||
|
effectRuleset._type = EffectRuleset.BubbleType.FogWarp;
|
||||||
|
effectRuleset._underwaterDistortScale = 0.001f;
|
||||||
|
effectRuleset._underwaterMaxDistort = 0.1f;
|
||||||
|
effectRuleset._underwaterMinDistort = 0.005f;
|
||||||
|
effectRuleset._material = GameObject.Find("DB_PioneerDimension_Body/Sector_PioneerDimension").GetComponent<EffectRuleset>()._material; // TODO: cache this
|
||||||
|
|
||||||
|
var antiTravelMusicRuleset = sector.gameObject.AddComponent<AntiTravelMusicRuleset>();
|
||||||
|
antiTravelMusicRuleset._attachedBody = owRigidBody;
|
||||||
|
antiTravelMusicRuleset._triggerVolume = sectorTriggerVolume;
|
||||||
|
|
||||||
// Set up warps
|
// Set up warps
|
||||||
var outerFogWarpVolume = exitWarps.GetComponent<OuterFogWarpVolume>();
|
var outerFogWarpVolume = exitWarps.GetComponent<OuterFogWarpVolume>();
|
||||||
outerFogWarpVolume._senderWarps = new List<InnerFogWarpVolume>();
|
outerFogWarpVolume._senderWarps = new List<InnerFogWarpVolume>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user