using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HarmonyLib.Tools;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ATTMorePlayers")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.9.4.0")]
[assembly: AssemblyInformationalVersion("0.9.4-alpha+01b03d8fcf61e4506c0c1a805d1400e1cc818c93")]
[assembly: AssemblyProduct("Ale and Tavern Tale - 8 Players Mod")]
[assembly: AssemblyTitle("ATTMorePlayers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.9.4.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ATTMorePlayers
{
[BepInPlugin("com.michaelrooplall.mods.attmoreplayers", "More Players", "0.9.4")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Master), "Awake")]
public class MasterMaxPlayersPatch
{
private static byte maxPlayers = 8;
private static void Prefix(Master __instance)
{
Debug.Log((object)"[MOREPLAYERS] Loading Master maxMembers Patch");
__instance.maxPlayers = maxPlayers;
if (Object.op_Implicit((Object)(object)Master.Instance))
{
Master.Instance.maxPlayers = maxPlayers;
Debug.Log((object)"[MOREPLAYERS] Patching maxPlayers on Master Instance");
}
else
{
Debug.Log((object)"[MOREPLAYERS] Master Instance not found");
}
Debug.Log((object)("[MOREPLAYERS] Master maxPlayers:" + __instance.maxPlayers));
}
}
[HarmonyPatch(typeof(SteamManager), "Awake")]
public static class SteamManagerTranspilerPatch
{
private static int maxPlayers = 8;
[HarmonyPrefix]
public static void Postfix(SteamManager __instance)
{
Debug.Log((object)"[MOREPLAYERS] Loading SteamManager maxMembers Patch");
__instance.maxMembers = maxPlayers;
if (Object.op_Implicit((Object)(object)SteamManager.Instance))
{
SteamManager.Instance.maxMembers = maxPlayers;
Debug.Log((object)"[MOREPLAYERS] Patching maxMembers on SteamManager");
}
else
{
Debug.Log((object)"[MOREPLAYERS] SteamManager Instance not found!");
}
}
}
public static class GenNewGameName_Patch
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private bool <found>5__1;
private IEnumerator<CodeInstruction> <>s__2;
private CodeInstruction <instruction>5__3;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__2 = null;
<instruction>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<found>5__1 = false;
Debug.Log((object)"\n\nPatching MainMenu GenNewGameName method");
<>s__2 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
Debug.Log((object)("Changed OpCode String variable with value \"" + <instruction>5__3.operand.ToString() + "\""));
goto IL_016d;
case 2:
{
<>1__state = -3;
goto IL_016d;
}
IL_016d:
<instruction>5__3 = null;
break;
}
if (<>s__2.MoveNext())
{
<instruction>5__3 = <>s__2.Current;
if (<instruction>5__3.opcode.Equals(OpCodes.Ldstr))
{
Debug.Log((object)("Found OpCode String variable with value \"" + <instruction>5__3.operand.ToString() + "\""));
}
if (<instruction>5__3.opcode.Equals(OpCodes.Ldstr) && <instruction>5__3.operand.ToString() == "Tavern")
{
<found>5__1 = true;
<>2__current = new CodeInstruction(OpCodes.Ldstr, (object)"BiggerTavern");
<>1__state = 1;
return true;
}
<>2__current = <instruction>5__3;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>s__2 = null;
if (!<found>5__1)
{
Debug.Log((object)"Failed to set OpCode String to BiggerTavern");
}
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__2 != null)
{
<>s__2.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
[HarmonyDebug]
[HarmonyPatch(typeof(MainMenu), "GenNewGameName")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__instructions = instructions
};
}
}
public class PatchPlayerManager_Awake
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private int <maxPlayers>5__1;
private bool <changed>5__2;
private IEnumerator<CodeInstruction> <>s__3;
private CodeInstruction <instruction>5__4;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 3u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__3 = null;
<instruction>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<maxPlayers>5__1 = 8;
<changed>5__2 = false;
Debug.Log((object)"\n\nPatching PlayerManager Awake method to edit lastPlayerPlatformIdByPlayerIndex");
<>s__3 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
goto IL_018c;
case 2:
<>1__state = -3;
goto IL_018c;
case 3:
<>1__state = -3;
goto IL_018c;
case 4:
{
<>1__state = -3;
goto IL_01b7;
}
IL_018c:
<changed>5__2 = true;
goto IL_01b7;
IL_01b7:
<instruction>5__4 = null;
break;
}
if (<>s__3.MoveNext())
{
<instruction>5__4 = <>s__3.Current;
if (<instruction>5__4.opcode.Equals(OpCodes.Ldc_I4_4))
{
if (<maxPlayers>5__1 >= 0 && <maxPlayers>5__1 <= 8)
{
<>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)<maxPlayers>5__1);
<>1__state = 1;
return true;
}
if (<maxPlayers>5__1 >= -128 && <maxPlayers>5__1 <= 127)
{
<>2__current = new CodeInstruction(OpCodes.Ldc_I4_S, (object)(sbyte)<maxPlayers>5__1);
<>1__state = 2;
return true;
}
<>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)<maxPlayers>5__1);
<>1__state = 3;
return true;
}
<>2__current = <instruction>5__4;
<>1__state = 4;
return true;
}
<>m__Finally1();
<>s__3 = null;
if (<changed>5__2)
{
Debug.Log((object)"Patched lastPlayerPlatformIdByPlayerIndex");
}
else
{
Debug.Log((object)"Failed to patch lastPlayerPlatformIdByPlayerIndex");
}
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__3 != null)
{
<>s__3.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
[HarmonyDebug]
[HarmonyPatch(typeof(PlayerManager), "Awake")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__instructions = instructions
};
}
}
[HarmonyPatch(typeof(PlayerManager), "GetFreePlayerIndex")]
public static class PatchPlayerManager_GetFreePlayerIndex
{
[HarmonyPrefix]
private static bool Prefix(PlayerManager __instance, ref byte __result, ulong playerId = 0uL)
{
Debug.Log((object)"\n\n[MORE PLAYERS] Patching PlayerManager GetFreePlayerIndex method");
List<byte> list = new List<byte> { 0, 1, 2, 3, 4, 5, 6, 7 };
foreach (KeyValuePair<ulong, byte> item in PlayerManager.Instance.playerIndex)
{
list.Remove(item.Value);
}
if (playerId != 0)
{
for (byte b = 0; b < PlayerManager.Instance.lastPlayerPlatformIdByPlayerIndex.Length; b++)
{
if (PlayerManager.Instance.lastPlayerPlatformIdByPlayerIndex[b] == playerId && list.Contains(b))
{
__result = b;
return false;
}
}
}
__result = list[0];
return false;
}
}
public class PatchContainerManager_Awake
{
[CompilerGenerated]
private sealed class <Transpiler>d__1 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private int <maxPlayers>5__1;
private bool <changed>5__2;
private IEnumerator<CodeInstruction> <>s__3;
private CodeInstruction <instruction>5__4;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__3 = null;
<instruction>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<maxPlayers>5__1 = 8;
<changed>5__2 = false;
Debug.Log((object)"\n\n[MORE PLAYERS] Patching ContainerManager Awake method");
<>s__3 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
<changed>5__2 = true;
goto IL_00f9;
case 2:
{
<>1__state = -3;
goto IL_00f9;
}
IL_00f9:
<instruction>5__4 = null;
break;
}
if (<>s__3.MoveNext())
{
<instruction>5__4 = <>s__3.Current;
if (<instruction>5__4.opcode.Equals(OpCodes.Ldc_I4_5))
{
<>2__current = new CodeInstruction(OpCodes.Ldc_I4_S, (object)(sbyte)(1 + <maxPlayers>5__1));
<>1__state = 1;
return true;
}
<>2__current = <instruction>5__4;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>s__3 = null;
if (<changed>5__2)
{
Debug.Log((object)"[MORE PLAYERS] Patched ContainerManager");
}
else
{
Debug.Log((object)"[MORE PLAYERS] Failed to patch ContainerManager");
}
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__3 != null)
{
<>s__3.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__1 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__1(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[HarmonyDebug]
[HarmonyPatch(typeof(ContainerManager), "Awake")]
[HarmonyPrefix]
private static void Prefix(ContainerManager __instance)
{
Debug.Log((object)("[MORE PLAYERS] ContainerManager Instance " + ((Object)(object)ContainerManager.Instance != (Object)null)));
if (!((Object)(object)ContainerManager.Instance != (Object)null))
{
expandPlayerContainers(__instance);
}
}
[IteratorStateMachine(typeof(<Transpiler>d__1))]
[HarmonyDebug]
[HarmonyPatch(typeof(ContainerManager), "Awake")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__1(-2)
{
<>3__instructions = instructions
};
}
private static void expandPlayerContainers(ContainerManager __instance)
{
int num = 8;
Debug.Log((object)"\n\n[MORE PLAYERS] [Adding More Player Containers]");
GameObject val = GameObject.Find("Common/Game/PlayerContainers/ContainerP0");
GameObject val2 = GameObject.Find("Common/Game/PlayerContainers");
Debug.Log((object)$"[MORE PLAYERS] (Before adding more player containers) Found number of slots: {__instance.playerContainers.Length} in playerContainers");
Array.Resize(ref __instance.playerContainers, num);
for (int i = 4; i < num; i++)
{
Debug.Log((object)("[MORE PLAYERS] Creating Networked Container ContainerP" + i));
GameObject val3 = Object.Instantiate<GameObject>(val);
((Object)val3).name = $"ContainerP{i}";
ContainerNet val4 = val3.GetComponent<ContainerNet>();
if ((Object)(object)val4 == (Object)null)
{
val4 = val3.AddComponent<ContainerNet>();
}
val4.id.Value = (ushort)(i + 1);
val3.transform.SetParent(((Component)val.transform.parent).transform);
__instance.playerContainers[i] = val4;
Debug.Log((object)("[MORE PLAYERS] Pushed Networked ContainerP" + i + " to ContainerManager and playerContainers"));
}
Debug.Log((object)$"[MORE PLAYERS] Found number of slots: {__instance.playerContainers.Length} in playerContainers");
buildBackpacks();
}
private static void buildBackpacks()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"\n\n[MORE PLAYERS] [Adding More Backpacks]");
modifyBackpackBaseboard();
int num = 8;
GameObject val = GameObject.Find("Tavern/Interactive/Backpacks/3");
GameObject val2 = GameObject.Find("Tavern/Interactive/Backpacks/2");
float num2 = val.transform.position.z - val2.transform.position.z;
if ((Object)(object)val != (Object)null)
{
for (int i = 4; i < num; i++)
{
GameObject val3 = Object.Instantiate<GameObject>(val);
((Object)val3).name = i.ToString();
val3.transform.SetParent(((Component)val.transform.parent).transform, false);
val3.transform.position = new Vector3(val.transform.position.x, val.transform.position.y, val.transform.position.z + (float)(i - 3) * num2);
val3.transform.rotation = val.transform.rotation;
PlayerContainerRef component = val3.GetComponent<PlayerContainerRef>();
if ((Object)(object)component != (Object)null)
{
FieldInfo field = typeof(PlayerContainerRef).GetField("playerIndex", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(component, (byte)i);
}
else
{
Logger.LogWarning((object)"[MORE PLAYERS] Unable to find playerIndex field via reflection.");
}
Interactive component2 = val3.GetComponent<Interactive>();
if ((Object)(object)component2 != (Object)null)
{
component2.ObjectTitle = $"Player {i + 1} Inventory";
((Object)component2).name = i.ToString();
}
else
{
Logger.LogWarning((object)"[MORE PLAYERS] Unable to find Interactive Component.");
}
}
else
{
Logger.LogWarning((object)"[MORE PLAYERS] Unable to find PlayerContainerRef Component.");
}
Logger.LogInfo((object)$"[MORE PLAYERS] Created wall backpack for {i + 1}.");
}
}
else
{
Logger.LogWarning((object)"[MORE PLAYERS] Original object originalBackpack3 not found at Tavern/Interactive/Backpacks/3.");
}
}
private static void modifyBackpackBaseboard()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
int num = 8;
Debug.Log((object)"\n\n[MORE PLAYERS] [Modifying Backpack Baseboard]");
GameObject val = GameObject.Find("Tavern/Interactive/Backpacks");
GameObject val2 = GameObject.Find("Tavern/Interactive/Backpacks/Modular_Door_A");
val.transform.position = new Vector3(val.transform.position.x, val.transform.position.y, 46.6f);
if ((Object)(object)val2 != (Object)null)
{
val2.transform.position = new Vector3(-22.05f, 4.65f, 46.9f + 0.38f * (float)(num - 4));
val2.transform.localScale = new Vector3(1f, 1f + 0.3f * (float)(num - 4), 1f);
Logger.LogInfo((object)"[MORE PLAYERS] Backpack backboard position and scale modified!");
}
else
{
Logger.LogWarning((object)"[MORE PLAYERS] Backpack backboard not found!");
}
}
}
public class PatchSpawnManager_Awake
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private int <maxPlayers>5__1;
private bool <changed>5__2;
private IEnumerator<CodeInstruction> <>s__3;
private CodeInstruction <instruction>5__4;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 3u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__3 = null;
<instruction>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<maxPlayers>5__1 = 8;
<changed>5__2 = false;
Debug.Log((object)"\n\n[MORE PLAYERS] Patching SpawnManager Awake method to edit _playerCheckPoint");
<>s__3 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
goto IL_018c;
case 2:
<>1__state = -3;
goto IL_018c;
case 3:
<>1__state = -3;
goto IL_018c;
case 4:
{
<>1__state = -3;
goto IL_01b7;
}
IL_018c:
<changed>5__2 = true;
goto IL_01b7;
IL_01b7:
<instruction>5__4 = null;
break;
}
if (<>s__3.MoveNext())
{
<instruction>5__4 = <>s__3.Current;
if (<instruction>5__4.opcode.Equals(OpCodes.Ldc_I4_4))
{
if (<maxPlayers>5__1 >= 0 && <maxPlayers>5__1 <= 8)
{
<>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)<maxPlayers>5__1);
<>1__state = 1;
return true;
}
if (<maxPlayers>5__1 >= -128 && <maxPlayers>5__1 <= 127)
{
<>2__current = new CodeInstruction(OpCodes.Ldc_I4_S, (object)(sbyte)<maxPlayers>5__1);
<>1__state = 2;
return true;
}
<>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)<maxPlayers>5__1);
<>1__state = 3;
return true;
}
<>2__current = <instruction>5__4;
<>1__state = 4;
return true;
}
<>m__Finally1();
<>s__3 = null;
if (<changed>5__2)
{
Debug.Log((object)"[MORE PLAYERS] Patched SpawnManager _playerCheckPoint");
}
else
{
Debug.Log((object)"[MORE PLAYERS] Failed to patch SpawnManager _playerCheckPoint");
}
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__3 != null)
{
<>s__3.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
[HarmonyDebug]
[HarmonyPatch(typeof(SpawnManager), "Awake")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__instructions = instructions
};
}
}
public class PatchPlayerList_Refresh
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private int <maxPlayers>5__1;
private bool <changed>5__2;
private IEnumerator<CodeInstruction> <>s__3;
private CodeInstruction <instruction>5__4;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 3u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__3 = null;
<instruction>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<maxPlayers>5__1 = 8;
<changed>5__2 = false;
Debug.Log((object)"\n\n[MORE PLAYERS] Patching PlayerList Refresh method");
<>s__3 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
goto IL_018c;
case 2:
<>1__state = -3;
goto IL_018c;
case 3:
<>1__state = -3;
goto IL_018c;
case 4:
{
<>1__state = -3;
goto IL_01b7;
}
IL_018c:
<changed>5__2 = true;
goto IL_01b7;
IL_01b7:
<instruction>5__4 = null;
break;
}
if (<>s__3.MoveNext())
{
<instruction>5__4 = <>s__3.Current;
if (<instruction>5__4.opcode.Equals(OpCodes.Ldc_I4_4))
{
if (<maxPlayers>5__1 >= 0 && <maxPlayers>5__1 <= 8)
{
<>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)<maxPlayers>5__1);
<>1__state = 1;
return true;
}
if (<maxPlayers>5__1 >= -128 && <maxPlayers>5__1 <= 127)
{
<>2__current = new CodeInstruction(OpCodes.Ldc_I4_S, (object)(sbyte)<maxPlayers>5__1);
<>1__state = 2;
return true;
}
<>2__current = new CodeInstruction(OpCodes.Ldc_I4, (object)<maxPlayers>5__1);
<>1__state = 3;
return true;
}
<>2__current = <instruction>5__4;
<>1__state = 4;
return true;
}
<>m__Finally1();
<>s__3 = null;
if (<changed>5__2)
{
Debug.Log((object)"[MORE PLAYERS] Patched PlayerList[Refresh]");
}
else
{
Debug.Log((object)"[MORE PLAYERS] Failed to patch PlayerList[Refresh]");
}
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__3 != null)
{
<>s__3.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
[HarmonyDebug]
[HarmonyPatch(typeof(PlayerList), "Refresh")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__instructions = instructions
};
}
}
[HarmonyPatch(typeof(RecipeManager), "Awake")]
public static class RecipeManagerTranspilerPatch
{
private static int maxPlayers = 8;
[HarmonyPrefix]
public static void Prefix(RecipeManager __instance)
{
Debug.Log((object)"[MORE PLAYERS] Patching RecipeManager playerCountK EXP Multiplier");
FieldInfo field = ((object)__instance).GetType().GetField("playerCountK", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
float[] value = new float[8] { 2f, 1.5f, 1.25f, 1f, 1f, 1f, 1f, 1f };
field.SetValue(__instance, value);
}
else
{
Debug.LogError((object)"[MORE PLAYERS] playerCountK field not found!");
}
}
}
[HarmonyPatch(typeof(CaveSpawnManager), "SpawnCreatures")]
public static class CaveSpawnManager_SpawnCreatures_Patch
{
[HarmonyPrefix]
private static bool Prefix(CaveSpawnManager __instance, ref int creaturesCount)
{
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"\n\n[MORE PLAYERS] Patching (Overwriting) CaveSpawnManager SpawnCreatures method");
Debug.Log((object)"CaveSpawnManager.SpawnCreatures");
int num = 2 * Random.Range(PlayerManager.Instance.players.Count, PlayerManager.Instance.players.Count * 3 + 1);
creaturesCount = ((creaturesCount == -1) ? num : creaturesCount);
FieldInfo field = ((object)CaveSpawnManager.Instance).GetType().GetField("creaturesSpawnPoints", BindingFlags.Instance | BindingFlags.NonPublic);
List<Transform> source = (List<Transform>)field.GetValue(__instance);
FieldInfo field2 = ((object)CaveSpawnManager.Instance).GetType().GetField("creatureTypes", BindingFlags.Instance | BindingFlags.NonPublic);
List<Type> list = (List<Type>)field2.GetValue(__instance);
FieldInfo field3 = ((object)CaveSpawnManager.Instance).GetType().GetField("spawnedCreatures", BindingFlags.Instance | BindingFlags.NonPublic);
List<Vulnerable> list2 = (List<Vulnerable>)field3.GetValue(__instance);
MethodInfo method = ((object)__instance).GetType().GetMethod("OnCreatureDeath", BindingFlags.Instance | BindingFlags.NonPublic);
List<Transform> list3 = source.OrderBy((Transform n) => Guid.NewGuid()).ToList();
creaturesCount = Math.Min(creaturesCount, list3.Count - 1);
Spawnable val2 = default(Spawnable);
Vulnerable val3 = default(Vulnerable);
for (int i = 0; i < creaturesCount; i++)
{
Type val = list[Random.Range(0, list.Count)];
SpawnManager.Instance.ManualSpawn(val, list3[i].position, Quaternion.identity, ref val2, true);
if (((Component)val2).TryGetComponent<Vulnerable>(ref val3))
{
list2.Add(val3);
Vulnerable val4 = val3;
Action<Vulnerable> b = (Action<Vulnerable>)Delegate.CreateDelegate(typeof(Action<Vulnerable>), __instance, method);
val4.onDeath = (Action<Vulnerable>)Delegate.Combine(val4.onDeath, b);
}
}
return false;
}
}
[HarmonyPatch(typeof(CaveSpawnManager), "SpawnLoot")]
public static class CaveSpawnManager_SpawnLoot_Patch
{
[HarmonyPrefix]
private static bool Prefix(CaveSpawnManager __instance, ref int lootItemsCount)
{
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"\n\n[MORE PLAYERS] Patching (Overwriting) CaveSpawnManager SpawnLoot method");
Debug.Log((object)"CaveSpawnManager.SpawnLoot");
int count = PlayerManager.Instance.players.Count;
FieldInfo field = ((object)CaveSpawnManager.Instance).GetType().GetField("minLootObjectsPerPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
int num = (int)field.GetValue(CaveSpawnManager.Instance);
FieldInfo field2 = ((object)CaveSpawnManager.Instance).GetType().GetField("maxLootObjectsPerPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
int num2 = (int)field2.GetValue(CaveSpawnManager.Instance);
FieldInfo field3 = ((object)CaveSpawnManager.Instance).GetType().GetField("lootSpawnPositions", BindingFlags.Instance | BindingFlags.NonPublic);
List<Transform> source = (List<Transform>)field3.GetValue(CaveSpawnManager.Instance);
FieldInfo field4 = ((object)CaveSpawnManager.Instance).GetType().GetField("spawnedLoot", BindingFlags.Instance | BindingFlags.NonPublic);
List<Vulnerable> list = (List<Vulnerable>)field4.GetValue(__instance);
MethodInfo method = ((object)__instance).GetType().GetMethod("OnLootDestroy", BindingFlags.Instance | BindingFlags.NonPublic);
int num3 = 2 * Random.Range(PlayerManager.Instance.players.Count * num, PlayerManager.Instance.players.Count * num2 + 1);
lootItemsCount = ((lootItemsCount == -1) ? num3 : lootItemsCount);
List<Transform> list2 = source.OrderBy((Transform n) => Guid.NewGuid()).ToList();
lootItemsCount = Math.Min(lootItemsCount, list2.Count - 1);
Spawnable val2 = default(Spawnable);
Vulnerable val3 = default(Vulnerable);
for (int i = 0; i < lootItemsCount; i++)
{
Vector3 position = list2[i].position;
Quaternion rotation = list2[i].rotation;
Type val = (Type)(((double)Random.value > 0.5) ? 51 : 50);
if (SpawnManager.Instance.ManualSpawn(val, position, rotation, ref val2, true) && ((Component)val2).TryGetComponent<Vulnerable>(ref val3))
{
list.Add(val3);
Vulnerable val4 = val3;
Action<Vulnerable> b = (Action<Vulnerable>)Delegate.CreateDelegate(typeof(Action<Vulnerable>), __instance, method);
val4.onDeath = (Action<Vulnerable>)Delegate.Combine(val4.onDeath, b);
}
}
return false;
}
}
[HarmonyPatch(typeof(CaveSpawnManager), "SpawnChests")]
public static class CaveSpawnManager_SpawnChests_Patch
{
[HarmonyPrefix]
private static bool Prefix(CaveSpawnManager __instance)
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"\n\n[MORE PLAYERS] Patching (Overwriting) CaveSpawnManager SpawnChests method");
Debug.Log((object)"CaveSpawnManager.SpawnChests");
FieldInfo field = ((object)CaveSpawnManager.Instance).GetType().GetField("minChestsPerPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
int num = (int)field.GetValue(CaveSpawnManager.Instance);
FieldInfo field2 = ((object)CaveSpawnManager.Instance).GetType().GetField("maxChestsPerPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
int num2 = (int)field2.GetValue(CaveSpawnManager.Instance);
FieldInfo field3 = ((object)CaveSpawnManager.Instance).GetType().GetField("chestSpawnPositions", BindingFlags.Instance | BindingFlags.NonPublic);
List<Transform> source = (List<Transform>)field3.GetValue(CaveSpawnManager.Instance);
FieldInfo field4 = ((object)CaveSpawnManager.Instance).GetType().GetField("chestPrefab", BindingFlags.Instance | BindingFlags.NonPublic);
NetworkObject val = (NetworkObject)field4.GetValue(CaveSpawnManager.Instance);
FieldInfo field5 = ((object)CaveSpawnManager.Instance).GetType().GetField("spawnedChests", BindingFlags.Instance | BindingFlags.NonPublic);
List<NetworkObject> list = (List<NetworkObject>)field5.GetValue(CaveSpawnManager.Instance);
MethodInfo method = ((object)__instance).GetType().GetMethod("FillChestWithLoot", BindingFlags.Instance | BindingFlags.NonPublic);
int val2 = Random.Range(PlayerManager.Instance.players.Count * num, PlayerManager.Instance.players.Count * num2 + 1);
List<Transform> list2 = source.OrderBy((Transform n) => Guid.NewGuid()).ToList();
val2 = Math.Min(val2, list2.Count - 1);
ContainerNet val5 = default(ContainerNet);
for (int i = 0; i < val2; i++)
{
Vector3 position = list2[i].position;
Quaternion rotation = list2[i].rotation;
NetworkObject val3 = Object.Instantiate<NetworkObject>(val, position, rotation);
list.Add(val3);
NetworkObject val4 = val3;
if (Master.Instance.HasConnectingClients() && AppSettingsManager.Instance.appSettings.system.useSpawnQueue)
{
Game.Instance.SpawnEnqueue(val4);
}
else
{
val4.Spawn(false);
}
if (((Component)val3).TryGetComponent<ContainerNet>(ref val5))
{
method.Invoke(__instance, new object[1] { val5 });
}
}
return false;
}
}
[HarmonyPatch(typeof(CaveSpawnManager), "SpawnChests")]
public class Alpha_CaveSpawnManager_SpawnChests_Patch
{
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
FieldInfo fieldInfo = AccessTools.Field(typeof(CaveSpawnManager), "chestSpawnPositions");
for (int i = 0; i < list.Count; i++)
{
if (i + 4 < list.Count && list[i].opcode == OpCodes.Ldloc_S && list[i + 1].opcode == OpCodes.Ldc_I4_1 && list[i + 2].opcode == OpCodes.Ldloc_S && CodeInstructionExtensions.Calls(list[i + 3], typeof(Mathf).GetMethod("Clamp", new Type[3]
{
typeof(int),
typeof(int),
typeof(int)
})) && list[i + 4].opcode == OpCodes.Stloc_S)
{
list[i + 2] = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
list.Insert(i + 3, new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo));
list.Insert(i + 4, new CodeInstruction(OpCodes.Callvirt, (object)typeof(List<Transform>).GetProperty("Count").GetGetMethod()));
i += 5;
}
}
return list;
}
}
[HarmonyPatch(typeof(DefenceQuestController), "Awake")]
public static class DefenceQuestControllerTranspilerPatch
{
[HarmonyPrefix]
public static void Prefix(DefenceQuestController __instance)
{
Debug.Log((object)"[MORE PLAYERS] Patching DefenceQuestController delayPerEnemyByPlayers List");
FieldInfo field = ((object)__instance).GetType().GetField("delayPerEnemyByPlayers", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
List<int> value = new List<int> { 7, 5, 4, 3, 3, 3, 3, 3 };
field.SetValue(__instance, value);
Debug.Log((object)"[MORE PLAYERS] Successfully added values to delayField for more players");
}
else
{
Debug.LogWarning((object)"[MORE PLAYERS] delayPerEnemyByPlayers field not found");
}
}
}
[HarmonyPatch(typeof(HerbalistQuestController), "Awake")]
public static class HerbalistQuestControllerPatch
{
[HarmonyPrefix]
public static void Prefix(HerbalistQuestController __instance)
{
Debug.Log((object)"[MORE PLAYERS] Adding more HerbalistQuestController Bear Spawns");
FieldInfo field = ((object)__instance).GetType().GetField("_bearSpawnPoint", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
Transform[] array = (Transform[])field.GetValue(__instance);
Transform[] value = (Transform[])(object)new Transform[6]
{
array[0],
array[1],
array[0],
array[1],
array[0],
array[1]
};
field.SetValue(__instance, value);
Debug.Log((object)"[MORE PLAYERS] Re-using bearSpawnPoints for more players");
}
else
{
Debug.LogError((object)"[MORE PLAYERS] _bearSpawnPoint field not found!");
}
}
}
private ConfigEntry<int> maxPlayers;
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
maxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "MaxPlayers", 8, "<int> Max Players (maximum : 8)");
Logger = ((BaseUnityPlugin)this).Logger;
HarmonyFileLog.Enabled = true;
Logger.LogInfo((object)"[MORE PLAYERS] Plugin ATTMorePlayers - v0.9.4-alpha is loaded!");
Harmony val = new Harmony("com.michaelrooplall.mods.attmoreplayers.patch");
Debug.Log((object)"\n\n==========================\n[MORE PLAYERS][PATCHES][HARMONY]\n==========================\n");
val.PatchAll(typeof(MainMenu));
val.PatchAll(typeof(MasterMaxPlayersPatch));
val.PatchAll(typeof(SteamManagerTranspilerPatch));
val.PatchAll(typeof(GenNewGameName_Patch));
val.PatchAll(typeof(PatchContainerManager_Awake));
val.PatchAll(typeof(PatchPlayerManager_Awake));
val.PatchAll(typeof(PatchPlayerManager_GetFreePlayerIndex));
val.PatchAll(typeof(PatchSpawnManager_Awake));
val.PatchAll(typeof(RecipeManagerTranspilerPatch));
val.PatchAll(typeof(CaveSpawnManager_SpawnCreatures_Patch));
val.PatchAll(typeof(CaveSpawnManager_SpawnLoot_Patch));
val.PatchAll(typeof(CaveSpawnManager_SpawnChests_Patch));
val.PatchAll(typeof(DefenceQuestControllerTranspilerPatch));
val.PatchAll(typeof(HerbalistQuestControllerPatch));
Debug.Log((object)"\n==========================\n\n");
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).name == "Playtest")
{
Debug.Log((object)"\n\n[MORE PLAYERS] SCENE CHANGE DETECTED");
((MonoBehaviour)this).Invoke("build", 2f);
}
GameObject val = GameObject.Find("SteamNetManager");
if ((Object)(object)val != (Object)null)
{
Debug.Log((object)("[MORE PLAYERS] SteamNetManager found in scene: " + ((Scene)(ref scene)).name));
SteamManager component = val.GetComponent<SteamManager>();
if ((Object)(object)component != (Object)null)
{
component.maxMembers = maxPlayers.Value;
Debug.Log((object)("[MORE PLAYERS] SteamManager maxMembers set to: " + component.maxMembers));
}
else
{
Debug.Log((object)"[MORE PLAYERS] SteamManager component not found in SteamNetManager GameObject");
}
}
}
private void build()
{
Debug.Log((object)"\n\n==========================\n[MORE PLAYERS][PATCHES][UNITY]\n==========================\n");
DebugLog.Instance.logAll = true;
try
{
createMorePlayerSpawns();
}
catch (Exception ex)
{
Logger.LogError((object)ex);
}
Debug.Log((object)"\n==========================\n\n");
}
private void createMorePlayerSpawns()
{
Debug.Log((object)"\n\n[MORE PLAYERS] [Adding Spawn Points for Extra Players]");
GameObject val = GameObject.Find("Common/Game");
if ((Object)(object)val == (Object)null)
{
Debug.Log((object)"[MORE PLAYERS] Failed to find Common/Game GameObject");
return;
}
PlayerManager component = val.GetComponent<PlayerManager>();
Transform[] array = (Transform[])(object)new Transform[maxPlayers.Value];
for (int i = 0; i < component.playerSpawnPos.Length; i++)
{
array[i] = component.playerSpawnPos[i];
}
for (int j = 4; j < maxPlayers.Value; j++)
{
array[j] = component.playerSpawnPos[j % 4];
}
component.playerSpawnPos = array;
Debug.Log((object)"[MORE PLAYERS] Added more spawnpoints");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ATTMorePlayers";
public const string PLUGIN_NAME = "Ale and Tavern Tale - 8 Players Mod";
public const string PLUGIN_VERSION = "0.9.4-alpha";
}
}