diff --git a/ScarletMansion/ScarletMansion/Assets.cs b/ScarletMansion/ScarletMansion/Assets.cs index e975d2d..3474970 100644 --- a/ScarletMansion/ScarletMansion/Assets.cs +++ b/ScarletMansion/ScarletMansion/Assets.cs @@ -176,7 +176,7 @@ namespace ScarletMansion { if (resourceNames.Length >= 1) { var name = resourceNames[0]; using (var assetStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name)) { - Plugin.logger.LogInfo($"Loading resource {name}"); + Plugin.logger.LogDebug($"Loading resource {name}"); MainAssetBundle = AssetBundle.LoadFromStream(assetStream); } } @@ -213,7 +213,7 @@ namespace ScarletMansion { globalItems.Add(entry); Items.RegisterItem(i); - Plugin.logger.LogInfo($"Global Item {i.itemName} registered"); + Plugin.logger.LogDebug($"Global Item {i.itemName} registered"); } foreach(var i in networkObjectList.scrapItems) { @@ -223,7 +223,7 @@ namespace ScarletMansion { Items.RegisterScrap(i, 0, Levels.LevelTypes.None); NetworkPrefabs.RegisterNetworkPrefab(i.spawnPrefab); - Plugin.logger.LogInfo($"Scrap Item {i.itemName} registered"); + Plugin.logger.LogDebug($"Scrap Item {i.itemName} registered"); } flashlight = new Flashlight("Pro Flashlight", 0); @@ -268,7 +268,7 @@ namespace ScarletMansion { var missingasset = asset == null; if (missingasset || onlyReportErrors == true) { - logger.LogInfo($"Loading asset {name}"); + logger.LogDebug($"Loading asset {name}"); } if (missingasset) { diff --git a/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePathPatch.cs b/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePathPatch.cs index 7b03896..bf6188a 100644 --- a/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePathPatch.cs +++ b/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePathPatch.cs @@ -21,12 +21,12 @@ namespace ScarletMansion.DunGenPatch { [HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")] [HarmonyPrefix] public static void DungeonGeneratorGenerate_PrefixPrefix(){ - Plugin.logger.LogInfo("Disabling SDM logic"); + Plugin.logger.LogDebug("Disabling SDM logic"); Patch.Deactivate(); } public static void GeneratePatch(RoundManager roundManager){ - Plugin.logger.LogInfo("Loading Scarlet Mansion map so we are activating the alt. dungen scripts"); + Plugin.logger.LogDebug("Loading Scarlet Mansion map so we are activating the alt. dungen scripts"); Patch.Activate(roundManager.dungeonGenerator.Generator); } diff --git a/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs b/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs index ab47b40..9273f72 100644 --- a/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs +++ b/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs @@ -29,7 +29,7 @@ namespace ScarletMansion.DunGenPatch { var scale = generator.LengthMultiplier; var mainPathLength = generator.DungeonFlow.Length; - Plugin.logger.LogInfo($"Length of main path be: {GetLength(mainPathLength, scale)}"); + Plugin.logger.LogDebug($"Length of main path be: {GetLength(mainPathLength, scale)}"); GamePatch.LoadAssetsIntoLevelPatch.ModifyLevel(StartOfRound.Instance.currentLevel); } @@ -60,17 +60,13 @@ namespace ScarletMansion.DunGenPatch { public static void UpdateDunGenExtenderProperties(DunGenExtenderProperties props) { props.MainPathCount = PluginConfig.Instance.mainPathCountValue; - if (PluginConfig.Instance.disableBasementValue) { - props.MainPathCount = Mathf.Min(props.MainPathCount, 2); - } - - var mayorTileSet = PluginConfig.Instance.disableBasementValue ? Assets.networkObjectList.mayorVanillaTileset : Assets.networkObjectList.mayorRegularTileset; - Assets.dungeon.Nodes[1].TileSets = new List() { mayorTileSet }; - props.MainRoomTilePrefab = mayorTileSet.TileWeights.Weights[0].Value; props.DungeonSizeBase = new Vector3(PluginConfig.Instance.dunGenWidthBaseValue, props.DungeonSizeBase.y, PluginConfig.Instance.dunGenLengthBaseValue); props.DungeonSizeFactor = new Vector3(PluginConfig.Instance.dunGenWidthMultiFactorValue, props.DungeonSizeFactor.y, PluginConfig.Instance.dunGenLengthMultiFactorValue); + props.UseBranchLoopBoost = PluginConfig.Instance.branchLoopBoostValue; + props.BranchLoopBoostTileSearch = PluginConfig.Instance.branchLoopBoostTileSearchValue; + var i = 0; while(i < 3) { PluginConfig.Instance.branchPathSectionOneValue.UpdateValues(props.LineRandomizerArchetypes[i]); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/FloorCleanUpParent.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/FloorCleanUpParent.cs index 927dae2..00467a0 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/FloorCleanUpParent.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/FloorCleanUpParent.cs @@ -19,7 +19,10 @@ namespace ScarletMansion { var anyChanges = true; while(anyChanges) { anyChanges = false; - foreach(var c in children) anyChanges = anyChanges | c.UpdateRender(); + foreach(var c in children) { + var lastChanges = c.UpdateRender(); + anyChanges|= lastChanges; + } } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/KnightSpawnPoint.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/KnightSpawnPoint.cs index a002919..9f262b5 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/KnightSpawnPoint.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/KnightSpawnPoint.cs @@ -39,7 +39,7 @@ namespace ScarletMansion { var dist = Vector3.SqrMagnitude(transform.position - player.transform.position); if (dist <= minSqrDistance) { KnightSpawnManager.Instance.lastKnightSeenPlayer = index; - Plugin.logger.LogInfo($"Knight {index} has noticed player {player.playerUsername}"); + Plugin.logger.LogDebug($"Knight {index} has noticed player {player.playerUsername}"); } } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletBedroom.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletBedroom.cs index 4b6c2d3..aff66d0 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletBedroom.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletBedroom.cs @@ -155,7 +155,7 @@ namespace ScarletMansion.GamePatch.Components { var reference = new EnemyReferenceSpawnLogic(enemyType, i, spawnValue); spawnableEnemiesTrueList.Add(reference); - Plugin.logger.LogInfo($"Added {reference.ToString()} to bedroom event"); + Plugin.logger.LogDebug($"Added {reference.ToString()} to bedroom event"); } } } @@ -172,7 +172,7 @@ namespace ScarletMansion.GamePatch.Components { var index = sysRandom.Next(spawnableEnemiesTrueList.Count); var enemy = spawnableEnemiesTrueList[index]; - Plugin.logger.LogInfo($"Selected enemy to spawn {enemy.ToString()}"); + Plugin.logger.LogDebug($"Selected enemy to spawn {enemy.ToString()}"); return enemy; } @@ -194,7 +194,7 @@ namespace ScarletMansion.GamePatch.Components { bonusEnemy.ApplySpawnLogic(); roundmanager.currentEnemyPower += enemy.PowerLevel; - var spawnedEnemy = ScarletNetworkManagerUtility.CreateEnemyWithRef(bonusEnemy, vent.transform.position, y); + var spawnedEnemy = ScarletNetworkManagerUtility.CreateEnemyWithRef(bonusEnemy, pos, y); ScarletNetworkManager.Instance.RequestEvilSkinApply(spawnedEnemy, enemy.name.ToLowerInvariant()); } @@ -238,14 +238,5 @@ namespace ScarletMansion.GamePatch.Components { bonusEnemy = GetRandomEnemy(sysRandom); } - public void OnTriggerEnter(Collider other){ - Plugin.logger.LogInfo(other.gameObject.tag); - if (other.gameObject.tag == "Player"){ - var player = other.gameObject.GetComponent(); - if (player && player.IsLocalPlayer){ - HUDManager.Instance.DisplayTip("SDM Dungeon Events", "Paintings fetch a good price, if you are daring...", false, true, "SDM_Bedroom"); - } - } - } } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletClock.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletClock.cs index 6b42482..cba535d 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletClock.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletClock.cs @@ -106,10 +106,10 @@ namespace ScarletMansion.GamePatch.Components { public void HourlySelfDestroyCheck(){ if (stop || timerTillDestroyed > 0) return; - Plugin.logger.LogInfo("Hourly clock self-destroy check"); + Plugin.logger.LogDebug("Hourly clock self-destroy check"); if (UnityEngine.Random.value < chanceEveryHourToDestroy) { timerTillDestroyed = UnityEngine.Random.value * 60f + 15f; - Plugin.logger.LogInfo($"Clock offing itself in {timerTillDestroyed} sec"); + Plugin.logger.LogDebug($"Clock offing itself in {timerTillDestroyed} sec"); } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoor.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoor.cs index 4b8c647..881658c 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoor.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoor.cs @@ -12,7 +12,7 @@ namespace ScarletMansion.GamePatch.Components { public class ScarletDoor : NetworkBehaviour { [Header("Door Reference")] - public DoorLock door; + public ScarletDoorLock door; public bool doorState; public bool overrideLock; public bool overrideUnlock; diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoorLock.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoorLock.cs index 9b7d9af..ba5873e 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoorLock.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletDoorLock.cs @@ -86,7 +86,7 @@ namespace ScarletMansion.GamePatch.Components { { typeof(PufferAI), (e) => e.currentBehaviourStateIndex == 0 }, { typeof(SandSpiderAI), (e) => e.currentBehaviourStateIndex <= 1 }, { typeof(SpringManAI), (e) => e.currentBehaviourStateIndex == 0 }, - { typeof(KnightVariant), (e) => e.currentBehaviourStateIndex == 0 }, + { typeof(KnightV2Variant), (e) => e.currentBehaviourStateIndex == 0 }, { typeof(ButlerEnemyAI), (e) => e.currentBehaviourStateIndex <= 1 }, { typeof(MaidVariant), (e) => e.currentBehaviourStateIndex <= 1 }, { typeof(KnightGhostVariant), (e) => false } @@ -105,7 +105,7 @@ namespace ScarletMansion.GamePatch.Components { { typeof(PufferAI), 25f }, { typeof(SandSpiderAI), 25f }, { typeof(SpringManAI), 12.5f }, - { typeof(KnightVariant), 12.5f }, + { typeof(KnightV2Variant), 12.5f }, { typeof(ButlerEnemyAI), 50f }, { typeof(MaidVariant), 50f }, { typeof(KnightGhostVariant), 9999f } @@ -148,7 +148,7 @@ namespace ScarletMansion.GamePatch.Components { [ServerRpc(RequireOwnership = false)] public void DestroyAndOpenDoorServerRpc(Vector3 direction){ - Plugin.logger.LogInfo("Destro time"); + Plugin.logger.LogDebug("Destro time"); OpenDoorAsEnemyClientRpc(); DestroyDoorClientRpc(direction); } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletPlayerControllerB.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletPlayerControllerB.cs index cb738c8..f418497 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletPlayerControllerB.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletPlayerControllerB.cs @@ -15,7 +15,7 @@ namespace ScarletMansion.GamePatch.Components { public PlayerControllerB player; // animation - public AnimatorOverrideController playerOverrideController; + //public AnimatorOverrideController playerOverrideController; // second-chance states public bool stabbedSelf; @@ -61,7 +61,7 @@ namespace ScarletMansion.GamePatch.Components { var newFlashlightHelmetIndex = helmetLights.Count; if (flashlight.scarletHelmetIndex != newFlashlightHelmetIndex) - Plugin.logger.LogInfo($"Created helmet light for scarlet flashlight {index}. Updated index from {flashlight.scarletHelmetIndex} to {newFlashlightHelmetIndex}"); + Plugin.logger.LogDebug($"Created helmet light for scarlet flashlight {index}. Updated index from {flashlight.scarletHelmetIndex} to {newFlashlightHelmetIndex}"); flashlight.scarletHelmetIndex = newFlashlightHelmetIndex; helmetLights.Add(gameObj.GetComponent()); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletVent.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletVent.cs index 0c3d7fb..57df414 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletVent.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletVent.cs @@ -25,7 +25,7 @@ namespace ScarletMansion { if (!prewarm){ OpenVentClientRpc(); prewarm = true; - Plugin.logger.LogInfo("Prewarming particles by forcing it emit now lmao"); + Plugin.logger.LogDebug("Prewarming particles by forcing it emit now lmao"); } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletYukariTrigger.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletYukariTrigger.cs index 8e7c539..a427c2d 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletYukariTrigger.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletYukariTrigger.cs @@ -60,7 +60,6 @@ namespace ScarletMansion.GamePatch.Components } if (comp.CheckConditionsForSinkingInQuicksand()){ - Debug.Log("Set local player to sinking"); sinkingLocalPlayer = true; comp.sourcesCausingSinking++; comp.isMovementHindered++; @@ -76,28 +75,28 @@ namespace ScarletMansion.GamePatch.Components public void OnExit(Collider other){ if (!sinkingLocalPlayer) { - Debug.Log("Yukari is not sinking local player"); + Plugin.logger.LogDebug("Yukari is not sinking local player"); return; } - Debug.Log("Yukari is sinking something"); + Plugin.logger.LogDebug("Yukari is sinking something"); var otherGameObject = other.gameObject; if (!otherGameObject.CompareTag("Player")){ return; } - Debug.Log("Yukari is sinking a player"); + Plugin.logger.LogDebug("Yukari is sinking a player"); var comp = otherGameObject.GetComponent(); if (comp != GameNetworkManager.Instance.localPlayerController) return; - Debug.Log("Yukari is sinking local player"); + Plugin.logger.LogDebug("Yukari is sinking local player"); StopSinkingLocalPlayer(comp); } private void StopSinkingLocalPlayer(PlayerControllerB player) { if (!sinkingLocalPlayer) return; - Plugin.logger.LogInfo("Stopping"); + Plugin.logger.LogDebug("Stopping"); sinkingLocalPlayer = false; player.sourcesCausingSinking = Mathf.Clamp(player.sourcesCausingSinking - 1, 0, 100); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoom.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoom.cs index ef1207a..5f8ccf1 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoom.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoom.cs @@ -29,11 +29,13 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom { if (CanOpen()) { foreach(var d in treasureDoorLocks){ d.LockDoorOverrideClientRpc(false); + d.door?.DestroyDoorClientRpc(d.transform.forward); } opened = true; } } + public abstract bool CanOpen(); public virtual int GetDoorStatusValue() => 0; @@ -72,7 +74,7 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom { var tile = GetComponentInParent(); var doorways = tile.UsedDoorways; var targetDoorways = new List(); - foreach(var d in doorways) { + foreach(var d in doorways) { var neighboorTile = d.ConnectedDoorway.Tile.gameObject.name.ToLowerInvariant(); if (neighboorTile.Contains("treasure")){ targetDoorways.Add(d); @@ -83,20 +85,25 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom { var dunRandom = DunGenPatch.Patch.generatorInstance.RandomStream; randomStream = new System.Random((int)(dunRandom.NextDouble() * int.MaxValue)); - StartCoroutine(LockTreasureDoor(targetDoorways)); + Plugin.logger.LogInfo($"Adding treasure room event {GetType().ToString()}"); + DunGenPlus.Managers.DoorwayManager.onMainEntranceTeleportSpawnedEvent.AddTemporaryEvent("TreasureRoom", () => LockTreasureDoor(targetDoorways)); } } - protected virtual IEnumerator LockTreasureDoor(List doorways){ - if (!StartOfRound.Instance.IsHost) yield break; - - yield return new WaitForSecondsRealtime(4f); - Plugin.logger.LogInfo("Setting up lock for treasure room"); + protected virtual void LockTreasureDoor(List doorways){ + if (!StartOfRound.Instance.IsHost) return; + Plugin.logger.LogDebug($"Setting up lock for treasure room ({GetType().ToString()})"); treasureDoorLocks = new List(); foreach(var d in doorways){ - var doorLock = AngerManager.Instance.GetScarletDoor(d.transform.position); + if (d == null) { + Plugin.logger.LogWarning("For some reason, a doorway is null"); + continue; + } + + var doorPosition = d.transform.position; + var doorLock = AngerManager.Instance.GetScarletDoor(doorPosition); doorLock.LockDoorOverrideClientRpc(true); treasureDoorLocks.Add(doorLock); } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomBookPullEvent.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomBookPullEvent.cs index 34cc15f..82f64c9 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomBookPullEvent.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomBookPullEvent.cs @@ -22,7 +22,7 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom { public override bool CanOpen() { var ready = switches.All(s => s.pulled); if (ready) { - Plugin.logger.LogInfo($"Opening cause all books pulled"); + Plugin.logger.LogDebug($"Opening cause all books pulled"); return ready; } return false; @@ -32,13 +32,12 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom { return switches.Count(s => s.pulled); } - protected override IEnumerator LockTreasureDoor(List doorways) { - - yield return base.LockTreasureDoor(doorways); + protected override void LockTreasureDoor(List doorways) { + base.LockTreasureDoor(doorways); if (StartOfRound.Instance.IsHost) { - Plugin.logger.LogInfo("Creating book switches"); + Plugin.logger.LogDebug("HOST: Creating book switches"); switches = new TreasureRoomBookSwitch[3]; var switchOrdered = zones.Where(z => z != null && z.gameObject.activeInHierarchy).OrderBy(s => randomStream.NextDouble()); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomPaintingGrabEvent.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomPaintingGrabEvent.cs new file mode 100644 index 0000000..0a2fed1 --- /dev/null +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomPaintingGrabEvent.cs @@ -0,0 +1,59 @@ +using DunGen; +using ScarletMansion.GamePatch.Items; +using ScarletMansion.GamePatch.Managers; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Unity.Netcode; +using UnityEngine; + +namespace ScarletMansion.GamePatch.Components.TreasureRoom { + public class TreasureRoomPaintingGrabEvent : TreasureRoom { + + public ScarletPainting paintingTarget; + + public override bool CanOpen() { + var ready = paintingTarget && !paintingTarget.isAttached; + if (ready) { + Plugin.logger.LogDebug($"Opening cause painting grabbed"); + return ready; + } + return false; + } + + protected override void LockTreasureDoor(List doorways) { + base.LockTreasureDoor(doorways); + + var bedroomEvent = GetComponentInParent().GetComponentInChildren(true); + + Plugin.logger.LogDebug("Moving vent to inside of the treasure room"); + var firstDoorway = doorways.FirstOrDefault(); + var treasureRoomCenterTransform = firstDoorway.ConnectedDoorway.Tile.transform; + var bedroomEventVent = bedroomEvent.vent.transform; + Plugin.logger.LogInfo($"{bedroomEventVent.position} -> {treasureRoomCenterTransform.position}"); + bedroomEventVent.position = treasureRoomCenterTransform.position; + bedroomEventVent.rotation = treasureRoomCenterTransform.rotation; + + if (StartOfRound.Instance.IsHost) { + Plugin.logger.LogDebug("HOST: Translocating an avaiable painting"); + + // grab random painting to use + var paintingTransform = bedroomEvent.paintingSpawnTransform; + var allPaintings = FindObjectsOfType(); + var firstAvailablePainting = allPaintings.Where(p => !p.grabbedByEvent) + .OrderBy(p => Vector3.SqrMagnitude(paintingTransform.position - p.transform.position)) + .FirstOrDefault(); + + if (firstAvailablePainting) { + paintingTarget = firstAvailablePainting; + paintingTarget.RepositionClientRpc(paintingTransform.position, paintingTransform.rotation); + } else { + Plugin.logger.LogWarning($"Bedroom treasure room failed since there's no available paintings to grab"); + } + } + } + } +} diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomTimeEvent.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomTimeEvent.cs index fd770d7..2713007 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomTimeEvent.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomTimeEvent.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using TMPro; +using Unity.Netcode; using UnityEngine; namespace ScarletMansion.GamePatch.Components.TreasureRoom { @@ -26,28 +27,37 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom { var time = Utility.GetTime(); var ready = time.hours > hourSelected || (time.hours >= hourSelected && time.minutes >= mintuesSelected); if (ready) { - Plugin.logger.LogInfo($"Opening cause {time.hours}:{time.minutes} > {hourSelected}:{mintuesSelected}"); + Plugin.logger.LogDebug($"Opening cause {time.hours}:{time.minutes} > {hourSelected}:{mintuesSelected}"); return ready; } return false; } - protected override IEnumerator LockTreasureDoor(List doorways) { - Plugin.logger.LogInfo("Setting up treasure room (kitchen)"); + protected override void LockTreasureDoor(List doorways) { + base.LockTreasureDoor(doorways); hourSelected = randomStream.Next(hourRange.x, hourRange.y); mintuesSelected = randomStream.Next(0, 3) * 15; - Plugin.logger.LogInfo($"Opening at {hourSelected}:{mintuesSelected:D2}"); + Plugin.logger.LogDebug($"Opening at {hourSelected}:{mintuesSelected:D2}"); timeClockSpawnTransformIndex = randomStream.Next(timeClockSpawnTransforms.Length); var parent = timeClockSpawnTransforms[timeClockSpawnTransformIndex]; var copy = Instantiate(timeClockPrefab, parent); + if (StartOfRound.Instance.IsHost) { + Plugin.logger.LogDebug("HOST: Creating clock"); + + var spawnSyncedObject = copy.GetComponentInChildren(); + var mapPropsContainer = GetMapPropsContainer(); + var spawnedObject = Instantiate(spawnSyncedObject.spawnPrefab, spawnSyncedObject.transform.position, spawnSyncedObject.transform.rotation, mapPropsContainer.transform); + + var networkObject = spawnedObject.GetComponent(); + networkObject.Spawn(true); + } + var textMesh = copy.GetComponentInChildren(); textMesh.text = $"{hourSelected}:{mintuesSelected:D2}"; RandomizeCharacters(textMesh); - - yield return base.LockTreasureDoor(doorways); } private void RandomizeCharacters(TextMeshPro textMesh){ diff --git a/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightGhostVariant.cs b/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightGhostVariant.cs index 8496420..ff16dd9 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightGhostVariant.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightGhostVariant.cs @@ -50,6 +50,10 @@ namespace ScarletMansion { var targetLookingAtMe = !Physics.Linecast(transform.position + Vector3.up * 0.5f, targetPlayer.gameplayCamera.transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(base.transform.position, targetPlayer.transform.position) < 30f; var newBehaviourState = targetLookingAtMe ? 1 : 0; + if (targetLookingAtMe) { + targetPlayer.JumpToFearLevel(0.75f, true); + } + if (newBehaviourState != currentBehaviourStateIndex) { SwitchToBehaviourState(newBehaviourState); } @@ -86,7 +90,7 @@ namespace ScarletMansion { [ClientRpc] public void SyncKnightReplacementClientRpc(int index){ - Plugin.logger.LogInfo($"Spawning ghost knight at {index}"); + Plugin.logger.LogDebug($"Spawning ghost knight at {index}"); try { var target = KnightSpawnManager.Instance.GetSpawnPointTransform(index); @@ -130,7 +134,7 @@ namespace ScarletMansion { public void TunnelPlayerClientRpc(NetworkBehaviourReference playerRef){ if (playerRef.TryGet(out var player)){ targetPlayer = player; - Plugin.logger.LogInfo($"Targeting {player.playerUsername} for death"); + Plugin.logger.LogDebug($"Targeting {player.playerUsername} for death"); if (targetPlayer.IsOwner) return; @@ -147,7 +151,7 @@ namespace ScarletMansion { public void CallDisappear(){ if (calledDisappear) return; - Plugin.logger.LogInfo("Killing ghost knight"); + Plugin.logger.LogDebug("Killing ghost knight"); calledDisappear = true; mainCollider.enabled = false; diff --git a/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightV2Variant.cs b/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightV2Variant.cs new file mode 100644 index 0000000..8163388 --- /dev/null +++ b/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightV2Variant.cs @@ -0,0 +1,428 @@ +using GameNetcodeStuff; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Unity.Netcode; +using UnityEngine; +using UnityEngine.AI; + +namespace ScarletMansion.GamePatch.Enemies { + + public class KnightV2Variant : EnemyAI { + + public AISearchRoutine searchForPlayers; + private float checkLineOfSightInterval; + private bool hasEnteredChaseMode; + private bool stoppingMovement; + private bool hasStopped; + + public AnimationStopPoints animStopPoints; + private float currentChaseSpeed = 14.5f * 0.9f; + private float currentAnimSpeed = 1f; + private PlayerControllerB previousTarget; + private bool wasOwnerLastFrame; + private float stopAndGoMinimumInterval; + private float hitPlayerTimer; + + public AudioClip[] springNoises; + public AudioClip enterCooldownSFX; + public Collider mainCollider; + private float loseAggroTimer; + private float timeSinceHittingPlayer; + private bool movingOnOffMeshLink; + private Coroutine offMeshLinkCoroutine; + private float stopMovementTimer; + + public float timeSpentMoving; + public float onCooldownPhase; + private bool setOnCooldown; + public float timeAtLastCooldown; + + // Token: 0x04000F2A RID: 3882 + private bool inCooldownAnimation; + + public override void Start(){ + base.Start(); + + if (IsOwner && KnightSpawnManager.Instance) { + var index = KnightSpawnManager.Instance.GetSpawnPointIndex(); + if (index == -1) return; + + SyncKnightReplacementClientRpc(index); + } + } + + [ServerRpc(RequireOwnership = false)] + public void SetCoilheadOnCooldownServerRpc(bool setTrue) { + SetCoilheadOnCooldownClientRpc(setTrue); + } + + // Token: 0x06000F6F RID: 3951 RVA: 0x000942FC File Offset: 0x000924FC + [ClientRpc] + public void SetCoilheadOnCooldownClientRpc(bool setTrue) { + timeSpentMoving = 0f; + if (setTrue) { + onCooldownPhase = 20f; + setOnCooldown = true; + inCooldownAnimation = true; + SwitchToBehaviourStateOnLocalClient(0); + creatureVoice.PlayOneShot(enterCooldownSFX); + + if (animStopPoints.animationPosition == 1) creatureAnimator.SetTrigger("springBoing"); + else creatureAnimator.SetTrigger("springBoingPosition2"); + creatureAnimator.SetFloat("walkSpeed", 0f); + + return; + } + onCooldownPhase = 0f; + setOnCooldown = false; + timeAtLastCooldown = Time.realtimeSinceStartup; + } + + // Token: 0x06000F70 RID: 3952 RVA: 0x0009443C File Offset: 0x0009263C + public override void DoAIInterval() { + base.DoAIInterval(); + if (StartOfRound.Instance.allPlayersDead) return; + if (isEnemyDead) return; + + var currentBehaviourStateIndex = this.currentBehaviourStateIndex; + if (currentBehaviourStateIndex != 0) { + if (currentBehaviourStateIndex != 1) return; + if (searchForPlayers.inProgress) StopSearch(searchForPlayers, true); + + if (TargetClosestPlayer(1.5f, false, 70f)) { + if (previousTarget != targetPlayer) { + previousTarget = targetPlayer; + ChangeOwnershipOfEnemy(targetPlayer.actualClientId); + } + if (Time.realtimeSinceStartup - timeSinceHittingPlayer > 7f && !stoppingMovement) { + if (Vector3.Distance(targetPlayer.transform.position, transform.position) <= 40f || CheckLineOfSightForPosition(targetPlayer.gameplayCamera.transform.position, 180f, 140, -1f, null)) { + loseAggroTimer = 0f; + return; + } + + loseAggroTimer += AIIntervalTime; + if (loseAggroTimer > 4.5f) { + SwitchToBehaviourState(0); + ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); + return; + } + } + } else { + var flag = false; + for (var i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { + if (StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(transform.position + Vector3.up * 0.3f, 68f, 60, -1f) || StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(transform.position + Vector3.up * 1.6f, 68f, 60, -1f)) { + flag = true; + break; + } + } + + if (!flag) { + loseAggroTimer += AIIntervalTime; + if (loseAggroTimer > 1f) { + SwitchToBehaviourState(0); + ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); + } + } + } + } else { + if (!IsServer) { + ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); + return; + } + + if (onCooldownPhase > 0f) { + agent.speed = 0f; + SetDestinationToPosition(transform.position, false); + onCooldownPhase -= AIIntervalTime; + return; + } + + if (setOnCooldown) { + setOnCooldown = false; + SetCoilheadOnCooldownClientRpc(false); + } + + loseAggroTimer = 0f; + for (var j = 0; j < StartOfRound.Instance.allPlayerScripts.Length; j++) { + if (PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[j], false, false)) { + if (StartOfRound.Instance.allPlayerScripts[j].HasLineOfSightToPosition(transform.position + Vector3.up * 0.3f, 60f, 20, -1f)) { + targetPlayer = StartOfRound.Instance.allPlayerScripts[j]; + SwitchToBehaviourState(1); + } + + if (!PathIsIntersectedByLineOfSight(StartOfRound.Instance.allPlayerScripts[j].transform.position, false, false, false) && !Physics.Linecast(transform.position + Vector3.up * 0.5f, StartOfRound.Instance.allPlayerScripts[j].gameplayCamera.transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(transform.position, StartOfRound.Instance.allPlayerScripts[j].transform.position) < 30f) { + SwitchToBehaviourState(1); + return; + } + } + } + + agent.speed = 6f; + if (!searchForPlayers.inProgress) { + movingTowardsTargetPlayer = false; + SetDestinationToPosition(transform.position, false); + StartSearch(transform.position, searchForPlayers); + return; + } + } + } + + // Token: 0x06000F71 RID: 3953 RVA: 0x00094882 File Offset: 0x00092A82 + private IEnumerator Parabola(NavMeshAgent agent, float height, float duration) { + var data = agent.currentOffMeshLinkData; + var startPos = agent.transform.position; + var endPos = data.endPos + Vector3.up * agent.baseOffset; + var normalizedTime = 0f; + + while (normalizedTime < 1f && data.valid && data.activated && IsOwner) { + var num = height * 4f * (normalizedTime - normalizedTime * normalizedTime); + + agent.transform.position = Vector3.Lerp(startPos, endPos, normalizedTime) + num * Vector3.up; + normalizedTime += Time.deltaTime / duration; + yield return null; + } + + agent.CompleteOffMeshLink(); + offMeshLinkCoroutine = null; + yield break; + } + + // Token: 0x06000F72 RID: 3954 RVA: 0x000948A8 File Offset: 0x00092AA8 + private void StopOffMeshLinkMovement() { + if (offMeshLinkCoroutine != null) { + StopCoroutine(offMeshLinkCoroutine); + offMeshLinkCoroutine = null; + var currentOffMeshLinkData = agent.currentOffMeshLinkData; + agent.CompleteOffMeshLink(); + if (currentOffMeshLinkData.valid) { + if (Vector3.SqrMagnitude(transform.position - currentOffMeshLinkData.startPos) < Vector3.SqrMagnitude(transform.position - currentOffMeshLinkData.endPos)) { + agent.Warp(currentOffMeshLinkData.startPos); + return; + } + + agent.Warp(currentOffMeshLinkData.endPos); + return; + } + } + } + + // Token: 0x06000F73 RID: 3955 RVA: 0x000949B0 File Offset: 0x00092BB0 + private void DoSpringAnimation(bool springPopUp = false) { + if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(transform.position, 70f, 25, -1f)) { + var num = Vector3.Distance(transform.position, GameNetworkManager.Instance.localPlayerController.transform.position); + if (num < 4f) { + GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.9f, true); + } else if (num < 9f) { + GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.4f, true); + } + } + + if (currentAnimSpeed > 2f || springPopUp) { + RoundManager.PlayRandomClip(creatureVoice, springNoises, false, 1f, 0, 1000); + if (animStopPoints.animationPosition == 1) creatureAnimator.SetTrigger("springBoing"); + else creatureAnimator.SetTrigger("springBoingPosition2"); + } + } + + // Token: 0x06000F74 RID: 3956 RVA: 0x00094AA4 File Offset: 0x00092CA4 + public override void Update() { + base.Update(); + if (isEnemyDead) return; + if (hitPlayerTimer >= 0f) hitPlayerTimer -= Time.deltaTime; + + if (!IsOwner) { + stopMovementTimer = 5f; + loseAggroTimer = 0f; + if (offMeshLinkCoroutine != null) StopCoroutine(offMeshLinkCoroutine); + } + + if (IsOwner) { + if (agent.isOnOffMeshLink) { + if (!stoppingMovement && agent.currentOffMeshLinkData.activated) { + if (offMeshLinkCoroutine == null) offMeshLinkCoroutine = StartCoroutine(Parabola(agent, 0.6f, 0.5f)); + } + else { + StopOffMeshLinkMovement(); + } + } else if (offMeshLinkCoroutine != null) { + StopOffMeshLinkMovement(); + } + } + + creatureAnimator.SetBool("OnCooldown", setOnCooldown); + if (setOnCooldown) { + mainCollider.isTrigger = true; + stoppingMovement = true; + hasStopped = true; + return; + } + + var currentBehaviourStateIndex = this.currentBehaviourStateIndex; + if (currentBehaviourStateIndex == 0) { + agent.autoTraverseOffMeshLink = false; + creatureAnimator.SetFloat("walkSpeed", 2.5f); + stoppingMovement = false; + hasStopped = false; + return; + } + + if (currentBehaviourStateIndex != 1) return; + + if (IsOwner) { + if (onCooldownPhase > 0f) { + SwitchToBehaviourState(0); + return; + } + + if (stopAndGoMinimumInterval > 0f) stopAndGoMinimumInterval -= Time.deltaTime; + if (!wasOwnerLastFrame) { + wasOwnerLastFrame = true; + if (!stoppingMovement && hitPlayerTimer < 0.12f) agent.speed = currentChaseSpeed; + else agent.speed = 0f; + } + + var flag = false; + for (int i = 0; i < 4; i++) { + if (PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && (StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(transform.position + Vector3.up * 0.25f, 68f, 60, -1f) || StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(transform.position + Vector3.up * 1.6f, 68f, 60, -1f)) && Vector3.Distance(StartOfRound.Instance.allPlayerScripts[i].gameplayCamera.transform.position, eye.position) > 0.3f) { + flag = true; + } + } + + if (stunNormalizedTimer > 0f) flag = true; + if (flag != stoppingMovement && stopAndGoMinimumInterval <= 0f) { + stopAndGoMinimumInterval = 0.15f; + if (flag) SetAnimationStopServerRpc(); + else SetAnimationGoServerRpc(); + stoppingMovement = flag; + } + } + + if (stoppingMovement) { + if (!animStopPoints.canAnimationStop && stopMovementTimer <= 0.27f) { + stopMovementTimer += Time.deltaTime; + return; + } + + if (!hasStopped) { + hasStopped = true; + DoSpringAnimation(false); + } else if (inCooldownAnimation) { + inCooldownAnimation = false; + DoSpringAnimation(true); + } + + if (mainCollider.isTrigger && Vector3.Distance(GameNetworkManager.Instance.localPlayerController.transform.position, transform.position) > 0.3f) { + mainCollider.isTrigger = false; + } + + creatureAnimator.SetFloat("walkSpeed", 0f); + currentAnimSpeed = 0f; + if (IsOwner) { + agent.speed = 0f; + movingTowardsTargetPlayer = false; + SetDestinationToPosition(transform.position, false); + return; + } + } else { + stopMovementTimer = 0f; + if (hasStopped) { + hasStopped = false; + mainCollider.isTrigger = true; + } + currentAnimSpeed = Mathf.Lerp(currentAnimSpeed, currentChaseSpeed * 0.4597f, 5f * Time.deltaTime); + creatureAnimator.SetFloat("walkSpeed", currentAnimSpeed); + inCooldownAnimation = false; + + if (IsServer) { + timeSpentMoving += Time.deltaTime; + if (timeSpentMoving > 20f) + { + onCooldownPhase = 20f; + setOnCooldown = true; + inCooldownAnimation = true; + SetCoilheadOnCooldownClientRpc(true); + SwitchToBehaviourStateOnLocalClient(0); + } + } + + if (IsOwner) { + agent.speed = Mathf.Lerp(agent.speed, currentChaseSpeed, 4.5f * Time.deltaTime); + movingTowardsTargetPlayer = true; + } + } + } + + // Token: 0x06000F75 RID: 3957 RVA: 0x00094F98 File Offset: 0x00093198 + [ServerRpc] + public void SetAnimationStopServerRpc() { + SetAnimationStopClientRpc(); + } + + // Token: 0x06000F76 RID: 3958 RVA: 0x000950AC File Offset: 0x000932AC + [ClientRpc] + public void SetAnimationStopClientRpc() { + stoppingMovement = true; + } + + // Token: 0x06000F77 RID: 3959 RVA: 0x0009517C File Offset: 0x0009337C + [ServerRpc] + public void SetAnimationGoServerRpc() { + SetAnimationGoClientRpc(); + } + + // Token: 0x06000F78 RID: 3960 RVA: 0x00095290 File Offset: 0x00093490 + [ClientRpc] + public void SetAnimationGoClientRpc() { + stoppingMovement = false; + } + + // Token: 0x06000F79 RID: 3961 RVA: 0x00095360 File Offset: 0x00093560 + public override void OnCollideWithPlayer(Collider other) { + base.OnCollideWithPlayer(other); + if (stoppingMovement || currentBehaviourStateIndex != 1 || hitPlayerTimer >= 0f || setOnCooldown || (Time.realtimeSinceStartup - timeAtLastCooldown) < 0.45f) { + return; + } + + var playerControllerB = MeetsStandardPlayerCollisionConditions(other, false, false); + if (playerControllerB != null) { + hitPlayerTimer = 0.2f; + playerControllerB.DamagePlayer(90, true, true, CauseOfDeath.Mauling, 0); + playerControllerB.JumpToFearLevel(1f, true); + timeSinceHittingPlayer = Time.realtimeSinceStartup; + } + } + + [ClientRpc] + public void SyncKnightReplacementClientRpc(int index){ + SyncKnightReplacement(index); + } + + public void SyncKnightReplacement(int index){ + Plugin.logger.LogDebug($"Spawning knight at {index}"); + + try { + var target = KnightSpawnManager.Instance.GetSpawnPointTransform(index); + target.gameObject.SetActive(false); + + transform.position = target.position; + transform.rotation = target.rotation; + serverPosition = target.position; + + if (agent == null) agent = GetComponentInChildren(); + agent.Warp(target.position); + + if (IsOwner) { + SyncPositionToClients(); + } + } catch (Exception e){ + Plugin.logger.LogError($"Tried to knight spawn at {index}, but completely failed"); + Plugin.logger.LogError(e); + } + } + + } +} diff --git a/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightVariant.cs b/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightVariant.cs index 249d5f1..198ac52 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightVariant.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Enemies/KnightVariant.cs @@ -221,7 +221,7 @@ namespace ScarletMansion { } public void SyncKnightReplacement(int index){ - Plugin.logger.LogInfo($"Spawning knight at {index}"); + Plugin.logger.LogDebug($"Spawning knight at {index}"); try { var target = KnightSpawnManager.Instance.GetSpawnPointTransform(index); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Enemies/MaidVariant.cs b/ScarletMansion/ScarletMansion/GamePatch/Enemies/MaidVariant.cs index aa83c41..08627f8 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Enemies/MaidVariant.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Enemies/MaidVariant.cs @@ -319,8 +319,6 @@ namespace ScarletMansion.GamePatch.Enemies { case 0: // run away from crime scene if (killedLastTarget && !startedCrimeSceneTimer) { - Debug.Log("Starting leave crime scene timer"); - Debug.Log(string.Format("Target player: {0}", targetPlayer.playerClientId)); startedCrimeSceneTimer = true; leaveCrimeSceneTimer = 15f; movingTowardsTargetPlayer = false; @@ -352,13 +350,11 @@ namespace ScarletMansion.GamePatch.Enemies { if (playerControllerB != null) { targetPlayer = playerControllerB; SwitchOwnershipAndSetToStateServerRpc(2, targetPlayer.actualClientId, berserkModeTimer); - Debug.Log("State 2, changing ownership A"); return; } } // otherwise try to run away - Debug.Log("State 2, Switching to state 0, killed target"); SyncKilledLastTargetServerRpc((int)targetPlayer.playerClientId); SwitchToBehaviourState(0); ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); @@ -388,7 +384,6 @@ namespace ScarletMansion.GamePatch.Enemies { loseInChaseTimer += AIIntervalTime; if (loseInChaseTimer > 12f) { targetedPlayerAlonePreviously = this.targetPlayer; - Debug.Log("State 2, Switching to state 0, lost in chase"); SwitchToBehaviourState(0); ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); return; @@ -406,7 +401,6 @@ namespace ScarletMansion.GamePatch.Enemies { // they no longer alone, whoops! if (berserkModeTimer <= 0f) { targetedPlayerAlonePreviously = this.targetPlayer; - Debug.Log("State 2, Switching to state 0, found another player or multiple players 1"); SwitchToBehaviourState(0); ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); return; @@ -428,7 +422,6 @@ namespace ScarletMansion.GamePatch.Enemies { // who wasn't our og target, whoops! if ((x2 != targetPlayer || playersInVicinity > 1) && berserkModeTimer <= 0f) { targetedPlayerAlonePreviously = targetPlayer; - Debug.Log("State 2, Switching to state 0, found another player or multiple players 2"); SwitchToBehaviourState(0); ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); return; @@ -472,7 +465,6 @@ namespace ScarletMansion.GamePatch.Enemies { SwitchKillerState(false); SyncKilledLastTargetFalseClientRpc(); - Debug.Log("Exiting leave crime scene mode, 0"); return; } } @@ -515,11 +507,6 @@ namespace ScarletMansion.GamePatch.Enemies { startedCrimeSceneTimer = false; SwitchToBehaviourStateOnLocalClient(2); SwitchOwnershipAndSetToStateServerRpc(2, targetPlayer.actualClientId, -1f); - Debug.Log("Found a player; Caught red-handed, entering murder state"); - - for (int i = 0; i < this.seenPlayers.Length; i++) { - Debug.Log(string.Format("Seen player {0}: {1}", i, this.seenPlayers[i])); - } } // no one saw nothing, we bounce else { @@ -750,10 +737,6 @@ namespace ScarletMansion.GamePatch.Enemies { switch (currentBehaviourStateIndex) { case 0: if (previousBehaviourState != currentBehaviourStateIndex) { - if (targetPlayer != null) { - Debug.Log(string.Format("Target player: {0}; is dead?: {1}", targetPlayer.playerClientId, targetPlayer.isPlayerDead)); - } - creatureSFX.PlayOneShot(enemyType.audioClips[1]); WalkieTalkie.TransmitOneShotAudio(creatureSFX, enemyType.audioClips[1], 1f); checkedForTargetedPlayerPosition = false; @@ -931,7 +914,6 @@ namespace ScarletMansion.GamePatch.Enemies { [ClientRpc] public void SyncKilledLastTargetFalseClientRpc() { if (IsServer) return; - Debug.Log("Client received sync killed last target false client rpc"); killedLastTarget = false; } @@ -985,7 +967,6 @@ namespace ScarletMansion.GamePatch.Enemies { timeSinceCheckingForMultiplePlayers = 0f; timeUntilNextCheck = Random.Range(8f, 11f); TurnAndCheckForPlayers(); - Debug.Log("Butler: Checking for players"); } // Token: 0x060000F8 RID: 248 RVA: 0x0000CB20 File Offset: 0x0000AD20 @@ -1052,8 +1033,6 @@ namespace ScarletMansion.GamePatch.Enemies { timeToLook *= 0.5f; } - Debug.Log("Butler: pinged attention to position"); - Debug.DrawLine(eye.position, attentionPosition, Color.yellow, timeToLook); focusLevel = newFocusLevel; pingAttentionTimer = timeToLook; pingAttentionPosition = attentionPosition; diff --git a/ScarletMansion/ScarletMansion/GamePatch/EnemyVentPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/EnemyVentPatch.cs index eaf226e..bebe525 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/EnemyVentPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/EnemyVentPatch.cs @@ -37,7 +37,7 @@ namespace ScarletMansion.GamePatch { var comp = __instance.GetComponent(); if (comp) { - Plugin.logger.LogInfo("Doing scalet open vent"); + Plugin.logger.LogDebug("Doing scalet open vent"); comp.OpenVentClientRpc(); } diff --git a/ScarletMansion/ScarletMansion/GamePatch/FixValues/FixFireExit.cs b/ScarletMansion/ScarletMansion/GamePatch/FixValues/FixFireExit.cs index 59292f5..cc8c7a4 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/FixValues/FixFireExit.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/FixValues/FixFireExit.cs @@ -62,7 +62,7 @@ namespace ScarletMansion.GamePatch.FixValues { vanillaSetup = true; //Plugin.logger.LogInfo("Vanilla fire exit set up"); } catch (Exception e){ - Plugin.logger.LogInfo("Failed to setup vanilla fire exit. The 'Use SDM Fire Exits' config will be ignored"); + Plugin.logger.LogDebug("Failed to setup vanilla fire exit. The 'Use SDM Fire Exits' config will be ignored"); Plugin.logger.LogError(e.ToString()); vanillaSetup = false; diff --git a/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs index c6ff3a8..5113d39 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs @@ -17,20 +17,21 @@ using System.Security.Cryptography; using ScarletMansion.GamePatch.Enemies; using UnityEngine.UI; using ScarletMansion.GamePatch.Items; +using DunGenPlus.Managers; namespace ScarletMansion.GamePatch { public class InitPatch { private static void CreateNetworkManager(StartOfRound __instance){ - Plugin.logger.LogInfo($"IsServer: {__instance.IsServer}"); + Plugin.logger.LogDebug($"IsServer: {__instance.IsServer}"); if (__instance.IsServer) { if (ScarletNetworkManager.Instance == null) { var prefab = Assets.networkObjectList.scarletNetworkManager; var obj = GameObject.Instantiate(prefab); var comp = obj.GetComponent(); comp.Spawn(false); - Plugin.logger.LogInfo("Created Scarlet Network Manager. We in"); + Plugin.logger.LogDebug("Created Scarlet Network Manager. We in"); } else { Plugin.logger.LogWarning("Scarlet Network Manager already exists? Probably scary"); } @@ -49,6 +50,7 @@ namespace ScarletMansion.GamePatch { public static void StartOfRound_Start(ref StartOfRound __instance) { ScarletYukariTrigger.audioClipIndex = -1; ScarletPlayerControllerB.InitializeScarletScripts(); + DoorwayManager.onMainEntranceTeleportSpawnedEvent.ClearTemporaryActionList(); __instance.StartCoroutine(WaitForNetworkObject(__instance, CreateNetworkManager)); @@ -236,7 +238,7 @@ namespace ScarletMansion.GamePatch { var scarletTieMesh = scarletTie.GetComponent(); var refTieMesh = refTie.GetComponent(); if (scarletTieMesh && refTieMesh) { - Plugin.logger.LogInfo("Fixed tie of bb flashlight"); + Plugin.logger.LogDebug("Fixed tie of bb flashlight"); CopyAndPasteMeshFilterAndRenderer(scarletTieMesh, refTieMesh); } } @@ -350,7 +352,7 @@ namespace ScarletMansion.GamePatch { prefabFixList[4].GetComponent().Setup(fireProp.gameObject); } catch (Exception e){ - Plugin.logger.LogInfo("Failed to setup vanilla fire exit. The 'Use SDM Fire Exits' config will be ignored"); + Plugin.logger.LogDebug("Failed to setup vanilla fire exit. The 'Use SDM Fire Exits' config will be ignored"); Plugin.logger.LogError(e.ToString()); } @@ -382,7 +384,7 @@ namespace ScarletMansion.GamePatch { PluginConfig.Instance.paintingCountValue ); - Plugin.logger.LogInfo("Set networked config values"); + Plugin.logger.LogDebug("Set networked config values"); } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Items/FlandreCrystal.cs b/ScarletMansion/ScarletMansion/GamePatch/Items/FlandreCrystal.cs index c0d040e..20828c3 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Items/FlandreCrystal.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Items/FlandreCrystal.cs @@ -98,7 +98,7 @@ namespace ScarletMansion.GamePatch.Items { for(var i = 0; i < items.Length; ++i){ var item = items[i] as FlashlightItem; if (item != null && Assets.GetFlashlight(item.itemProperties) != null) { - Plugin.logger.LogInfo($"Flashlight slot {i}"); + Plugin.logger.LogDebug($"Flashlight slot {i}"); return (item, i); } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletFlashlight.cs b/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletFlashlight.cs index 363f48a..92ceeb6 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletFlashlight.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletFlashlight.cs @@ -81,14 +81,14 @@ namespace ScarletMansion.GamePatch.Items { } public IEnumerator WaitForRealFlashlightID(){ - Plugin.logger.LogInfo("Waiting for real helmet index for scarlet flashlight"); + Plugin.logger.LogDebug("Waiting for real helmet index for scarlet flashlight"); var t = Time.realtimeSinceStartup + 8f; while(true) { yield return null; var flashlight = Assets.GetFlashlight(itemProperties); if (flashlight != null && flashlight.scarletHelmetIndex != -1) { - Plugin.logger.LogInfo("Got real helmet index for scarlet flashlight"); + Plugin.logger.LogDebug("Got real helmet index for scarlet flashlight"); flashlightTypeID = flashlight.scarletHelmetIndex; yield break; } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletPainting.cs b/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletPainting.cs index f2a76c3..5ad303a 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletPainting.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletPainting.cs @@ -13,6 +13,7 @@ namespace ScarletMansion.GamePatch.Items { public ScarletBedroom bedroom; public bool isAttached = true; + public bool grabbedByEvent = true; [Header("Variations")] public int variation; @@ -49,11 +50,12 @@ namespace ScarletMansion.GamePatch.Items { if (isAttached){ bedroom = AngerManager.Instance.GetBedroomWithPainting(transform.position); scrapValue = PluginConfig.Instance.paintingValueValue; + grabbedByEvent = false; } } public override void EquipItem() { - Plugin.logger.LogInfo($"Scarlet painting was grabbed. Is owner: {IsOwner}"); + Plugin.logger.LogDebug($"Scarlet painting was grabbed. Is owner: {IsOwner}"); if (isAttached) { if (bedroom) bedroom.Anger(playerHeldBy.transform); isAttached = false; @@ -62,6 +64,15 @@ namespace ScarletMansion.GamePatch.Items { base.EquipItem(); } + [ClientRpc] + public void RepositionClientRpc(Vector3 position, Quaternion rotation){ + transform.position = position; + transform.rotation = rotation; + bedroom = AngerManager.Instance.GetBedroomWithPainting(position); + + grabbedByEvent = true; + } + /* public override void ItemActivate(bool used, bool buttonDown = true) { base.ItemActivate(used, buttonDown); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletSnowGlobe.cs b/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletSnowGlobe.cs index 9ecda06..9a8ed95 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletSnowGlobe.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Items/ScarletSnowGlobe.cs @@ -19,11 +19,11 @@ namespace ScarletMansion.GamePatch.Items { public ParticleSystemRenderer snowRenderer; public AudioSource musicAS; + //public PlayerControllerB previouslyHeldBy; [Header("Extra")] - public PlayerControllerB previouslyHeldBy; public Transform prefabPivot; public ScanNodeProperties scanNode; - public AnimationClip SnowGlobeOverrideHoldClip; + //public AnimationClip SnowGlobeOverrideHoldClip; [System.Serializable] public class SnowGlobeType { @@ -61,6 +61,8 @@ namespace ScarletMansion.GamePatch.Items { scanNode.headerText = $"{currentType.name} Snow Globe"; } + /* + public override void GrabItem() { base.GrabItem(); previouslyHeldBy = playerHeldBy; @@ -88,10 +90,12 @@ namespace ScarletMansion.GamePatch.Items { } base.DiscardItem(); } + */ + + /* public void ReplaceOrPutBackAnimationClip(PlayerControllerB player, bool _override) { if (player == null) return; - var playerOverrideController = ScarletPlayerControllerB.GetScarletPlayerScript(player).playerOverrideController; if (playerOverrideController == null) return; @@ -113,6 +117,7 @@ namespace ScarletMansion.GamePatch.Items { playerOverrideController["HoldLungApparatice"] = SnowGlobeOverrideHoldClip; } } + */ public override void ItemActivate(bool used, bool buttonDown = true) { diff --git a/ScarletMansion/ScarletMansion/GamePatch/JesterAIPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/JesterAIPatch.cs index 89ee650..fd26c8d 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/JesterAIPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/JesterAIPatch.cs @@ -16,7 +16,7 @@ namespace ScarletMansion.GamePatch { [HarmonyPostfix] public static void StartPatch(ref JesterAI __instance){ if (DunGenPatch.Patch.active && active && __instance.IsOwner) { - Plugin.logger.LogInfo("Activing kill order for Jester"); + Plugin.logger.LogDebug("Activing kill order for Jester"); __instance.SwitchToBehaviourState(1); } active = false; diff --git a/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs index c7ad4c8..4cca40e 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs @@ -113,10 +113,10 @@ namespace ScarletMansion.GamePatch { .FirstOrDefault(); if (target == null){ - Plugin.logger.LogInfo($"No enemy {targetEnemyName} in level, using default rarity of {minBaseWeight}."); + Plugin.logger.LogDebug($"No enemy {targetEnemyName} in level, using default rarity of {minBaseWeight}."); var entry = enemy.GetItemEntry(baseWeight + minBaseWeight); - Plugin.logger.LogInfo($"Adding enemy {sourceEnemyName} with weight {entry.rarity}"); + Plugin.logger.LogDebug($"Adding enemy {sourceEnemyName} with weight {entry.rarity}"); currentEnemiesRarity.Add(entry); } else { @@ -129,8 +129,8 @@ namespace ScarletMansion.GamePatch { var newEntry = enemy.GetItemEntry(baseWeight + entryRarity); - Plugin.logger.LogInfo($"Adding enemy {sourceEnemyName} with weight {newEntry.rarity}"); - Plugin.logger.LogInfo($"Setting enemy {targetEnemyName} with weight {prevEntry.rarity}"); + Plugin.logger.LogDebug($"Adding enemy {sourceEnemyName} with weight {newEntry.rarity}"); + Plugin.logger.LogDebug($"Setting enemy {targetEnemyName} with weight {prevEntry.rarity}"); currentEnemiesRarity.Add(newEntry); currentEnemiesRarity.Add(prevEntry); } @@ -146,13 +146,13 @@ namespace ScarletMansion.GamePatch { var entry = i.GetItemRarity(); if (entry.rarity > 0) { - Plugin.logger.LogInfo($"Adding item {entry.spawnableItem.itemName} with weight {entry.rarity}"); + Plugin.logger.LogDebug($"Adding item {entry.spawnableItem.itemName} with weight {entry.rarity}"); currentItemsRarity.Add(entry); } } - Plugin.logger.LogInfo($"Loaded custom enemies and items for {level.sceneName}"); + Plugin.logger.LogDebug($"Loaded custom enemies and items for {level.sceneName}"); Components.ScarletBedroom.CreateRandomEnemyList(currentEnemiesRarity); } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Managers/AngerManager.cs b/ScarletMansion/ScarletMansion/GamePatch/Managers/AngerManager.cs index 8b27bd9..b4d91f9 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Managers/AngerManager.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Managers/AngerManager.cs @@ -86,7 +86,7 @@ namespace ScarletMansion.GamePatch.Managers { } */ public void Anger(int angerAmount = 1){ - Plugin.logger.LogInfo($"Raising anger from {level} to {level + angerAmount}"); + Plugin.logger.LogDebug($"Raising anger from {level} to {level + angerAmount}"); var manager = RoundManager.Instance; manager.minEnemiesToSpawn += angerAmount; level += angerAmount; diff --git a/ScarletMansion/ScarletMansion/GamePatch/Managers/KnightSpawnManager.cs b/ScarletMansion/ScarletMansion/GamePatch/Managers/KnightSpawnManager.cs index 304503f..6ed06cc 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Managers/KnightSpawnManager.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Managers/KnightSpawnManager.cs @@ -30,7 +30,7 @@ namespace ScarletMansion { } unusedSpawnPoints = points.ToList(); - Plugin.logger.LogInfo($"Found {spawnPoints.Count} spawn points for the knight"); + Plugin.logger.LogDebug($"Found {spawnPoints.Count} spawn points for the knight"); } public int GetSpawnPointIndex(){ @@ -45,7 +45,7 @@ namespace ScarletMansion { if (lastKnightSeenPlayer >= 0){ var tempitem = spawnPoints[lastKnightSeenPlayer]; if (tempitem.gameObject.activeInHierarchy){ - Plugin.logger.LogInfo($"Using the last knight {tempitem.index} that saw a player"); + Plugin.logger.LogDebug($"Using the last knight {tempitem.index} that saw a player"); unusedSpawnPoints.Remove(tempitem); lastKnightSeenPlayer = -1; return tempitem.index; diff --git a/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs b/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs index e5897c8..6cae2d3 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs @@ -86,7 +86,7 @@ namespace ScarletMansion { [ServerRpc(RequireOwnership = false)] public void DestroyPlayerItemInSlotServerRpc(NetworkBehaviourReference playerRef, int itemSlot, ServerRpcParams callParams = default(ServerRpcParams)){ if (playerRef.TryGet(out var player)){ - Plugin.logger.LogInfo($"P{player.OwnerClientId}, S{callParams.Receive.SenderClientId}"); + Plugin.logger.LogDebug($"P{player.OwnerClientId}, S{callParams.Receive.SenderClientId}"); DestroyPlayerItemInSlotClientRpc(playerRef, itemSlot); return; @@ -291,7 +291,7 @@ namespace ScarletMansion { var enemyName = enemy.name; try { - Plugin.logger.LogInfo($"Applying evil material to {enemyName}"); + Plugin.logger.LogDebug($"Applying evil material to {enemyName}"); ApplyMaterialToRenderers(enemy.GetComponentsInChildren()); ApplyMaterialToRenderers(enemy.GetComponentsInChildren()); } catch (Exception e){ @@ -454,14 +454,14 @@ namespace ScarletMansion { // better safe and slow then sorry if (GameNetworkManager.Instance.localPlayerController == null || NetworkManager.Singleton == null || NetworkManager.Singleton.ShutdownInProgress) return; - Plugin.logger.LogInfo($"Destroying player {player.playerUsername}:{player.actualClientId}'s item in slot {itemSlot}"); + Plugin.logger.LogDebug($"Destroying player {player.playerUsername}:{player.actualClientId}'s item in slot {itemSlot}"); var heldObj = player.currentlyHeldObjectServer; var heldObjString = heldObj ? heldObj.itemProperties.itemName : "NULL"; var grabObj = player.ItemSlots[itemSlot]; var grabObjString = grabObj ? grabObj.itemProperties.itemName : "NULL"; - Plugin.logger.LogInfo($"Held item {player.currentItemSlot}:{heldObjString}"); - Plugin.logger.LogInfo($"Target item {itemSlot}:{grabObjString}"); + Plugin.logger.LogDebug($"Held item {player.currentItemSlot}:{heldObjString}"); + Plugin.logger.LogDebug($"Target item {itemSlot}:{grabObjString}"); // fix weight and values player.carryWeight -= Mathf.Clamp(grabObj.itemProperties.weight - 1f, 0f, 10f); diff --git a/ScarletMansion/ScarletMansion/GamePatch/PlayerControllerBPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/PlayerControllerBPatch.cs index e52b206..57e20d0 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/PlayerControllerBPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/PlayerControllerBPatch.cs @@ -16,7 +16,7 @@ namespace ScarletMansion.GamePatch { public static void AwakePatch(ref PlayerControllerB __instance){ var currentComp = __instance.GetComponent(); if (currentComp == null) { - Plugin.logger.LogInfo($"Adding Scarlet player script to player {__instance.playerClientId}"); + Plugin.logger.LogDebug($"Adding Scarlet player script to player {__instance.playerClientId}"); var comp = __instance.gameObject.AddComponent(); comp.Initialize(__instance); comp.Register(); @@ -26,6 +26,7 @@ namespace ScarletMansion.GamePatch { } } + /* [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] public static void UpdatePatch(ref PlayerControllerB __instance) { @@ -36,6 +37,7 @@ namespace ScarletMansion.GamePatch { __instance.playerBodyAnimator.runtimeAnimatorController = controller.playerOverrideController; } + */ } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs index f92701b..685931b 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs @@ -16,7 +16,7 @@ namespace ScarletMansion.GamePatch.Props { var b = GetBounds(); var layerMask = LayerMask.GetMask(new string[3] { "Room", "Railing", "MapHazards" }); if (Physics.CheckBox(b.center, b.extents, transform.rotation, layerMask)){ - Plugin.logger.LogInfo("Disabling fire exit potential spawn due to overlapping space"); + Plugin.logger.LogDebug("Disabling fire exit potential spawn due to overlapping space"); target.SetActive(false); } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs index 5d4d43f..80fa87f 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs @@ -20,7 +20,7 @@ namespace ScarletMansion.GamePatch.Props { var currentY = tile.transform.position.y; var floor = Mathf.RoundToInt((currentY - baseY) / 8f); - Plugin.logger.LogInfo($"F{floor}"); + Plugin.logger.LogDebug($"F{floor}"); // fuck it im lazy GameObject p; if (floor == 0) { diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs index b8af607..d7a330f 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs @@ -12,14 +12,14 @@ namespace ScarletMansion.GamePatch.Props { public static int cycle = 0; public static void UpdateCycle(int value){ - Plugin.logger.LogInfo($"Updating RandomPrefab cylce to {value}"); + Plugin.logger.LogDebug($"Updating RandomPrefab cylce to {value}"); cycle = value; } public override void Process(RandomStream randomStream, Tile tile) { if (props.Count <= 0) return; - Plugin.logger.LogInfo($"Cycle {cycle}"); + Plugin.logger.LogDebug($"Cycle {cycle}"); var cycleValue = cycle++; var index = cycleValue % props.Count; var prefab = props[index]; diff --git a/ScarletMansion/ScarletMansion/GamePatch/RoundManagerPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/RoundManagerPatch.cs index b8f6b32..2b343e3 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/RoundManagerPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/RoundManagerPatch.cs @@ -40,13 +40,13 @@ namespace ScarletMansion.GamePatch { public static float ModifyScrapCount(float count){ if (DunGenPatch.Patch.active == false) return count; - Plugin.logger.LogInfo($"Scrap: {count} -> {count * PluginConfig.Instance.lootMultiplierValue}"); + Plugin.logger.LogDebug($"Scrap: {count} -> {count * PluginConfig.Instance.lootMultiplierValue}"); return count * PluginConfig.Instance.lootMultiplierValue; } public static float ModifyMapCount(float count){ if (DunGenPatch.Patch.active == false) return count; - Plugin.logger.LogInfo($"Map Hazards: {count} -> {count * PluginConfig.Instance.mapHazardsMultiplierValue}"); + Plugin.logger.LogDebug($"Map Hazards: {count} -> {count * PluginConfig.Instance.mapHazardsMultiplierValue}"); return count * PluginConfig.Instance.mapHazardsMultiplierValue; } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Weathers/SDMWeatherManager.cs b/ScarletMansion/ScarletMansion/GamePatch/Weathers/SDMWeatherManager.cs index 06913ce..399a3b8 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Weathers/SDMWeatherManager.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Weathers/SDMWeatherManager.cs @@ -27,7 +27,7 @@ namespace ScarletMansion.GamePatch.Weathers { rainAudioSource.clip = rainGameObject.GetComponentInChildren().clip; rainAudioSource.Play(); - Plugin.logger.LogInfo("Fixed Rainy weather references"); + Plugin.logger.LogDebug("Fixed Rainy weather references"); } diff --git a/ScarletMansion/ScarletMansion/Plugin.cs b/ScarletMansion/ScarletMansion/Plugin.cs index 6198234..026ec8f 100644 --- a/ScarletMansion/ScarletMansion/Plugin.cs +++ b/ScarletMansion/ScarletMansion/Plugin.cs @@ -23,7 +23,7 @@ namespace ScarletMansion { [BepInDependency("imabatby.lethallevelloader", "1.2.0.3")] [BepInDependency("evaisa.lethallib", "0.13.2")] - [BepInDependency("dev.ladyalice.dungenplus", "1.0.3")] + [BepInDependency("dev.ladyalice.dungenplus", "1.0.5")] //[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.23"; + private const string modVersion = "1.3.24"; public readonly Harmony harmony = new Harmony(modGUID); diff --git a/ScarletMansion/ScarletMansion/PluginConfig.cs b/ScarletMansion/ScarletMansion/PluginConfig.cs index 9e622bd..81da950 100644 --- a/ScarletMansion/ScarletMansion/PluginConfig.cs +++ b/ScarletMansion/ScarletMansion/PluginConfig.cs @@ -28,6 +28,7 @@ namespace ScarletMansion { public const string dungeonGenerationBoundingBoxPrefix = "DunGen Bounding Box"; public const string dungeonGenerationMPathsPrefix = "DunGen Main Path"; + public const string dungeonGenerationBPathPrefix = "DunGen Branching Path"; public const string dungeonGenerationBPathOnePrefix = "DunGen Branching Path 1"; public const string dungeonGenerationBPathTwoPrefix = "DunGen Branching Path 2"; public const string dungeonGenerationBPathThreePrefix = "DunGen Branching Path 3"; @@ -169,27 +170,38 @@ namespace ScarletMansion { dungeonGenerationMPathsPrefix, "Main Path Length Min", "Main Path Length Max", + 3, 4, - 5, $"The minimum allowed length of the main path. This value is multiplied by the dungeon's size.\n\n{_mainPathLengthPostMessage}", $"The maximum allowed length of the main path. This value is multiplied by the dungeon's size.\n\n{_mainPathLengthPostMessage}", null, new AcceptableValueRange(3, 20) ); - public static ConfigEntryBundle disableBasement = new ConfigEntryBundle( - dungeonGenerationMPathsPrefix, - "Disable Mayor Basement", - false, - "Removes the basement section of the mayor tile. Forces the Main Path Count to a maximum of 2." - ); - public int mainPathCountValue; public IntRange mainPathLengthValue = new IntRange("main path length"); - public bool disableBasementValue; - // branching path + public static ConfigEntryBundle branchLoopBoost = new ConfigEntryBundle( + dungeonGenerationBPathPrefix, + "Use Branch Loop Prioritization", + true, + "If enabled, the dungeon generation will prioritize branch tiles that connect to already generated tiles.\nThis increases the chance of circular/looping paths. Slows dungeon generation times a bit at the end.", + null + ); + public static ConfigEntryBundle branchLoopBoostTileSearch = new ConfigEntryBundle( + dungeonGenerationBPathPrefix, + "Tile Search Count", + 10, + "The maximum number of valid branch tiles that the dungeon generation will consider before choosing the best tile.\nIncreasing this value gives the dungeon generation a higher chance of finding a good tile but impacts dungeon generation times. Decreasing this value gives the dungeon generation a lower chance of finding a good tile but also lessens the impact to dungeon generation times.", + null, + new AcceptableValueRange(1, 20) + ); + + public bool branchLoopBoostValue; + public int branchLoopBoostTileSearchValue; + + // branching path mini sections private static string _branchPathBranchCountMessage(int section, string minmax, string middleSection) => $"The {minmax} amount of branching paths in Section {section} of the dungeon generation process.\n{middleSection}\n\n{_branchPathPostCountMessage}"; private static string _branchPathBranchDepthMessage(int section, string minmax, string middleSection) => $"The {minmax} length of the branching paths in Section {section} of the dungeon generation process.\n{middleSection}\n\n{_branchPathPostDepthMessage}"; @@ -570,7 +582,7 @@ namespace ScarletMansion { } public static void VerifyLightingValues(PluginConfig instance){ - Plugin.logger.LogInfo("Verifying lightsSpawn 0/1/2 values"); + Plugin.logger.LogDebug("Verifying lightsSpawn 0/1/2 values"); if (instance.lightsSpawnZeroWeightValue == 0f && instance.lightsSpawnOneWeightValue == 0f && instance.lightsSpawnTwoWeightValue == 0f){ instance.lightsSpawnZeroWeightValue = 1; } @@ -585,8 +597,8 @@ namespace ScarletMansion { var bytes = SerializeToBytes(Instance); var copy = DeserializeFromBytes(bytes); - Plugin.logger.LogInfo($"Inst: {Instance.ToString()}"); - Plugin.logger.LogInfo($"Copy: {copy.ToString()}"); + Plugin.logger.LogDebug($"Inst: {Instance.ToString()}"); + Plugin.logger.LogDebug($"Copy: {copy.ToString()}"); } } diff --git a/ScarletMansion/ScarletMansion/PluginConfigClasses.cs b/ScarletMansion/ScarletMansion/PluginConfigClasses.cs index bef32cf..759cf8a 100644 --- a/ScarletMansion/ScarletMansion/PluginConfigClasses.cs +++ b/ScarletMansion/ScarletMansion/PluginConfigClasses.cs @@ -46,7 +46,7 @@ namespace ScarletMansion { } public virtual void Verify(){ - Plugin.logger.LogInfo($"Verifying min/max for {name}"); + Plugin.logger.LogDebug($"Verifying min/max for {name}"); } public override string ToString() { @@ -177,7 +177,7 @@ namespace ScarletMansion { public override void Bind(ConfigFile cfg, PluginConfig instance, FieldPropertyInfo memberInfo, object memberTarget) { config = cfg.Bind(definition, defaultValue, description); config.SettingChanged += (obj, args) => { - Plugin.logger.LogInfo($"Config settings {config.Definition.Key} changed"); + Plugin.logger.LogDebug($"Config settings {config.Definition.Key} changed"); memberInfo.SetValue(memberTarget, config.Value); extra.CallAction(instance, false); }; @@ -189,7 +189,7 @@ namespace ScarletMansion { public void Bind(ConfigFile cfg, PluginConfig instance){ config = cfg.Bind(definition, defaultValue, description); config.SettingChanged += (obj, args) => { - Plugin.logger.LogInfo($"Config settings {config.Definition.Key} changed"); + Plugin.logger.LogDebug($"Config settings {config.Definition.Key} changed"); extra.CallAction(instance, false); }; diff --git a/ScarletMansion/ScarletMansion/PluginConfigNetwork.cs b/ScarletMansion/ScarletMansion/PluginConfigNetwork.cs index 84c0105..ba4e425 100644 --- a/ScarletMansion/ScarletMansion/PluginConfigNetwork.cs +++ b/ScarletMansion/ScarletMansion/PluginConfigNetwork.cs @@ -25,7 +25,7 @@ namespace ScarletMansion { public static void OnRequestSync(ulong clientId, FastBufferReader _){ if (!IsHost) return; - logger.LogInfo($"Config sync request received from client: {clientId}"); + logger.LogDebug($"Config sync request received from client: {clientId}"); var array = SerializeToBytes(Instance); var value = array.Length; @@ -56,7 +56,7 @@ namespace ScarletMansion { var data = new byte[val]; reader.ReadBytesSafe(ref data, val); SyncInstance(data); - logger.LogInfo("Successfully synced config with host."); + logger.LogDebug("Successfully synced config with host."); } [HarmonyPatch(typeof(GameNetcodeStuff.PlayerControllerB), "ConnectClientToPlayerObject")] diff --git a/ScarletMansion/ScarletMansion/PresetConfig.cs b/ScarletMansion/ScarletMansion/PresetConfig.cs index fbe5a56..278db26 100644 --- a/ScarletMansion/ScarletMansion/PresetConfig.cs +++ b/ScarletMansion/ScarletMansion/PresetConfig.cs @@ -32,7 +32,6 @@ namespace ScarletMansion { new ChangeInt ( PluginConfig.mainPathCount ), new ChangeMinMaxInt ( PluginConfig.mainPathLength ), - new ChangeBool( PluginConfig.disableBasement ), new ChangeBranchingPath( PluginConfig.branchPathSectionOne ), new ChangeBranchingPath( PluginConfig.branchPathSectionTwo ), @@ -112,7 +111,6 @@ namespace ScarletMansion { new ChangeInt ( PluginConfig.mainPathCount, 1 ), new ChangeMinMaxInt ( PluginConfig.mainPathLength, 6, 9 ), - new ChangeBool( PluginConfig.disableBasement, true ), new ChangeBranchingPath( PluginConfig.branchPathSectionOne, 4, 6, 3, 4 ), new ChangeBranchingPath( PluginConfig.branchPathSectionTwo, 2, 3, 2, 3 ), @@ -227,7 +225,7 @@ namespace ScarletMansion { } public void UpdateChanges(){ - Plugin.logger.LogInfo($"Updating config values with preset {name}"); + Plugin.logger.LogDebug($"Updating config values with preset {name}"); foreach(var c in changes){ c.Update(); } diff --git a/ScarletMansion/ScarletMansion/PrintProperties.cs b/ScarletMansion/ScarletMansion/PrintProperties.cs index 28496bc..8687b66 100644 --- a/ScarletMansion/ScarletMansion/PrintProperties.cs +++ b/ScarletMansion/ScarletMansion/PrintProperties.cs @@ -36,7 +36,7 @@ namespace ScarletMansion { } var spacing = new string(' ', index); - Plugin.logger.LogInfo($"{spacing}[{o.ToString()}]"); + Plugin.logger.LogDebug($"{spacing}[{o.ToString()}]"); var props = o.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); foreach(var pi in props){ @@ -52,14 +52,14 @@ namespace ScarletMansion { for(var i = 0; i < count; ++i) { var value = pi.GetValue(o, new object[] { i } ); - Plugin.logger.LogInfo($"{spacing}{pi.Name}[{i}]: {GetObjectString(value)}"); + Plugin.logger.LogDebug($"{spacing}{pi.Name}[{i}]: {GetObjectString(value)}"); PrintObject(value, index + 1, depth + 1, ignoreList); } } else { var value = pi.GetValue(o); - Plugin.logger.LogInfo($"{spacing}{pi.Name}: {GetObjectString(value)}"); + Plugin.logger.LogDebug($"{spacing}{pi.Name}: {GetObjectString(value)}"); PrintObject(value, index + 1, depth + 1, ignoreList); } @@ -68,26 +68,26 @@ namespace ScarletMansion { var fields = o.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); foreach(var fi in fields){ var value = fi.GetValue(o); - Plugin.logger.LogInfo($"{spacing}{fi.Name}: {GetObjectString(value)}"); + Plugin.logger.LogDebug($"{spacing}{fi.Name}: {GetObjectString(value)}"); PrintObject(value, index + 1, depth + 1, ignoreList); } if (o is GameObject){ var gameobject = o as GameObject; var comps = gameobject.GetComponents(); - Plugin.logger.LogInfo("--- Components --- "); + Plugin.logger.LogDebug("--- Components --- "); foreach(var c in comps){ PrintObject(c, index, depth, ignoreList); } - Plugin.logger.LogInfo("--- Children --- "); + Plugin.logger.LogDebug("--- Children --- "); foreach(Transform t in gameobject.transform){ PrintObject(t.gameObject, index + 1, depth + 1, ignoreList); } } - Plugin.logger.LogInfo(""); + Plugin.logger.LogDebug(""); } public static void PrintIEnumerable(object o, int index, int depth, params Type[] ignoreList){ @@ -97,7 +97,7 @@ namespace ScarletMansion { var list = o as IEnumerable; var i = 0; foreach(var item in list){ - Plugin.logger.LogInfo($"{spacing}[IEnumerable {i}]: {GetObjectString(item)}"); + Plugin.logger.LogDebug($"{spacing}[IEnumerable {i}]: {GetObjectString(item)}"); PrintObject(item, index + 1, depth + 1, ignoreList); i++; } diff --git a/ScarletMansion/ScarletMansion/ScarletMansion.csproj b/ScarletMansion/ScarletMansion/ScarletMansion.csproj index 05f0666..f28937e 100644 --- a/ScarletMansion/ScarletMansion/ScarletMansion.csproj +++ b/ScarletMansion/ScarletMansion/ScarletMansion.csproj @@ -176,10 +176,12 @@ + + diff --git a/ScarletMansion/ScarletMansion/SyncedInstance.cs b/ScarletMansion/ScarletMansion/SyncedInstance.cs index b34187c..868a3b4 100644 --- a/ScarletMansion/ScarletMansion/SyncedInstance.cs +++ b/ScarletMansion/ScarletMansion/SyncedInstance.cs @@ -71,11 +71,11 @@ namespace ScarletMansion { var pastCapacity = stream.Capacity > 1300; var flag = pastCapacity ? NetworkDelivery.ReliableFragmentedSequenced : NetworkDelivery.Reliable; if (pastCapacity){ - logger.LogInfo("Stream is past capacity. Sending fragmented message"); + logger.LogDebug("Stream is past capacity. Sending fragmented message"); } MessageManager.SendNamedMessage(title, clientId, stream, flag); - Plugin.logger.LogInfo($"Send message to client {clientId} with title {title} and flag {flag}"); + Plugin.logger.LogDebug($"Send message to client {clientId} with title {title} and flag {flag}"); } } diff --git a/ScarletMansion/ScarletMansion/TranspilerUtilities.cs b/ScarletMansion/ScarletMansion/TranspilerUtilities.cs index 4d40ce6..314319b 100644 --- a/ScarletMansion/ScarletMansion/TranspilerUtilities.cs +++ b/ScarletMansion/ScarletMansion/TranspilerUtilities.cs @@ -45,7 +45,7 @@ namespace ScarletMansion { if (counter == 0) { Plugin.logger.LogError($"{debugFunction} could not inject {name}. Probably scary"); } else if (!expectedCounter.HasValue) { - Plugin.logger.LogInfo($"{debugFunction} inject {name} {counter} time(s)"); + Plugin.logger.LogDebug($"{debugFunction} inject {name} {counter} time(s)"); } else if (expectedCounter.Value != counter){ Plugin.logger.LogWarning($"{debugFunction} inject {name} {counter} time(s) (Expected {expectedCounter.Value}). Probably not an error but be warned"); } @@ -182,7 +182,7 @@ namespace ScarletMansion { foreach(var i in instructions){ var opString = i.opcode.ToString(); var objString = i.operand != null ? i.operand.ToString() : "NULL"; - Plugin.logger.LogInfo($"{opString}: {objString}"); + Plugin.logger.LogDebug($"{opString}: {objString}"); } } diff --git a/ScarletMansion/ScarletMansion/Utility.cs b/ScarletMansion/ScarletMansion/Utility.cs index 6bb7ac0..40b89b4 100644 --- a/ScarletMansion/ScarletMansion/Utility.cs +++ b/ScarletMansion/ScarletMansion/Utility.cs @@ -86,7 +86,7 @@ namespace ScarletMansion { protected override void UpdateValue(int direction) { current = Mathf.Clamp(current + direction * delta, min, max); - Plugin.logger.LogInfo($"{name}: {current}"); + Plugin.logger.LogDebug($"{name}: {current}"); } } @@ -205,12 +205,12 @@ namespace ScarletMansion { } public static void PrintToParent(Transform t) { - Plugin.logger.LogInfo(t.name); + Plugin.logger.LogDebug(t.name); var parent = t.parent; var i = 0; while (parent != null) { var header = new string(' ', ++i); - Plugin.logger.LogInfo($"{header}{parent.name}"); + Plugin.logger.LogDebug($"{header}{parent.name}"); parent = parent.parent; } } @@ -234,7 +234,7 @@ namespace ScarletMansion { if (debug) { for(var i = 0; i < items.Count; ++i){ - Plugin.logger.LogInfo($"{i}: {items[i].spawnableItem.itemName}"); + Plugin.logger.LogDebug($"{i}: {items[i].spawnableItem.itemName}"); } } @@ -249,7 +249,7 @@ namespace ScarletMansion { if (debug) { for(var i = 0; i < items.Count; ++i){ - Plugin.logger.LogInfo($"{i}: {items[i].itemName}"); + Plugin.logger.LogDebug($"{i}: {items[i].itemName}"); } } @@ -274,13 +274,13 @@ namespace ScarletMansion { if (result) strList.Add($"({i}){LayerMask.LayerToName(i)}"); } var combine = string.Join(", ", strList); - Plugin.logger.LogInfo($"({layer}){LayerMask.LayerToName(layer)}: {combine}"); + Plugin.logger.LogDebug($"({layer}){LayerMask.LayerToName(layer)}: {combine}"); } public static void PrintCodeInstructions(IEnumerable instructions){ foreach(var i in instructions){ var objString = i.operand != null ? $"[{i.operand.GetType().ToString()}] {i.operand.ToString()}" : "NULL"; - Plugin.logger.LogInfo($"{i.opcode.ToString()}: {objString}"); + Plugin.logger.LogDebug($"{i.opcode.ToString()}: {objString}"); } } @@ -392,7 +392,7 @@ namespace ScarletMansion { var list = c as InteractEvent; for(var i = 0; i < list.GetPersistentEventCount(); i++){ var call = list.GetPersistentListenerState(i); - Plugin.logger.LogInfo($"{spacing}CALL: {call}"); + Plugin.logger.LogDebug($"{spacing}CALL: {call}"); } } @@ -400,7 +400,7 @@ namespace ScarletMansion { var list = c as InteractEventFloat; for(var i = 0; i < list.GetPersistentEventCount(); i++){ var call = list.GetPersistentMethodName(i); - Plugin.logger.LogInfo($"{spacing}CALL: {call}"); + Plugin.logger.LogDebug($"{spacing}CALL: {call}"); } } @@ -408,7 +408,7 @@ namespace ScarletMansion { var list = c as BooleanEvent; for(var i = 0; i < list.GetPersistentEventCount(); i++){ var call = list.GetPersistentMethodName(i); - Plugin.logger.LogInfo($"{spacing}CALL: {call}"); + Plugin.logger.LogDebug($"{spacing}CALL: {call}"); } } @@ -417,10 +417,10 @@ namespace ScarletMansion { try { var met = m.GetFloat("_Metallic"); var smo = m.GetFloat("_Smoothness"); - Plugin.logger.LogInfo($"{spacing}METAL: {met}"); - Plugin.logger.LogInfo($"{spacing}SMOOTH: {smo}"); + Plugin.logger.LogDebug($"{spacing}METAL: {met}"); + Plugin.logger.LogDebug($"{spacing}SMOOTH: {smo}"); } catch { - Plugin.logger.LogInfo($"{spacing}FAILED READING"); + Plugin.logger.LogDebug($"{spacing}FAILED READING"); } }