diff --git a/CoronerPatch/ScarletMansionCoronerPatch/Plugin.cs b/CoronerPatch/ScarletMansionCoronerPatch/Plugin.cs index 3b0a3c9..8297fa7 100644 --- a/CoronerPatch/ScarletMansionCoronerPatch/Plugin.cs +++ b/CoronerPatch/ScarletMansionCoronerPatch/Plugin.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace ScarletMansionCoronerPatch { [BepInPlugin(modGUID, modName, modVersion)] - [BepInDependency("dev.ladyalice.scarletmansion", "1.3.27")] + [BepInDependency("dev.ladyalice.scarletmansion", "2.4.0")] [BepInDependency(targetModGUID, BepInDependency.DependencyFlags.SoftDependency)] public class Plugin : BaseUnityPlugin { @@ -21,7 +21,7 @@ namespace ScarletMansionCoronerPatch { private const string modVersion = "1.0.0"; public const string targetModGUID = "com.elitemastereric.coroner"; - public const string targetModVersion = "2.1.0"; + public const string targetModVersion = "2.4.0"; public readonly Harmony harmony = new Harmony(modGUID); public static Plugin Instance {get; private set;} diff --git a/MimicsPatch/ScarletMansionMimicsPatch/Patch.cs b/MimicsPatch/ScarletMansionMimicsPatch/Patch.cs index f4e2ec9..2890365 100644 --- a/MimicsPatch/ScarletMansionMimicsPatch/Patch.cs +++ b/MimicsPatch/ScarletMansionMimicsPatch/Patch.cs @@ -46,20 +46,20 @@ namespace ScarletMansionMimicsPatch { public override bool IsMyInteriorLoaded => ScarletMansion.DunGenPatch.Patch.active; public override void OnMimicCreated(MimicDoor mimicDoor, Doorway doorway) { - var fixfireexit = doorway.GetComponentInChildren(true); - fixfireexit.ForcefullyEnableDoorway(); + var fixfireexit = doorway.GetComponentInChildren(true); + fixfireexit.ForcefullyEnableDoorway(); - var mimicDoorMesh = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "DoorMesh"); - var mimicFrame = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "Frame"); - var mimicLight = ScarletMansion.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); - } else { - FixDoorwayForSDMFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight); - } + if (fixfireexit.EnableVanillaFireExit){ + FixDoorwayForVanillaFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight); + } else { + FixDoorwayForSDMFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight); + } - Plugin.logger.LogDebug("Fixed a doorway for a mimic"); + Plugin.logger.LogDebug("Fixed a doorway for a mimic"); } public override void OnMimicAttackStart(MimicDoor mimicDoor, PlayerControllerB playerToAttack) { diff --git a/MimicsPatch/ScarletMansionMimicsPatch/Plugin.cs b/MimicsPatch/ScarletMansionMimicsPatch/Plugin.cs index 85e5ea5..4c0e253 100644 --- a/MimicsPatch/ScarletMansionMimicsPatch/Plugin.cs +++ b/MimicsPatch/ScarletMansionMimicsPatch/Plugin.cs @@ -19,7 +19,7 @@ namespace ScarletMansionMimicsPatch { [BepInPlugin(modGUID, modName, modVersion)] - [BepInDependency("dev.ladyalice.scarletmansion", "1.3.22")] + [BepInDependency("dev.ladyalice.scarletmansion", "2.4.0")] [BepInDependency(targetModGUID, BepInDependency.DependencyFlags.SoftDependency)] public class Plugin : BaseUnityPlugin { @@ -29,7 +29,7 @@ namespace ScarletMansionMimicsPatch { private const string modVersion = "1.0.0"; public const string targetModGUID = "x753.Mimics"; - public const string targetModVersion = "2.6.0"; + public const string targetModVersion = "2.7.4"; public readonly Harmony harmony = new Harmony(modGUID); public static Plugin Instance {get; private set;} diff --git a/MimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj b/MimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj index c7025b5..e5cc99e 100644 --- a/MimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj +++ b/MimicsPatch/ScarletMansionMimicsPatch/ScarletMansionMimicsPatch.csproj @@ -40,6 +40,9 @@ ..\..\..\Libraries\BepInEx.dll + + ..\..\..\Libraries\DunGen-publicized.dll + ..\..\..\Libraries\DunGenPlus.dll diff --git a/Retrospective b/Retrospective new file mode 100644 index 0000000..896e79c --- /dev/null +++ b/Retrospective @@ -0,0 +1,7 @@ +Let me explain quickly how this mod came to be. + +Lethal Company becomes popular. Me and all my boys play LC a lot. I start dabbling on LC mods for things our group wanted. It was my first time ever modding but I have used Unity for a long while so the progress was mostly smooth. Near the completion of the boombox mod, I start thinking of what to do next. + +By that point, me and our group was starting to find our personal issues with LC. In particular, the mansion interior. We expected the mansion to feel like... well... a mansion. We expected many short paths and interconnecting paths. You know, what you expect a mansion to be. But instead the mansion interior is just a regular dungeon with only one super duper long path and barely any interconnecting paths. + +It was then when my friend suggested to make a mansion interior but better. I almost said lmao no shot, but I realized that I already had mansion assets from previous game projects. So I figured why not, let's try reusing the assets into making this interior. And from there, the rest is histoy. \ No newline at end of file diff --git a/ScarletMansion/ScarletMansion/Assets.cs b/ScarletMansion/ScarletMansion/Assets.cs index daca1ca..cac5ae1 100644 --- a/ScarletMansion/ScarletMansion/Assets.cs +++ b/ScarletMansion/ScarletMansion/Assets.cs @@ -1,18 +1,19 @@ -using System; +using DunGen.Graph; +using DunGenPlus; +using LethalLevelLoader; +using LethalLib.Modules; +using ScarletMansion.Configs; +using ScarletMansion.ModPatch; +using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using UnityEngine; -using System.Reflection; -using System.IO; -using DunGen.Graph; -using LethalLib.Modules; -using LethalLevelLoader; -using DunGenPlus; -using ScarletMansion.ModPatch; -using ScarletMansion.Configs; +using static UnityEngine.GraphicsBuffer; namespace ScarletMansion { public static class Assets { @@ -33,6 +34,8 @@ namespace ScarletMansion { // enemy values public class Enemy { + public bool initialized; + public GameObject enemy; public EnemyType enemyType; public Func rarityFunc; @@ -42,14 +45,15 @@ namespace ScarletMansion { public Enemy(GameObject enemy, TerminalNode node, TerminalKeyword keyword) { this.enemy = enemy; + this.enemyType = enemy.GetComponentInChildren().enemyType; this.terminalNode = node; this.terminalKeyword = keyword; + + LethalLib.Modules.Enemies.RegisterEnemy(enemyType, 0, Levels.LevelTypes.None, terminalNode, terminalKeyword); } public SpawnableEnemyWithRarity GetItemEntry(int rarity){ - var entry = new SpawnableEnemyWithRarity(); - entry.enemyType = enemyType; - entry.rarity = rarity; + var entry = new SpawnableEnemyWithRarity(enemyType, rarity); return entry; } } @@ -114,9 +118,8 @@ namespace ScarletMansion { public SpawnableItemWithRarity GetItemRarity(){ var configEntry = GetConfigScrapItemEntry(); - var item = new SpawnableItemWithRarity(); - item.spawnableItem = this.item; - item.rarity = configEntry != null ? configEntry.spawnWeight : 0; + var rarity = configEntry != null ? configEntry.spawnWeight : 0; + var item = new SpawnableItemWithRarity(this.item, rarity); return item; } @@ -205,7 +208,6 @@ namespace ScarletMansion { MainAssetBundle = AssetBundle.LoadFromStream(assetStream); } } - } Plugin.ConfigFoyer.dungeon = Load("sdmFoyer"); @@ -222,7 +224,7 @@ namespace ScarletMansion { Load("KnightNode"), Load("KnightKeyword") ); - + maid = new Enemy( Load("NET_MaidEnemy"), Load("MaidNode"), diff --git a/ScarletMansion/ScarletMansion/Configs/ConfigDungeonBasement.cs b/ScarletMansion/ScarletMansion/Configs/ConfigDungeonBasement.cs index d4eb615..15e8fce 100644 --- a/ScarletMansion/ScarletMansion/Configs/ConfigDungeonBasement.cs +++ b/ScarletMansion/ScarletMansion/Configs/ConfigDungeonBasement.cs @@ -27,10 +27,10 @@ namespace ScarletMansion.Configs "Default", "The default generation values. Intended for lobbies with 3+ players.", - new ChangeInt ( dunGenWidthBase, 120 ), - new ChangeInt ( dunGenLengthBase, 80 ), - new ChangeFloat ( dunGenWidthMultiFactor, 0.5f ), - new ChangeFloat ( dunGenLengthMultiFactor, 0.3333333f ), + new ChangeInt ( dunGenWidthBase, 140 ), + new ChangeInt ( dunGenLengthBase, 90 ), + new ChangeFloat ( dunGenWidthMultiFactor, 0.75f ), + new ChangeFloat ( dunGenLengthMultiFactor, 0.1428f ), new ChangeInt ( mainPathCount, 3 ), new ChangeMinMaxInt ( mainPathLength, 6, 7 ), diff --git a/ScarletMansion/ScarletMansion/Configs/ConfigDungeonFoyer.cs b/ScarletMansion/ScarletMansion/Configs/ConfigDungeonFoyer.cs index 07a0c8d..fd40b12 100644 --- a/ScarletMansion/ScarletMansion/Configs/ConfigDungeonFoyer.cs +++ b/ScarletMansion/ScarletMansion/Configs/ConfigDungeonFoyer.cs @@ -27,8 +27,8 @@ namespace ScarletMansion.Configs { "Default", "The default generation values. Intended for lobbies with 3+ players.", - new ChangeInt ( dunGenWidthBase, 120 ), - new ChangeInt ( dunGenLengthBase, 80 ), + new ChangeInt ( dunGenWidthBase, 140 ), + new ChangeInt ( dunGenLengthBase, 100 ), new ChangeFloat ( dunGenWidthMultiFactor, 0.5f ), new ChangeFloat ( dunGenLengthMultiFactor, 0.3333333f ), diff --git a/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs b/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs index 9c53149..34ab66c 100644 --- a/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs +++ b/ScarletMansion/ScarletMansion/DunGenPatch/Patch.cs @@ -133,5 +133,12 @@ namespace ScarletMansion.DunGenPatch { return ConnectionResult.Passthrough; } + public static void PriotizeDoorwaysGoingDownward(ref float weight, DoorwayPairCollection param, EventCallbackScenario callback){ + var diff = param.nextDoor.Position.y - param.previousDoor.Position.y; + if (diff < -0.01f){ + weight *= 1.25f; + } + } + } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomRadioEvent.cs b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomRadioEvent.cs index da83ea0..96ea12a 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomRadioEvent.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Components/TreasureRoom/TreasureRoomRadioEvent.cs @@ -62,11 +62,12 @@ namespace ScarletMansion.GamePatch.Components.TreasureRoom { prop.ProcessSkipCount(randomStream, 1); } } else { - prop.Process(randomStream, null); + var spawned = new List(); + prop.Process(randomStream, null, ref spawned); } // so the children get the process prop cycling as well - DunGenPatch.Patch.generatorInstance.ProcessProps(null, prop.transform.GetChild(0).gameObject); + Utility.ProcessLocalProps(DunGenPatch.Patch.generatorInstance, prop.transform.GetChild(0).gameObject); } // hack so i can set up the SpawnSycnedObject myself diff --git a/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs index b3cb001..934d55d 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/InitPatch.cs @@ -47,6 +47,7 @@ namespace ScarletMansion.GamePatch { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] public static void StartOfRound_Start(ref StartOfRound __instance) { + ScarletYukariTrigger.audioClipIndex = -1; ScarletPlayerControllerB.InitializeScarletScripts(); DoorwayManager.onMainEntranceTeleportSpawnedEvent.ClearTemporaryActionList(); @@ -118,41 +119,37 @@ namespace ScarletMansion.GamePatch { .SelectMany(lev => lev.Enemies); var knight = Assets.knight; - if (knight.enemyType == null){ + if (!knight.initialized){ var springItem = allEnemies.FirstOrDefault(e => e.enemyType.name.ToLowerInvariant() == "springman"); - if (GameReadNullCheck(springItem, "springman", "Knight enemy will not spawn")) { - var type = ScriptableObject.Instantiate(springItem.enemyType); - type.name = "Knight"; - type.enemyPrefab = knight.enemy; - type.enemyName = "Knight"; + if (GameReadNullCheck(springItem, "springman", "Knight enemy will not have correct assets")) { + var source = springItem.enemyType; + var target = knight.enemy.GetComponent().enemyType; + + target.hitBodySFX = source.hitBodySFX; - knight.enemyType = type; - knight.enemy.GetComponentInChildren().enemyType = type; - LethalLib.Modules.Enemies.RegisterEnemy(type, 0, Levels.LevelTypes.None, knight.terminalNode, knight.terminalKeyword); + knight.initialized = true; + Plugin.logger.LogDebug("Initialized knight"); } } var maid = Assets.maid; - if (maid.enemyType == null){ + if (!maid.initialized){ var butlerItem = allEnemies.FirstOrDefault(e => e.enemyType.name.ToLowerInvariant() == "butler"); - if (GameReadNullCheck(butlerItem, "butler", "Maid enemy will not spawn")) { - var type = ScriptableObject.Instantiate(butlerItem.enemyType); - type.name = "Maid"; - type.enemyPrefab = maid.enemy; - type.enemyName = "Maid"; - type.pushPlayerForce *= 0.25f; + if (GameReadNullCheck(butlerItem, "butler", "Maid enemy will not have correct assets")) { + var source = butlerItem.enemyType; + var target = maid.enemy.GetComponent().enemyType; + + target.hitBodySFX = source.hitBodySFX; + target.audioClips = source.audioClips; - maid.enemyType = type; - var maidScript = maid.enemy.GetComponentInChildren(); - maidScript.enemyType = type; - - var butlerPrefab = butlerItem.enemyType.enemyPrefab; - var butlerScript = butlerPrefab.GetComponent(); + var butlerScript = source.enemyPrefab.GetComponent(); + var maidScript = target.enemyPrefab.GetComponent(); Utility.FixParticleSystemMaterialAndChildren(maidScript.stabBloodParticle, butlerScript.stabBloodParticle); - LethalLib.Modules.Enemies.RegisterEnemy(type, 0, Levels.LevelTypes.None, maid.terminalNode, maid.terminalKeyword); + maid.initialized = true; + Plugin.logger.LogDebug("Initialized maid"); } } @@ -319,23 +316,30 @@ namespace ScarletMansion.GamePatch { var steeldoor = prefabs.FirstOrDefault(p => p.Prefab.name.ToLowerInvariant() == "fancydoormapmodel"); if (GameReadNullCheck(steeldoor, "FancyDoorMapModel", "SDM doors will have missing icons and sounds")){ - var interact = steeldoor.Prefab.GetComponentInChildren(); - var animateTrigger = steeldoor.Prefab.GetComponentInChildren(); - Assets.hoverIcon = interact.hoverIcon; + var sourceInteract = steeldoor.Prefab.GetComponentInChildren(); + var sourceAnimate = steeldoor.Prefab.GetComponentInChildren(); + var sourceDoor = steeldoor.Prefab.GetComponentInChildren(); + Assets.hoverIcon = sourceInteract.hoverIcon; - var boolFalse = animateTrigger.boolFalseAudios; - var boolTrue = animateTrigger.boolTrueAudios; - var secondary = animateTrigger.secondaryAudios; + var boolFalse = sourceAnimate.boolFalseAudios; + var boolTrue = sourceAnimate.boolTrueAudios; + var secondary = sourceAnimate.secondaryAudios; + + var pickingSFX = sourceDoor.pickingLockSFX; + var unlockSFX = sourceDoor.unlockSFX; FixDoorway(prefabFixList[0]); FixDoorway(prefabFixList[1]); void FixDoorway(GameObject g){ var animate = g.GetComponentInChildren(); - animate.boolFalseAudios = boolFalse; animate.boolTrueAudios = boolTrue; animate.secondaryAudios = secondary; + + var doorlock = g.GetComponentInChildren(); + doorlock.pickingLockSFX = pickingSFX; + doorlock.unlockSFX = unlockSFX; } } diff --git a/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs b/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs index affb637..5777048 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/LoadAssetsIntoLevelPatch.cs @@ -67,10 +67,7 @@ namespace ScarletMansion.GamePatch { } else { var entryRarity = Mathf.RoundToInt(target.rarity * enemyConfig.spawnWeightStealPercentage); - var prevEntry = new SpawnableEnemyWithRarity(); - prevEntry.enemyType = target.enemyType; - prevEntry.rarity = target.rarity - entryRarity; - + var prevEntry = new SpawnableEnemyWithRarity(target.enemyType, target.rarity - entryRarity); var newEntry = enemy.GetItemEntry(enemyConfig.spawnWeightBase + entryRarity); EnemyManager.AddEnemy(newEntry); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs b/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs index cf1b416..4aa4af9 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Managers/ScarletNetworkManager.cs @@ -409,7 +409,6 @@ namespace ScarletMansion { var gameObject = GameObject.Instantiate(enemy.enemyPrefab, position, Quaternion.Euler(0f, yRotation, 0f)); var networkScript = gameObject.GetComponentInChildren(); networkScript.SpawnWithOwnership(ownerID, true); - Plugin.logger.LogFatal(ownerID); var enemyScript = gameObject.GetComponent(); RoundManager.Instance.SpawnedEnemies.Add(enemyScript); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs index 685931b..3577258 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/FireExitEmptySpaceCheck.cs @@ -12,7 +12,7 @@ namespace ScarletMansion.GamePatch.Props { public GameObject target; public Bounds bounds; - public override void Process(RandomStream randomStream, Tile tile) { + public override void Process(RandomStream randomStream, Tile tile, ref List spawnedObjects) { var b = GetBounds(); var layerMask = LayerMask.GetMask(new string[3] { "Room", "Railing", "MapHazards" }); if (Physics.CheckBox(b.center, b.extents, transform.rotation, layerMask)){ diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs index 80fa87f..33846c3 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/FloorPropBasedOnFloor.cs @@ -15,7 +15,7 @@ namespace ScarletMansion.GamePatch.Props { public List basementFloorPrefabs; public GameObject bottomFloorPrefab; - public override void Process(RandomStream randomStream, Tile tile) { + public override void Process(RandomStream randomStream, Tile tile, ref List spawnedObjects) { var baseY = KnightSpawnManager.Instance.transform.position.y; var currentY = tile.transform.position.y; diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropBasic.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropBasic.cs index 57bae02..9a954c9 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropBasic.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropBasic.cs @@ -9,7 +9,7 @@ using DunGen; namespace ScarletMansion.GamePatch.Props { public class LocalPropSetBasic : RandomProp { - public override void Process(RandomStream randomStream, Tile tile) { + public override void Process(RandomStream randomStream, Tile tile, ref List spawnedObjects) { var transformCount = transform.childCount; var count = Mathf.Clamp(propCount.GetRandom(randomStream), 0, transformCount); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropSingle.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropSingle.cs index 798f150..4f36a98 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropSingle.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/LocalPropSingle.cs @@ -9,7 +9,7 @@ using DunGen; namespace ScarletMansion.GamePatch.Props { public class LocalPropSingle : RandomProp { - public override void Process(RandomStream randomStream, Tile tile) { + public override void Process(RandomStream randomStream, Tile tile, ref List spawnedObjects) { if (randomizePosition){ var x = (float)randomStream.NextDouble() * randomPositionRange; diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabBasic.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabBasic.cs index 790a9da..330c979 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabBasic.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabBasic.cs @@ -9,7 +9,7 @@ using DunGen; namespace ScarletMansion.GamePatch.Props { public class RandomPrefabBasic : RandomPrefabBase { - public override void Process(RandomStream randomStream, Tile tile) { + public override void Process(RandomStream randomStream, Tile tile, ref List spawnedObjects) { if (props.Count <= 0) return; var value = randomStream.Next(props.Count); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs index d7a330f..ea8072b 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabCycle.cs @@ -16,7 +16,7 @@ namespace ScarletMansion.GamePatch.Props { cycle = value; } - public override void Process(RandomStream randomStream, Tile tile) { + public override void Process(RandomStream randomStream, Tile tile, ref List spawnedObjects) { if (props.Count <= 0) return; Plugin.logger.LogDebug($"Cycle {cycle}"); diff --git a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabWithScale.cs b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabWithScale.cs index 451f23e..1c3dd61 100644 --- a/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabWithScale.cs +++ b/ScarletMansion/ScarletMansion/GamePatch/Props/RandomPrefabWithScale.cs @@ -1,5 +1,7 @@ using System; using UnityEngine; +using System.Collections; +using System.Collections.Generic; using DunGen; namespace ScarletMansion { @@ -7,7 +9,7 @@ namespace ScarletMansion { [AddComponentMenu("DunGen/Random Props/Random Prefab with Scale")] public class RandomPrefabWithScale : RandomProp { - public override void Process(RandomStream randomStream, Tile tile) { + public override void Process(RandomStream randomStream, Tile tile, ref List spawnedObjects) { if (Props.Weights.Count <= 0) return; var value = this.Props.GetRandom(randomStream, tile.Placement.IsOnMainPath, tile.Placement.NormalizedDepth, null, true, true).Value; diff --git a/ScarletMansion/ScarletMansion/Plugin.cs b/ScarletMansion/ScarletMansion/Plugin.cs index d98da62..ef4d674 100644 --- a/ScarletMansion/ScarletMansion/Plugin.cs +++ b/ScarletMansion/ScarletMansion/Plugin.cs @@ -23,9 +23,9 @@ namespace ScarletMansion { [BepInPlugin(modGUID, modName, modVersion)] - [BepInDependency("imabatby.lethallevelloader", "1.4.5")] - [BepInDependency("evaisa.lethallib", "0.13.2")] - [BepInDependency("dev.ladyalice.dungenplus", "1.4.0")] + [BepInDependency("imabatby.lethallevelloader", "1.6.9")] + [BepInDependency("evaisa.lethallib", "1.2.0")] + [BepInDependency("dev.ladyalice.dungenplus", "1.5.0")] [BepInDependency("dev.ladyalice.scarletmansion.foyer")] [BepInDependency("dev.ladyalice.scarletmansion.basement")] //[BepInDependency(ModCompability.advancedCompanyGuid, BepInDependency.DependencyFlags.SoftDependency)] @@ -37,7 +37,7 @@ namespace ScarletMansion { public class Plugin : BaseUnityPlugin { public const string modGUID = "dev.ladyalice.scarletmansion"; private const string modName = "Scarlet Devil Mansion"; - private const string modVersion = "2.3.0"; + private const string modVersion = "2.4.0"; public readonly Harmony harmony = new Harmony(modGUID); @@ -84,7 +84,7 @@ namespace ScarletMansion { harmony.PatchAll(typeof(ConfigPatch)); - SetupForNetcodePatcher(); + //SetupForNetcodePatcher(); Assets.LoadAssetBundle(); @@ -127,6 +127,7 @@ namespace ScarletMansion { extendedContent.Add(CreateExtendedDungeonFlow(ConfigFoyer, "Scarlet Foyer", 100, 200, 30)); extendedContent.Add(CreateExtendedDungeonFlow(ConfigBasement, "Scarlet Basement", 200, 100, 30)); + ConfigBasement.dunGenExtender.Events.OnModifyDoorwayPairWeight.AddListener(DunGenPatch.Patch.PriotizeDoorwaysGoingDownward); var extendedMod = ExtendedMod.Create("Scarlet Devil Mansion", "Alice", extendedContent.ToArray()); diff --git a/ScarletMansion/ScarletMansion/ScarletMansion.csproj b/ScarletMansion/ScarletMansion/ScarletMansion.csproj index 9141b6b..31923d2 100644 --- a/ScarletMansion/ScarletMansion/ScarletMansion.csproj +++ b/ScarletMansion/ScarletMansion/ScarletMansion.csproj @@ -46,6 +46,9 @@ ..\..\..\Libraries\BepInEx.Harmony.dll + + ..\..\..\Libraries\DunGen-publicized.dll + ..\..\..\Libraries\DunGenPlus.dll @@ -277,10 +280,10 @@ - copy "D:\Previous Computer\Desktop\LethalCompany Modding\Unity Template\Assets\AssetBundles\scarletmansion" "$(SolutionDir)\scarletmansion" + copy "D:\Unity Projects\Lethal Company Project\Assets\AssetBundles\scarletmansion" "$(SolutionDir)\scarletmansion" - copy "$(TargetPath)" "C:\Users\Jose Garcia\AppData\Roaming\r2modmanPlus-local\LethalCompany\profiles\SDM Debug\BepInEx\plugins\Alice-ScarletDevilMansion\$(TargetName).dll" + copy "$(TargetPath)" "C:\Users\Jose Garcia\AppData\Roaming\r2modmanPlus-local\LethalCompany\profiles\DunGenPlus\BepInEx\plugins\Alice-ScarletDevilMansion\$(TargetName).dll" copy "$(TargetPath)" "D:\Previous Computer\Desktop\LethalCompany Modding\NetcodePatcher\plugins\$(TargetName).dll" \ No newline at end of file diff --git a/ScarletMansion/ScarletMansion/Utility.cs b/ScarletMansion/ScarletMansion/Utility.cs index 341a52c..15a9322 100644 --- a/ScarletMansion/ScarletMansion/Utility.cs +++ b/ScarletMansion/ScarletMansion/Utility.cs @@ -142,6 +142,59 @@ namespace ScarletMansion { public static class Utility { + // https://stackoverflow.com/questions/930433/apply-properties-values-from-one-object-to-another-of-the-same-type-automaticall + /// + /// Extension for 'Object' that copies the properties to a destination object. + /// + /// The source. + /// The destination. + public static void CopyProperties(this object source, object destination, params string[] variableDenies) + { + // If any this null throw an exception + if (source == null || destination == null) + throw new Exception("Source or/and Destination Objects are null"); + // Getting the Types of the objects + Type typeDest = destination.GetType(); + Type typeSrc = source.GetType(); + + // Iterate the Properties of the source instance and + // populate them from their desination counterparts + PropertyInfo[] srcProps = typeSrc.GetProperties(); + foreach (PropertyInfo srcProp in srcProps) + { + if (!srcProp.CanRead) + { + continue; + } + PropertyInfo targetProperty = typeDest.GetProperty(srcProp.Name); + if (targetProperty == null) + { + continue; + } + if (!targetProperty.CanWrite) + { + continue; + } + if (variableDenies.Contains(targetProperty.Name)){ + continue; + } + if (targetProperty.GetSetMethod(true) != null && targetProperty.GetSetMethod(true).IsPrivate) + { + continue; + } + if ((targetProperty.GetSetMethod().Attributes & MethodAttributes.Static) != 0) + { + continue; + } + if (!targetProperty.PropertyType.IsAssignableFrom(srcProp.PropertyType)) + { + continue; + } + // Passed all tests, lets set the value + targetProperty.SetValue(destination, srcProp.GetValue(source, null), null); + } + } + public static float GetRandomNumber(this System.Random random, double minimum, double maximum) { return (float)(random.NextDouble() * (maximum - minimum) + minimum); } @@ -381,6 +434,51 @@ namespace ScarletMansion { } } + public static void ProcessLocalProps(DungeonGenerator dungeonGenerator, GameObject target){ + void g__GetHierarchyDepth(Transform transform, ref int depth) { + if (transform.parent != null) { + depth++; + g__GetHierarchyDepth(transform.parent, ref depth); + } + } + + RandomProp[] componentsInChildren = target.GetComponentsInChildren(); + List list = new List(); + foreach (RandomProp randomProp in componentsInChildren) + { + int hierarchyDepth = 0; + g__GetHierarchyDepth(randomProp.transform, ref hierarchyDepth); + list.Add(new DungeonGenerator.PropProcessingData + { + PropComponent = randomProp, + HierarchyDepth = hierarchyDepth, + OwningTile = randomProp.GetComponentInParent() + }); + } + list = (from x in list + orderby x.HierarchyDepth + select x).ToList(); + List list2 = new List(); + for (int j = 0; j < list.Count; j++) + { + DungeonGenerator.PropProcessingData propProcessingData = list[j]; + if (!(propProcessingData.PropComponent == null)) + { + list2.Clear(); + propProcessingData.PropComponent.Process(dungeonGenerator.RandomStream, propProcessingData.OwningTile, ref list2); + foreach (RandomProp propComponent in list2.SelectMany((GameObject x) => x.GetComponentsInChildren()).Distinct()) + { + list.Insert(j + 1, new DungeonGenerator.PropProcessingData + { + PropComponent = propComponent, + HierarchyDepth = propProcessingData.HierarchyDepth + 1, + OwningTile = propProcessingData.OwningTile + }); + } + } + } + } + /* public static GameObject GetParentWithNetworkObject(GameObject g){ diff --git a/SeichiPatch/ScarletMansionSeichiPatch/Plugin.cs b/SeichiPatch/ScarletMansionSeichiPatch/Plugin.cs index 1b2a942..3e58596 100644 --- a/SeichiPatch/ScarletMansionSeichiPatch/Plugin.cs +++ b/SeichiPatch/ScarletMansionSeichiPatch/Plugin.cs @@ -20,7 +20,7 @@ namespace ScarletMansionSeichiPatch { private const string modVersion = "1.0.0"; public const string targetModGUID = "dev.ladyalice.scarletmansion"; - public const string targetModVersion = "1.3.27"; + public const string targetModVersion = "2.3.3"; public readonly Harmony harmony = new Harmony(modGUID); public static Plugin Instance {get; private set;}