Skip to content

Commit a7c2665

Browse files
2 parents 4a9695e + 9f6d634 commit a7c2665

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1475
-0
lines changed

TheRumbling/.idea/.idea.TheRumbling/.idea/workspace.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WeatherMod/.idea/.idea.WeatherMod/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WeatherMod/.idea/.idea.WeatherMod/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WeatherMod/.idea/.idea.WeatherMod/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WeatherMod/.idea/.idea.WeatherMod/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WeatherMod/WeatherMod.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherMod", "WeatherMod\WeatherMod.csproj", "{60BC6375-225F-40FD-9504-FA07A0C083A4}"
4+
EndProject
5+
Global
6+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7+
Debug|Any CPU = Debug|Any CPU
8+
Release|Any CPU = Release|Any CPU
9+
EndGlobalSection
10+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
11+
{60BC6375-225F-40FD-9504-FA07A0C083A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
12+
{60BC6375-225F-40FD-9504-FA07A0C083A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
13+
{60BC6375-225F-40FD-9504-FA07A0C083A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
14+
{60BC6375-225F-40FD-9504-FA07A0C083A4}.Release|Any CPU.Build.0 = Release|Any CPU
15+
EndGlobalSection
16+
EndGlobal
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using UnityEngine;
2+
3+
namespace WeatherMod;
4+
5+
public static class CloudUtils
6+
{
7+
private static GameObject _smokeVfxOriginal;
8+
private static GameObject _stormCloudPrefab;
9+
10+
public static GameObject GetStormCloudEffect()
11+
{
12+
if (_stormCloudPrefab != null)
13+
return _stormCloudPrefab;
14+
15+
EnsureOriginalCloudFX();
16+
17+
_stormCloudPrefab = Object.Instantiate(_smokeVfxOriginal);
18+
19+
_stormCloudPrefab.SetActive(false);
20+
21+
var ps = _stormCloudPrefab.GetComponent<ParticleSystem>();
22+
var main = ps.main;
23+
main.startLifetimeMultiplier = 18;
24+
main.startSpeedMultiplier = 0;
25+
main.startSizeMultiplier = 500;
26+
main.simulationSpace = ParticleSystemSimulationSpace.World;
27+
main.maxParticles = 750;
28+
main.prewarm = false;
29+
var velocity = ps.velocityOverLifetime;
30+
velocity.xMultiplier = 15;
31+
velocity.yMultiplier = 0;
32+
var emission = ps.emission;
33+
emission.rateOverTimeMultiplier = 200;
34+
var shape = ps.shape;
35+
shape.shapeType = ParticleSystemShapeType.Circle;
36+
shape.radius = 1600;
37+
shape.rotation = Vector3.left * 90;
38+
var anim = ps.textureSheetAnimation;
39+
anim.frameOverTimeMultiplier = 1f;
40+
41+
var renderer = _stormCloudPrefab.GetComponent<ParticleSystemRenderer>();
42+
renderer.sortingFudge = 0;
43+
44+
_stormCloudPrefab.transform.localEulerAngles = Vector3.zero;
45+
46+
var r = _stormCloudPrefab.GetComponent<Renderer>();
47+
r.material.SetColor(ShaderPropertyID._Color, new Color(1, 1, 1, 2));
48+
49+
return _stormCloudPrefab;
50+
}
51+
52+
private static void EnsureOriginalCloudFX()
53+
{
54+
if (_smokeVfxOriginal != null) return;
55+
56+
if (CrashedShipExploder.main == null) ErrorMessage.AddMessage("Weather mod error: AURORA NOT FOUND! Where did it go lol?");
57+
58+
// "Failed cloud T_T X_X smh lol"
59+
_smokeVfxOriginal = CrashedShipExploder.main.transform
60+
.Find("unexplodedFX/Ship_Exterior_CrashedFX(Clone)/xSmkColumn2").gameObject;
61+
}
62+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections.Generic;
2+
using Random = UnityEngine.Random;
3+
4+
namespace WeatherMod;
5+
6+
public static class Extensions
7+
{
8+
public static T GetRandomUnity<T>(this IList<T> list)
9+
{
10+
return list[Random.Range(0, list.Count)];
11+
}
12+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
using UnityEngine;
2+
3+
namespace WeatherMod;
4+
5+
public static class FogManager
6+
{
7+
private static float _currentTransitionDuration = 4f;
8+
9+
private static bool _initializedValues;
10+
11+
private static Color _defaultWaterReflectionColor;
12+
private static Color _defaultWaterRefractionColor;
13+
14+
private static float _timeLastTransitionBegun;
15+
16+
private static float _lastFogDensity;
17+
private static float _lastWaterBrightness = 1f;
18+
private static Color[] _lastGradientColors;
19+
private static float _lastExposure = 0.66f;
20+
private static float _lastSunlightBrightnessBelowWater = 1f;
21+
22+
private static float _newFogDensity;
23+
private static float _newWaterBrightness = 1f;
24+
private static Color[] _newGradientColors;
25+
private static float _newExposure = 0.66f;
26+
private static float _newSunlightBrightnessBelowWater = 1f;
27+
28+
private static Gradient _skyFogColorGradient;
29+
30+
public static float Exposure { get; private set; } = 1f;
31+
public static float SunlightBrightnessBelowWater { get; private set; } = 1f;
32+
33+
public static void ChangeCurrentFog(FogSettings newFogSettings)
34+
{
35+
var skyManager = uSkyManager.main;
36+
37+
if (!_initializedValues)
38+
{
39+
_defaultWaterReflectionColor =
40+
WaterSurface._instance.surfaceMaterial.GetColor(ShaderPropertyID._ReflectionColor);
41+
_defaultWaterRefractionColor =
42+
WaterSurface._instance.surfaceMaterial.GetColor(ShaderPropertyID._RefractionColor);
43+
44+
_skyFogColorGradient = uSkyManager.main.skyFogColor;
45+
46+
_initializedValues = true;
47+
}
48+
49+
_lastFogDensity = skyManager.skyFogDensity;
50+
_lastGradientColors = new[]
51+
{
52+
skyManager.skyFogColor.colorKeys[0].color, skyManager.skyFogColor.colorKeys[1].color,
53+
skyManager.skyFogColor.colorKeys[2].color, skyManager.skyFogColor.colorKeys[3].color
54+
};
55+
_lastWaterBrightness = _newWaterBrightness;
56+
_lastSunlightBrightnessBelowWater = _newSunlightBrightnessBelowWater;
57+
_lastExposure = _newExposure;
58+
59+
_newFogDensity = newFogSettings.FogDensity;
60+
_newGradientColors = new[]
61+
{newFogSettings.Color1, newFogSettings.Color2, newFogSettings.Color3, newFogSettings.Color4};
62+
_newWaterBrightness = newFogSettings.WaterBrightness;
63+
_newSunlightBrightnessBelowWater = newFogSettings.SunlightBrightnessBelowWater;
64+
_newExposure = newFogSettings.Exposure;
65+
66+
_timeLastTransitionBegun = Time.time;
67+
68+
FogManagerUpdater.Ensure();
69+
}
70+
71+
private static Color ScaleColor(Color a, Color b)
72+
{
73+
return new Color(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a);
74+
}
75+
76+
private static Color ScaleColor(Color a, float b)
77+
{
78+
return new Color(a.r * b, a.g * b, a.b * b, a.a);
79+
}
80+
81+
internal static void Update()
82+
{
83+
if (Time.time > _timeLastTransitionBegun + _currentTransitionDuration + 1.1987f)
84+
return;
85+
86+
var lerpT = Mathf.Clamp01((Time.time - _timeLastTransitionBegun) / _currentTransitionDuration);
87+
88+
var skyManager = uSkyManager.main;
89+
90+
skyManager.skyFogDensity = Mathf.Lerp(_lastFogDensity, _newFogDensity, lerpT);
91+
92+
_skyFogColorGradient.colorKeys = new[]
93+
{
94+
new GradientColorKey(Color.Lerp(_lastGradientColors[0], _newGradientColors[0], lerpT), 0.2558785f),
95+
new GradientColorKey(Color.Lerp(_lastGradientColors[1], _newGradientColors[1], lerpT), 0.3000076f),
96+
new GradientColorKey(Color.Lerp(_lastGradientColors[2], _newGradientColors[2], lerpT), 0.7000076f),
97+
new GradientColorKey(Color.Lerp(_lastGradientColors[3], _newGradientColors[3], lerpT), 0.7499962f)
98+
};
99+
100+
WaterSurface._instance.surfaceMaterial.SetColor(ShaderPropertyID._ReflectionColor,
101+
ScaleColor(_defaultWaterReflectionColor, Mathf.Lerp(_lastWaterBrightness, _newWaterBrightness, lerpT)));
102+
WaterSurface._instance.surfaceMaterial.SetColor(ShaderPropertyID._RefractionColor,
103+
ScaleColor(_defaultWaterRefractionColor, Mathf.Lerp(_lastWaterBrightness, _newWaterBrightness, lerpT)));
104+
105+
Exposure = Mathf.Lerp(_lastExposure, _newExposure, lerpT);
106+
SunlightBrightnessBelowWater = Mathf.Lerp(_lastSunlightBrightnessBelowWater, _newSunlightBrightnessBelowWater, lerpT);
107+
}
108+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using UnityEngine;
2+
3+
namespace WeatherMod;
4+
5+
internal class FogManagerUpdater : MonoBehaviour
6+
{
7+
private static FogManagerUpdater main;
8+
9+
public static void Ensure()
10+
{
11+
var updater = new GameObject("FogManagerUpdater");
12+
updater.AddComponent<FogManagerUpdater>();
13+
}
14+
15+
private void Awake()
16+
{
17+
main = this;
18+
}
19+
20+
private void Update()
21+
{
22+
FogManager.Update();
23+
}
24+
}

0 commit comments

Comments
 (0)