Added new treasure room spawn (servant's quarters)

Fixed treasure room event for bedroom
Fixed painting's interaction with MattyFixes
Fixed critical damage bug introduced by v62
Increased lights spawn for all presets by a lot
Added Coroner compatibility
Added Scarlet Devil Mansion (moon) to the interior's spawn list
Lights now have a chance of flickering and dying
This commit is contained in:
LadyAliceMargatroid 2024-09-01 18:45:16 -07:00
parent 93e249d838
commit 4413d12ea3
42 changed files with 986 additions and 333 deletions

View File

@ -8,12 +8,10 @@ using UnityEngine;
using System.Reflection; using System.Reflection;
using System.IO; using System.IO;
using DunGen.Graph; using DunGen.Graph;
using UnityEngine.Experimental.Rendering;
using LethalLib.Modules; using LethalLib.Modules;
using LethalLevelLoader; using LethalLevelLoader;
using ScarletMansion.GamePatch.Items;
using static ScarletMansion.Assets;
using DunGenPlus; using DunGenPlus;
using ScarletMansion.ModPatch;
namespace ScarletMansion { namespace ScarletMansion {
public static class Assets { public static class Assets {
@ -21,6 +19,7 @@ namespace ScarletMansion {
static BepInEx.Logging.ManualLogSource logger => Plugin.logger; static BepInEx.Logging.ManualLogSource logger => Plugin.logger;
public static ActionList onAssetsLoadEvent = new ActionList("onAssetsLoad"); public static ActionList onAssetsLoadEvent = new ActionList("onAssetsLoad");
public static ActionList<CoronerParameters> onPlayerDeath = new ActionList<CoronerParameters>("onPlayerDeath");
const string mainAssetBundleName = "scarletmansion"; const string mainAssetBundleName = "scarletmansion";

View File

@ -21,6 +21,18 @@ namespace ScarletMansion.DunGenPatch {
public static bool callAlternative; public static bool callAlternative;
public static DungeonGenerator generatorInstance; public static DungeonGenerator generatorInstance;
public static RandomStream GetRandomStream(){
return generatorInstance.RandomStream;
}
public static int CreateSystemRandomSeed(){
return GetRandomStream().Next();
}
public static System.Random CreateSystemRandom(){
return new System.Random(CreateSystemRandomSeed());
}
public static void Activate(DungeonGenerator generator){ public static void Activate(DungeonGenerator generator){
active = true; active = true;
callAlternative = true; callAlternative = true;

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScarletMansion.GamePatch.Components {
public interface IScarletSelfDestroy {
float Chance { get; }
bool IsDestroyed { get; }
void PreDestroy();
void Destroy();
}
}

View File

@ -6,16 +6,32 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using DunGen; using DunGen;
using LethalLevelLoader;
using ScarletMansion.GamePatch.Components;
namespace ScarletMansion.Lights { namespace ScarletMansion.Lights {
public class ScarletLight : MonoBehaviour, IComparable<ScarletLight>, IDungeonCompleteReceiver { public class ScarletLight : MonoBehaviour, IComparable<ScarletLight>, IDungeonCompleteReceiver, IScarletSelfDestroy {
public Light light; public Light light;
public int priority = 0; public int priority = 0;
public float chanceEveryHourToDestroy = 1 / 52f;
private Coroutine anger; public enum FlickeringState { None, Light, Heavy, Broke }
private bool permenantAnger; public FlickeringState flickeringState;
private Coroutine flickeringCoroutine;
public enum ColorState { Normal, TemporaryRed, Red }
public ColorState colorState;
private Coroutine colorCoroutine;
private bool preDestroy;
private int systemRandomSeed;
public float Chance => chanceEveryHourToDestroy;
public bool IsDestroyed => preDestroy;
public int CompareTo(ScarletLight obj) { public int CompareTo(ScarletLight obj) {
return obj.priority.CompareTo(priority); return obj.priority.CompareTo(priority);
@ -25,15 +41,69 @@ namespace ScarletMansion.Lights {
light = GetComponent<Light>(); light = GetComponent<Light>();
} }
public void BeginAngry(float duration, bool forever){ public void SetFlickeringState(FlickeringState state) {
if (permenantAnger) return; if (flickeringState >= state) return;
if (anger != null) StopCoroutine(anger); flickeringState = state;
if (flickeringCoroutine != null) StopCoroutine(flickeringCoroutine);
flickeringCoroutine = null;
switch(flickeringState) {
case FlickeringState.None:
light.enabled = true;
break;
case FlickeringState.Broke:
light.enabled = false;
preDestroy = true;
break;
case FlickeringState.Light:
flickeringCoroutine = StartCoroutine(FlickerLight(12, 18, 0.25f, 0.4f, 0.75f, 1f, 1.5f));
break;
case FlickeringState.Heavy:
flickeringCoroutine = StartCoroutine(FlickerLight(6, 8, 0.15f, 0.25f, 0.5f, 0.6f, 0.5f));
preDestroy = true;
break;
}
if (forever) permenantAnger = true;
anger = StartCoroutine(AngerCoroutine(duration));
} }
private IEnumerator AngerCoroutine(float duration){ public void SetColorState(ColorState state) {
if (colorState >= state) return;
colorState = state;
if (colorCoroutine != null) StopCoroutine(colorCoroutine);
colorCoroutine = null;
switch (colorState){
case ColorState.Normal:
light.color = Color.white;
break;
case ColorState.TemporaryRed:
colorCoroutine = StartCoroutine(AngerLight(6f));
break;
case ColorState.Red:
colorCoroutine = StartCoroutine(AngerLight(0f));
break;
}
}
private IEnumerator FlickerLight(int minFlicker, int maxFlicker, float minOffPause, float maxOffPause, float minOnPause, float maxOnPause, float cycleMultiplier){
var random = new System.Random(systemRandomSeed);
var count = random.Next(minFlicker, maxFlicker);
for (var i = 0; i < count; ++i) {
var cycleM = Mathf.Lerp(1f, cycleMultiplier, (float)i / count);
light.enabled = false;
yield return new WaitForSeconds(random.GetRandomNumber(minOffPause, maxOffPause) * cycleM);
light.enabled = true;
yield return new WaitForSeconds(random.GetRandomNumber(minOnPause, maxOnPause) * cycleM);
}
light.enabled = false;
flickeringState = FlickeringState.Broke;
}
private IEnumerator AngerLight(float duration){
var t = 0f; var t = 0f;
var c = light.color; var c = light.color;
while(t < 0.375f) { while(t < 0.375f) {
@ -42,7 +112,7 @@ namespace ScarletMansion.Lights {
light.color = Color.Lerp(c, Color.red, t / 0.375f); light.color = Color.Lerp(c, Color.red, t / 0.375f);
} }
if (permenantAnger) yield break; if (duration == 0f) yield break;
yield return new WaitForSeconds(duration + UnityEngine.Random.value); yield return new WaitForSeconds(duration + UnityEngine.Random.value);
c = light.color; c = light.color;
@ -53,11 +123,23 @@ namespace ScarletMansion.Lights {
light.color = Color.Lerp(c, Color.white, t / 1.25f); light.color = Color.Lerp(c, Color.white, t / 1.25f);
} }
colorState = ColorState.Normal;
} }
public void OnDungeonComplete(Dungeon dungeon) { public void OnDungeonComplete(Dungeon dungeon) {
if (!gameObject.activeInHierarchy) return; if (!gameObject.activeInHierarchy) return;
GamePatch.Managers.AngerManager.Instance.AddLight(this);
GamePatch.Managers.ScarletGenericManager.Instance.AddLight(this);
systemRandomSeed = DunGenPatch.Patch.CreateSystemRandomSeed();
//Plugin.logger.LogInfo(systemRandomSeed);
}
public void PreDestroy() {
preDestroy = true;
}
public void Destroy() {
SetFlickeringState(FlickeringState.Light);
} }
} }

View File

@ -18,7 +18,7 @@ namespace ScarletMansion.Lights {
if (lights.Length == 0) return; if (lights.Length == 0) return;
// the smallest amount of optimization // the smallest amount of optimization
var random = DunGenPatch.Patch.generatorInstance.RandomStream; var random = DunGenPatch.Patch.GetRandomStream();
if (lights.Length > 1){ if (lights.Length > 1){
Utility.Shuffle(random, lights); Utility.Shuffle(random, lights);
System.Array.Sort(lights); System.Array.Sort(lights);
@ -29,7 +29,7 @@ namespace ScarletMansion.Lights {
var count = GetRandom(random, weights); var count = GetRandom(random, weights);
count = Mathf.Min(count, maxLights); count = Mathf.Min(count, maxLights);
for(var i = count; i < lights.Length; ++i){ for(var i = count; i < lights.Length; ++i){
lights[i].gameObject.SetActive(false); lights[i].SetFlickeringState(ScarletLight.FlickeringState.Broke);
} }
} }

View File

@ -44,8 +44,7 @@ namespace ScarletMansion.GamePatch.Components
public void OnDungeonComplete(Dungeon dungeon) { public void OnDungeonComplete(Dungeon dungeon) {
var anyChanges = true; var anyChanges = true;
var dunRandom = DunGenPatch.Patch.generatorInstance.RandomStream; var sysRandom = DunGenPatch.Patch.CreateSystemRandom();
var sysRandom = new System.Random(dunRandom.Next());
foreach(var c in chokepoints) { foreach(var c in chokepoints) {
c.UpdatePath(sysRandom); c.UpdatePath(sysRandom);

View File

@ -66,7 +66,7 @@ namespace ScarletMansion.GamePatch.Components {
// lock doors // lock doors
if (roundmanager.IsServer){ if (roundmanager.IsServer){
foreach(var d in doorways){ foreach(var d in doorways){
var result = AngerManager.Instance.GetScarletDoor(d.transform.position); var result = ScarletGenericManager.Instance.GetScarletDoor(d.transform.position);
if (result) doors.Add(result); if (result) doors.Add(result);
} }
@ -112,17 +112,9 @@ namespace ScarletMansion.GamePatch.Components {
yield return new WaitForSeconds(UnityEngine.Random.Range(1f, 1.5f)); yield return new WaitForSeconds(UnityEngine.Random.Range(1f, 1.5f));
// scarlet lights flicker // scarlet lights flicker
var isScarletLight = light.GetComponent<ScarletLight>() != null; var scarletLight = light.GetComponent<ScarletLight>();
if (isScarletLight){ if (scarletLight != null){
var count = UnityEngine.Random.Range(6, 8); scarletLight.SetFlickeringState(ScarletLight.FlickeringState.Heavy);
for (var i = 0; i < count; ++i) {
light.enabled = false;
yield return new WaitForSeconds(UnityEngine.Random.Range(0.15f, 0.25f) * (1f - count * 0.05f));
light.enabled = true;
yield return new WaitForSeconds(UnityEngine.Random.Range(0.5f, 0.6f) * (1f - count * 0.05f));
}
light.enabled = false;
} }
// normal lights are candles, so just turn them off // normal lights are candles, so just turn them off
else { else {
@ -211,7 +203,7 @@ namespace ScarletMansion.GamePatch.Components {
if (!roundmanager.IsServer) return; if (!roundmanager.IsServer) return;
try { try {
AngerManager.Instance.SpawnAngerLoot(bonusItems, itemSpawns); AngerManager.SpawnAngerLoot(bonusItems, itemSpawns);
} catch (Exception e) { } catch (Exception e) {
var itemStrings = string.Join("\n", bonusItems.Select(i => i != null ? i.ToString() : "NULL")); var itemStrings = string.Join("\n", bonusItems.Select(i => i != null ? i.ToString() : "NULL"));
Plugin.logger.LogError($"Failed to spawn items for bedroom event, the smelly culprits are {itemStrings}"); Plugin.logger.LogError($"Failed to spawn items for bedroom event, the smelly culprits are {itemStrings}");
@ -220,21 +212,19 @@ namespace ScarletMansion.GamePatch.Components {
} }
public void OnDungeonComplete(Dungeon dungeon) { public void OnDungeonComplete(Dungeon dungeon) {
AngerManager.Instance.AddBedroom(this); ScarletGenericManager.Instance.AddBedroom(this);
AngerManager.Instance.AddRoomOfInterest(transform); ScarletGenericManager.Instance.AddRoomOfInterest(transform);
var parent = GetComponentInParent<Tile>(); var parent = GetComponentInParent<Tile>();
lights = parent.GetComponentsInChildren<Light>(); lights = parent.GetComponentsInChildren<Light>();
doorways = parent.UsedDoorways.ToArray(); doorways = parent.UsedDoorways.ToArray();
var dunRandom = DunGenPatch.Patch.generatorInstance.RandomStream; var sysRandom = DunGenPatch.Patch.CreateSystemRandom();
var randomValue = (int)(dunRandom.NextDouble() * int.MaxValue);
var sysRandom = new System.Random(randomValue);
Utility.Shuffle(sysRandom, itemSpawns); Utility.Shuffle(sysRandom, itemSpawns);
var count = sysRandom.Next(PluginConfig.Instance.paintingExtraLootValue.min, PluginConfig.Instance.paintingExtraLootValue.max + 1); var count = sysRandom.Next(PluginConfig.Instance.paintingExtraLootValue.min, PluginConfig.Instance.paintingExtraLootValue.max + 1);
bonusItems = AngerManager.Instance.CreateAngerLoot(count, sysRandom); bonusItems = AngerManager.CreateAngerLoot(count, sysRandom);
bonusEnemy = GetRandomEnemy(sysRandom); bonusEnemy = GetRandomEnemy(sysRandom);
} }

View File

@ -0,0 +1,56 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.Netcode;
using UnityEngine;
namespace ScarletMansion.GamePatch.Components {
public class ScarletBookPath : MonoBehaviour {
public Transform bookTransform;
[Header("Nodes")]
public Transform[] nodeTransforms;
public float nodeRadius = 0.25f;
public int index = 0;
[Header("Speed")]
public float velocity = 1f;
public float rotationVelocity = 45f;
void Update(){
var nextTransform = nodeTransforms[index];
var forwardDirection = nextTransform.position - bookTransform.position;
bookTransform.rotation = Quaternion.RotateTowards(bookTransform.rotation, Quaternion.LookRotation(forwardDirection), Time.deltaTime * rotationVelocity);
bookTransform.position += forwardDirection.normalized * Time.deltaTime * velocity;
if (Vector3.SqrMagnitude(forwardDirection) <= nodeRadius * nodeRadius){
index = (index + 1) % nodeTransforms.Length;
}
}
public void ResetPath(){
index = 0;
var current = nodeTransforms[index];
var next= nodeTransforms[index + 1];
bookTransform.position = current.position;
bookTransform.rotation = Quaternion.LookRotation(next.position - current.position);
}
public void OnDrawGizmosSelected(){
Gizmos.color = Color.green;
for(var i = 0; i < nodeTransforms.Length; ++i){
var current = nodeTransforms[i];
var next = nodeTransforms[(i + 1) % nodeTransforms.Length];
Gizmos.DrawWireSphere(current.position, nodeRadius);
Gizmos.DrawLine(current.position, next.position);
}
}
}
}

View File

@ -8,7 +8,8 @@ using UnityEngine;
using Unity.Netcode; using Unity.Netcode;
namespace ScarletMansion.GamePatch.Components { namespace ScarletMansion.GamePatch.Components {
public class ScarletClock : NetworkBehaviour {
public class ScarletClock : MonoBehaviour, IScarletSelfDestroy {
[Header("Animations")] [Header("Animations")]
public Vector3 eulerAngleOffset = new Vector3(-90f, -90f, -90f); public Vector3 eulerAngleOffset = new Vector3(-90f, -90f, -90f);
@ -24,21 +25,18 @@ namespace ScarletMansion.GamePatch.Components {
[Header("Destruction Values")] [Header("Destruction Values")]
public bool stop; public bool stop;
public bool preStop;
public float chanceEveryHourToDestroy = 1f / 52f; public float chanceEveryHourToDestroy = 1f / 52f;
private float timerTillDestroyed = -1f; private float timerTillDestroyed = -1f;
public float Chance => chanceEveryHourToDestroy;
public bool IsDestroyed => preStop;
void Update(){ void Update(){
if (stop) return; if (stop) return;
if (IsServer && timerTillDestroyed > 0f){
timerTillDestroyed -= Time.deltaTime;
if (timerTillDestroyed <= 0f) {
StopClockClientRpc();
return;
}
}
var time = Utility.GetTime(); var time = Utility.GetTime();
var totalMinutes = time.totalMinutes; var totalMinutes = time.totalMinutes;
var hours = time.hours; var hours = time.hours;
@ -52,10 +50,6 @@ namespace ScarletMansion.GamePatch.Components {
animationCoroutine = StartCoroutine(MoveHands(hours, minutes)); animationCoroutine = StartCoroutine(MoveHands(hours, minutes));
} }
if (IsServer && hourChanged){
HourlySelfDestroyCheck();
}
lastHour = hours; lastHour = hours;
lastTotalMinutes = totalMinutes; lastTotalMinutes = totalMinutes;
} }
@ -103,20 +97,12 @@ namespace ScarletMansion.GamePatch.Components {
WalkieTalkie.TransmitOneShotAudio(audioSource, clip); WalkieTalkie.TransmitOneShotAudio(audioSource, clip);
} }
public void HourlySelfDestroyCheck(){ public void PreDestroy() {
if (stop || timerTillDestroyed > 0) return; preStop = true;
Plugin.logger.LogDebug("Hourly clock self-destroy check");
if (UnityEngine.Random.value < chanceEveryHourToDestroy) {
timerTillDestroyed = UnityEngine.Random.value * 60f + 15f;
Plugin.logger.LogDebug($"Clock offing itself in {timerTillDestroyed} sec");
}
} }
[ClientRpc] public void Destroy() {
public void StopClockClientRpc(){
stop = true; stop = true;
} }
} }
} }

View File

@ -25,7 +25,7 @@ namespace ScarletMansion.GamePatch.Components {
private bool previousDoorLockValue; private bool previousDoorLockValue;
void Awake(){ void Awake(){
AngerManager.Instance.AddDoor(this); ScarletGenericManager.Instance.AddDoor(this);
} }
[ClientRpc] [ClientRpc]

View File

@ -1,4 +1,6 @@
using System; using ScarletMansion.GamePatch.Components.TreasureRoom;
using ScarletMansion.GamePatch.Managers;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -9,6 +11,8 @@ using UnityEngine;
namespace ScarletMansion.GamePatch.Components { namespace ScarletMansion.GamePatch.Components {
public class ScarletRadio : NetworkBehaviour{ public class ScarletRadio : NetworkBehaviour{
public TreasureRoomRadioEvent treasureRoomEvent;
[Header("Networked Values")] [Header("Networked Values")]
public int volume; public int volume;
public bool playing; public bool playing;
@ -83,6 +87,7 @@ namespace ScarletMansion.GamePatch.Components {
[ServerRpc(RequireOwnership = false)] [ServerRpc(RequireOwnership = false)]
public void ToggleOnOffSwitchServerRpc(){ public void ToggleOnOffSwitchServerRpc(){
ToggleOnOffSwitchClientRpc(!playing); ToggleOnOffSwitchClientRpc(!playing);
treasureRoomEvent?.UpdateTreasureDoorStatus();
} }
[ClientRpc] [ClientRpc]
@ -96,6 +101,7 @@ namespace ScarletMansion.GamePatch.Components {
[ServerRpc(RequireOwnership = false)] [ServerRpc(RequireOwnership = false)]
public void ToggleVolumeSwitchServerRpc(int count){ public void ToggleVolumeSwitchServerRpc(int count){
ToggleVolumeSwitchClientRpc(Mathf.Clamp(volume + count, 0, 10)); ToggleVolumeSwitchClientRpc(Mathf.Clamp(volume + count, 0, 10));
treasureRoomEvent?.UpdateTreasureDoorStatus();
} }
[ClientRpc] [ClientRpc]
@ -107,6 +113,7 @@ namespace ScarletMansion.GamePatch.Components {
[ServerRpc(RequireOwnership = false)] [ServerRpc(RequireOwnership = false)]
public void ToggleSongSwitchServerRpc(){ public void ToggleSongSwitchServerRpc(){
ToggleSongSwitchClientRpc((audioIndex + 1) % audioClips.Length); ToggleSongSwitchClientRpc((audioIndex + 1) % audioClips.Length);
treasureRoomEvent?.UpdateTreasureDoorStatus();
} }
[ClientRpc] [ClientRpc]

View File

@ -1,4 +1,5 @@
using GameNetcodeStuff; using GameNetcodeStuff;
using LethalLib.Modules;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -22,49 +23,69 @@ namespace ScarletMansion.GamePatch.Components
if (!otherGameObject.CompareTag("Player")) { if (!otherGameObject.CompareTag("Player")) {
return; return;
} }
var comp = otherGameObject.GetComponent<PlayerControllerB>(); var playerControllerB = otherGameObject.GetComponent<PlayerControllerB>();
if (comp != GameNetworkManager.Instance.localPlayerController) return; if (playerControllerB != GameNetworkManager.Instance.localPlayerController) return;
// sanity check // sanity check
if (audioClipIndex == -1) comp.statusEffectAudioIndex = 0; if (audioClipIndex == -1) playerControllerB.statusEffectAudioIndex = 0;
comp.statusEffectAudioIndex = audioClipIndex; playerControllerB.statusEffectAudioIndex = audioClipIndex;
if (comp.isSinking) { if (playerControllerB.isSinking) {
// teleporting them out for a second time in life
// won't be easy though kek
var scarletPlayer = ScarletPlayerControllerB.GetScarletPlayerScript(comp);
if (scarletPlayer != null && !scarletPlayer.fellInPit && comp.sinkingValue >= 0.9f && comp.health > 20) {
var selfPos = scarletPlayer.transform.position;
var farthestAINode = RoundManager.Instance.insideAINodes
.Select(n => n.transform.position)
.OrderByDescending(n => (selfPos - n).magnitude).FirstOrDefault();
comp.TeleportPlayer(farthestAINode); // to override the normal sinking kill behaviour
var damage = ScarletNetworkManagerUtility.GetCriticalDamageToPlayer(comp, false); if (playerControllerB.sinkingValue >= 0.9f){
comp.DamagePlayer(damage, false, true, CauseOfDeath.Suffocation); // teleporting them out for a second time in life
// won't be easy though kek
var scarletPlayer = ScarletPlayerControllerB.GetScarletPlayerScript(playerControllerB);
if (scarletPlayer != null && !scarletPlayer.fellInPit && !playerControllerB.criticallyInjured) {
var selfPos = scarletPlayer.transform.position;
var farthestAINode = RoundManager.Instance.insideAINodes
.Select(n => n.transform.position)
.OrderByDescending(n => (selfPos - n).magnitude).FirstOrDefault();
ScarletNetworkManager.Instance.CreateSpawnAudioPrefab(farthestAINode, comp.actualClientId); playerControllerB.TeleportPlayer(farthestAINode);
StopSinkingLocalPlayer(comp); var damage = ScarletNetworkManagerUtility.GetCriticalDamageToPlayer(playerControllerB, false);
playerControllerB.DamagePlayer(damage, false, true, CauseOfDeath.Suffocation);
scarletPlayer.fellInPit = true; if (playerControllerB.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(playerControllerB, ModPatch.CoronerDeathEnum.Void));
}
StopSinkingLocalPlayer(playerControllerB);
ScarletNetworkManager.Instance.CreateSpawnAudioPrefab(farthestAINode, playerControllerB.actualClientId);
scarletPlayer.fellInPit = true;
}
// just straight up murder
else {
// this is to prevent Coroner from thinking it's quicksand
playerControllerB.isSinking = false;
playerControllerB.KillPlayer(Vector3.zero, false, CauseOfDeath.Suffocation);
if (playerControllerB.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(playerControllerB, ModPatch.CoronerDeathEnum.Void));
} else {
// a just in case
playerControllerB.isSinking = true;
}
}
} }
return; return;
} }
if (sinkingLocalPlayer){ if (sinkingLocalPlayer){
if (!comp.CheckConditionsForSinkingInQuicksand()) { if (!playerControllerB.CheckConditionsForSinkingInQuicksand()) {
StopSinkingLocalPlayer(comp); StopSinkingLocalPlayer(playerControllerB);
} }
return; return;
} }
if (comp.CheckConditionsForSinkingInQuicksand()){ if (playerControllerB.CheckConditionsForSinkingInQuicksand()){
sinkingLocalPlayer = true; sinkingLocalPlayer = true;
comp.sourcesCausingSinking++; playerControllerB.sourcesCausingSinking++;
comp.isMovementHindered++; playerControllerB.isMovementHindered++;
comp.hinderedMultiplier *= movementHinderence; playerControllerB.hinderedMultiplier *= movementHinderence;
comp.sinkingSpeedMultiplier = sinkingSpeedMultiplier; playerControllerB.sinkingSpeedMultiplier = sinkingSpeedMultiplier;
} }
} }

View File

@ -16,7 +16,7 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
public GameObject doorStatusPrefab; public GameObject doorStatusPrefab;
protected List<TreasureRoomDoorStatus> treasureDoorStatuses; protected List<TreasureRoomDoorStatus> treasureDoorStatuses;
protected System.Random randomStream; protected System.Random systemRandom;
protected List<ScarletDoor> treasureDoorLocks; protected List<ScarletDoor> treasureDoorLocks;
protected bool opened; protected bool opened;
@ -69,7 +69,7 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
} }
public virtual void OnDungeonComplete(Dungeon dungeon) { public virtual void OnDungeonComplete(Dungeon dungeon) {
AngerManager.Instance.AddRoomOfInterest(transform); ScarletGenericManager.Instance.AddRoomOfInterest(transform);
var tile = GetComponentInParent<Tile>(); var tile = GetComponentInParent<Tile>();
var doorways = tile.UsedDoorways; var doorways = tile.UsedDoorways;
@ -81,14 +81,19 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
} }
} }
if (targetDoorways.Count > 0) { var hasTreasureRoom = targetDoorways.Count > 0;
var dunRandom = DunGenPatch.Patch.generatorInstance.RandomStream; if (hasTreasureRoom) {
randomStream = new System.Random((int)(dunRandom.NextDouble() * int.MaxValue)); systemRandom = DunGenPatch.Patch.CreateSystemRandom();
Plugin.logger.LogInfo($"Adding treasure room event {GetType().ToString()}"); Plugin.logger.LogInfo($"Adding treasure room event {GetType().ToString()}");
DunGenPlus.Managers.DoorwayManager.onMainEntranceTeleportSpawnedEvent.AddTemporaryEvent("TreasureRoom", () => LockTreasureDoor(targetDoorways)); DunGenPlus.Managers.DoorwayManager.onMainEntranceTeleportSpawnedEvent.AddTemporaryEvent("TreasureRoom", () => LockTreasureDoor(targetDoorways));
} }
OnTreasureRoomSetup(hasTreasureRoom);
}
protected virtual void OnTreasureRoomSetup(bool hasTreasureRoom){
} }
protected virtual void LockTreasureDoor(List<Doorway> doorways){ protected virtual void LockTreasureDoor(List<Doorway> doorways){
@ -103,7 +108,7 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
} }
var doorPosition = d.transform.position; var doorPosition = d.transform.position;
var doorLock = AngerManager.Instance.GetScarletDoor(doorPosition); var doorLock = ScarletGenericManager.Instance.GetScarletDoor(doorPosition);
doorLock.LockDoorOverrideClientRpc(true); doorLock.LockDoorOverrideClientRpc(true);
treasureDoorLocks.Add(doorLock); treasureDoorLocks.Add(doorLock);
} }

View File

@ -13,14 +13,13 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
public class TreasureRoomBookPullEvent : TreasureRoom { public class TreasureRoomBookPullEvent : TreasureRoom {
[Header("References")] [Header("References")]
public TreasureRoomBookZone[] zones;
public TreasureRoomBookSwitch[] switches; public TreasureRoomBookSwitch[] switches;
[Header("Prefabs")] [Header("Prefabs")]
public GameObject bookPrefab; public GameObject bookPrefab;
public override bool CanOpen() { public override bool CanOpen() {
var ready = switches.All(s => s.pulled); var ready = GetDoorStatusValue() == switches.Length;
if (ready) { if (ready) {
Plugin.logger.LogDebug($"Opening cause all books pulled"); Plugin.logger.LogDebug($"Opening cause all books pulled");
return ready; return ready;
@ -40,10 +39,11 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
Plugin.logger.LogDebug("HOST: Creating book switches"); Plugin.logger.LogDebug("HOST: Creating book switches");
switches = new TreasureRoomBookSwitch[3]; switches = new TreasureRoomBookSwitch[3];
var switchOrdered = zones.Where(z => z != null && z.gameObject.activeInHierarchy).OrderBy(s => randomStream.NextDouble()); var zones = GetComponentInParent<Tile>().GetComponentsInChildren<TreasureRoomBookZone>();
var switchOrdered = zones.Where(z => z != null && z.gameObject.activeInHierarchy).OrderBy(s => systemRandom.NextDouble());
var mapPropsContainer = GetMapPropsContainer(); var mapPropsContainer = GetMapPropsContainer();
for(var i = 0; i < 3; ++i) { for(var i = 0; i < 3; ++i) {
var result = switchOrdered.ElementAt(i).GetRandomPosition(randomStream); var result = switchOrdered.ElementAt(i).GetRandomPosition(systemRandom);
var bookGameObject = GameObject.Instantiate(bookPrefab, result.position, result.rotation, mapPropsContainer.transform); var bookGameObject = GameObject.Instantiate(bookPrefab, result.position, result.rotation, mapPropsContainer.transform);
var networkObject = bookGameObject.GetComponent<NetworkObject>(); var networkObject = bookGameObject.GetComponent<NetworkObject>();

View File

@ -11,6 +11,9 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
public GameObject[] doorStatusTargets; public GameObject[] doorStatusTargets;
public TreasureRoom treasureRoom; public TreasureRoom treasureRoom;
public AudioSource audioSource;
private int previousCount;
[ClientRpc] [ClientRpc]
public void UpdateDoorStatusClientRpc(int count) { public void UpdateDoorStatusClientRpc(int count) {
@ -24,6 +27,12 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
doorStatusTargets[i].SetActive(false); doorStatusTargets[i].SetActive(false);
++i; ++i;
} }
if (count > previousCount) {
audioSource.PlayOneShot(audioSource.clip);
}
previousCount = count;
} }
} }

View File

@ -27,13 +27,15 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
protected override void LockTreasureDoor(List<Doorway> doorways) { protected override void LockTreasureDoor(List<Doorway> doorways) {
base.LockTreasureDoor(doorways); base.LockTreasureDoor(doorways);
var bedroomEvent = GetComponentInParent<Tile>().GetComponentInChildren<ScarletBedroom>(true); var bedroomEvent = GetComponentInParent<Tile>().GetComponentInChildren<ScarletBedroom>();
var globalProp = bedroomEvent.GetComponentInChildren<GlobalProp>(true);
globalProp.gameObject.SetActive(true);
Plugin.logger.LogDebug("Moving vent to inside of the treasure room"); Plugin.logger.LogDebug("Moving vent to inside of the treasure room");
var firstDoorway = doorways.FirstOrDefault(); var firstDoorway = doorways.FirstOrDefault();
var treasureRoomCenterTransform = firstDoorway.ConnectedDoorway.Tile.transform; var treasureRoomCenterTransform = firstDoorway.ConnectedDoorway.Tile.transform;
var bedroomEventVent = bedroomEvent.vent.transform; var bedroomEventVent = bedroomEvent.vent.transform;
Plugin.logger.LogInfo($"{bedroomEventVent.position} -> {treasureRoomCenterTransform.position}"); Plugin.logger.LogDebug($"{bedroomEventVent.position} -> {treasureRoomCenterTransform.position}");
bedroomEventVent.position = treasureRoomCenterTransform.position; bedroomEventVent.position = treasureRoomCenterTransform.position;
bedroomEventVent.rotation = treasureRoomCenterTransform.rotation; bedroomEventVent.rotation = treasureRoomCenterTransform.rotation;
@ -42,7 +44,7 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
// grab random painting to use // grab random painting to use
var paintingTransform = bedroomEvent.paintingSpawnTransform; var paintingTransform = bedroomEvent.paintingSpawnTransform;
var allPaintings = FindObjectsOfType<ScarletPainting>(); var allPaintings = ScarletGenericManager.Instance.paintings;
var firstAvailablePainting = allPaintings.Where(p => !p.grabbedByEvent) var firstAvailablePainting = allPaintings.Where(p => !p.grabbedByEvent)
.OrderBy(p => Vector3.SqrMagnitude(paintingTransform.position - p.transform.position)) .OrderBy(p => Vector3.SqrMagnitude(paintingTransform.position - p.transform.position))
.FirstOrDefault(); .FirstOrDefault();

View File

@ -0,0 +1,120 @@
using DunGen;
using ScarletMansion.GamePatch.Managers;
using ScarletMansion.GamePatch.Props;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.Netcode;
using UnityEngine;
namespace ScarletMansion.GamePatch.Components.TreasureRoom {
public class TreasureRoomRadioEvent : TreasureRoom {
[Header("References")]
public Transform radioParentTransform;
public ScarletRadio radio;
private int selectedAudioIndex;
private int selectedVolume;
public override bool CanOpen() {
var ready = GetDoorStatusValue() == 3;
if (ready) {
Plugin.logger.LogDebug($"Opening cause radio all setup");
return ready;
}
return false;
}
public override int GetDoorStatusValue() {
if (radio == null) return 3;
var count = 0;
if (radio.playing) count++;
if (radio.audioIndex == selectedAudioIndex) count++;
if (radio.volume == selectedVolume) count++;
return count;
}
private IEnumerable<Transform> GetChildren(Transform parent){
foreach(Transform child in parent){
yield return child;
}
}
protected override void OnTreasureRoomSetup(bool hasTreasureRoom) {
var randomStream = DunGenPatch.Patch.GetRandomStream();
var randomProps = GetChildren(radioParentTransform).Where(t => t.gameObject.activeSelf).ToArray();
Utility.Shuffle(randomStream, randomProps);
var spawnedRadioProp = false;
foreach(var parentTransform in randomProps) {
var prop = parentTransform.GetComponentInChildren<RandomPrefabBasic>();
if (hasTreasureRoom) {
if (!spawnedRadioProp) {
prop.ProcessIndex(randomStream, 0);
spawnedRadioProp = true;
} else {
prop.ProcessSkipCount(randomStream, 1);
}
} else {
prop.Process(randomStream, null);
}
// so the children get the process prop cycling as well
DunGenPatch.Patch.generatorInstance.ProcessProps(null, prop.transform.GetChild(0).gameObject);
}
// hack so i can set up the SpawnSycnedObject myself
if (hasTreasureRoom) {
radioParentTransform.gameObject.SetActive(false);
}
}
protected override void LockTreasureDoor(List<Doorway> doorways) {
base.LockTreasureDoor(doorways);
radioParentTransform.gameObject.SetActive(true);
if (StartOfRound.Instance.IsHost) {
Plugin.logger.LogDebug("HOST: Creating scarlet radio");
var mapPropsContainer = GetMapPropsContainer();
var ssoList = radioParentTransform.GetComponentsInChildren<SpawnSyncedObject>();
foreach(var sso in ssoList) {
var ssoGameobject = GameObject.Instantiate(sso.spawnPrefab, sso.transform.position, sso.transform.rotation, mapPropsContainer.transform);
var networkObject = ssoGameobject.GetComponent<NetworkObject>();
Plugin.logger.LogDebug($"Spawned {ssoGameobject.name}");
var r = ssoGameobject.GetComponentInChildren<ScarletRadio>();
if (r != null) {
radio = r;
radio.treasureRoomEvent = this;
}
networkObject.Spawn(true);
}
if (radio == null) {
Plugin.logger.LogError($"Somehow didn't spawn a scarlet radio. Not really expected but the world won't explode");
return;
}
selectedAudioIndex = UnityEngine.Random.Range(0, radio.audioClips.Length);
selectedVolume = UnityEngine.Random.Range(1, 11);
CreateDoorStatuses(doorways);
UpdateTreasureDoorStatus();
Plugin.logger.LogDebug($"HOST: Radio combination is song index {selectedAudioIndex} and volume {selectedVolume}");
}
}
}
}

View File

@ -36,25 +36,14 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom {
protected override void LockTreasureDoor(List<Doorway> doorways) { protected override void LockTreasureDoor(List<Doorway> doorways) {
base.LockTreasureDoor(doorways); base.LockTreasureDoor(doorways);
hourSelected = randomStream.Next(hourRange.x, hourRange.y); hourSelected = systemRandom.Next(hourRange.x, hourRange.y);
mintuesSelected = randomStream.Next(0, 3) * 15; mintuesSelected = systemRandom.Next(0, 3) * 15;
Plugin.logger.LogDebug($"Opening at {hourSelected}:{mintuesSelected:D2}"); Plugin.logger.LogDebug($"Opening at {hourSelected}:{mintuesSelected:D2}");
timeClockSpawnTransformIndex = randomStream.Next(timeClockSpawnTransforms.Length); timeClockSpawnTransformIndex = systemRandom.Next(timeClockSpawnTransforms.Length);
var parent = timeClockSpawnTransforms[timeClockSpawnTransformIndex]; var parent = timeClockSpawnTransforms[timeClockSpawnTransformIndex];
var copy = Instantiate(timeClockPrefab, parent); var copy = Instantiate(timeClockPrefab, parent);
if (StartOfRound.Instance.IsHost) {
Plugin.logger.LogDebug("HOST: Creating clock");
var spawnSyncedObject = copy.GetComponentInChildren<SpawnSyncedObject>();
var mapPropsContainer = GetMapPropsContainer();
var spawnedObject = Instantiate(spawnSyncedObject.spawnPrefab, spawnSyncedObject.transform.position, spawnSyncedObject.transform.rotation, mapPropsContainer.transform);
var networkObject = spawnedObject.GetComponent<NetworkObject>();
networkObject.Spawn(true);
}
var textMesh = copy.GetComponentInChildren<TextMeshPro>(); var textMesh = copy.GetComponentInChildren<TextMeshPro>();
textMesh.text = $"{hourSelected}:{mintuesSelected:D2}"; textMesh.text = $"{hourSelected}:{mintuesSelected:D2}";
RandomizeCharacters(textMesh); RandomizeCharacters(textMesh);

View File

@ -82,8 +82,11 @@ namespace ScarletMansion {
playerControllerB.DamagePlayer(damage, true, true, CauseOfDeath.Mauling, 1, false, default(Vector3)); playerControllerB.DamagePlayer(damage, true, true, CauseOfDeath.Mauling, 1, false, default(Vector3));
playerControllerB.JumpToFearLevel(1f, true); playerControllerB.JumpToFearLevel(1f, true);
RoundManager.PlayRandomClip(creatureVoice, ramAudioClips, false, 1f, 0); if (playerControllerB.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(playerControllerB, ModPatch.CoronerDeathEnum.GhostKnight));
}
RoundManager.PlayRandomClip(creatureVoice, ramAudioClips, false, 1f, 0);
CallDisappear(); CallDisappear();
} }
} }

View File

@ -423,6 +423,10 @@ namespace ScarletMansion.GamePatch.Enemies {
playerControllerB.JumpToFearLevel(1f, true); playerControllerB.JumpToFearLevel(1f, true);
timeSinceHittingPlayer = Time.realtimeSinceStartup; timeSinceHittingPlayer = Time.realtimeSinceStartup;
if (playerControllerB.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(playerControllerB, ModPatch.CoronerDeathEnum.Knight));
}
SetCoilheadOnCooldownServerRpc(5f); SetCoilheadOnCooldownServerRpc(5f);
} }
} }

View File

@ -1189,6 +1189,10 @@ namespace ScarletMansion.GamePatch.Enemies {
berserkModeTimer = 3f; berserkModeTimer = 3f;
} }
playerControllerB.DamagePlayer(50, true, true, CauseOfDeath.Stabbing, 0, false); playerControllerB.DamagePlayer(50, true, true, CauseOfDeath.Stabbing, 0, false);
if (playerControllerB.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(playerControllerB, ModPatch.CoronerDeathEnum.Maid));
}
StabPlayerServerRpc((int)playerControllerB.playerClientId, currentBehaviourStateIndex != 2); StabPlayerServerRpc((int)playerControllerB.playerClientId, currentBehaviourStateIndex != 2);
} }
} }

View File

@ -134,11 +134,22 @@ namespace ScarletMansion.GamePatch.Items
} }
target.Hit(damage, forward, previousPlayerHeldBy, playHitSFX: true); target.Hit(damage, forward, previousPlayerHeldBy, playHitSFX: true);
var playerComponent = target as PlayerControllerB;
if (playerComponent && playerComponent.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(playerComponent, ModPatch.CoronerDeathEnum.KnifeFriendlyFire));
}
UnBuffShovelServerRpc(); UnBuffShovelServerRpc();
} }
// normal knife // normal knife
else { else {
component.Hit(knifeHitForce, forward, previousPlayerHeldBy, playHitSFX: true); component.Hit(knifeHitForce, forward, previousPlayerHeldBy, playHitSFX: true);
var playerComponent = component as PlayerControllerB;
if (playerComponent && playerComponent.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(playerComponent, ModPatch.CoronerDeathEnum.Knife));
}
} }
bloodParticle.Play(withChildren: true); bloodParticle.Play(withChildren: true);
@ -166,7 +177,7 @@ namespace ScarletMansion.GamePatch.Items
public int GetDamageToPlayer(PlayerControllerB player) { public int GetDamageToPlayer(PlayerControllerB player) {
var scarletPlayer = ScarletPlayerControllerB.GetScarletPlayerScript(player); var scarletPlayer = ScarletPlayerControllerB.GetScarletPlayerScript(player);
if (scarletPlayer == null) return 85; if (scarletPlayer == null) return 95;
var forceKill = scarletPlayer.stabbedSelf; var forceKill = scarletPlayer.stabbedSelf;
scarletPlayer.stabbedSelf = true; scarletPlayer.stabbedSelf = true;
@ -209,8 +220,13 @@ namespace ScarletMansion.GamePatch.Items
yield return new WaitForSeconds(0.25f); yield return new WaitForSeconds(0.25f);
var damage = GetDamageToPlayer(player); var damage = GetDamageToPlayer(player);
Plugin.logger.LogInfo(damage);
player.DamagePlayer(damage, true, true, CauseOfDeath.Stabbing); player.DamagePlayer(damage, true, true, CauseOfDeath.Stabbing);
if (player.isPlayerDead) {
Assets.onPlayerDeath.Call(new ModPatch.CoronerParameters(player, ModPatch.CoronerDeathEnum.KnifeFeed));
}
bloodParticle.Play(withChildren: true); bloodParticle.Play(withChildren: true);
RoundManager.PlayRandomClip(knifeAudio, hitSFX); RoundManager.PlayRandomClip(knifeAudio, hitSFX);

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -39,18 +40,21 @@ namespace ScarletMansion.GamePatch.Items {
public override void LoadItemSaveData(int saveData) { public override void LoadItemSaveData(int saveData) {
base.LoadItemSaveData(saveData); base.LoadItemSaveData(saveData);
variation = saveData; variation = saveData;
mainObjectRenderer.material = variationMaterials[variation];
mainObjectRenderer.material = variationMaterials[variation];
transform.rotation = Quaternion.Euler(itemProperties.restingRotation); // why zeekers
} }
public override void Start() { public override void Start() {
base.Start(); base.Start();
if (isAttached){ if (isAttached){
bedroom = AngerManager.Instance.GetBedroomWithPainting(transform.position); var manager = ScarletGenericManager.Instance;
manager.AddPainting(this);
bedroom = manager.GetBedroomWithPainting(transform.position);
scrapValue = PluginConfig.Instance.paintingValueValue; scrapValue = PluginConfig.Instance.paintingValueValue;
grabbedByEvent = false; grabbedByEvent = false;
} else {
transform.rotation = Quaternion.Euler(itemProperties.restingRotation); // why zeekers
} }
} }
@ -67,8 +71,10 @@ namespace ScarletMansion.GamePatch.Items {
[ClientRpc] [ClientRpc]
public void RepositionClientRpc(Vector3 position, Quaternion rotation){ public void RepositionClientRpc(Vector3 position, Quaternion rotation){
transform.position = position; transform.position = position;
targetFloorPosition = transform.localPosition;
transform.rotation = rotation; transform.rotation = rotation;
bedroom = AngerManager.Instance.GetBedroomWithPainting(position); bedroom = ScarletGenericManager.Instance.GetBedroomWithPainting(position);
grabbedByEvent = true; grabbedByEvent = true;
} }

View File

@ -5,86 +5,22 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using HarmonyLib;
using Unity.Netcode;
using ScarletMansion.GamePatch.Components; using ScarletMansion.GamePatch.Components;
using DunGen; using DunGen;
using Key = UnityEngine.InputSystem.Key;
using ScarletMansion.Lights; using ScarletMansion.Lights;
using UnityEngine.Rendering; using DunGenPlus.Managers;
using UnityEngine.Rendering.HighDefinition;
namespace ScarletMansion.GamePatch.Managers { namespace ScarletMansion.GamePatch.Managers {
public class AngerManager : MonoBehaviour, IDungeonCompleteReceiver { public class AngerManager : MonoBehaviour, IDungeonCompleteReceiver {
public static AngerManager Instance { get; private set; } public static AngerManager Instance { get; private set; }
//public Dictionary<EnemyAI, int> angeredEnemies;
public int level; public int level;
public List<Transform> roomsOfInterest;
public List<ScarletBedroom> bedrooms;
public List<ScarletDoor> doors;
public List<ScarletLight> lights;
//public KeyboardFloatDebug metal = new KeyboardFloatDebug("metal", 0f, 0f, 1f, 0.1f, Key.Numpad4, Key.Numpad7);
//public KeyboardFloatDebug smooth = new KeyboardFloatDebug("smooth", 0f, 0f, 1f, 0.1f, Key.Numpad6, Key.Numpad9);
void Awake(){ void Awake(){
Instance = this; Instance = this;
roomsOfInterest = new List<Transform>();
bedrooms = new List<ScarletBedroom>();
doors = new List<ScarletDoor>();
lights = new List<ScarletLight>();
} }
/*
void Update(){
var enabled = 0;
var active = 0;
var total = 0;
foreach(var l in lights){
if (l.enabled) enabled++;
if (l.gameObject.activeInHierarchy) active++;
total++;
}
Plugin.logger.LogInfo($"{enabled}|{active}/{total}");
}
*/
/*
void Update(){
var deltaIntensity = 0;
if (Utility.IfKeyPress(Key.Numpad7)) {
deltaIntensity = 1;
} else if (Utility.IfKeyPress(Key.Numpad4)) {
deltaIntensity = -1;
}
var deltaRange = 0;
if (Utility.IfKeyPress(Key.Numpad9)) {
deltaRange = 1;
} else if (Utility.IfKeyPress(Key.Numpad6)) {
deltaRange = -1;
}
if (deltaIntensity != 0 || deltaRange != 0){
var tile = Utility.GetClosestTileToPlayer();
var lights = tile.GetComponentsInChildren<ScarletLight>();
var localPlayer = StartOfRound.Instance.localPlayerController.transform.position;
var closestLight = lights.OrderBy(t => Vector3.SqrMagnitude(t.transform.position - localPlayer)).FirstOrDefault();
if (closestLight != null) {
closestLight.light.intensity += deltaIntensity * 0.5f;
closestLight.light.range += deltaRange * 0.25f;
Plugin.logger.LogInfo($"{closestLight.light.intensity}, {closestLight.light.range}");
}
}
}
*/
public void Anger(int angerAmount = 1){ public void Anger(int angerAmount = 1){
Plugin.logger.LogDebug($"Raising anger from {level} to {level + angerAmount}"); Plugin.logger.LogDebug($"Raising anger from {level} to {level + angerAmount}");
var manager = RoundManager.Instance; var manager = RoundManager.Instance;
@ -92,72 +28,7 @@ namespace ScarletMansion.GamePatch.Managers {
level += angerAmount; level += angerAmount;
} }
public void AddBedroom(ScarletBedroom b){ public static ItemReference[] CreateAngerLoot(int count, System.Random sysRandom){
bedrooms.Add(b);
}
public void AddRoomOfInterest(Transform t) {
roomsOfInterest.Add(t);
}
public void AddDoor(ScarletDoor d){
// I want to get only doors that are revelant
foreach(var t in roomsOfInterest){
var dist = Vector3.SqrMagnitude(d.transform.position - t.position);
if (dist < 24f * 24f){
doors.Add(d);
return;
}
}
}
public ScarletBedroom GetBedroomWithPainting(Vector3 basePosition){
ScarletBedroom target = null;
var dist = 1f;
foreach(var b in bedrooms){
var newdist = Vector3.SqrMagnitude(basePosition - b.paintingSpawnTransform.position);
if (newdist < dist){
target = b;
dist = newdist;
}
}
if (target == null){
Plugin.logger.LogError($"There is no close bedroom painting spawn at {basePosition}");
return null;
}
//Plugin.logger.LogInfo($"Closest bedroom painting spawn {dist} away");
return target;
}
public ScarletDoor GetScarletDoor(Vector3 basePosition){
ScarletDoor target = null;
var dist = 1f;
foreach(var b in doors){
var newdist = Vector3.SqrMagnitude(basePosition - b.transform.position);
if (newdist < dist){
target = b;
dist = newdist;
}
}
if (target == null){
Plugin.logger.LogError($"There is no close door spawn at {basePosition}");
return null;
}
//Plugin.logger.LogInfo($"Closest door spawn {dist} away");
return target;
}
public void AddLight(ScarletLight light){
lights.Add(light);
}
public ItemReference[] CreateAngerLoot(int count, System.Random sysRandom){
var roundManager = RoundManager.Instance; var roundManager = RoundManager.Instance;
if (!roundManager.IsServer) return null; if (!roundManager.IsServer) return null;
@ -185,7 +56,7 @@ namespace ScarletMansion.GamePatch.Managers {
return bonusItems; return bonusItems;
} }
public void SpawnAngerLoot(ItemReference[] loot, Transform[] spawnTransforms){ public static void SpawnAngerLoot(ItemReference[] loot, Transform[] spawnTransforms){
var roundManager = RoundManager.Instance; var roundManager = RoundManager.Instance;
if (loot == null) { if (loot == null) {
@ -206,61 +77,17 @@ namespace ScarletMansion.GamePatch.Managers {
} }
public void TriggerAngerLightBrief(float duration){ public void TriggerAngerLightBrief(float duration){
foreach(var s in lights){ foreach(var s in ScarletGenericManager.Instance.lights){
s.BeginAngry(duration, false); s.SetColorState(ScarletLight.ColorState.TemporaryRed);
} }
} }
public void TriggerAngerLightForever(){ public void TriggerAngerLightForever(){
foreach(var s in lights){ foreach(var s in ScarletGenericManager.Instance.lights){
s.BeginAngry(0f, true); s.SetColorState(ScarletLight.ColorState.Red);
} }
} }
/*
public void Anger(){
level += 1;
var manager = RoundManager.Instance;
var enemies = manager.SpawnedEnemies;
foreach(var e in enemies){
// only inside
if (e.enemyType.isDaytimeEnemy || e.isOutside) continue;
if (!angeredEnemies.ContainsKey(e))
angeredEnemies.Add(e, 0);
}
foreach(var e in angeredEnemies.Keys){
AngerEnemy(e, level - angeredEnemies[e]);
angeredEnemies[e] = level;
}
}
[ClientRpc]
public void AngerEnemyClientRpc(NetworkBehaviourReference enemyRef, int levelOffset){
if (enemyRef.TryGet<EnemyAI>(out var enemy)){
if (levelOffset < 1) return;
var type = enemy.GetType();
if (type == typeof(BlobAI)){
Plugin.logger.LogInfo("Can't anger blob yet");
}
else {
Plugin.logger.LogInfo($"Angering {type} is not yet supported");
}
}
}
public void Remove(EnemyAI enemy){
angeredEnemies.Remove(enemy);
}
*/
} }
} }

View File

@ -0,0 +1,160 @@
using DunGen;
using DunGenPlus.Managers;
using ScarletMansion.GamePatch.Components;
using ScarletMansion.GamePatch.Items;
using ScarletMansion.Lights;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace ScarletMansion.GamePatch.Managers {
public class ScarletGenericManager : MonoBehaviour, IDungeonCompleteReceiver {
public static ScarletGenericManager Instance { get; private set; }
public List<Transform> roomsOfInterest;
public List<ScarletBedroom> bedrooms;
public List<ScarletPainting> paintings;
public List<ScarletDoor> doors;
public List<ScarletLight> lights;
public ScarletBookPath[] bookPaths;
public List<IScarletSelfDestroy> selfDestroyTargets;
private int lastHour;
void Awake(){
Instance = this;
roomsOfInterest = new List<Transform>();
bedrooms = new List<ScarletBedroom>();
paintings = new List<ScarletPainting>();
doors = new List<ScarletDoor>();
lights = new List<ScarletLight>();
}
void Update(){
if (!StartOfRound.Instance.IsServer) return;
var time = Utility.GetTime();
var hours = time.hours;
var hourChanged = lastHour != hours;
if (!hourChanged) return;
Plugin.logger.LogDebug($"New hour: {hours}");
for (var i = 0; i < selfDestroyTargets.Count; i++){
var t = selfDestroyTargets[i];
var index = i;
if (!t.IsDestroyed && UnityEngine.Random.value < t.Chance) {
t.PreDestroy();
StartCoroutine(DelayDestroy(t, index, UnityEngine.Random.Range(0f, 60f)));
}
}
lastHour = hours;
}
private IEnumerator DelayDestroy(IScarletSelfDestroy target, int index, float delay){
Plugin.logger.LogDebug($"{target} destroying itself in {delay} sec");
yield return new WaitForSeconds(delay);
ScarletNetworkManager.Instance.CallSelfDestroyTargetClientRpc(index);
}
public void AddBedroom(ScarletBedroom b){
bedrooms.Add(b);
}
public void AddPainting(ScarletPainting painting){
paintings.Add(painting);
}
public void AddRoomOfInterest(Transform t) {
roomsOfInterest.Add(t);
}
public void AddDoor(ScarletDoor d){
// I want to get only doors that are revelant
foreach(var t in roomsOfInterest){
var dist = Vector3.SqrMagnitude(d.transform.position - t.position);
if (dist < 24f * 24f){
doors.Add(d);
return;
}
}
}
public ScarletBedroom GetBedroomWithPainting(Vector3 basePosition){
ScarletBedroom target = null;
var dist = 1f;
foreach(var b in bedrooms){
var newdist = Vector3.SqrMagnitude(basePosition - b.paintingSpawnTransform.position);
if (newdist < dist){
target = b;
dist = newdist;
}
}
if (target == null){
Plugin.logger.LogError($"There is no close bedroom painting spawn at {basePosition}");
return null;
}
//Plugin.logger.LogInfo($"Closest bedroom painting spawn {dist} away");
return target;
}
public ScarletDoor GetScarletDoor(Vector3 basePosition){
ScarletDoor target = null;
var dist = 1f;
foreach(var b in doors){
var newdist = Vector3.SqrMagnitude(basePosition - b.transform.position);
if (newdist < dist){
target = b;
dist = newdist;
}
}
if (target == null){
Plugin.logger.LogError($"There is no close door spawn at {basePosition}");
return null;
}
//Plugin.logger.LogInfo($"Closest door spawn {dist} away");
return target;
}
public void AddLight(ScarletLight light){
lights.Add(light);
}
public void OnDungeonComplete(Dungeon dungeon) {
selfDestroyTargets = dungeon.GetComponentsInChildren<IScarletSelfDestroy>().ToList();
bookPaths = dungeon.GetComponentsInChildren<ScarletBookPath>();
if (StartOfRound.Instance.IsServer){
DoorwayManager.onMainEntranceTeleportSpawnedEvent.AddTemporaryEvent("BookPaths", () => SetupBookPaths());
}
}
private void SetupBookPaths(){
StartCoroutine(SetupBookPathsDelay(5f));
}
private IEnumerator SetupBookPathsDelay(float delay){
yield return new WaitForSecondsRealtime(delay);
ScarletNetworkManager.Instance.SetupBookPathsClientRpc();
}
}
}

View File

@ -11,6 +11,7 @@ using ScarletMansion.GamePatch.Items;
using ScarletMansion.GamePatch; using ScarletMansion.GamePatch;
using ScarletMansion.GamePatch.Components; using ScarletMansion.GamePatch.Components;
using static LethalLevelLoader.ExtendedEvent; using static LethalLevelLoader.ExtendedEvent;
using ScarletMansion.GamePatch.Managers;
namespace ScarletMansion { namespace ScarletMansion {
@ -325,13 +326,30 @@ namespace ScarletMansion {
Destroy(copy, 5f); Destroy(copy, 5f);
} }
[ClientRpc]
public void SetupBookPathsClientRpc(){
if (ScarletGenericManager.Instance == null) return;
var bookPaths = ScarletGenericManager.Instance.bookPaths;
foreach(var b in bookPaths) {
b.ResetPath();
}
}
[ClientRpc]
public void CallSelfDestroyTargetClientRpc(int index){
if (ScarletGenericManager.Instance == null) return;
ScarletGenericManager.Instance.selfDestroyTargets[index].Destroy();
}
} }
public static class ScarletNetworkManagerUtility { public static class ScarletNetworkManagerUtility {
public static int GetCriticalDamageToPlayer(PlayerControllerB player, bool forceKill) { public static int GetCriticalDamageToPlayer(PlayerControllerB player, bool forceKill) {
if (player.health > 20 && !forceKill) { if (!player.criticallyInjured && !forceKill) {
return player.health - 15; return player.health - 5;
} }
return player.health; return player.health;
} }

View File

@ -16,8 +16,24 @@ namespace ScarletMansion.GamePatch.Props {
var prefab = props[value]; var prefab = props[value];
SpawnGameObject(randomStream, prefab); SpawnGameObject(randomStream, prefab);
} }
public void ProcessIndex(RandomStream randomStream, int index){
if (index >= props.Count) return;
var prefab = props[index];
SpawnGameObject(randomStream, prefab);
}
public void ProcessSkipCount(RandomStream randomStream, int count){
if (count >= props.Count) return;
var index = randomStream.Next(count, props.Count);
var prefab = props[index];
SpawnGameObject(randomStream, prefab);
}
} }
} }

View File

@ -11,12 +11,24 @@ namespace ScarletMansion.GamePatch.Props {
public List<GameObject> props = new List<GameObject>(); public List<GameObject> props = new List<GameObject>();
[Header("Randomizer")]
public bool randomizePosition = false; public bool randomizePosition = false;
public float randomPositionRange = 0f; public float randomPositionRange = 0f;
public bool randomizeRotation = true; public bool randomizeRotation = true;
public FloatRange randomRotationRange = new FloatRange(0f, 360f); public FloatRange randomRotationRange = new FloatRange(0f, 360f);
[Header("Special Logic")]
public bool skipNextSpawn;
public void SpawnGameObject(RandomStream randomStream, GameObject prefab){ public void SpawnGameObject(RandomStream randomStream, GameObject prefab){
// I really hate that I have to do this
// but DungeonGenerator.ProcessProps() goes through every RandomProp regardless if the gameobject is active or not
// I cannot escape it
if (skipNextSpawn) {
skipNextSpawn = false;
return;
}
var gameObject = GameObject.Instantiate(prefab); var gameObject = GameObject.Instantiate(prefab);
var gameObjectTransform = gameObject.transform; var gameObjectTransform = gameObject.transform;
gameObjectTransform.parent = transform; gameObjectTransform.parent = transform;
@ -37,6 +49,7 @@ namespace ScarletMansion.GamePatch.Props {
} }
} }
public void OnDrawGizmosSelected(){ public void OnDrawGizmosSelected(){
if (randomizePosition) { if (randomizePosition) {
Utility.DrawGizmoCircle(transform, randomPositionRange, Color.green); Utility.DrawGizmoCircle(transform, randomPositionRange, Color.green);

View File

@ -0,0 +1,29 @@
using GameNetcodeStuff;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScarletMansion.ModPatch {
public enum CoronerDeathEnum {
Knight,
Maid,
Void,
GhostKnight,
Knife,
KnifeFeed,
KnifeFriendlyFire
}
public struct CoronerParameters {
public PlayerControllerB player;
public CoronerDeathEnum death;
public CoronerParameters(PlayerControllerB player, CoronerDeathEnum death){
this.player = player;
this.death = death;
}
}
}

View File

@ -20,7 +20,7 @@ namespace ScarletMansion.ModPatch {
new LethalConfigPatch(lethalConfigGuid), new LethalConfigPatch(lethalConfigGuid),
new FacilityMeltdownPatch(facilityMeldownGuid), new FacilityMeltdownPatch(facilityMeldownGuid),
new ReservedFlashlightPatch(reserveFlashlightGuid), new ReservedFlashlightPatch(reserveFlashlightGuid),
new ReservedKeyPatch(reserveKeyGuid), new ReservedKeyPatch(reserveKeyGuid)
}; };

View File

@ -23,7 +23,7 @@ namespace ScarletMansion {
[BepInDependency("imabatby.lethallevelloader", "1.2.0.3")] [BepInDependency("imabatby.lethallevelloader", "1.2.0.3")]
[BepInDependency("evaisa.lethallib", "0.13.2")] [BepInDependency("evaisa.lethallib", "0.13.2")]
[BepInDependency("dev.ladyalice.dungenplus", "1.1.0")] [BepInDependency("dev.ladyalice.dungenplus", "1.1.2")]
//[BepInDependency(ModCompability.advancedCompanyGuid, BepInDependency.DependencyFlags.SoftDependency)] //[BepInDependency(ModCompability.advancedCompanyGuid, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(ModCompability.lethalConfigGuid, BepInDependency.DependencyFlags.SoftDependency)] [BepInDependency(ModCompability.lethalConfigGuid, BepInDependency.DependencyFlags.SoftDependency)]
@ -34,7 +34,7 @@ namespace ScarletMansion {
public class Plugin : BaseUnityPlugin { public class Plugin : BaseUnityPlugin {
public const string modGUID = "dev.ladyalice.scarletmansion"; public const string modGUID = "dev.ladyalice.scarletmansion";
private const string modName = "Scarlet Mansion"; private const string modName = "Scarlet Mansion";
private const string modVersion = "1.3.26"; private const string modVersion = "1.3.27";
public readonly Harmony harmony = new Harmony(modGUID); public readonly Harmony harmony = new Harmony(modGUID);
@ -92,6 +92,7 @@ namespace ScarletMansion {
sdmLevelMatchProperties.planetNames.Add(new StringWithRarity("Rend", 300)); sdmLevelMatchProperties.planetNames.Add(new StringWithRarity("Rend", 300));
sdmLevelMatchProperties.planetNames.Add(new StringWithRarity("Titan", 69)); sdmLevelMatchProperties.planetNames.Add(new StringWithRarity("Titan", 69));
sdmLevelMatchProperties.planetNames.Add(new StringWithRarity("Sanguine", 900)); sdmLevelMatchProperties.planetNames.Add(new StringWithRarity("Sanguine", 900));
sdmLevelMatchProperties.planetNames.Add(new StringWithRarity("Scarlet Devil Mansion", 900));
var extendedContent = new List<ExtendedContent>(); var extendedContent = new List<ExtendedContent>();

View File

@ -473,8 +473,8 @@ namespace ScarletMansion {
public static ConfigEntryBundle<int> hallwayLightsWeight = new ConfigEntryBundle<int>( public static ConfigEntryBundle<int> hallwayLightsWeight = new ConfigEntryBundle<int>(
dungeonLightingPrefix, dungeonLightingPrefix,
"Hallway Lights Weight", "Hallway Lights Weight",
75, 150,
"The weight for a hallway wall lamp to appear on its respective walls. With the default weight of 75 against the weight of the empty wall of 75, there is a 50% chance that a wall lamp will spawn. Increasing the weight to 225 will give you a 75% chance, 675=90% chance, and so on.", "The weight for a hallway wall lamp to appear on its respective walls. With the default weight of 150 against the weight of the empty wall of 50, there is a 75% chance that a wall lamp will spawn. Setting the weight to 100 will give you a 67% chance, 450=90% chance, and so on.",
null, null,
new AcceptableValueRange<int>(0, 999) new AcceptableValueRange<int>(0, 999)
); );
@ -482,8 +482,8 @@ namespace ScarletMansion {
public static ConfigEntryBundle<int> ceilingLightsWeight = new ConfigEntryBundle<int>( public static ConfigEntryBundle<int> ceilingLightsWeight = new ConfigEntryBundle<int>(
dungeonLightingPrefix, dungeonLightingPrefix,
"Chandelier Lights Weight", "Chandelier Lights Weight",
75, 150,
"The weight for a chandelier to appear on its respective ceilings. With the default weight of 75 against the weight of the empty ceiling of 75, there is a 50% chance that a chandelier will spawn. Increasing the weight to 225 will give you a 75% chance, 675=90% chance, and so on.", "The weight for a chandelier to appear on its respective ceilings. With the default weight of 150 against the weight of the empty ceiling of 50, there is a 75% chance that a chandelier will spawn. Setting the weight to 100 will give you a 67% chance, 450=90% chance, and so on.",
null, null,
new AcceptableValueRange<int>(0, 999) new AcceptableValueRange<int>(0, 999)
); );
@ -491,8 +491,8 @@ namespace ScarletMansion {
public static ConfigEntryBundle<int> lightsSpawnZeroWeight = new ConfigEntryBundle<int>( public static ConfigEntryBundle<int> lightsSpawnZeroWeight = new ConfigEntryBundle<int>(
dungeonLightingPrefix, dungeonLightingPrefix,
"0 Lights Weight", "0 Lights Weight",
2, 1,
"The weight that none of the spawned light sources (desk lamps, wall lamps, chandeliers) in a given tile will emit light. With the default weight spread of [2, 7, 1], there is a 20% chance that even in a room filled with lamps, none of them will emit light.", "The weight that none of the spawned light sources (desk lamps, wall lamps, chandeliers) in a given tile will emit light. With the default weight spread of [1, 7, 2], there is a 10% chance that even in a room filled with lamps, none of them will emit light.",
new ConfigEntryBundleExtraParameters(VerifyLightingValues, false), new ConfigEntryBundleExtraParameters(VerifyLightingValues, false),
new AcceptableValueRange<int>(0, 99) new AcceptableValueRange<int>(0, 99)
); );
@ -501,7 +501,7 @@ namespace ScarletMansion {
dungeonLightingPrefix, dungeonLightingPrefix,
"1 Light Weight", "1 Light Weight",
7, 7,
"The weight that only 1 of the spawned light sources (desk lamps, wall lamps, chandeliers) in a given tile will emit light. With the default weight spread of [2, 7, 1], there is a 70% chance that even in a room filled with lamps, only one of them will emit light.", "The weight that only 1 of the spawned light sources (desk lamps, wall lamps, chandeliers) in a given tile will emit light. With the default weight spread of [1, 7, 2], there is a 70% chance that even in a room filled with lamps, only one of them will emit light.",
new ConfigEntryBundleExtraParameters(VerifyLightingValues, false), new ConfigEntryBundleExtraParameters(VerifyLightingValues, false),
new AcceptableValueRange<int>(0, 99) new AcceptableValueRange<int>(0, 99)
); );
@ -509,8 +509,8 @@ namespace ScarletMansion {
public static ConfigEntryBundle<int> lightsSpawnTwoWeight = new ConfigEntryBundle<int>( public static ConfigEntryBundle<int> lightsSpawnTwoWeight = new ConfigEntryBundle<int>(
dungeonLightingPrefix, dungeonLightingPrefix,
"2 Lights Weight", "2 Lights Weight",
1, 2,
"The weight that only 2 of the spawned light sources (desk lamps, wall lamps, chandeliers) in a given tile will emit light. With the default weight spread of [2, 7, 1], there is a 10% chance that even in a room filled with lamps, only two of them will emit light.", "The weight that only 2 of the spawned light sources (desk lamps, wall lamps, chandeliers) in a given tile will emit light. With the default weight spread of [1, 7, 2], there is a 20% chance that even in a room filled with lamps, only two of them will emit light.",
new ConfigEntryBundleExtraParameters(VerifyLightingValues, true), new ConfigEntryBundleExtraParameters(VerifyLightingValues, true),
new AcceptableValueRange<int>(0, 99) new AcceptableValueRange<int>(0, 99)
); );

View File

@ -129,7 +129,7 @@ namespace ScarletMansion {
Dark Dark
} }
// 2, 7, 1 // 1, 8, 2
public static ChangeList defaultLighting = new ChangeList( public static ChangeList defaultLighting = new ChangeList(
"Default", "Default",
"The default lighting values.", "The default lighting values.",
@ -145,10 +145,10 @@ namespace ScarletMansion {
public static ChangeList brightLighting = new ChangeList( public static ChangeList brightLighting = new ChangeList(
"Bright", "Bright",
"Makes light sources much more common.", "Makes light sources much more common.",
new ChangeInt ( PluginConfig.hallwayLightsWeight, 225 ), new ChangeInt ( PluginConfig.hallwayLightsWeight, 450 ),
new ChangeInt ( PluginConfig.ceilingLightsWeight, 225 ), new ChangeInt ( PluginConfig.ceilingLightsWeight, 450 ),
new ChangeInt ( PluginConfig.lightsSpawnZeroWeight, 1 ), new ChangeInt ( PluginConfig.lightsSpawnZeroWeight, 0 ),
new ChangeInt ( PluginConfig.lightsSpawnOneWeight, 6 ), new ChangeInt ( PluginConfig.lightsSpawnOneWeight, 7 ),
new ChangeInt ( PluginConfig.lightsSpawnTwoWeight, 3 ) new ChangeInt ( PluginConfig.lightsSpawnTwoWeight, 3 )
//new ChangeInt ( PluginConfig.lightsSpawnThreeWeight, 2 ) //new ChangeInt ( PluginConfig.lightsSpawnThreeWeight, 2 )
); );
@ -156,10 +156,10 @@ namespace ScarletMansion {
public static ChangeList darkLighting = new ChangeList( public static ChangeList darkLighting = new ChangeList(
"Dark", "Dark",
"Makes light sources much less common.", "Makes light sources much less common.",
new ChangeInt ( PluginConfig.hallwayLightsWeight, 25 ), new ChangeInt ( PluginConfig.hallwayLightsWeight, 50 ),
new ChangeInt ( PluginConfig.ceilingLightsWeight, 25 ), new ChangeInt ( PluginConfig.ceilingLightsWeight, 50 ),
new ChangeInt ( PluginConfig.lightsSpawnZeroWeight, 3 ), new ChangeInt ( PluginConfig.lightsSpawnZeroWeight, 2 ),
new ChangeInt ( PluginConfig.lightsSpawnOneWeight, 7 ), new ChangeInt ( PluginConfig.lightsSpawnOneWeight, 8 ),
new ChangeInt ( PluginConfig.lightsSpawnTwoWeight, 0 ) new ChangeInt ( PluginConfig.lightsSpawnTwoWeight, 0 )
//new ChangeInt ( PluginConfig.lightsSpawnThreeWeight, 0 ) //new ChangeInt ( PluginConfig.lightsSpawnThreeWeight, 0 )
); );

View File

@ -34,9 +34,6 @@
<Reference Include="0Harmony"> <Reference Include="0Harmony">
<HintPath>..\..\..\Libraries\0Harmony.dll</HintPath> <HintPath>..\..\..\Libraries\0Harmony.dll</HintPath>
</Reference> </Reference>
<Reference Include="AdvancedCompany">
<HintPath>..\..\..\Libraries\AdvancedCompany.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass"> <Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\Libraries\Assembly-CSharp-firstpass.dll</HintPath> <HintPath>..\..\..\Libraries\Assembly-CSharp-firstpass.dll</HintPath>
</Reference> </Reference>
@ -154,12 +151,14 @@
<Compile Include="DunGenPatch\Patch.cs" /> <Compile Include="DunGenPatch\Patch.cs" />
<Compile Include="GamePatch\Components\FloorCleanup.cs" /> <Compile Include="GamePatch\Components\FloorCleanup.cs" />
<Compile Include="GamePatch\Components\FloorCleanUpParent.cs" /> <Compile Include="GamePatch\Components\FloorCleanUpParent.cs" />
<Compile Include="GamePatch\Components\IScarletSelfDestroy.cs" />
<Compile Include="GamePatch\Components\KnightSpawnPoint.cs" /> <Compile Include="GamePatch\Components\KnightSpawnPoint.cs" />
<Compile Include="GamePatch\Components\Lights\ScarletLight.cs" /> <Compile Include="GamePatch\Components\Lights\ScarletLight.cs" />
<Compile Include="GamePatch\Components\Lights\ScarletLightCleanup.cs" /> <Compile Include="GamePatch\Components\Lights\ScarletLightCleanup.cs" />
<Compile Include="GamePatch\Components\PathOpenup.cs" /> <Compile Include="GamePatch\Components\PathOpenup.cs" />
<Compile Include="GamePatch\Components\PathOpenUpParent.cs" /> <Compile Include="GamePatch\Components\PathOpenUpParent.cs" />
<Compile Include="GamePatch\Components\ScarletBedroom.cs" /> <Compile Include="GamePatch\Components\ScarletBedroom.cs" />
<Compile Include="GamePatch\Components\ScarletBookPath.cs" />
<Compile Include="GamePatch\Components\ScarletClock.cs" /> <Compile Include="GamePatch\Components\ScarletClock.cs" />
<Compile Include="GamePatch\Components\ScarletDoor.cs" /> <Compile Include="GamePatch\Components\ScarletDoor.cs" />
<Compile Include="GamePatch\Components\ScarletDoorLock.cs" /> <Compile Include="GamePatch\Components\ScarletDoorLock.cs" />
@ -177,6 +176,7 @@
<Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomBookZone.cs" /> <Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomBookZone.cs" />
<Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomDoorStatus.cs" /> <Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomDoorStatus.cs" />
<Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomPaintingGrabEvent.cs" /> <Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomPaintingGrabEvent.cs" />
<Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomRadioEvent.cs" />
<Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomTimeEvent.cs" /> <Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomTimeEvent.cs" />
<Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomBookPullEvent.cs" /> <Compile Include="GamePatch\Components\TreasureRoom\TreasureRoomBookPullEvent.cs" />
<Compile Include="GamePatch\DoorLockPatch.cs" /> <Compile Include="GamePatch\DoorLockPatch.cs" />
@ -205,6 +205,7 @@
<Compile Include="GamePatch\LoadAssetsIntoLevelPatch.cs" /> <Compile Include="GamePatch\LoadAssetsIntoLevelPatch.cs" />
<Compile Include="GamePatch\Managers\AngerManager.cs" /> <Compile Include="GamePatch\Managers\AngerManager.cs" />
<Compile Include="GamePatch\Managers\KnightSpawnManager.cs" /> <Compile Include="GamePatch\Managers\KnightSpawnManager.cs" />
<Compile Include="GamePatch\Managers\ScarletGenericManager.cs" />
<Compile Include="GamePatch\Managers\ScarletLightingManager.cs" /> <Compile Include="GamePatch\Managers\ScarletLightingManager.cs" />
<Compile Include="GamePatch\Managers\ScarletNetworkManager.cs" /> <Compile Include="GamePatch\Managers\ScarletNetworkManager.cs" />
<Compile Include="GamePatch\MenuManagerPatch.cs" /> <Compile Include="GamePatch\MenuManagerPatch.cs" />
@ -225,6 +226,7 @@
<Compile Include="GamePatch\Weathers\SDMWeatherManager.cs" /> <Compile Include="GamePatch\Weathers\SDMWeatherManager.cs" />
<Compile Include="LoadingPatch\NetworkObjectListScriptableObject.cs" /> <Compile Include="LoadingPatch\NetworkObjectListScriptableObject.cs" />
<Compile Include="MainMenuUpdate.cs" /> <Compile Include="MainMenuUpdate.cs" />
<Compile Include="ModPatch\CoronerParameters.cs" />
<Compile Include="ModPatch\FacilityMeltdownPatch.cs" /> <Compile Include="ModPatch\FacilityMeltdownPatch.cs" />
<Compile Include="ModPatch\LethalConfigPatch.cs" /> <Compile Include="ModPatch\LethalConfigPatch.cs" />
<Compile Include="ModPatch\ModCompability.cs" /> <Compile Include="ModPatch\ModCompability.cs" />

View File

@ -115,6 +115,31 @@ namespace ScarletMansion {
} }
} }
public class ActionList<T> {
public string name;
public List<(string name, Action<T> action)> actionList;
public ActionList(string name){
this.name = name;
actionList = new List<(string, Action<T>)>();
}
public void AddEvent(string name, Action<T> act){
actionList.Add((name, act));
}
public void Call(T argument){
foreach(var pair in actionList){
try {
pair.action.Invoke(argument);
} catch (Exception e) {
Plugin.logger.LogError($"Error with event {name}/{pair.name}");
Plugin.logger.LogError(e.ToString());
}
}
}
}
public static class Utility { public static class Utility {
public static float GetRandomNumber(this System.Random random, double minimum, double maximum) { public static float GetRandomNumber(this System.Random random, double minimum, double maximum) {

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScarletMansionCoronerPatch", "ScarletMansionCoronerPatch\ScarletMansionCoronerPatch.csproj", "{CB30B9C8-2679-4C65-86A3-B4680B73DA4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CB30B9C8-2679-4C65-86A3-B4680B73DA4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB30B9C8-2679-4C65-86A3-B4680B73DA4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB30B9C8-2679-4C65-86A3-B4680B73DA4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB30B9C8-2679-4C65-86A3-B4680B73DA4F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {15C1AA9F-BF3A-43DA-8275-637922601260}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,37 @@
using Coroner;
using GameNetcodeStuff;
using ScarletMansion.ModPatch;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScarletMansionCoronerPatch {
public class Patch {
public static Dictionary<CoronerDeathEnum, object> causesOfDeath;
public static void Activate() {
causesOfDeath = new Dictionary<CoronerDeathEnum, object>();
causesOfDeath.Add(CoronerDeathEnum.Knight, AdvancedCauseOfDeath.Build("DeathEnemyKnight"));
causesOfDeath.Add(CoronerDeathEnum.Maid, AdvancedCauseOfDeath.Build("DeathEnemyMaid"));
causesOfDeath.Add(CoronerDeathEnum.Void, AdvancedCauseOfDeath.Build("DeathPitVoid"));
causesOfDeath.Add(CoronerDeathEnum.GhostKnight, AdvancedCauseOfDeath.Build("DeathEnemyGhostKnight"));
causesOfDeath.Add(CoronerDeathEnum.Knife, AdvancedCauseOfDeath.Build("DeathPlayerMaidKnife"));
causesOfDeath.Add(CoronerDeathEnum.KnifeFeed, AdvancedCauseOfDeath.Build("DeathPlayerMaidKnifeFeed"));
causesOfDeath.Add(CoronerDeathEnum.KnifeFriendlyFire, AdvancedCauseOfDeath.Build("DeathPlayerMaidKnifeFriendlyFire"));
ScarletMansion.Assets.onPlayerDeath.AddEvent("CoronerPatch", ProcessCauseOfDeath);
}
public static void ProcessCauseOfDeath(CoronerParameters parameters) {
if (causesOfDeath.TryGetValue(parameters.death, out var value)) {
Coroner.API.SetCauseOfDeath(parameters.player, (AdvancedCauseOfDeath)value);
Plugin.logger.LogInfo(parameters.death);
}
}
}
}

View File

@ -0,0 +1,54 @@
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScarletMansionCoronerPatch {
[BepInPlugin(modGUID, modName, modVersion)]
[BepInDependency("dev.ladyalice.scarletmansion", "1.3.27")]
[BepInDependency(targetModGUID, BepInDependency.DependencyFlags.SoftDependency)]
public class Plugin : BaseUnityPlugin {
public const string modGUID = "dev.ladyalice.scarletmansion.coronerpatch";
private const string modName = "Scarlet Mansion Coroner Patch";
private const string modVersion = "1.0.0";
public const string targetModGUID = "com.elitemastereric.coroner";
public const string targetModVersion = "2.1.0";
public readonly Harmony harmony = new Harmony(modGUID);
public static Plugin Instance {get; private set;}
public static ManualLogSource logger { get; internal set; }
void Awake(){
if (Instance == null) Instance = this;
logger = BepInEx.Logging.Logger.CreateLogSource(modGUID);
var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID);
if (!modLoaded) return;
bool validVersion;
var pluginInfo = Chainloader.PluginInfos[targetModGUID];
var loadedVersion = pluginInfo.Metadata.Version;
if (string.IsNullOrWhiteSpace(targetModVersion)){
validVersion = true;
} else {
var requiredVersion = new Version(targetModVersion);
validVersion = loadedVersion >= requiredVersion;
}
if (validVersion){
logger.LogInfo($"Plugin {modName} has been added!");
Patch.Activate();
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// アセンブリに関する一般情報は以下を通して制御されます
// 制御されます。アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
[assembly: AssemblyTitle("ScarletMansionCoronerPatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScarletMansionCoronerPatch")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
// その型の ComVisible 属性を true に設定してください。
[assembly: ComVisible(false)]
// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
[assembly: Guid("cb30b9c8-2679-4c65-86a3-b4680b73da4f")]
// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
//
// メジャー バージョン
// マイナー バージョン
// ビルド番号
// リビジョン
//
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CB30B9C8-2679-4C65-86A3-B4680B73DA4F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ScarletMansionCoronerPatch</RootNamespace>
<AssemblyName>ScarletMansionCoronerPatch</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\..\Libraries\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\..\..\Libraries\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-publicized">
<HintPath>..\..\..\Libraries\Assembly-CSharp-publicized.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\..\Libraries\BepInEx.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>..\..\..\Libraries\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="Coroner">
<HintPath>..\..\..\Libraries\Coroner.dll</HintPath>
</Reference>
<Reference Include="ScarletMansion">
<HintPath>..\..\..\Libraries\ScarletMansion.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.Netcode.Components">
<HintPath>..\..\..\Libraries\Unity.Netcode.Components.dll</HintPath>
</Reference>
<Reference Include="Unity.Netcode.Runtime">
<HintPath>..\..\..\Libraries\Unity.Netcode.Runtime.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\Libraries\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\Libraries\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Patch.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -55,7 +55,7 @@ namespace ScarletMansionMimicsPatch {
FixDoorwayForSDMFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight); FixDoorwayForSDMFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight);
} }
Plugin.logger.LogInfo("Fixed a doorway for a mimic"); Plugin.logger.LogDebug("Fixed a doorway for a mimic");
} }
public override void OnMimicAttackStart(MimicDoor mimicDoor, PlayerControllerB playerToAttack) { public override void OnMimicAttackStart(MimicDoor mimicDoor, PlayerControllerB playerToAttack) {

View File

@ -39,7 +39,6 @@ namespace ScarletMansionMimicsPatch {
if (Instance == null) Instance = this; if (Instance == null) Instance = this;
logger = BepInEx.Logging.Logger.CreateLogSource(modGUID); logger = BepInEx.Logging.Logger.CreateLogSource(modGUID);
logger.LogInfo($"Plugin {modName} has been added!");
var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID); var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID);
if (!modLoaded) return; if (!modLoaded) return;