Decompiled source of SillyFalseSon v2.0.0

SillyFalseSon.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.FalseSon;
using HG.BlendableTypes;
using Microsoft.CodeAnalysis;
using On.EntityStates.FalseSon;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Skills;
using RoR2.UI;
using SillyFalseSon;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SillyFalseSon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fb5db6113e4843833d43a6940424b1b544b78664")]
[assembly: AssemblyProduct("SillyFalseSon")]
[assembly: AssemblyTitle("SillyFalseSon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
internal static class Configuration
{
	private static bool loadedIcon;

	public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, string description = "", bool restartRequired = false)
	{
		return BindAndOptions(section, name, defaultValue, 0f, 20f, description, restartRequired);
	}

	public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, float min, float max, string description = "", bool restartRequired = false)
	{
		if (string.IsNullOrEmpty(description))
		{
			description = name;
		}
		description += $"\nDefault: {defaultValue}";
		if (restartRequired)
		{
			description += " (restart required)";
		}
		ConfigEntry<T> val = ((BaseUnityPlugin)SillyFalseSonPlugin.instance).Config.Bind<T>(section, name, defaultValue, description);
		if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
		{
			TryRegisterOption<T>(val, min, max, restartRequired);
		}
		return val;
	}

	public static ConfigEntry<float> BindAndOptionsSlider(string section, string name, float defaultValue, string description, float min = 0f, float max = 20f, bool restartRequired = false)
	{
		return BindAndOptions(section, name, defaultValue, min, max, description, restartRequired);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	private static void TryRegisterOption<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0021: 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_0038: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Expected O, but got Unknown
		if (entry is ConfigEntry<float>)
		{
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry as ConfigEntry<float>, new SliderConfig
			{
				min = min,
				max = max,
				formatString = "{0:0.00}",
				restartRequired = restartRequired
			}));
		}
		if (entry is ConfigEntry<int>)
		{
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry as ConfigEntry<int>, new IntSliderConfig
			{
				min = (int)min,
				max = (int)max,
				restartRequired = restartRequired
			}));
		}
		if (entry is ConfigEntry<bool>)
		{
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry as ConfigEntry<bool>, restartRequired));
		}
		if (entry is ConfigEntry<KeyboardShortcut>)
		{
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry as ConfigEntry<KeyboardShortcut>, restartRequired));
		}
		if (!loadedIcon)
		{
			loadedIcon = true;
			try
			{
				ModSettingsManager.SetModIcon(LoadSpriteFromModFolder("icon.png"));
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("error adding ROO mod icon\n" + ex));
			}
		}
	}

	public static bool GetKeyPressed(ConfigEntry<KeyboardShortcut> entry)
	{
		//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)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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)
		KeyboardShortcut value = entry.Value;
		foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
		{
			if (!Input.GetKey(modifier))
			{
				return false;
			}
		}
		value = entry.Value;
		return Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey);
	}

	public static void ConfigureBody(CharacterBody bodyComponent, string section, string bodyInfoTitle = "")
	{
		if (string.IsNullOrEmpty(bodyInfoTitle))
		{
			bodyInfoTitle = ((Object)bodyComponent).name;
		}
		bodyComponent.baseMaxHealth = BindAndOptions(section, bodyInfoTitle + " Base Max Health", bodyComponent.baseMaxHealth, 0f, 1000f, "levelMaxHealth will be adjusted accordingly (baseMaxHealth * 0.3)", restartRequired: true).Value;
		bodyComponent.levelMaxHealth = Mathf.Round(bodyComponent.baseMaxHealth * 0.3f);
		bodyComponent.baseRegen = BindAndOptions(section, bodyInfoTitle + " Base Regen", bodyComponent.baseRegen, "levelRegen will be adjusted accordingly (baseRegen * 0.2)", restartRequired: true).Value;
		bodyComponent.levelRegen = bodyComponent.baseRegen * 0.2f;
		bodyComponent.baseArmor = BindAndOptions(section, bodyInfoTitle + " Armor", bodyComponent.baseArmor, "", restartRequired: true).Value;
		bodyComponent.baseDamage = BindAndOptions(section, bodyInfoTitle + " Base Damage", bodyComponent.baseDamage, "pretty much all survivors are 12. If you want to change damage, change damage of the moves instead.\nlevelDamage will be adjusted accordingly (baseDamage * 0.2)", restartRequired: true).Value;
		bodyComponent.levelDamage = bodyComponent.baseDamage * 0.2f;
		bodyComponent.baseJumpCount = BindAndOptions(section, bodyInfoTitle + " Jump Count", bodyComponent.baseJumpCount, "", restartRequired: true).Value;
	}

	public static void ConfigureSkillDef(SkillDef skillDef, string section, string skillTitle, bool cooldown = true, bool maxStock = true, bool rechargeStock = false)
	{
		if (cooldown)
		{
			skillDef.baseRechargeInterval = BindAndOptions(section, skillTitle + " cooldown", skillDef.baseRechargeInterval, 0f, 20f, "", restartRequired: true).Value;
		}
		if (maxStock)
		{
			skillDef.baseMaxStock = BindAndOptions(section, skillTitle + " stocks", skillDef.baseMaxStock, 0f, 100f, "", restartRequired: true).Value;
		}
		if (rechargeStock)
		{
			skillDef.rechargeStock = BindAndOptions(section, skillTitle + " recharge stocks", skillDef.baseMaxStock, 0f, 100f, "", restartRequired: true).Value;
		}
	}

	internal static Sprite LoadSpriteFromModFolder(string fileName, bool pointFilter = false)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)SillyFalseSonPlugin.instance).Info.Location), fileName);
		Texture2D val = new Texture2D(2, 2);
		byte[] array = File.ReadAllBytes(path);
		ImageConversion.LoadImage(val, array);
		((Texture)val).filterMode = (FilterMode)((!pointFilter) ? 1 : 0);
		val.Apply();
		if (pointFilter)
		{
			((Texture)val).filterMode = (FilterMode)0;
			val.Apply();
		}
		((Object)val).name = fileName;
		((Texture)val).filterMode = (FilterMode)0;
		val.Apply();
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height);
		Sprite val3 = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f), 16f);
		((Object)val3).name = fileName;
		return val3;
	}
}
namespace SillyFalseSon
{
	[BepInPlugin("com.TheTimeSweeper.SillyFalseSon", "Silly False Son", "2.0.0")]
	public class SillyFalseSonPlugin : BaseUnityPlugin
	{
		private const string configSection = "hi";

		private ConfigEntry<float> cfg_funnySize;

		private ConfigEntry<float> cfg_displaySizeMulti;

		private ConfigEntry<float> cfg_hitboxSize;

		private ConfigEntry<float> cfg_cameraBack;

		private ConfigEntry<float> cfg_cameraHigh;

		private ConfigEntry<bool> cfg_dashOnBody;

		private ConfigEntry<int> cfg_extraStockDisplays;

		private ConfigEntry<bool> cfg_slamMovementTweaks;

		internal static SillyFalseSonPlugin instance;

		private float _originalClubGroundSlamMinimumDuration;

		private void Awake()
		{
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			instance = this;
			cfg_funnySize = Configuration.BindAndOptions("hi", "In-game size", 1.12f, "go nuts", restartRequired: true);
			cfg_displaySizeMulti = Configuration.BindAndOptions("hi", "CSS size multiplier", 1f, "vanilla is 0.7 * his in-game size, which is why I thought he was small and made this mod but he's actually kinda big. keeping the big funny size anyways lol", restartRequired: true);
			cfg_hitboxSize = Configuration.BindAndOptions("hi", "hitbox size", 9f, "relative to size. if you make him really small you should crank this up. swing effects will not be affected cause I can't be arsed", restartRequired: true);
			cfg_cameraBack = Configuration.BindAndOptions("hi", "camera back", 13f, "how far back the camera is pulled dout. default false son is 13. pull it back or forward if you're making him larger or smaller respectively", restartRequired: true);
			cfg_cameraHigh = Configuration.BindAndOptions("hi", "camera high", 1f, "how far higher the camera is raised. I forget what default is.", restartRequired: true);
			cfg_dashOnBody = Configuration.BindAndOptions("hi", "dash while attacking", defaultValue: true, "puts dash on the body state machine. allowing you to dash while using other abilities", restartRequired: true);
			cfg_extraStockDisplays = Configuration.BindAndOptions("hi", "Extra Stock Displays", 20, 0f, 100f, "added stock displays to crosshair for secondary stocks. if it's not a multiple of 4 you're a felon", restartRequired: true);
			cfg_slamMovementTweaks = Configuration.BindAndOptions("hi", "Slam movement Tweaks", defaultValue: true, "jump arc of the m1+m2 changes:\ninstantly activate when landing on the ground consistently\ninitial jump arc adjusted\nninitial jump arc no longer affected by attack speed", restartRequired: true);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
			if (cfg_slamMovementTweaks.Value)
			{
				ClubGroundSlam.OnEnter += new hook_OnEnter(ClubGroundSlam_OnEnter);
				ClubGroundSlam.OnExit += new hook_OnExit(ClubGroundSlam_OnExit);
				PreClubGroundSlam.OnEnter += new hook_OnEnter(PreClubGroundSlam_OnEnter);
				PreClubGroundSlam.FixedUpdate += new hook_FixedUpdate(PreClubGroundSlam_FixedUpdate);
			}
		}

		private void PreClubGroundSlam_OnEnter(orig_OnEnter orig, PreClubGroundSlam self)
		{
			PreClubGroundSlam.upwardVelocity = 22f;
			((BaseUnityPlugin)this).Logger.LogWarning((object)PreClubGroundSlam.baseDuration);
			orig.Invoke(self);
			self.duration = 0.3f;
		}

		private void PreClubGroundSlam_FixedUpdate(orig_FixedUpdate orig, PreClubGroundSlam self)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			((EntityState)self).characterMotor.velocity.y += Physics.gravity.y * 2.5f * Time.deltaTime;
		}

		private void ClubGroundSlam_OnEnter(orig_OnEnter orig, ClubGroundSlam self)
		{
			_originalClubGroundSlamMinimumDuration = ClubGroundSlam.minimumDuration;
			if (!((EntityState)self).characterMotor.isGrounded)
			{
				ClubGroundSlam.minimumDuration = 0f;
			}
			orig.Invoke(self);
		}

		private void ClubGroundSlam_OnExit(orig_OnExit orig, ClubGroundSlam self)
		{
			orig.Invoke(self);
			ClubGroundSlam.minimumDuration = _originalClubGroundSlamMinimumDuration;
		}

		private void OnLoad()
		{
			DoEverything();
		}

		private void DoEverything()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody component = BodyCatalog.FindBodyPrefab("FalseSonBody").GetComponent<CharacterBody>();
			Transform transform = ((Component)((Component)component).GetComponentInChildren<CharacterModel>()).transform;
			transform.localScale = Vector3.one * cfg_funnySize.Value;
			transform.Find("ClubHitBox").localScale = new Vector3(1f, 1.1f, 1f) * cfg_hitboxSize.Value;
			transform.Find("ClubHitBox").localPosition = new Vector3(0f, 2f, 3f);
			SurvivorCatalog.FindSurvivorDefFromBody(((Component)component).gameObject).displayPrefab.transform.GetChild(0).localScale = Vector3.one * cfg_funnySize.Value * cfg_displaySizeMulti.Value;
			CharacterCameraParams cameraParams = ((Component)component).GetComponent<CameraTargetParams>().cameraParams;
			cameraParams.data.idealLocalCameraPos = BlendableVector3.op_Implicit(new Vector3(0f, cfg_cameraHigh.Value, 0f - cfg_cameraBack.Value));
			cameraParams.data.pivotVerticalOffset = BlendableFloat.op_Implicit(1f);
			EntityState obj = EntityStateCatalog.InstantiateState(typeof(ClubSwing));
			ClubSwing val = (ClubSwing)(object)((obj is ClubSwing) ? obj : null);
			GameObject swingEffectPrefab = ((BasicMeleeAttack)val).swingEffectPrefab;
			swingEffectPrefab.transform.GetChild(0).localScale = Vector3.one * 0.8f;
			swingEffectPrefab.transform.GetChild(0).localPosition = new Vector3(0f, 0f, -2.5f);
			swingEffectPrefab = ClubSwing.secondarySwingEffectPrefab;
			swingEffectPrefab.transform.GetChild(0).localScale = Vector3.one * 0.8f;
			swingEffectPrefab.transform.GetChild(0).localPosition = new Vector3(0f, 1f, -2.5f);
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/FalseSon/FalseSonGroundSlam.prefab").WaitForCompletion();
			val2.transform.Find("Debris/Spikes, Small").localScale = new Vector3(3.5f, 3.5f, 2f);
			val2.transform.Find("Debris/Particle System").localScale = new Vector3(2f, 2f, 2f);
			val2.GetComponent<DestroyOnTimer>().duration = 2f;
			if (cfg_dashOnBody.Value)
			{
				((Component)component).GetComponents<GenericSkill>().First((GenericSkill skill) => skill.skillName == "StepBrothers").skillFamily.variants[0].skillDef.activationStateMachineName = "Body";
			}
			AddStockStoCrosshair(component);
		}

		private void AddStockStoCrosshair(CharacterBody funnyGuy)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			if (cfg_extraStockDisplays.Value > 0)
			{
				Transform transform = PrefabAPI.InstantiateClone(funnyGuy.defaultCrosshairPrefab, ((Object)funnyGuy.defaultCrosshairPrefab).name, false).transform;
				CrosshairController component = ((Component)transform).GetComponent<CrosshairController>();
				SkillStockSpriteDisplay val = component.skillStockSpriteDisplays[0];
				Queue<Transform> queue = new Queue<Transform>();
				queue.Enqueue(transform.Find("Holder/TR/TRFill"));
				queue.Enqueue(transform.Find("Holder/BR/BRFill"));
				queue.Enqueue(transform.Find("Holder/BL/BLFill"));
				queue.Enqueue(transform.Find("Holder/TL/TLFill"));
				List<SkillStockSpriteDisplay> list = new List<SkillStockSpriteDisplay>();
				list.AddRange(component.skillStockSpriteDisplays);
				for (int i = 0; i < cfg_extraStockDisplays.Value; i++)
				{
					Transform val2 = queue.Dequeue();
					Transform transform2 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val2.parent).transform;
					transform2.localPosition = new Vector3(0f, val2.localPosition.y + 20f, 0f);
					list.Add(new SkillStockSpriteDisplay
					{
						target = ((Component)transform2).gameObject,
						skillSlot = val.skillSlot,
						requiredSkillDef = val.requiredSkillDef
					});
					queue.Enqueue(transform2);
				}
				for (int j = 0; j < list.Count; j++)
				{
					SkillStockSpriteDisplay value = list[j];
					value.minimumStockCountToBeValid = j + 1;
					value.maximumStockCountToBeValid = 100;
					list[j] = value;
				}
				component.skillStockSpriteDisplays = list.ToArray();
				funnyGuy._defaultCrosshairPrefab = ((Component)transform).gameObject;
			}
		}
	}
}