Updated for new DunGenPlus version

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
This commit is contained in:
LadyAliceMargatroid 2024-10-30 07:43:28 -07:00
parent 719e4380c1
commit de24bf4173
16 changed files with 380 additions and 132 deletions

View file

@ -98,12 +98,12 @@ namespace ScarletMansion.DunGenPatch {
}
var count = PluginConfig.Instance.treasureRoomCountValue;
props.ForcedTilesProperties.UseForcedTiles = count > 0;
props.AdditionalTilesProperties.UseAdditionalTiles = count > 0;
var forcedTilesProperties = props.ForcedTilesProperties;
var copyTarget = forcedTilesProperties.ForcedTileSets[0];
forcedTilesProperties.ForcedTileSets = new List<ForcedTileSetList>();
for(var j = 0; j < count; ++j) forcedTilesProperties.ForcedTileSets.Add(copyTarget);
var addTilesProperties = props.AdditionalTilesProperties;
var copyTarget = addTilesProperties.AdditionalTileSets[0];
addTilesProperties.AdditionalTileSets = new List<AdditionalTileSetList>();
for(var j = 0; j < count; ++j) addTilesProperties.AdditionalTileSets.Add(copyTarget);
}
}

View file

@ -17,6 +17,8 @@ namespace ScarletMansion.Lights {
public int priority = 0;
public float chanceEveryHourToDestroy = 1 / 52f;
public const float MAX_LERP = 0.5f;
public enum FlickeringState { None, Light, Heavy, Broke }
public FlickeringState flickeringState;
private Coroutine flickeringCoroutine;
@ -109,7 +111,7 @@ namespace ScarletMansion.Lights {
while(t < 0.375f) {
yield return null;
t += Time.deltaTime;
light.color = Color.Lerp(c, Color.red, t / 0.375f);
light.color = Color.Lerp(c, Color.red, t / 0.375f * MAX_LERP);
}
if (duration == 0f) yield break;

View file

@ -89,7 +89,9 @@ namespace ScarletMansion.GamePatch.Components {
{ typeof(KnightV2Variant), (e) => e.currentBehaviourStateIndex == 0 },
{ typeof(ButlerEnemyAI), (e) => e.currentBehaviourStateIndex <= 1 },
{ typeof(MaidVariant), (e) => e.currentBehaviourStateIndex <= 1 },
{ typeof(KnightGhostVariant), (e) => false }
{ typeof(KnightGhostVariant), (e) => false },
{ typeof(ClaySurgeonAI), (e) => false },
{ typeof(CaveDwellerAI), (e) => e.currentBehaviourStateIndex == 0 }
};
static readonly Dictionary<Type, float> EnemyDoorDamagePerSecond = new Dictionary<Type, float>(){
@ -108,13 +110,15 @@ namespace ScarletMansion.GamePatch.Components {
{ typeof(KnightV2Variant), 12.5f },
{ typeof(ButlerEnemyAI), 50f },
{ typeof(MaidVariant), 50f },
{ typeof(KnightGhostVariant), 9999f }
{ typeof(KnightGhostVariant), 9999f },
{ typeof(ClaySurgeonAI), 9999f },
{ typeof(CaveDwellerAI), 50f }
};
public bool IsInOpenDoorNormallyState(EnemyAI enemy){
var type = enemy.GetType();
if (EnemyToDoorOpen.ContainsKey(type)) return EnemyToDoorOpen[type](enemy);
return false;
return true;
}
public float GetDoorDamagePerSecond(EnemyAI enemy){

View file

@ -1,85 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
/*
namespace ScarletMansion {
public class ScarletHDRISky : ScarletLighting {
public Volume volume;
public HDRISky GetSky(){
volume.sharedProfile.TryGet<HDRISky>(out var sky);
return sky;
}
public VisualEnvironment GetEnv(){
volume.sharedProfile.TryGet<VisualEnvironment>(out var env);
return env;
}
public override void DisableLights() {
volume.enabled = false;
}
public override void UpdateLight(float ratio) {
GetSky().multiplier.value = valueRatio;
GetEnv().skyAmbientMode.value = skyMode;
volume.enabled = trueEnabled;
}
public int value = 100;
public float valueRatio = 1f;
public bool trueEnabled = true;
public SkyAmbientMode skyMode = SkyAmbientMode.Dynamic;
void Update(){
int direction = 0;
if (IfKeyPress(Keyboard.current.minusKey, Keyboard.current.numpadMinusKey)){
direction = -1;
} else if (IfKeyPress(Keyboard.current.equalsKey, Keyboard.current.numpadPlusKey)){
direction = 1;
}
if (IfKeyPress(Keyboard.current.backspaceKey)){
trueEnabled = !trueEnabled;
Plugin.logger.LogInfo(trueEnabled);
}
if (IfKeyPress(Keyboard.current.digit0Key, Keyboard.current.numpad0Key)){
if (skyMode == SkyAmbientMode.Dynamic) skyMode = SkyAmbientMode.Static;
else skyMode = SkyAmbientMode.Dynamic;
Plugin.logger.LogInfo(skyMode);
}
if (direction != 0){
value = Mathf.Clamp(value + direction * 5, -100, 200);
valueRatio = value * 0.01f;
Plugin.logger.LogInfo(value);
}
}
bool IfKeyPress(params KeyControl[] keys){
foreach(var k in keys){
if (k.wasPressedThisFrame) return true;
}
return false;
}
}
}
*/

View file

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
/*
namespace ScarletMansion {
public abstract class ScarletLighting : MonoBehaviour {
public abstract void UpdateLight(float ratio);
public abstract void DisableLights() ;
}
}
*/

View file

@ -28,8 +28,13 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
var time = Utility.GetTime();
if (CanOpen()) {
foreach(var d in treasureDoorLocks){
if (d == null) {
Plugin.logger.LogWarning($"Scarlet door was null for {GetType()}: {GetComponentInParent<Tile>().gameObject.name}. Report to Mr. Dev");
continue;
};
d.LockDoorOverrideClientRpc(false);
d.door?.DestroyDoorClientRpc(d.transform.forward);
if (d.door != null) d.door.DestroyDoorClientRpc(d.transform.forward);
}
opened = true;
}

View file

@ -57,6 +57,11 @@ namespace ScarletMansion.GamePatch.Items {
var index = scrapValue % types.Length;
currentType = types[index];
var childCount = prefabPivot.childCount;
for(var i = childCount - 1; i >= 0; i--) {
Destroy(prefabPivot.GetChild(i).gameObject);
}
Instantiate(currentType.prefab, prefabPivot);
scanNode.headerText = $"{currentType.name} Snow Globe";
}

View file

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace ScarletMansion.GamePatch {
public class ScarletFakeSun : MonoBehaviour {
public Light light;
public AnimationCurve curve;
private float intensityInitial;
void Awake(){
intensityInitial = light.intensity;
}
void Update(){
var timeOfDay = TimeOfDay.Instance;
if (timeOfDay == null) return;
var timeRatio = timeOfDay.normalizedTimeOfDay;
light.intensity = intensityInitial * curve.Evaluate(timeRatio);
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using DunGen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -6,30 +7,66 @@ using System.Threading.Tasks;
using UnityEngine;
namespace ScarletMansion.GamePatch.Weathers {
public class SDMWeatherManager : MonoBehaviour {
public class SDMWeatherManager : MonoBehaviour, IDungeonCompleteReceiver {
[Header("Rainy")]
public GameObject rainGameObject;
public ParticleSystem rainParticleSystem;
public AudioSource rainAudioSource;
// fix itself
void Start() {
var timeofDay = TimeOfDay.Instance;
if (timeofDay == null) {
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 rainEffect = timeofDay.effects.FirstOrDefault(x => x.name == "rainy");
var rainGameObject = rainEffect.effectObject;
Utility.FixParticleSystemMaterialAndChildren(rainParticleSystem, rainGameObject.GetComponentInChildren<ParticleSystem>());
rainAudioSource.clip = rainGameObject.GetComponentInChildren<AudioSource>().clip;
rainAudioSource.Play();
var weather = timeOfDay.currentLevelWeather;
Plugin.logger.LogDebug("Fixed Rainy weather references");
// 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");
}
}
}
}

View file

@ -23,7 +23,7 @@ namespace ScarletMansion {
[BepInDependency("imabatby.lethallevelloader", "1.2.0.3")]
[BepInDependency("evaisa.lethallib", "0.13.2")]
[BepInDependency("dev.ladyalice.dungenplus", "1.1.2")]
[BepInDependency("dev.ladyalice.dungenplus", "1.2.0")]
//[BepInDependency(ModCompability.advancedCompanyGuid, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(ModCompability.lethalConfigGuid, BepInDependency.DependencyFlags.SoftDependency)]
@ -34,7 +34,7 @@ namespace ScarletMansion {
public class Plugin : BaseUnityPlugin {
public const string modGUID = "dev.ladyalice.scarletmansion";
private const string modName = "Scarlet Mansion";
private const string modVersion = "1.3.27";
private const string modVersion = "1.3.29";
public readonly Harmony harmony = new Harmony(modGUID);
@ -47,7 +47,7 @@ namespace ScarletMansion {
if (Instance == null) Instance = this;
logger = BepInEx.Logging.Logger.CreateLogSource(modGUID);
logger.LogInfo($"Plugin {modName} has been added!");
logger.LogInfo($"Plugin {modName} has been added! Death to Bepinex!");
MyConfig = new PluginConfig(Config);

View file

@ -164,8 +164,6 @@
<Compile Include="GamePatch\Components\ScarletDoorLock.cs" />
<Compile Include="GamePatch\Components\ScarletFireExit.cs" />
<Compile Include="GamePatch\Components\ScarletFrame.cs" />
<Compile Include="GamePatch\Components\ScarletHDRISky.cs" />
<Compile Include="GamePatch\Components\ScarletLighting.cs" />
<Compile Include="GamePatch\Components\ScarletPlayerControllerB.cs" />
<Compile Include="GamePatch\Components\ScarletProp.cs" />
<Compile Include="GamePatch\Components\ScarletRadio.cs" />
@ -220,6 +218,7 @@
<Compile Include="GamePatch\Props\RandomPrefabCycle.cs" />
<Compile Include="GamePatch\Props\RandomPrefabWithScale.cs" />
<Compile Include="GamePatch\RoundManagerPatch.cs" />
<Compile Include="GamePatch\ScarletFakeSun.cs" />
<Compile Include="GamePatch\ScarletLightPatch.cs" />
<Compile Include="GamePatch\ShotgunItemPatch.cs" />
<Compile Include="GamePatch\ShovelPatch.cs" />