2024-04-28 21:41:33 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using BepInEx;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using Mimics;
|
|
|
|
|
using Mimics.API;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Reflection.Emit;
|
|
|
|
|
using DunGen;
|
|
|
|
|
using ScarletMansion.GamePatch.FixValues;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
using GameNetcodeStuff;
|
2024-05-01 10:51:41 +00:00
|
|
|
|
using ScarletMansion;
|
2024-04-28 21:41:33 +00:00
|
|
|
|
using ScarletMansion.GamePatch.Components;
|
2024-05-01 10:51:41 +00:00
|
|
|
|
using ScarletMansion.DunGenPatch;
|
2024-04-28 21:41:33 +00:00
|
|
|
|
|
2024-05-01 10:51:41 +00:00
|
|
|
|
namespace ScarletMansionMimicsPatch {
|
2024-04-28 21:41:33 +00:00
|
|
|
|
|
|
|
|
|
public class Patch {
|
2024-05-01 10:51:41 +00:00
|
|
|
|
|
|
|
|
|
public static void Activate() {
|
|
|
|
|
MimicsAPI.GetAPI().RegisterMimicEventHandler(new Patch.SDMMimicEventHandler());
|
2024-04-28 21:41:33 +00:00
|
|
|
|
Plugin.Instance.harmony.PatchAll(typeof(Patch));
|
|
|
|
|
}
|
2024-05-01 10:51:41 +00:00
|
|
|
|
|
2024-04-28 21:41:33 +00:00
|
|
|
|
public class SDMMimicEventHandler : MimicEventHandler
|
|
|
|
|
{
|
2024-05-01 10:51:41 +00:00
|
|
|
|
|
2024-04-28 21:41:33 +00:00
|
|
|
|
public override string ModGUID => Plugin.modGUID;
|
|
|
|
|
|
2024-05-01 10:51:41 +00:00
|
|
|
|
public override bool IsMyInteriorLoaded => ScarletMansion.DunGenPatch.Patch.active;
|
2024-04-28 21:41:33 +00:00
|
|
|
|
|
|
|
|
|
public override void OnMimicCreated(MimicDoor mimicDoor, Doorway doorway) {
|
2024-08-02 15:56:09 +00:00
|
|
|
|
var c = doorway.transform.parent.GetComponentInChildren<DunGenPlus.Components.DoorwayCleanup>();
|
2024-04-28 21:41:33 +00:00
|
|
|
|
if (c != null) {
|
|
|
|
|
c.overrideConnector = true;
|
|
|
|
|
c.overrideNoDoorway = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fixfireexit = doorway.GetComponentInChildren<FixFireExit>(true);
|
|
|
|
|
fixfireexit.ForcefullyEnableDoorway();
|
|
|
|
|
|
2024-05-01 10:51:41 +00:00
|
|
|
|
var mimicDoorMesh = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "DoorMesh");
|
|
|
|
|
var mimicFrame = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "Frame");
|
|
|
|
|
var mimicLight = ScarletMansion.Utility.FindChildRecurvisely(mimicDoor.transform, "Light");
|
2024-04-28 21:41:33 +00:00
|
|
|
|
|
|
|
|
|
if (fixfireexit.EnableVanillaFireExit){
|
|
|
|
|
FixDoorwayForVanillaFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight);
|
|
|
|
|
} else {
|
|
|
|
|
FixDoorwayForSDMFireExit(fixfireexit, mimicDoorMesh, mimicFrame, mimicLight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Plugin.logger.LogInfo("Fixed a doorway for a mimic");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnMimicAttackStart(MimicDoor mimicDoor, PlayerControllerB playerToAttack) {
|
|
|
|
|
var doorway = mimicDoor.GetComponentInParent<Doorway>();
|
|
|
|
|
var fireexit = doorway.GetComponentInChildren<ScarletFireExit>();
|
|
|
|
|
fireexit?.DisableEnablePortal();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static bool colorBlindModeLastValue;
|
|
|
|
|
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch("Mimics.Mimics+RoundManagerPatch, Mimics", "SetExitIDsPatch")]
|
|
|
|
|
public static void SetExitIDsPatchPrefix(){
|
|
|
|
|
colorBlindModeLastValue = Mimics.Mimics.ColorBlindMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPostfix]
|
|
|
|
|
[HarmonyPatch("Mimics.Mimics+RoundManagerPatch, Mimics", "SetExitIDsPatch")]
|
|
|
|
|
public static void SetExitIDsPatchPostfix(){
|
|
|
|
|
Mimics.Mimics.ColorBlindMode = colorBlindModeLastValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void FixDoorwayForVanillaFireExit(FixFireExit fixFireExit, Transform mimicDoorMesh, Transform mimicFrame, Transform mimicLight){
|
|
|
|
|
if (mimicDoorMesh != null) {
|
|
|
|
|
mimicDoorMesh.localPosition = new Vector3(-0.07f, 0f, 0.06f);
|
|
|
|
|
var sc = mimicDoorMesh.localScale;
|
|
|
|
|
sc.y = -0.0002f;
|
|
|
|
|
sc.z = -0.000161f;
|
|
|
|
|
mimicDoorMesh.localScale = sc;
|
|
|
|
|
} else {
|
|
|
|
|
Plugin.logger.LogWarning("Could not find DoorMesh in mimic gameobject. It will look weird but nothing should break");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mimicFrame != null) {
|
|
|
|
|
mimicFrame.localPosition = new Vector3(0f, -0.02f, 0.07f);
|
|
|
|
|
mimicFrame.localScale = new Vector3(1.08f, 1.008f, 1.02f);
|
|
|
|
|
} else {
|
|
|
|
|
Plugin.logger.LogWarning("Could not find Frame in mimic gameobject. It will look weird but nothing should break");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void FixDoorwayForSDMFireExit(FixFireExit fixFireExit, Transform mimicDoorMesh, Transform mimicFrame, Transform mimicLight){
|
|
|
|
|
Mimics.Mimics.ColorBlindMode = true;
|
|
|
|
|
fixFireExit.ForcefullyEnableSDMRender();
|
|
|
|
|
fixFireExit.sdmFireExit.enablePortalAnimation = true;
|
|
|
|
|
|
|
|
|
|
if (mimicDoorMesh != null) mimicDoorMesh.gameObject.SetActive(false);
|
|
|
|
|
else Plugin.logger.LogWarning("Could not find DoorMesh in mimic gameobject. It will look weird but nothing should break");
|
|
|
|
|
|
|
|
|
|
if (mimicFrame != null) mimicFrame.gameObject.SetActive(false);
|
|
|
|
|
else Plugin.logger.LogWarning("Could not find Frame in mimic gameobject. It will look weird but nothing should break");
|
|
|
|
|
|
|
|
|
|
if (mimicLight != null) mimicLight.gameObject.SetActive(false);
|
|
|
|
|
else Plugin.logger.LogWarning("Could not find Light in mimic gameobject. It will look weird but nothing should break");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|