Decompiled source of SwampMiniboss v1.0.2

SwampMiniboss.dll

Decompiled 2 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using EntityStates;
using EntityStates.Destructible;
using On.EntityStates.Destructible;
using On.RoR2;
using On.RoR2.UI.MainMenu;
using RoR2;
using RoR2.UI.MainMenu;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("SwampMiniboss")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SwampMiniboss")]
[assembly: AssemblyTitle("SwampMiniboss")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SwampMiniboss;

[BepInPlugin("com.rob.SwampMiniboss", "SwampMiniboss", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
	public const string MODUID = "com.rob.SwampMiniboss";

	public static Vector3 spawnPoint = new Vector3(36f, -148f, -191f);

	public static bool hasInit = false;

	private void Awake()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		BaseMainMenuScreen.Awake += new hook_Awake(BaseMainMenuScreen_Awake);
		SceneManager.sceneLoaded += SceneManager_sceneLoaded;
		AltarSkeletonDeath.Explode += new hook_Explode(AltarSkeletonDeath_Explode);
		CharacterBody.OnDeathStart += new hook_OnDeathStart(CharacterBody_OnDeathStart);
	}

	private void BaseMainMenuScreen_Awake(orig_Awake orig, BaseMainMenuScreen self)
	{
		if (!hasInit)
		{
			hasInit = true;
			AddBeetleDisplayRule();
		}
		orig.Invoke(self);
	}

	private void CharacterBody_OnDeathStart(orig_OnDeathStart orig, CharacterBody self)
	{
		SwampBossHandler component = ((Component)self).GetComponent<SwampBossHandler>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.TrySpawnPickup();
		}
		orig.Invoke(self);
	}

	public static void AddBeetleDisplayRule()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		ItemDisplayRuleSet val = Addressables.LoadAssetAsync<ItemDisplayRuleSet>((object)"RoR2/Base/Beetle/idrsBeetleGuard.asset").WaitForCompletion();
		List<KeyAssetRuleGroup> list = val.keyAssetRuleGroups.ToList();
		GameObject followerPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/NovaOnHeal/DisplayDevilHorns.prefab").WaitForCompletion();
		list.Add(new KeyAssetRuleGroup
		{
			keyAsset = (Object)(object)Items.NovaOnHeal,
			displayRuleGroup = new DisplayRuleGroup
			{
				rules = (ItemDisplayRule[])(object)new ItemDisplayRule[1]
				{
					new ItemDisplayRule
					{
						ruleType = (ItemDisplayRuleType)0,
						followerPrefab = followerPrefab,
						limbMask = (LimbFlags)0,
						childName = "Head",
						localPos = new Vector3(-0.06254f, 0.60391f, -0.66027f),
						localAngles = new Vector3(357.0576f, 201.3958f, 263.8221f),
						localScale = new Vector3(0.60461f, 0.69721f, 0.60435f)
					}
				}
			}
		});
		val.keyAssetRuleGroups = list.ToArray();
	}

	public static void SpawnBoss()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active)
		{
			return;
		}
		MasterSummon val = new MasterSummon();
		val.position = spawnPoint;
		val.masterPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Beetle/BeetleGuardMaster.prefab").WaitForCompletion();
		val.summonerBodyObject = null;
		val.teamIndexOverride = (TeamIndex)2;
		val.ignoreTeamMemberLimit = true;
		CharacterMaster val2 = val.Perform();
		if (Object.op_Implicit((Object)(object)val2))
		{
			Inventory component = ((Component)val2).GetComponent<Inventory>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.SetEquipmentIndex(Equipment.AffixPoison.equipmentIndex);
				component.GiveItem(Items.NovaOnHeal, 1);
				component.GiveItem(Items.UseAmbientLevel, 1);
			}
			val2.onBodyStart += Master_onBodyStart;
		}
		Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
		{
			baseToken = "<style=cWorldEvent>A horrible chill goes down your spine..</style>"
		});
	}

	private static void Master_onBodyStart(CharacterBody characterBody)
	{
		if (Object.op_Implicit((Object)(object)characterBody))
		{
			((Component)characterBody).gameObject.AddComponent<SwampBossHandler>();
		}
	}

	private void AltarSkeletonDeath_Explode(orig_Explode orig, AltarSkeletonDeath self)
	{
		SpawnBoss();
		orig.Invoke(self);
	}

	private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene = SceneManager.GetActiveScene();
		string name = ((Scene)(ref activeScene)).name;
		if (name == "foggyswamp")
		{
			GameObject gameObject = ((Component)GameObject.Find("HOLDER: Hidden Altar Stuff").transform.Find("AltarCenter").GetChild(0)).gameObject;
			if (Object.op_Implicit((Object)(object)gameObject))
			{
				Object.Destroy((Object)(object)gameObject.GetComponent<GameObjectUnlockableFilter>());
				gameObject.SetActive(true);
			}
		}
	}
}
public class SwampBossHandler : MonoBehaviour
{
	private CharacterBody characterBody;

	private bool hasEquippedHeal;

	private bool hasDroppedItem;

	private void Awake()
	{
		characterBody = ((Component)this).GetComponent<CharacterBody>();
	}

	private void Start()
	{
		characterBody.isElite = true;
		CharacterBody obj = characterBody;
		obj.baseMaxHealth *= 8f;
		CharacterBody obj2 = characterBody;
		obj2.baseDamage *= 4f;
		characterBody.baseNameToken = "N'kuhana's Devotee";
		hasEquippedHeal = false;
	}

	private void FixedUpdate()
	{
		if (!hasEquippedHeal && Object.op_Implicit((Object)(object)characterBody) && Object.op_Implicit((Object)(object)characterBody.healthComponent) && characterBody.healthComponent.combinedHealth <= characterBody.healthComponent.fullCombinedHealth * 0.5f)
		{
			hasEquippedHeal = true;
		}
	}

	public void TrySpawnPickup()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		if (!hasDroppedItem && NetworkServer.active)
		{
			hasDroppedItem = true;
			PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(Items.NovaOnHeal.itemIndex), characterBody.corePosition + Vector3.up * 0.25f, Vector3.up * 10f);
		}
	}
}
public class UseHeal : BaseSkillState
{
	private float duration = 1.8f;

	private bool hasHealed = false;

	public override void OnEnter()
	{
		((BaseState)this).OnEnter();
	}

	public override void FixedUpdate()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).fixedAge >= duration * 0.5f && !hasHealed)
		{
			hasHealed = true;
			if (NetworkServer.active)
			{
				((EntityState)this).healthComponent.HealFraction(0.5f, default(ProcChainMask));
			}
		}
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		return (InterruptPriority)3;
	}
}