Added Yukari pit hallway tile

Changed generation to use dungeonflow nodes
Made map smaller
Updated mimics patch to not be dumb
This commit is contained in:
LadyAliceMargatroid 2024-05-01 03:51:41 -07:00
parent cdadd75ee9
commit 6613191d7e
14 changed files with 223 additions and 84 deletions

View File

@ -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<TileProxy>();
newMainPathTiles.Add(mainTile);
var nodes = gen.DungeonFlow.Nodes.Skip(2);
var nodesVisited = new List<GraphNode>(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<TileSet> 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");

View File

@ -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<PlayerControllerB>();
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<PlayerControllerB>();
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);
}
}
}

View File

@ -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);
}

View File

@ -29,5 +29,6 @@ namespace ScarletMansion {
//public GameObject mainMenuPrefab;
[Header("Main Prefabs")]
public GameObject scarletNetworkManager;
public AudioClip sinkingAudioClip;
}
}

View File

@ -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);
}
}
}

View File

@ -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();

View File

@ -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);

View File

@ -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<int> hallwayLightsWeight = new ConfigEntryBundle<int>(
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<int>(0, 999)
);
@ -389,8 +389,8 @@ namespace ScarletMansion {
public static ConfigEntryBundle<int> ceilingLightsWeight = new ConfigEntryBundle<int>(
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<int>(0, 999)
);

View File

@ -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 )

View File

@ -184,6 +184,7 @@
<Compile Include="GamePatch\Components\ScarletPlayerControllerB.cs" />
<Compile Include="GamePatch\Components\ScarletProp.cs" />
<Compile Include="GamePatch\Components\ScarletVent.cs" />
<Compile Include="GamePatch\Components\ScarletYukariTrigger.cs" />
<Compile Include="GamePatch\DoorLockPatch.cs" />
<Compile Include="GamePatch\Enemies\KnightVariant.cs" />
<Compile Include="GamePatch\EnemyVentPatch.cs" />
@ -228,7 +229,6 @@
<Compile Include="ModPatch\AdvancedCompanyPatch.cs" />
<Compile Include="ModPatch\FacilityMeltdownPatch.cs" />
<Compile Include="ModPatch\LethalConfigPatch.cs" />
<Compile Include="ModPatch\MimicsPatch.cs" />
<Compile Include="ModPatch\ModCompability.cs" />
<Compile Include="ModPatch\ModPatch.cs" />
<Compile Include="ModPatch\ReservedItemSlotPatch.cs" />

View File

@ -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<SpawnableItemWithRarity> GetDungeonItems(){
return LoadAssetsIntoLevelPatch.GetItems(RoundManager.Instance.currentLevel.spawnableScrap);
}

View File

@ -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<DunGenPatch.Doorways.DoorwayCleanup>();
var c = doorway.transform.parent.GetComponentInChildren<ScarletMansion.DunGenPatch.Doorways.DoorwayCleanup>();
if (c != null) {
c.overrideConnector = true;
c.overrideNoDoorway = true;
@ -42,9 +45,9 @@ namespace ScarletMansion.ModPatch {
var fixfireexit = doorway.GetComponentInChildren<FixFireExit>(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);

View File

@ -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();
}
}
}
}

View File

@ -63,6 +63,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Patch.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />