Fixed anger lighting to be less red Added fake sun lighting Added weather effects to dungeon if moon has certain weathers Doors should work for new enemies. Enemies now open doors normally in their default behaviour Added compability used for Seichi
72 lines
2.6 KiB
C#
72 lines
2.6 KiB
C#
using DunGen;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace ScarletMansion.GamePatch.Weathers {
|
|
public class SDMWeatherManager : MonoBehaviour, IDungeonCompleteReceiver {
|
|
|
|
[Header("Rainy")]
|
|
public GameObject rainGameObject;
|
|
public ParticleSystem rainParticleSystem;
|
|
public AudioSource rainAudioSource;
|
|
|
|
private static readonly LevelWeatherType[] rainyWeathers = new LevelWeatherType[] { LevelWeatherType.Rainy, LevelWeatherType.Stormy, LevelWeatherType.Flooded, LevelWeatherType.Eclipsed };
|
|
private static readonly LevelWeatherType[] bloodRainWeathers = new LevelWeatherType[] { LevelWeatherType.Eclipsed };
|
|
|
|
public void OnDungeonComplete(Dungeon dungeon) {
|
|
DunGenPlus.Managers.DoorwayManager.onMainEntranceTeleportSpawnedEvent.AddTemporaryEvent("Weather", FixWeather);
|
|
}
|
|
|
|
private Color ColorLerp(Color a, Color b, float lerp, float alphaLerp){
|
|
return new Color(
|
|
Mathf.Lerp(a.r, b.r, lerp),
|
|
Mathf.Lerp(a.g, b.g, lerp),
|
|
Mathf.Lerp(a.b, b.b, lerp),
|
|
Mathf.Lerp(a.a, b.a, alphaLerp));
|
|
}
|
|
|
|
private void FixWeather(){
|
|
var timeOfDay = TimeOfDay.Instance;
|
|
if (timeOfDay == null) {
|
|
Plugin.logger.LogError("How is TimeOfDay null?");
|
|
return;
|
|
}
|
|
|
|
var weather = timeOfDay.currentLevelWeather;
|
|
|
|
// is rainy weather
|
|
if (rainyWeathers.Contains(weather)){
|
|
var rainEffect = timeOfDay.effects.FirstOrDefault(x => x.name == "rainy");
|
|
var rainCopy = rainEffect.effectObject;
|
|
Utility.FixParticleSystemMaterialAndChildren(rainParticleSystem, rainCopy.GetComponentInChildren<ParticleSystem>());
|
|
rainAudioSource.clip = rainCopy.GetComponentInChildren<AudioSource>().clip;
|
|
|
|
rainGameObject.SetActive(true);
|
|
rainParticleSystem.Play();
|
|
rainAudioSource.Play();
|
|
|
|
Plugin.logger.LogDebug("Fixed Rainy weather references");
|
|
}
|
|
|
|
if (bloodRainWeathers.Contains(weather)){
|
|
var pss = rainParticleSystem.GetComponentsInChildren<ParticleSystem>();
|
|
foreach(var p in pss){
|
|
//var main = p.main;
|
|
//var startColor = main.startColor;
|
|
//startColor.color = ColorLerp(startColor.color, new Color(1f, 0f, 0f), 0.8f, 0.2f);
|
|
//main.startColor = startColor;
|
|
|
|
var ren = p.GetComponent<ParticleSystemRenderer>();
|
|
var matCopy = ren.material;
|
|
matCopy.color = ColorLerp(matCopy.color, new Color(1f, 0f, 0f), 0.8f, 0.2f);
|
|
}
|
|
|
|
Plugin.logger.LogDebug("Fixed Eclipsed weather references");
|
|
}
|
|
}
|
|
}
|
|
}
|