Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ConfigurablePerPlayerScaling v1.0.0
plugins/ConfigurablePerPlayerScaling.dll
Decompiled 7 months agousing System; using System.Collections; 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.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using MiscFixes.Modules; using Mono.Cecil.Cil; using MonoDetour; using MonoDetour.Cil; using MonoDetour.DetourTypes; using MonoDetour.HookGen; using MonoDetourHooks.RoR2.Run; using MonoMod.Cil; using RoR2; [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("ConfigurablePerPlayerScaling")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ConfigurablePerPlayerScaling")] [assembly: AssemblyTitle("ConfigurablePerPlayerScaling")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MonoDetourHooks.RoR2.Run { internal static class RecalculateDifficultyCoefficentInternal { public delegate void PrefixSignature(Run self); public delegate void PostfixSignature(Run self); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (MethodBase)hook.Method, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MethodBase Target() { return typeof(Run).GetMethod("RecalculateDifficultyCoefficentInternal", (BindingFlags)(-1), null, Array.Empty<Type>(), null) ?? throw new MissingMethodException("RoR2.Run", "RecalculateDifficultyCoefficentInternal"); } } internal static class get_instance { } internal static class set_instance { } internal static class OnEnable { } internal static class OnDisable { } internal static class Awake { } internal static class get_ruleBook { } internal static class SetRuleBook { } internal static class OnRuleBookUpdated { } internal static class add_onServerRunSetRuleBookGlobal { } internal static class remove_onServerRunSetRuleBookGlobal { } internal static class add_onRunSetRuleBookGlobal { } internal static class remove_onRunSetRuleBookGlobal { } internal static class GetUniqueId { } internal static class GetStartTimeUtc { } internal static class SetRunStopwatchPaused { } internal static class GetRunStopwatch { } internal static class SetRunStopwatch { } internal static class get_isRunStopwatchPaused { } internal static class get_loopClearCount { } internal static class get_spawnWithPod { } internal static class get_autoGenerateSpawnPoints { } internal static class get_canFamilyEventTrigger { } internal static class get_uiInstances { } internal static class set_uiInstances { } internal static class InstantiateUi { } internal static class UnregisterUi { } internal static class get_seed { } internal static class set_seed { } internal static class GenerateStageRNG { } internal static class get_selectedDifficulty { } internal static class set_selectedDifficulty { } internal static class get_livingPlayerCount { } internal static class get_participatingPlayerCount { } internal static class get_ambientLevel { } internal static class set_ambientLevel { } internal static class get_ambientLevelFloor { } internal static class set_ambientLevelFloor { } internal static class add_onRunAmbientLevelUp { } internal static class remove_onRunAmbientLevelUp { } internal static class OnAmbientLevelUp { } internal static class get_teamlessDamageCoefficient { } internal static class FixedUpdate { } internal static class RecalculateDifficultyCoefficent { } internal static class InitializeTimeStamps { } internal static class OnFixedUpdate { } internal static class GetLowerPricedChestsTimer { } internal static class Update { } internal static class SetForcePauseRunStopwatch { } internal static class ShouldUpdateRunStopwatch { } internal static class CanUnlockableBeGrantedThisRun_System_String { } internal static class CanUnlockableBeGrantedThisRun_RoR2_UnlockableDef { } internal static class GrantUnlockToAllParticipatingPlayers_System_String { } internal static class GrantUnlockToAllParticipatingPlayers_RoR2_UnlockableDef { } internal static class GrantUnlockToSinglePlayer_System_String_RoR2_CharacterBody { } internal static class GrantUnlockToSinglePlayer_RoR2_UnlockableDef_RoR2_CharacterBody { } internal static class IsUnlockableUnlocked_System_String { } internal static class IsUnlockableUnlocked_RoR2_UnlockableDef { } internal static class DoesEveryoneHaveThisUnlockableUnlocked_System_String { } internal static class DoesEveryoneHaveThisUnlockableUnlocked_RoR2_UnlockableDef { } internal static class ForceUnlockImmediate_System_String { } internal static class ForceUnlockImmediate_RoR2_UnlockableDef { } internal static class PickNextStageSceneFromCurrentSceneDestinations { } internal static class CanPickStage { } internal static class PickNextStageScene { } internal static class GenerateSeedForNewRun { } internal static class RefreshUnlockAvailability { } internal static class BuildUnlockAvailability { } internal static class Start { } internal static class OnDestroy { } internal static class ServerGiveRebirthItems { } internal static class HandlePostRunDestination { } internal static class OnApplicationQuit { } internal static class GetUserMaster { } internal static class OnServerSceneChanged { } internal static class BeginStage { } internal static class EndStage { } internal static class OnUserAdded { } internal static class OnUserRemoved { } internal static class ShouldAllowNewParticipant { } internal static class SetupUserCharacterMaster { } internal static class add_onPlayerFirstCreatedServer { } internal static class remove_onPlayerFirstCreatedServer { } internal static class HandlePlayerFirstEntryAnimation { } internal static class OnServerBossAdded { } internal static class OnServerBossDefeated { } internal static class OnServerCharacterBodySpawned { } internal static class OnServerTeleporterPlaced { } internal static class OnPlayerSpawnPointsPlaced { } internal static class GetTeleportEffectPrefab { } internal static class GetDifficultyScaledCost_System_Int32_System_Single { } internal static class GetDifficultyScaledCost_System_Int32 { } internal static class BuildDropTable { } internal static class IsItemAvailable { } internal static class IsEquipmentAvailable { } internal static class IsItemExpansionLocked { } internal static class IsEquipmentExpansionLocked { } internal static class IsPickupAvailable { } internal static class DisablePickupDrop { } internal static class DisableItemDrop { } internal static class DisableEquipmentDrop { } internal static class EnablePickupDrop { } internal static class EnableItemDrop { } internal static class EnableEquipmentDrop { } internal static class RefreshLunarCombinedDropList { } internal static class CCRunEnd { } internal static class CCRunPrintUnlockables { } internal static class CCRunPrintSeed { } internal static class CCRunSetStagesCleared { } internal static class AdvanceStage { } internal static class add_onLoopEvent { } internal static class remove_onLoopEvent { } internal static class ResetEventFlagsOnNewLoop { } internal static class get_isGameOverServer { } internal static class set_isGameOverServer { } internal static class add_onServerGameOver { } internal static class remove_onServerGameOver { } internal static class BeginGameOver { } internal static class OnClientGameOver { } internal static class add_onClientGameOverGlobal { } internal static class remove_onClientGameOverGlobal { } internal static class OverrideRuleChoices { } internal static class ForceChoice_RoR2_RuleChoiceMask_RoR2_RuleChoiceMask_RoR2_RuleChoiceDef { } internal static class ForceChoice_RoR2_RuleChoiceMask_RoR2_RuleChoiceMask_System_String { } internal static class FindSafeTeleportPosition_RoR2_CharacterBody_UnityEngine_Transform { } internal static class FindSafeTeleportPosition_RoR2_CharacterBody_UnityEngine_Transform_System_Single_System_Single { } internal static class FindSafeTeleportPositionSimplified { } internal static class add_onRunStartGlobal { } internal static class remove_onRunStartGlobal { } internal static class add_onRunDestroyGlobal { } internal static class remove_onRunDestroyGlobal { } internal static class add_onAvailablePickupsModified { } internal static class remove_onAvailablePickupsModified { } internal static class SetEventFlag { } internal static class GetEventFlag { } internal static class ResetEventFlag { } internal static class ShouldAllowNonChampionBossSpawn { } internal static class IsExpansionEnabled { } internal static class OnSeedSet { } internal static class _ctor { } internal static class _cctor { } internal static class _PickNextStageScene_g__IsValidNextStage_137_0 { } internal static class UNetVersion { } internal static class get_Network_uniqueId { } internal static class set_Network_uniqueId { } internal static class get_NetworkstartTimeUtc { } internal static class set_NetworkstartTimeUtc { } internal static class get_NetworkfixedTime { } internal static class set_NetworkfixedTime { } internal static class get_NetworkrunStopwatch { } internal static class set_NetworkrunStopwatch { } internal static class get_NetworkisRunStopwatchForcePaused { } internal static class set_NetworkisRunStopwatchForcePaused { } internal static class get_NetworkstageClearCount { } internal static class set_NetworkstageClearCount { } internal static class get_NetworkselectedDifficultyInternal { } internal static class set_NetworkselectedDifficultyInternal { } internal static class OnSerialize { } internal static class OnDeserialize { } internal static class PreStartClient { } internal static class RunStopwatch { internal static class _ctor { } internal static class Equals_RoR2_Run_RunStopwatch { } internal static class Equals_System_Object { } internal new static class GetHashCode { } } internal static class TimeStamp { internal static class _ctor { } internal static class get_timeUntil { } internal static class get_timeSince { } internal static class get_timeUntilClamped { } internal static class get_timeSinceClamped { } internal static class get_hasPassed { } internal new static class GetHashCode { } internal static class get_isInfinity { } internal static class get_isPositiveInfinity { } internal static class get_isNegativeInfinity { } internal static class Update { } internal static class get_now { } internal static class _ctor_System_Single { } internal static class Equals_RoR2_Run_TimeStamp { } internal static class Equals_System_Object { } internal static class CompareTo { } internal static class op_Addition { } internal static class op_Subtraction_RoR2_Run_TimeStamp_System_Single { } internal static class op_Subtraction_RoR2_Run_TimeStamp_RoR2_Run_TimeStamp { } internal static class op_LessThan { } internal static class op_GreaterThan { } internal static class op_LessThanOrEqual { } internal static class op_GreaterThanOrEqual { } internal static class op_Equality { } internal static class op_Inequality { } internal static class op_Subtraction_RoR2_Run_TimeStamp_RoR2_Run_FixedTimeStamp { } internal static class Deserialize { } internal static class Serialize { } internal static class ToXml { } internal static class FromXml { } internal static class _cctor { } } internal static class FixedTimeStamp { internal static class _ctor { } internal static class get_timeUntil { } internal static class get_timeSince { } internal static class get_timeUntilClamped { } internal static class get_timeSinceClamped { } internal static class get_hasPassed { } internal new static class GetHashCode { } internal static class get_isInfinity { } internal static class get_isPositiveInfinity { } internal static class get_isNegativeInfinity { } internal static class Update { } internal static class get_now { } internal static class _ctor_System_Single { } internal static class Equals_RoR2_Run_FixedTimeStamp { } internal static class Equals_System_Object { } internal static class CompareTo { } internal static class op_Addition { } internal static class op_Subtraction_RoR2_Run_FixedTimeStamp_System_Single { } internal static class op_Subtraction_RoR2_Run_FixedTimeStamp_RoR2_Run_FixedTimeStamp { } internal static class op_LessThan { } internal static class op_GreaterThan { } internal static class op_LessThanOrEqual { } internal static class op_GreaterThanOrEqual { } internal static class op_Equality { } internal static class op_Inequality { } internal static class Deserialize { } internal static class Serialize { } internal static class ToXml { } internal static class FromXml { } internal static class _cctor { } } } namespace MonoDetour.HookGen { internal static class DefaultMonoDetourManager { internal static MonoDetourManager Instance { get; } = New(); internal static MonoDetourManager New() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return new MonoDetourManager(typeof(DefaultMonoDetourManager).Assembly.GetName().Name); } } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = true, Inherited = false)] internal class MonoDetourTargetsAttribute : Attribute, IMonoDetourTargets { public Type? TargetType { get; } public bool IncludeNestedTypes { get; set; } public bool DistinguishOverloadsByName { get; set; } public string[]? Members { get; set; } public string[]? MemberNamePrefixes { get; set; } public string[]? MemberNameSuffixes { get; set; } public bool GenerateControlFlowVariants { get; set; } public MonoDetourTargetsAttribute(Type? targetType = null) { TargetType = targetType; IncludeNestedTypes = true; base..ctor(); } } } namespace ConfigurablePerPlayerScaling { public static class ConfigOptions { private static string _sectionName = "configurable mod is configurable thats crazy"; public static ConfigEntry<float> DifficultyValuePerPlayer; public static ConfigEntry<int> MinimumPlayerCountForChangedDifficulty; internal static void BindConfigOptions(ConfigFile config) { DifficultyValuePerPlayer = Extensions.BindOptionSlider<float>(config, _sectionName, "Difficulty Value Per Player", "The value that each player contributes to the difficulty scaling. This also applies in singleplayer.", 0.15f, (ConfigFlags)0); MinimumPlayerCountForChangedDifficulty = Extensions.BindOptionSlider<int>(config, _sectionName, "Minimum Player Count Needed", "The player count needed for the difficulty value change to take effect. Set to 1 to always have the difficulty value change active.", 2, (ConfigFlags)0); Extensions.WipeConfig(config); } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInPlugin("LordVGames.ConfigurablePerPlayerScaling", "ConfigurablePerPlayerScaling", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "LordVGames.ConfigurablePerPlayerScaling"; public const string PluginAuthor = "LordVGames"; public const string PluginName = "ConfigurablePerPlayerScaling"; public const string PluginVersion = "1.0.0"; public static PluginInfo PluginInfo { get; private set; } public void Awake() { PluginInfo = ((BaseUnityPlugin)this).Info; Log.Init(((BaseUnityPlugin)this).Logger); ConfigOptions.BindConfigOptions(((BaseUnityPlugin)this).Config); MonoDetourManager.InvokeHookInitializers(typeof(Plugin).Assembly); } } [MonoDetourTargets(typeof(Run))] internal static class PerPlayerDifficultyChange { [CompilerGenerated] private static class <>O { public static Manipulator <0>__DoILHook; public static Func<float, Run, float> <1>__ChangePerPlayerDifficultyValue; } [MonoDetourHookInitialize] private static void DoChange() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DoILHook; if (obj == null) { Manipulator val = DoILHook; <>O.<0>__DoILHook = val; obj = (object)val; } RecalculateDifficultyCoefficentInternal.ILHook((Manipulator)obj); } private static void DoILHook(ILManipulationInfo info) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) ILWeaver w = new ILWeaver(info); w.MatchRelaxed(new Predicate<Instruction>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCall<Run>(x, "get_participatingPlayerCount"), (Instruction x) => ILPatternMatchingExt.MatchConvR4(x), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.2f) && w.SetCurrentTo(x) }).ThrowIfFailure().InsertAfterCurrent((IEnumerable<Instruction>)new <>z__ReadOnlyArray<Instruction>((Instruction[])(object)new Instruction[2] { w.Create(OpCodes.Ldarg_0), w.CreateCall((Delegate)new Func<float, Run, float>(ChangePerPlayerDifficultyValue)) })); } private static float ChangePerPlayerDifficultyValue(float perPlayerDifficulty, Run run) { if (run.participatingPlayerCount >= ConfigOptions.MinimumPlayerCountForChangedDifficulty.Value) { perPlayerDifficulty = ConfigOptions.DifficultyValuePerPlayer.Value; } return perPlayerDifficulty; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }