Decompiled source of Immortal Architect v1.1.3

HKImmortalArchitect/HKImmortalArchitectMod.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("HkImmortalArchitectMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HkImmortalArchitectMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("776946f5-27d7-4cb3-bce9-308f627b8644")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ImmortalArchitect;

[BepInPlugin("com.cjmorgan.hkimmortalarchitectmod", "Immortal Architect", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static readonly string ArchitectLine1 = "I have exhausted my supply of wares to sell, My s-s-service to you, Bug-Red... As it concludes I must speak-confess. I have felt my rotors slow their s-s-spin. My limbs weaker. I-I do not know how long I can hold-sustain this.<hpage>Whatever fading you feel has not shown in your craft, Master. You have provided tools of immaculate make.<hpage>What will follow if you pass? Would another take your place?<page>One cannot. The skill to construct an Architect... That was taken by t-t-time. I am the last-final. The core remains to sustain the song, but no more Architects to tend-toil or build anew.<page> For now, I-I continue my work as always.";

	internal static readonly string ArchitectLifebloodWarning = "Bug-red... th-that glow upon you... l-lifeblood.<page>It s-seems boon, but is malicious-p-poisoned gift.<page>It does not s-serve you... only itself.<page>Contain-W-wear it with care. Its whispers-lies do not end.";

	internal static readonly string ArchitectCurseWarning = "Bug-red... th-that parasite... twisted leech within shell.<page>Its intent-motive corrupt, it s-seeks your undoing.<page>Remediate immediately. I-I wish not for your frame to fall to it.<hpage>Understood, master... I am looking diligently for a way to get rid of it.<page>Good. Contain, purge, do not let it fuse. M-My systems record... vigilance active.";

	internal static readonly string ArchitectAct3Greeting = "Bug-Red... the ground shifts... tremors detected throughout the underworks.<page>Structures stress-tested. No collapse in my sector. Core integrity sustained heavy damage.<page>Bug-red What did you do?<hpage>Yes master, I am trying to set this right<page>Noted, Bug-red, I-I will remain here as I must.";

	private void Awake()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"Immortal Architect loaded – Architect will never leave.");
		ForceArchitectFlags();
		SceneManager.sceneLoaded += delegate
		{
			ForceArchitectFlags();
		};
		Harmony val = new Harmony("com.cjmorgan.hkimmortalarchitectmod");
		val.PatchAll();
	}

	private void ForceArchitectFlags()
	{
		if (PlayerData.instance != null)
		{
			PlayerData.instance.ArchitectWillLeave = false;
			PlayerData.instance.ArchitectLeft = false;
			PlayerData.instance.SeenArchitectLeft = false;
			if (!PlayerData.instance.GetBool("ArchitectTalkedLifeblood"))
			{
				PlayerData.instance.SetBool("ArchitectTalkedLifeblood", false);
			}
			if (!PlayerData.instance.GetBool("ArchitectTalkedCurse"))
			{
				PlayerData.instance.SetBool("ArchitectTalkedCurse", false);
			}
			Log.LogInfo((object)"[ForceArchitectFlags] Architect flags set to false.");
		}
	}
}
[HarmonyPatch(typeof(DialogueBox), "StartConversation", new Type[]
{
	typeof(string),
	typeof(NPCControlBase),
	typeof(bool),
	typeof(DisplayOptions),
	typeof(Action),
	typeof(Action)
})]
internal static class DialogueBoxOverridePatch
{
	private static void Prefix(ref string text, NPCControlBase instigator, bool overrideContinue, DisplayOptions displayOptions, Action onDialogueEnd, Action onDialogueCancelled)
	{
		string text2 = (((Object)(object)instigator != (Object)null) ? ((Object)instigator).name : "NULL");
		if (text2.Contains("Architect") && PlayerData.instance != null)
		{
			if (PlayerData.instance.gainedCurse && !PlayerData.instance.GetBool("ArchitectTalkedCurse"))
			{
				text = Plugin.ArchitectCurseWarning;
				PlayerData.instance.SetBool("ArchitectTalkedCurse", true);
				Plugin.Log.LogInfo((object)"[DialogueBox] Architect curse warning triggered.");
			}
			else if (PlayerData.instance.healthBlue > 1 && !PlayerData.instance.GetBool("ArchitectTalkedLifeblood"))
			{
				text = Plugin.ArchitectLifebloodWarning;
				PlayerData.instance.SetBool("ArchitectTalkedLifeblood", true);
				Plugin.Log.LogInfo((object)"[DialogueBox] Architect lifeblood warning triggered.");
			}
			else if (PlayerData.instance.GetBool("act3_wokeUp") && !PlayerData.instance.GetBool("MetArchitectAct3"))
			{
				text = Plugin.ArchitectAct3Greeting;
				PlayerData.instance.SetBool("MetArchitectAct3", true);
				Plugin.Log.LogInfo((object)"[DialogueBox] Architect Act 3 greeting triggered.");
			}
			else if (text.Contains("My s-s-service to you"))
			{
				text = Plugin.ArchitectLine1;
			}
		}
	}
}