using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using DunGen; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using System.Diagnostics; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using DunGenPlus.Collections; using GameNetcodeStuff; using ScarletMansion.GamePatch.Components; namespace ScarletMansion.DunGenPatch { public static class Patch { public static bool active; public static bool callAlternative; public static DungeonGenerator generatorInstance; public static void Activate(DungeonGenerator generator){ active = true; callAlternative = true; generatorInstance = generator; var scale = generator.LengthMultiplier; var mainPathLength = generator.DungeonFlow.Length; Plugin.logger.LogDebug($"Length of main path be: {GetLength(mainPathLength, scale)}"); GamePatch.LoadAssetsIntoLevelPatch.ModifyLevel(StartOfRound.Instance.currentLevel); } public static string GetLength(IntRange range, float multi){ return $"({range.Min * multi} - {range.Max * multi})"; } public static void Deactivate(bool ignoreScarletPlayer = false){ active = false; callAlternative = false; generatorInstance = null; GamePatch.JesterAIPatch.active = false; if (ignoreScarletPlayer) return; var localPlayer = StartOfRound.Instance.localPlayerController; var scarletPlayer = ScarletPlayerControllerB.GetScarletPlayerScript(localPlayer); if (scarletPlayer != null){ scarletPlayer.stabbedSelf = false; scarletPlayer.fellInPit = false; } } public static void UpdateDunGenExtenderProperties(DunGenExtenderProperties props) { props.MainPathCount = PluginConfig.Instance.mainPathCountValue; 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]); ++i; } while(i < 7) { PluginConfig.Instance.branchPathSectionTwoValue.UpdateValues(props.LineRandomizerArchetypes[i]); ++i; } while(i < 10) { PluginConfig.Instance.branchPathSectionThreeValue.UpdateValues(props.LineRandomizerArchetypes[i]); ++i; } var count = PluginConfig.Instance.treasureRoomCountValue; props.UseForcedTiles = count > 0; var copyTarget = props.ForcedTileSets[0]; props.ForcedTileSets = new List(); for(var j = 0; j < count; ++j) props.ForcedTileSets.Add(copyTarget); } } }