diff --git a/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePath.cs b/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePath.cs index 671a297..163f8f2 100644 --- a/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePath.cs +++ b/ScarletMansion/ScarletMansion/DunGenPatch/GeneratePath.cs @@ -8,6 +8,7 @@ using UnityEngine; using DunGen; using System.Security; using System.Security.Permissions; +using DunGen.Graph; [assembly: SecurityPermission( SecurityAction.RequestMinimum, SkipVerification = true )] namespace ScarletMansion.DunGenPatch { @@ -117,7 +118,6 @@ namespace ScarletMansion.DunGenPatch { // as such, the final node of an alternate main path CANNOT be a node that can be pruned // luckily, the last node is my Nodes section has tiles that won't be pruned // so i'm just using that so the final node cannot be a target for pruning - var finalNode = gen.DungeonFlow.Nodes.OrderBy(x => x.Position).LastOrDefault(); for (var b = 0; b < altCount; ++b) { RandomizeLineArchetypes(gen, true); @@ -128,6 +128,9 @@ namespace ScarletMansion.DunGenPatch { var newMainPathTiles = new List(); newMainPathTiles.Add(mainTile); + var nodes = gen.DungeonFlow.Nodes.Skip(2); + var nodesVisited = new List(nodes.Count()); + // most of this code is a mix of the GenerateMainPath() // and GenerateBranch() code for(var t = 1; t < targetLength; ++t){ @@ -138,6 +141,8 @@ namespace ScarletMansion.DunGenPatch { yield break; } + + if (lineAtDepth != gen.previousLineSegment){ gen.currentArchetype = lineAtDepth.GetRandomArchetype(gen.RandomStream, archetypes); gen.previousLineSegment = lineAtDepth; @@ -146,9 +151,18 @@ namespace ScarletMansion.DunGenPatch { // terrible solution but FUCK it // and yet it worked // this is how my last node cannot be a target of pruning + GraphNode graphNode = null; + foreach(var g in nodes) { + if (lineDepthRatio >= g.Position && !nodesVisited.Contains(g)) { + graphNode = g; + nodesVisited.Add(g); + break; + } + } + List useableTileSets; - if (lineDepthRatio >= 1f){ - useableTileSets = finalNode.TileSets; + if (graphNode != null) { + useableTileSets = graphNode.TileSets; } else { useableTileSets = gen.currentArchetype.TileSets; } @@ -178,6 +192,7 @@ namespace ScarletMansion.DunGenPatch { } + var tileProxy = gen.AddTile(previousTile, useableTileSets, lineDepthRatio, gen.currentArchetype, TilePlacementResult.None); if (tileProxy == null) { @@ -215,6 +230,7 @@ namespace ScarletMansion.DunGenPatch { } } + Patch.callAlternative = false; if (!Patch.startAnalysis) Plugin.logger.LogInfo($"Created {altCount} alt. paths, creating branches now"); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletYukariTrigger.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletYukariTrigger.cs new file mode 100644 index 0000000..c733485 --- /dev/null +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/ScarletYukariTrigger.cs @@ -0,0 +1,89 @@ +using GameNetcodeStuff; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace ScarletMansion.GamePatch.Components +{ + public class ScarletYukariTrigger : MonoBehaviour { + + public static int audioClipIndex = -1; + + public bool sinkingLocalPlayer; + public float movementHinderence = 1.6f; + public float sinkingSpeedMultiplier = 0.21f; + + private void OnTriggerStay(Collider other) { + + var otherGameObject = other.gameObject; + if (!otherGameObject.CompareTag("Player")) { + return; + } + var comp = otherGameObject.GetComponent(); + if (comp != GameNetworkManager.Instance.localPlayerController) return; + + // sanity check + if (audioClipIndex == -1) comp.statusEffectAudioIndex = 0; + comp.statusEffectAudioIndex = audioClipIndex; + + if (comp.isSinking) return; + + if (sinkingLocalPlayer){ + if (!comp.CheckConditionsForSinkingInQuicksand()) { + + StopSinkingLocalPlayer(comp); + } + return; + } + + if (comp.CheckConditionsForSinkingInQuicksand()){ + Debug.Log("Set local player to sinking"); + sinkingLocalPlayer = true; + comp.sourcesCausingSinking++; + comp.isMovementHindered++; + comp.hinderedMultiplier *= movementHinderence; + comp.sinkingSpeedMultiplier = sinkingSpeedMultiplier; + } + } + + + private void OnTriggerExit(Collider other){ + OnExit(other); + } + + public void OnExit(Collider other){ + if (!sinkingLocalPlayer) { + Debug.Log("Yukari is not sinking local player"); + return; + } + + Debug.Log("Yukari is sinking something"); + var otherGameObject = other.gameObject; + if (!otherGameObject.CompareTag("Player")){ + return; + } + + Debug.Log("Yukari is sinking a player"); + var comp = otherGameObject.GetComponent(); + if (comp != GameNetworkManager.Instance.localPlayerController) return; + + Debug.Log("Yukari is sinking local player"); + StopSinkingLocalPlayer(comp); + } + + private void StopSinkingLocalPlayer(PlayerControllerB player) { + if (!sinkingLocalPlayer) return; + + Plugin.logger.LogInfo("Stopping"); + + sinkingLocalPlayer = false; + player.sourcesCausingSinking = Mathf.Clamp(player.sourcesCausingSinking - 1, 0, 100); + player.isMovementHindered = Mathf.Clamp(player.isMovementHindered - 1, 0, 100); + player.hinderedMultiplier = Mathf.Clamp(player.hinderedMultiplier / movementHinderence - 1, 1f, 100f); + } + + } +} diff --git a/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs index 79aa74e..f430aaf 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs @@ -12,6 +12,7 @@ using LethalLib.Modules; using Unity.Netcode; using LethalLevelLoader; using static UnityEngine.GraphicsBuffer; +using ScarletMansion.GamePatch.Components; namespace ScarletMansion.GamePatch { @@ -42,6 +43,7 @@ namespace ScarletMansion.GamePatch { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] public static void StartOfRound_Start(ref StartOfRound __instance) { + ScarletYukariTrigger.audioClipIndex = -1; __instance.StartCoroutine(WaitForNetworkObject(__instance, CreateNetworkManager)); @@ -59,24 +61,11 @@ namespace ScarletMansion.GamePatch { FixMapReferences(__instance); FixItemPrefabValues(__instance); - - - /* - foreach(var l in __instance.levels) { - foreach(var i in l.dungeonFlowTypes){ - if (i.id == 1) i.rarity = 0; - } - } - */ - - /* - // my heart can't handle it - foreach(var lev in __instance.levels){ - lev.maxDaytimeEnemyPowerCount = 0; - lev.maxEnemyPowerCount = 0; - lev.maxOutsideEnemyPowerCount = 0; - } - */ + // fix audio clips + var statusEffectClips = __instance.statusEffectClips.ToList(); + ScarletYukariTrigger.audioClipIndex = statusEffectClips.Count; + statusEffectClips.Add(Assets.networkObjectList.sinkingAudioClip); + __instance.statusEffectClips = statusEffectClips.ToArray(); // DunGenAnalyis.Analysis(Assets.dungeon, __instance, RoundManager.Instance); } diff --git a/ScarletMansion/ScarletMansion/LoadingPatch/NetworkObjectListScriptableObject.cs b/ScarletMansion/ScarletMansion/LoadingPatch/NetworkObjectListScriptableObject.cs index 9c1715b..4b80bdf 100644 --- a/ScarletMansion/ScarletMansion/LoadingPatch/NetworkObjectListScriptableObject.cs +++ b/ScarletMansion/ScarletMansion/LoadingPatch/NetworkObjectListScriptableObject.cs @@ -29,5 +29,6 @@ namespace ScarletMansion { //public GameObject mainMenuPrefab; [Header("Main Prefabs")] public GameObject scarletNetworkManager; + public AudioClip sinkingAudioClip; } } diff --git a/ScarletMansion/ScarletMansion/ModPatch/MimicsPatch.cs b/ScarletMansion/ScarletMansion/ModPatch/MimicsPatch.cs deleted file mode 100644 index 444a1b6..0000000 --- a/ScarletMansion/ScarletMansion/ModPatch/MimicsPatch.cs +++ /dev/null @@ -1,37 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using BepInEx; -using HarmonyLib; -using System.Reflection; -using System.Reflection.Emit; -using DunGen; -using ScarletMansion.GamePatch.FixValues; -using UnityEngine.Events; -using GameNetcodeStuff; -using ScarletMansion.GamePatch.Components; -using System.IO; - -namespace ScarletMansion.ModPatch { - public class MimicsPatch : ModPatch { - - public override string version => "2.6.0"; - - public MimicsPatch(string guid) : base(guid) { } - - public override void AddPatch() { - var assemblyPath = Assembly.GetExecutingAssembly().Location; - var folderPath = Path.GetDirectoryName(assemblyPath); - var pathAssemblyPath = Path.Combine(folderPath, "ScarletMansionMimicsPatch.dll"); - - var assembly = Assembly.LoadFile(pathAssemblyPath); - var type = assembly.GetType("ScarletMansion.ModPatch.Patch"); - Activator.CreateInstance(type); - } - - } -} diff --git a/ScarletMansion/ScarletMansion/ModPatch/ModCompability.cs b/ScarletMansion/ScarletMansion/ModPatch/ModCompability.cs index b0a9501..e74a49b 100644 --- a/ScarletMansion/ScarletMansion/ModPatch/ModCompability.cs +++ b/ScarletMansion/ScarletMansion/ModPatch/ModCompability.cs @@ -13,16 +13,15 @@ namespace ScarletMansion.ModPatch { public const string lethalConfigGuid = "ainavt.lc.lethalconfig"; public const string facilityMeldownGuid = "me.loaforc.facilitymeltdown"; public const string reserveFlashlightGuid = "FlipMods.ReservedFlashlightSlot"; - public const string mimicsGuid = "x753.Mimics"; public static readonly ModPatch[] modPatches = new ModPatch[] { new AdvancedCompanyPatch(advancedCompanyGuid), new LethalConfigPatch(lethalConfigGuid), new FacilityMeltdownPatch(facilityMeldownGuid), - new ReservedItemSlotPatch(reserveFlashlightGuid), - new MimicsPatch(mimicsGuid) + new ReservedItemSlotPatch(reserveFlashlightGuid) }; + public static void GetActiveMods(){ foreach(var m in modPatches) m.CheckIfActive(); diff --git a/ScarletMansion/ScarletMansion/Plugin.cs b/ScarletMansion/ScarletMansion/Plugin.cs index 7158316..be48688 100644 --- a/ScarletMansion/ScarletMansion/Plugin.cs +++ b/ScarletMansion/ScarletMansion/Plugin.cs @@ -24,16 +24,16 @@ namespace ScarletMansion { [BepInDependency("imabatby.lethallevelloader", "1.2.0.1")] [BepInDependency("evaisa.lethallib", "0.13.2")] + [BepInDependency(ModCompability.advancedCompanyGuid, BepInDependency.DependencyFlags.SoftDependency)] [BepInDependency(ModCompability.lethalConfigGuid, BepInDependency.DependencyFlags.SoftDependency)] [BepInDependency(ModCompability.facilityMeldownGuid, BepInDependency.DependencyFlags.SoftDependency)] [BepInDependency(ModCompability.reserveFlashlightGuid, BepInDependency.DependencyFlags.SoftDependency)] - [BepInDependency(ModCompability.mimicsGuid, BepInDependency.DependencyFlags.SoftDependency)] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { public const string modGUID = "ImoutoSama.ScarletMansion"; private const string modName = "Scarlet Mansion"; - private const string modVersion = "1.3.10"; + private const string modVersion = "1.3.12"; public readonly Harmony harmony = new Harmony(modGUID); diff --git a/ScarletMansion/ScarletMansion/PluginConfig.cs b/ScarletMansion/ScarletMansion/PluginConfig.cs index 75e6e70..a35f119 100644 --- a/ScarletMansion/ScarletMansion/PluginConfig.cs +++ b/ScarletMansion/ScarletMansion/PluginConfig.cs @@ -187,11 +187,11 @@ namespace ScarletMansion { private static readonly string _branchPathPostDepthMessage = $"Each branching path will try to generate a number of connecting tiles equal to this number. {_branchPathPostGenericMessage}"; public static ConfigEntryBundleBranchingPath branchPathSectionOne = new ConfigEntryBundleBranchingPath( - dungeonGenerationBPathOnePrefix, 1, _branchPathSectionOneMessage, 6, 8, 3, 4 + dungeonGenerationBPathOnePrefix, 1, _branchPathSectionOneMessage, 6, 8, 0, 2 ); public static ConfigEntryBundleBranchingPath branchPathSectionTwo = new ConfigEntryBundleBranchingPath( - dungeonGenerationBPathTwoPrefix, 2, _branchPathSectionTwoMessage, 2, 3, 1, 2 + dungeonGenerationBPathTwoPrefix, 2, _branchPathSectionTwoMessage, 2, 3, 0, 1 ); public static ConfigEntryBundleBranchingPath branchPathSectionThree = new ConfigEntryBundleBranchingPath( @@ -380,8 +380,8 @@ namespace ScarletMansion { public static ConfigEntryBundle hallwayLightsWeight = new ConfigEntryBundle( dungeonLightingPrefix, "Hallway Lights Weight", - 225, - "The weight for a hallway wall lamp to appear on its respective walls. With the default weight of 225 against the weight of the empty wall of 75, there is a 60% chance that a wall lamp will spawn. Increasing the weight to 675 will give you a 90% chance, 75 = 50%, and so on.", + 75, + "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.", null, new AcceptableValueRange(0, 999) ); @@ -389,8 +389,8 @@ namespace ScarletMansion { public static ConfigEntryBundle ceilingLightsWeight = new ConfigEntryBundle( dungeonLightingPrefix, "Chandelier Lights Weight", - 225, - "The weight for a chandelier to appear on its respective ceilings. With the default weight of 225 against the weight of the empty ceiling of 75, there is a 75% chance that a chandelier will spawn. Increasing the weight to 675 will give you a 90%, 75 = 50%, and so on.", + 75, + "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.", null, new AcceptableValueRange(0, 999) ); diff --git a/ScarletMansion/ScarletMansion/PresetConfig.cs b/ScarletMansion/ScarletMansion/PresetConfig.cs index 5d9312d..b51279a 100644 --- a/ScarletMansion/ScarletMansion/PresetConfig.cs +++ b/ScarletMansion/ScarletMansion/PresetConfig.cs @@ -129,11 +129,12 @@ namespace ScarletMansion { //new ChangeInt ( PluginConfig.lightsSpawnThreeWeight ) ); + public static ChangeList brightLighting = new ChangeList( "Bright", "Makes light sources much more common.", - new ChangeInt ( PluginConfig.hallwayLightsWeight, 675 ), - new ChangeInt ( PluginConfig.ceilingLightsWeight, 675 ), + new ChangeInt ( PluginConfig.hallwayLightsWeight, 225 ), + new ChangeInt ( PluginConfig.ceilingLightsWeight, 225 ), new ChangeInt ( PluginConfig.lightsSpawnZeroWeight, 1 ), new ChangeInt ( PluginConfig.lightsSpawnOneWeight, 6 ), new ChangeInt ( PluginConfig.lightsSpawnTwoWeight, 3 ) @@ -143,8 +144,8 @@ namespace ScarletMansion { public static ChangeList darkLighting = new ChangeList( "Dark", "Makes light sources much less common.", - new ChangeInt ( PluginConfig.hallwayLightsWeight, 75 ), - new ChangeInt ( PluginConfig.ceilingLightsWeight, 75 ), + new ChangeInt ( PluginConfig.hallwayLightsWeight, 25 ), + new ChangeInt ( PluginConfig.ceilingLightsWeight, 25 ), new ChangeInt ( PluginConfig.lightsSpawnZeroWeight, 3 ), new ChangeInt ( PluginConfig.lightsSpawnOneWeight, 7 ), new ChangeInt ( PluginConfig.lightsSpawnTwoWeight, 0 ) diff --git a/ScarletMansion/ScarletMansion/ScarletMansion.csproj b/ScarletMansion/ScarletMansion/ScarletMansion.csproj index 06df543..c56f2f0 100644 --- a/ScarletMansion/ScarletMansion/ScarletMansion.csproj +++ b/ScarletMansion/ScarletMansion/ScarletMansion.csproj @@ -184,6 +184,7 @@ + @@ -228,7 +229,6 @@ - diff --git a/ScarletMansion/ScarletMansion/Utility.cs b/ScarletMansion/ScarletMansion/Utility.cs index 1e83fb0..cd88678 100644 --- a/ScarletMansion/ScarletMansion/Utility.cs +++ b/ScarletMansion/ScarletMansion/Utility.cs @@ -179,6 +179,17 @@ namespace ScarletMansion { return null; } + public static void PrintToParent(Transform t) { + Plugin.logger.LogInfo(t.name); + var parent = t.parent; + var i = 0; + while (parent != null) { + var header = new string(' ', ++i); + Plugin.logger.LogInfo($"{header}{parent.name}"); + parent = parent.parent; + } + } + public static List GetDungeonItems(){ return LoadAssetsIntoLevelPatch.GetItems(RoundManager.Instance.currentLevel.spawnableScrap); } diff --git a/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/Patch.cs b/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/Patch.cs index cbeeac3..b7cb7b3 100644 --- a/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/Patch.cs +++ b/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/Patch.cs @@ -15,25 +15,28 @@ using DunGen; using ScarletMansion.GamePatch.FixValues; using UnityEngine.Events; using GameNetcodeStuff; +using ScarletMansion; using ScarletMansion.GamePatch.Components; +using ScarletMansion.DunGenPatch; -namespace ScarletMansion.ModPatch { +namespace ScarletMansionMimicsPatch { public class Patch { - - public Patch() { - MimicsAPI.GetAPI().RegisterMimicEventHandler(new SDMMimicEventHandler()); + + public static void Activate() { + MimicsAPI.GetAPI().RegisterMimicEventHandler(new Patch.SDMMimicEventHandler()); Plugin.Instance.harmony.PatchAll(typeof(Patch)); } - + public class SDMMimicEventHandler : MimicEventHandler { + public override string ModGUID => Plugin.modGUID; - public override bool IsMyInteriorLoaded => DunGenPatch.Patch.active; + public override bool IsMyInteriorLoaded => ScarletMansion.DunGenPatch.Patch.active; public override void OnMimicCreated(MimicDoor mimicDoor, Doorway doorway) { - var c = doorway.transform.parent.GetComponentInChildren(); + var c = doorway.transform.parent.GetComponentInChildren(); if (c != null) { c.overrideConnector = true; c.overrideNoDoorway = true; @@ -42,9 +45,9 @@ namespace ScarletMansion.ModPatch { var fixfireexit = doorway.GetComponentInChildren(true); fixfireexit.ForcefullyEnableDoorway(); - var mimicDoorMesh = Utility.FindChildRecurvisely(mimicDoor.transform, "DoorMesh"); - var mimicFrame = Utility.FindChildRecurvisely(mimicDoor.transform, "Frame"); - var mimicLight = Utility.FindChildRecurvisely(mimicDoor.transform, "Light"); + var mimicDoorMesh = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "DoorMesh"); + var mimicFrame = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "Frame"); + var mimicLight = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "Light"); if (fixfireexit.EnableVanillaFireExit){ FixDoorwayForVanillaFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight); diff --git a/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/Plugin.cs b/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/Plugin.cs new file mode 100644 index 0000000..7d2efc4 --- /dev/null +++ b/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/Plugin.cs @@ -0,0 +1,66 @@ +using BepInEx; +using BepInEx.Logging; +using HarmonyLib; +using ScarletMansion; +using ScarletMansion.DunGenPatch; +using ScarletMansion.GamePatch.Managers; +using ScarletMansion.GamePatch; +using ScarletMansion.ModPatch; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Mimics.API; +using BepInEx.Bootstrap; + +namespace ScarletMansionMimicsPatch { + + [BepInPlugin(modGUID, modName, modVersion)] + + [BepInDependency("ImoutoSama.ScarletMansion", "1.3.12")] + [BepInDependency(targetModGUID, BepInDependency.DependencyFlags.SoftDependency)] + + public class Plugin : BaseUnityPlugin { + + public const string modGUID = "ImoutoSama.ScarletMansionMimicsPatch"; + private const string modName = "Scarlet Mansion Mimics Patch"; + private const string modVersion = "1.0.0"; + + public const string targetModGUID = "x753.Mimics"; + public const string targetModVersion = "2.6.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); + logger.LogInfo($"Plugin {modName} has been added!"); + + 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(); + } + + + } + + } +} diff --git a/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj b/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj index ba43b82..93269db 100644 --- a/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj +++ b/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj @@ -63,6 +63,7 @@ +