Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using UnityEngine;
- using BepInEx;
- using HarmonyLib;
- using Mimics.API;
- using System.Reflection;
- using System.Reflection.Emit;
- using DunGen;
- using ScarletMansion.GamePatch.FixValues;
- using UnityEngine.Events;
- using GameNetcodeStuff;
- using Mimics;
- using ScarletMansion.GamePatch.Components;
- namespace ScarletMansion.ModPatch {
- public class MimicsPatch : ModPatch {
- public MimicsPatch(string guid) : base(guid) { }
- public override void AddPatch() {
- MimicsAPI.GetAPI().RegisterMimicEventHandler(new SDMMimicEventHandler());
- Plugin.Instance.harmony.PatchAll(typeof(MimicsPatch));
- }
- public class SDMMimicEventHandler : MimicEventHandler
- {
- public override string ModGUID => Plugin.modGUID;
- public override bool IsMyInteriorLoaded => DunGenPatch.Patch.active;
- public override void OnMimicCreated(MimicDoor mimicDoor, Doorway doorway) {
- var c = doorway.transform.parent.GetComponentInChildren<DunGenPatch.Doorways.DoorwayCleanup>();
- if (c != null) {
- c.overrideConnector = true;
- c.overrideNoDoorway = true;
- }
- 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");
- 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");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment