Decompiled source of MoreMannequins v0.0.0

RoR2IncreaseMannequinCount.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx.Logging;
using InLobbyConfig;
using InLobbyConfig.Fields;
using Microsoft.CodeAnalysis;
using On.RoR2.SurvivorMannequins;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2.SurvivorMannequins;
using UnityEngine;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("RoR2IncreaseMannequinCount")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod for Risk of Rain 2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+524fe8ad2a6cee93d545ee752cb2840268af6ca2")]
[assembly: AssemblyProduct("RoR2IncreaseMannequinCount")]
[assembly: AssemblyTitle("RoR2IncreaseMannequinCount")]
[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;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace RoR2IncreaseMannequinCount
{
	internal class ModCompat
	{
		public static void Init()
		{
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				RiskOfOptionsCompat();
			}
			if (Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.InLobbyConfig"))
			{
				InLobbyConfigCompat();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void RiskOfOptionsCompat()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_002a: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Increases amount of character displays in lobby.");
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(Plugin.cfgMannequinCount, new IntSliderConfig
			{
				min = 0,
				max = 100
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(Plugin.cfgXOffset, new SliderConfig
			{
				min = 0f,
				max = 6f
			}));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void InLobbyConfigCompat()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			ModConfigEntry val = new ModConfigEntry();
			val.DisplayName = "More Mannequins";
			val.SectionFields.Add("Config", new List<IConfigField> { (IConfigField)new FloatConfigField(((ConfigEntryBase)Plugin.cfgXOffset).Definition.Key, (Func<float>)(() => Plugin.cfgXOffset.Value), (Action<float>)Hook_MannequinOffsetChanged, (Action<float>)null, (float?)null, (float?)null) });
			ModConfigCatalog.Add(val);
		}

		private static void Hook_MannequinOffsetChanged(float newValue)
		{
			Plugin.cfgXOffset.Value = newValue;
			Plugin.UpdateMannequinOffsets();
		}
	}
	[BepInPlugin("com.DestroyedClone.MoreMannequins", "More Mannequins", "0.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<int> cfgMannequinCount;

		public static ConfigEntry<float> cfgXOffset;

		public static SurvivorMannequinDioramaController controllerInstance;

		internal static ManualLogSource _logger;

		internal static ConfigFile _config;

		public void Awake()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			_logger = ((BaseUnityPlugin)this).Logger;
			_config = ((BaseUnityPlugin)this).Config;
			cfgMannequinCount = ((BaseUnityPlugin)this).Config.Bind<int>("", "Mannequin Count", 20, "The amount of extra mannequin slots to add on top of the existing amount. Needs to be set outside of lobby.");
			cfgMannequinCount.SettingChanged += CfgMannequinCount_SettingChanged;
			cfgXOffset = ((BaseUnityPlugin)this).Config.Bind<float>("", "X Offset", 3f, "X transform offset for each mannequin.");
			cfgXOffset.SettingChanged += CfgXOffset_SettingChanged;
			SurvivorMannequinDioramaController.OnEnable += new hook_OnEnable(SurvivorMannequinDioramaController_OnEnable);
			ModCompat.Init();
		}

		private static void CfgMannequinCount_SettingChanged(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)controllerInstance))
			{
				_logger.LogMessage((object)"CfgMannequinCount_SettingChanged : Will be activated outside of the lobby.");
			}
		}

		private static void CfgXOffset_SettingChanged(object sender, EventArgs e)
		{
			UpdateMannequinOffsets();
		}

		public static void UpdateMannequinOffsets(List<SurvivorMannequinSlotController> slots = null)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (slots == null)
			{
				slots = new List<SurvivorMannequinSlotController>();
				controllerInstance.GetSlots(slots);
			}
			Vector3 val = default(Vector3);
			for (int i = 0; i < slots.Count; i++)
			{
				((Vector3)(ref val))..ctor(cfgXOffset.Value * (float)i, 0f, 0f);
				((Component)slots[i]).transform.localPosition = val;
				_logger.LogMessage((object)$"Moving {((Object)slots[i]).name} {i} to {val.x}");
			}
		}

		private static void SurvivorMannequinDioramaController_OnEnable(orig_OnEnable orig, SurvivorMannequinDioramaController self)
		{
			orig.Invoke(self);
			controllerInstance = self;
			List<SurvivorMannequinSlotController> slots = new List<SurvivorMannequinSlotController>();
			self.GetSlots(slots);
			SurvivorMannequinSlotController referenceSlot = slots[0];
			for (int i = 0; i < cfgMannequinCount.Value; i++)
			{
				CopySlot();
			}
			UpdateMannequinOffsets(slots);
			self.SetSlots(slots.ToArray());
			SurvivorMannequinSlotController CopySlot()
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = Object.Instantiate<GameObject>(((Component)referenceSlot).gameObject);
				((Object)val).name = $"ExtraMannequin{slots.Count + 1}";
				val.transform.SetParent(((Component)referenceSlot).transform.parent);
				val.transform.rotation = ((Component)referenceSlot).transform.rotation;
				SurvivorMannequinSlotController component = val.GetComponent<SurvivorMannequinSlotController>();
				slots.Add(component);
				return component;
			}
		}
	}
}