using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using Ganimedes.Configuration;
using Ganimedes.NetcodePatcher;
using Ganimedes.Patches;
using HarmonyLib;
using LethalLib;
using LethalLib.Modules;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Ganimedes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ganimedes")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9c26ac22-c3d0-4403-a753-4338b8909d96")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Ganimedes
{
[Serializable]
public class Config : SyncedInstance<Config>
{
public int routeCost;
public float mp3Volume;
public bool mp3CustomSongs;
public bool mp3CustomSongsDirectory;
public bool mp3DefaultSongsChanges;
public bool mp3BoomboxVanilla;
public bool mp3song1;
public bool mp3song2;
public bool mp3song3;
public bool mp3song4;
public bool mp3song5;
public bool mp3song6;
public bool mp3song7;
public bool mp3song8;
public bool mp3song9;
public bool mp3song10;
public Config(ConfigFile cfg)
{
InitInstance(this);
routeCost = cfg.Bind<int>("General", "RouteCost", 1200, "Price to go to Ganimedes").Value;
mp3Volume = (float)(cfg.Bind<double>("Mp3.AudioVolume", "Volume", 70.0, "Change the volume of the Mp3 Player (0-100)").Value / 100.0);
if (mp3Volume > 1f)
{
mp3Volume = 1f;
}
mp3CustomSongs = cfg.Bind<bool>("Mp3.Custom", "CustomSongs", true, "Enable it to search songs to add to the Mp3 player (the default folder is 'BepInEx\\Plugins\\Ganimedes\\CustomSongs')").Value;
mp3CustomSongsDirectory = cfg.Bind<bool>("Mp3.CustomDirectory", "CustomSongsBoomboxDirectory", false, "Enable it to use the same directory that Custom Boombox Music for custom songs ('BepInEx\\Custom Songs\\Boombox Music')").Value;
mp3DefaultSongsChanges = cfg.Bind<bool>("Mp3.DefaultSongChanges", "Song1", false, "Enable it to eliminate the default songs marked as false").Value;
mp3BoomboxVanilla = cfg.Bind<bool>("Mp3.BoomboxVanilla", "BoomboxVanilla", false, "Enable it to add the vanilla boombox music to the Mp3 player (automatically true if the mp3 player is empty)").Value;
mp3song1 = cfg.Bind<bool>("Mp3.Song1", "Song1", true, "Desactivate it to eliminate 'Super Battle Train - Waterflame' song of the Mp3 player").Value;
mp3song2 = cfg.Bind<bool>("Mp3.Song2", "Song2", true, "Desactivate it to eliminate 'Payphone - Maroon 5' song of the Mp3 player").Value;
mp3song3 = cfg.Bind<bool>("Mp3.Song3", "Song3", true, "Desactivate it to eliminate 'I'm good (Blue) - David Guetta, Bebe Rexha' song of the Mp3 player").Value;
mp3song4 = cfg.Bind<bool>("Mp3.Song4", "Song4", true, "Desactivate it to eliminate 'Pandora's Music Box - Nox Arcana' song of the Mp3 player").Value;
mp3song5 = cfg.Bind<bool>("Mp3.Song5", "Song5", true, "Desactivate it to eliminate 'Lovumba - Daddy Yankee' song of the Mp3 player").Value;
mp3song6 = cfg.Bind<bool>("Mp3.Song6", "Song6", true, "Desactivate it to eliminate 'Splashing Around - The Green Orbs' song of the Mp3 player").Value;
mp3song7 = cfg.Bind<bool>("Mp3.Song7", "Song7", true, "Desactivate it to eliminate 'Rosas - La Oreja de Van Gogh' song of the Mp3 player").Value;
mp3song8 = cfg.Bind<bool>("Mp3.Song8", "Song8", true, "Desactivate it to eliminate 'Hikaru Nara - Goose House' song of the Mp3 player").Value;
mp3song9 = cfg.Bind<bool>("Mp3.Song9", "Song9", true, "Desactivate it to eliminate 'Quevedo - Bizarrap Music Sessions #52' song of the Mp3 player").Value;
mp3song10 = cfg.Bind<bool>("Mp3.Song10", "Song10", true, "Desactivate it to eliminate 'Numb - Linkin Park' song of the Mp3 player").Value;
}
public static void RequestSync()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (!SyncedInstance<Config>.IsClient)
{
return;
}
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1);
try
{
SyncedInstance<Config>.MessageManager.SendNamedMessage("Ganimedes_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
}
public static void OnRequestSync(ulong clientId, FastBufferReader _)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if (!SyncedInstance<Config>.IsHost)
{
return;
}
Plugin.logger.LogInfo((object)$"Config sync request received from client: {clientId}");
byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance);
int num = array.Length;
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1);
try
{
((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
SyncedInstance<Config>.MessageManager.SendNamedMessage("Ganimedes_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
}
catch (Exception arg)
{
Plugin.logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
}
public static void OnReceiveSync(ulong _, FastBufferReader reader)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize))
{
Plugin.logger.LogError((object)"Config sync error: Could not begin reading buffer.");
return;
}
int num = default(int);
((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
{
Plugin.logger.LogError((object)"Config sync error: Host could not sync.");
return;
}
byte[] data = new byte[num];
((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
SyncedInstance<Config>.SyncInstance(data);
Plugin.logger.LogInfo((object)"Successfully synced config with host.");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
public static void InitializeLocalPlayer()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
if (SyncedInstance<Config>.IsHost)
{
SyncedInstance<Config>.MessageManager.RegisterNamedMessageHandler("Ganimedes_OnRequestConfigSync", new HandleNamedMessageDelegate(OnRequestSync));
SyncedInstance<Config>.Synced = true;
}
else
{
SyncedInstance<Config>.Synced = false;
SyncedInstance<Config>.MessageManager.RegisterNamedMessageHandler("Ganimedes_OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveSync));
RequestSync();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
public static void PlayerLeave()
{
SyncedInstance<Config>.RevertSync();
}
}
internal class CustomGiftBoxItem : GrabbableObject
{
private GameObject objectInPresent;
public ParticleSystem PoofParticle;
public AudioSource presentAudio;
public AudioClip openGiftAudio;
public List<SpawnableItemWithRarity> spawnableItems;
public InteractTrigger trigger;
public DoorLock doorLock;
private PlayerControllerB previousPlayerHeldBy;
private bool hasUsedGift;
private int objectInPresentValue;
public override void Start()
{
((GrabbableObject)this).Start();
Random random = new Random(StartOfRound.Instance.randomMapSeed + (int)base.targetFloorPosition.x + (int)base.targetFloorPosition.y + (int)((NetworkBehaviour)this).NetworkObjectId);
if (!((NetworkBehaviour)this).IsServer)
{
return;
}
int num = 0;
for (int i = 0; i < spawnableItems.Count; i++)
{
num += spawnableItems[i].rarity;
}
int num2 = random.Next(1, num + 1);
int num3 = 0;
for (int j = 0; j < spawnableItems.Count; j++)
{
num3 += spawnableItems[j].rarity;
if (num3 >= num2)
{
objectInPresent = spawnableItems[j].spawnableItem.spawnPrefab;
objectInPresentValue = (int)((float)random.Next(spawnableItems[j].spawnableItem.minValue + 25, spawnableItems[j].spawnableItem.maxValue + 35) * RoundManager.Instance.scrapValueMultiplier);
break;
}
}
}
public override void EquipItem()
{
((GrabbableObject)this).EquipItem();
previousPlayerHeldBy = base.playerHeldBy;
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
if (Object.op_Implicit((Object)(object)doorLock))
{
if (!doorLock.isLocked)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (!((Object)(object)base.playerHeldBy == (Object)null) && !hasUsedGift)
{
hasUsedGift = true;
base.playerHeldBy.activatingItem = true;
OpenGiftBoxServerRpc();
}
}
}
else
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (!((Object)(object)base.playerHeldBy == (Object)null) && !hasUsedGift)
{
hasUsedGift = true;
base.playerHeldBy.activatingItem = true;
OpenGiftBoxServerRpc();
}
}
}
public override void PocketItem()
{
((GrabbableObject)this).PocketItem();
base.playerHeldBy.activatingItem = false;
}
[ServerRpc(RequireOwnership = false)]
public void OpenGiftBoxServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Invalid comparison between Unknown and I4
//IL_0104: 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_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3074326675u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3074326675u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 == null || !networkManager2.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager2.IsClient || networkManager2.IsHost))
{
ServerRpcParams val3 = default(ServerRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendServerRpc(2878544999u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val4, 2878544999u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager2.IsServer && !networkManager2.IsHost))
{
return;
}
GameObject val5 = null;
int num = 0;
Vector3 val6 = Vector3.zero;
if ((Object)(object)objectInPresent == (Object)null)
{
Debug.LogError((object)"Error: There is no object in gift box!");
}
else
{
Transform val7 = ((((!((Object)(object)base.playerHeldBy != (Object)null) || !base.playerHeldBy.isInElevator) && !StartOfRound.Instance.inShipPhase) || !((Object)(object)RoundManager.Instance.spawnedScrapContainer != (Object)null)) ? StartOfRound.Instance.elevatorTransform : RoundManager.Instance.spawnedScrapContainer);
val6 = ((Component)this).transform.position + Vector3.up * 0.25f;
val5 = Object.Instantiate<GameObject>(objectInPresent, val6, Quaternion.identity, val7);
GrabbableObject component = val5.GetComponent<GrabbableObject>();
component.startFallingPosition = val6;
((MonoBehaviour)this).StartCoroutine(SetObjectToHitGroundSFX(component));
component.targetFloorPosition = component.GetItemFloorPosition(((Component)this).transform.position);
if ((Object)(object)previousPlayerHeldBy != (Object)null && previousPlayerHeldBy.isInHangarShipRoom)
{
previousPlayerHeldBy.SetItemInElevator(true, true, component);
}
num = objectInPresentValue;
component.SetScrapValue(num);
((NetworkBehaviour)component).NetworkObject.Spawn(false);
}
if ((Object)(object)val5 != (Object)null)
{
OpenGiftBoxClientRpc(NetworkObjectReference.op_Implicit(val5.GetComponent<NetworkObject>()), num, val6);
}
OpenGiftBoxNoPresentClientRpc();
}
private IEnumerator SetObjectToHitGroundSFX(GrabbableObject gObject)
{
yield return (object)new WaitForEndOfFrame();
Debug.Log((object)("Setting " + gObject.itemProperties.itemName + " hit ground to false"));
gObject.reachedFloorTarget = false;
gObject.hasHitGround = false;
gObject.fallTime = 0f;
}
[ClientRpc]
public void OpenGiftBoxNoPresentClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Invalid comparison between Unknown and I4
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Invalid comparison between Unknown and I4
//IL_0100: 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_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2409335217u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2409335217u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 == null || !networkManager2.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager2.IsServer || networkManager2.IsHost))
{
ClientRpcParams val3 = default(ClientRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendClientRpc(3328558740u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val4, 3328558740u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager2.IsClient || networkManager2.IsHost))
{
PoofParticle.Play();
presentAudio.PlayOneShot(openGiftAudio);
WalkieTalkie.TransmitOneShotAudio(presentAudio, openGiftAudio, 1f);
RoundManager.Instance.PlayAudibleNoise(((Component)presentAudio).transform.position, 8f, 0.5f, 0, base.isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
if ((Object)(object)base.playerHeldBy != (Object)null)
{
base.playerHeldBy.activatingItem = false;
((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
}
}
}
[ClientRpc]
public void OpenGiftBoxClientRpc(NetworkObjectReference netObjectRef, int presentValue, Vector3 startFallingPos)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Invalid comparison between Unknown and I4
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Invalid comparison between Unknown and I4
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: 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)
//IL_0148: 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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2346037595u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
BytePacker.WriteValueBitPacked(val2, presentValue);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref startFallingPos);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2346037595u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 == null || !networkManager2.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager2.IsServer || networkManager2.IsHost))
{
ClientRpcParams val3 = default(ClientRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendClientRpc(1252354594u, val3, (RpcDelivery)0);
((FastBufferWriter)(ref val4)).WriteValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
BytePacker.WriteValueBitPacked(val4, presentValue);
((FastBufferWriter)(ref val4)).WriteValueSafe(ref startFallingPos);
((NetworkBehaviour)this).__endSendClientRpc(ref val4, 1252354594u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager2.IsClient || networkManager2.IsHost))
{
PoofParticle.Play();
presentAudio.PlayOneShot(openGiftAudio);
WalkieTalkie.TransmitOneShotAudio(presentAudio, openGiftAudio, 1f);
RoundManager.Instance.PlayAudibleNoise(((Component)presentAudio).transform.position, 8f, 0.5f, 0, base.isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
if ((Object)(object)base.playerHeldBy != (Object)null)
{
base.playerHeldBy.activatingItem = false;
((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
}
if (!((NetworkBehaviour)this).IsServer)
{
((MonoBehaviour)this).StartCoroutine(waitForGiftPresentToSpawnOnClient(netObjectRef, presentValue, startFallingPos));
}
}
}
private IEnumerator waitForGiftPresentToSpawnOnClient(NetworkObjectReference netObjectRef, int presentValue, Vector3 startFallingPos)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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)
NetworkObject netObject = null;
float startTime = Time.realtimeSinceStartup;
while (Time.realtimeSinceStartup - startTime < 8f && !((NetworkObjectReference)(ref netObjectRef)).TryGet(ref netObject, (NetworkManager)null))
{
yield return (object)new WaitForSeconds(0.03f);
}
if ((Object)(object)netObject == (Object)null)
{
Debug.Log((object)"No network object found");
yield break;
}
yield return (object)new WaitForEndOfFrame();
GrabbableObject component = ((Component)netObject).GetComponent<GrabbableObject>();
RoundManager instance = RoundManager.Instance;
instance.totalScrapValueInLevel -= (float)base.scrapValue;
RoundManager instance2 = RoundManager.Instance;
instance2.totalScrapValueInLevel += (float)component.scrapValue;
component.SetScrapValue(presentValue);
component.startFallingPosition = startFallingPos;
component.fallTime = 0f;
component.hasHitGround = false;
component.reachedFloorTarget = false;
if ((Object)(object)previousPlayerHeldBy != (Object)null && previousPlayerHeldBy.isInHangarShipRoom)
{
previousPlayerHeldBy.SetItemInElevator(true, true, component);
}
}
public override void __initializeVariables()
{
((GrabbableObject)this).__initializeVariables();
}
protected internal string __getTypeName()
{
return "CustomGiftBoxItem";
}
public override void Update()
{
((GrabbableObject)this).Update();
if (!Object.op_Implicit((Object)(object)doorLock) || !doorLock.isLocked)
{
return;
}
if (!doorLock.isPickingLock)
{
if (Object.op_Implicit((Object)(object)trigger))
{
GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
KeyItem val = null;
if ((Object)(object)base.playerHeldBy != (Object)null)
{
bool flag = (Object)(object)currentlyHeldObjectServer != (Object)null && ((Component)currentlyHeldObjectServer).TryGetComponent<KeyItem>(ref val);
trigger.disabledHoverTip = (flag ? "Unlock chest : [ LMB ]" : "Locked");
return;
}
LockPicker val2 = null;
bool flag2 = (Object)(object)currentlyHeldObjectServer != (Object)null && (((Component)currentlyHeldObjectServer).TryGetComponent<KeyItem>(ref val) || ((Component)currentlyHeldObjectServer).TryGetComponent<LockPicker>(ref val2));
trigger.disabledHoverTip = (flag2 ? "Unlock chest : [ LMB ]" : "Locked");
base.grabbable = true;
base.grabbableToEnemies = true;
}
}
else
{
if (doorLock.playersPickingDoor > 0)
{
doorLock.playerPickingLockProgress = Mathf.Clamp(doorLock.playerPickingLockProgress + (float)doorLock.playersPickingDoor * 0.85f * Time.deltaTime, 1f, 3.5f);
}
trigger.timeToHoldSpeedMultiplier = Mathf.Clamp((float)doorLock.playersPickingDoor * 0.85f, 1f, 3.5f);
DoorLock obj = doorLock;
obj.lockPickTimeLeft -= Time.deltaTime;
trigger.disabledHoverTip = $"Picking lock: {(int)doorLock.lockPickTimeLeft} sec.";
if (((NetworkBehaviour)this).IsServer && doorLock.lockPickTimeLeft < 0f)
{
UnlockChest();
UnlockChestServerRpc();
}
}
}
public void UnlockChest()
{
doorLock.doorLockSFX.Stop();
doorLock.doorLockSFX.PlayOneShot(doorLock.unlockSFX);
if (doorLock.isLocked)
{
((Component)trigger).gameObject.SetActive(false);
doorLock.isPickingLock = false;
base.grabbable = true;
base.grabbableToEnemies = true;
doorLock.isLocked = false;
Debug.Log((object)"Unlocking chest");
}
}
public void UnlockChestSyncWithServer()
{
if (doorLock.isLocked)
{
UnlockChest();
UnlockChestServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
public void UnlockChestServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Invalid comparison between Unknown and I4
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Invalid comparison between Unknown and I4
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: 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_0115: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1509870645u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1509870645u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 != null && networkManager2.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager2.IsClient || networkManager2.IsHost))
{
ServerRpcParams val3 = default(ServerRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendServerRpc(184554516u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val4, 184554516u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager2.IsServer || networkManager2.IsHost))
{
UnlockChestClientRpc();
}
}
}
[ClientRpc]
public void UnlockChestClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Invalid comparison between Unknown and I4
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Invalid comparison between Unknown and I4
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: 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_0115: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3101790943u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3101790943u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 != null && networkManager2.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager2.IsServer || networkManager2.IsHost))
{
ClientRpcParams val3 = default(ClientRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendClientRpc(1778576778u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val4, 1778576778u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager2.IsClient || networkManager2.IsHost))
{
UnlockChest();
}
}
}
public void TryPickingLock()
{
if (doorLock.isLocked)
{
HUDManager.Instance.holdFillAmount = doorLock.playerPickingLockProgress;
if (!doorLock.localPlayerPickingLock)
{
doorLock.localPlayerPickingLock = true;
PlayerPickLockServerRpc();
}
}
}
public void StopPickingLock()
{
if (doorLock.localPlayerPickingLock)
{
doorLock.localPlayerPickingLock = false;
if (doorLock.playersPickingDoor == 1)
{
doorLock.playerPickingLockProgress = Mathf.Clamp(doorLock.playerPickingLockProgress - 1f, 0f, 45f);
}
PlayerStopPickingLockServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
public void PlayerStopPickingLockServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Invalid comparison between Unknown and I4
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Invalid comparison between Unknown and I4
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: 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_0115: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(990236973u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 990236973u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 != null && networkManager2.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager2.IsClient || networkManager2.IsHost))
{
ServerRpcParams val3 = default(ServerRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendServerRpc(3458026102u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val4, 3458026102u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager2.IsServer || networkManager2.IsHost))
{
PlayerStopPickingLockClientRpc();
}
}
}
[ClientRpc]
public void PlayerStopPickingLockClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Invalid comparison between Unknown and I4
//IL_00fb: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2465752461u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2465752461u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 != null && networkManager2.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager2.IsServer || networkManager2.IsHost))
{
ClientRpcParams val3 = default(ClientRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendClientRpc(3319502281u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val4, 3319502281u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager2.IsClient || networkManager2.IsHost))
{
doorLock.doorLockSFX.Stop();
doorLock.playersPickingDoor = Mathf.Clamp(doorLock.playersPickingDoor - 1, 0, 4);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void PlayerPickLockServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Invalid comparison between Unknown and I4
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Invalid comparison between Unknown and I4
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: 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_0115: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2530714241u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2530714241u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 != null && networkManager2.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager2.IsClient || networkManager2.IsHost))
{
ServerRpcParams val3 = default(ServerRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendServerRpc(2269869251u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val4, 2269869251u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager2.IsServer || networkManager2.IsHost))
{
PlayerPickLockClientRpc();
}
}
}
[ClientRpc]
public void PlayerPickLockClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Invalid comparison between Unknown and I4
//IL_00fb: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(928987699u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 928987699u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
NetworkManager networkManager2 = ((NetworkBehaviour)this).NetworkManager;
if (networkManager2 != null && networkManager2.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager2.IsServer || networkManager2.IsHost))
{
ClientRpcParams val3 = default(ClientRpcParams);
FastBufferWriter val4 = ((NetworkBehaviour)this).__beginSendClientRpc(1721192172u, val3, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val4, 1721192172u, val3, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager2.IsClient || networkManager2.IsHost))
{
doorLock.doorLockSFX.clip = doorLock.pickingLockSFX;
doorLock.doorLockSFX.Play();
doorLock.playersPickingDoor = Mathf.Clamp(doorLock.playersPickingDoor + 1, 0, 4);
}
}
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_CustomGiftBoxItem()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3074326675u, new RpcReceiveHandler(__rpc_handler_3074326675));
NetworkManager.__rpc_func_table.Add(2409335217u, new RpcReceiveHandler(__rpc_handler_2409335217));
NetworkManager.__rpc_func_table.Add(2346037595u, new RpcReceiveHandler(__rpc_handler_2346037595));
NetworkManager.__rpc_func_table.Add(1509870645u, new RpcReceiveHandler(__rpc_handler_1509870645));
NetworkManager.__rpc_func_table.Add(3101790943u, new RpcReceiveHandler(__rpc_handler_3101790943));
NetworkManager.__rpc_func_table.Add(990236973u, new RpcReceiveHandler(__rpc_handler_990236973));
NetworkManager.__rpc_func_table.Add(2465752461u, new RpcReceiveHandler(__rpc_handler_2465752461));
NetworkManager.__rpc_func_table.Add(2530714241u, new RpcReceiveHandler(__rpc_handler_2530714241));
NetworkManager.__rpc_func_table.Add(928987699u, new RpcReceiveHandler(__rpc_handler_928987699));
}
private static void __rpc_handler_3074326675(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((CustomGiftBoxItem)(object)target).OpenGiftBoxServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2409335217(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomGiftBoxItem)(object)target).OpenGiftBoxNoPresentClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2346037595(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference netObjectRef = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
int presentValue = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref presentValue);
Vector3 startFallingPos = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref startFallingPos);
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomGiftBoxItem)(object)target).OpenGiftBoxClientRpc(netObjectRef, presentValue, startFallingPos);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1509870645(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((CustomGiftBoxItem)(object)target).UnlockChestServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3101790943(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomGiftBoxItem)(object)target).UnlockChestClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_990236973(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((CustomGiftBoxItem)(object)target).PlayerStopPickingLockServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2465752461(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomGiftBoxItem)(object)target).PlayerStopPickingLockClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2530714241(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((CustomGiftBoxItem)(object)target).PlayerPickLockServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_928987699(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomGiftBoxItem)(object)target).PlayerPickLockClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "CustomGiftBoxItem";
}
}
[BepInPlugin("Boniato.Ganimedes", "Ganimedes", "2.1.0")]
public class GanimedesBase : BaseUnityPlugin
{
private const string modGUID = "Boniato.Ganimedes";
private const string modName = "Ganimedes";
private const string modVersion = "2.1.0";
private readonly Harmony harmony = new Harmony("Boniato.Ganimedes");
internal static GanimedesBase instance;
internal static ManualLogSource mls;
public static Config cfg { get; internal set; }
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
mls = Logger.CreateLogSource("Boniato.Ganimedes");
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
cfg = new Config(((BaseUnityPlugin)this).Config);
harmony.PatchAll(typeof(Config));
harmony.PatchAll(typeof(RouteCostPatch));
harmony.PatchAll(typeof(BoomboxPatches));
harmony.PatchAll(typeof(LockPickerPatch));
harmony.PatchAll(typeof(DoorLockPatch));
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ganimedesscrap");
AssetBundle val = AssetBundle.LoadFromFile(text);
List<Item> list = new List<Item>
{
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/bronzebar/BronzeBar.asset"),
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/silverbar/SilverBar.asset"),
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/emerald/Emerald.asset"),
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/ruby/Ruby.asset"),
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/diamond/Diamond.asset"),
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/pickaxe/Pickaxe.asset"),
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/chest/Chest.asset"),
val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/greatchest/GreatChest.asset")
};
Item val2 = val.LoadAsset<Item>("Assets/Scenes/Ganimedes/items/scraps/mp3/MP3.asset");
GameObject spawnPrefab = val2.spawnPrefab;
Utilities.FixMixerGroups(spawnPrefab);
spawnPrefab.GetComponent<AudioSource>().volume = cfg.mp3Volume;
List<AudioClip> list2 = new List<AudioClip>();
if (cfg.mp3CustomSongs)
{
CustomSongs(list2);
}
AudioClip[] musicAudios = spawnPrefab.GetComponent<BoomboxItem>().musicAudios;
if (cfg.mp3DefaultSongsChanges)
{
if (cfg.mp3song1)
{
list2.Add(musicAudios[0]);
}
if (cfg.mp3song2)
{
list2.Add(musicAudios[1]);
}
if (cfg.mp3song3)
{
list2.Add(musicAudios[2]);
}
if (cfg.mp3song4)
{
list2.Add(musicAudios[3]);
}
if (cfg.mp3song5)
{
list2.Add(musicAudios[4]);
}
if (cfg.mp3song6)
{
list2.Add(musicAudios[5]);
}
if (cfg.mp3song7)
{
list2.Add(musicAudios[6]);
}
if (cfg.mp3song8)
{
list2.Add(musicAudios[7]);
}
if (cfg.mp3song9)
{
list2.Add(musicAudios[8]);
}
if (cfg.mp3song10)
{
list2.Add(musicAudios[9]);
}
}
else
{
for (int k = 0; k < musicAudios.Count(); k++)
{
list2.Add(musicAudios[k]);
}
}
if (list2.Count == 0 || cfg.mp3BoomboxVanilla)
{
list2.Add(val.LoadAsset<AudioClip>("Assets/Scenes/Ganimedes/items/scraps/mp3/boomboxmusic/BoomboxMusic1.ogg"));
list2.Add(val.LoadAsset<AudioClip>("Assets/Scenes/Ganimedes/items/scraps/mp3/boomboxmusic/BoomboxMusic2.ogg"));
list2.Add(val.LoadAsset<AudioClip>("Assets/Scenes/Ganimedes/items/scraps/mp3/boomboxmusic/BoomboxMusic3.ogg"));
list2.Add(val.LoadAsset<AudioClip>("Assets/Scenes/Ganimedes/items/scraps/mp3/boomboxmusic/BoomboxMusic4.ogg"));
list2.Add(val.LoadAsset<AudioClip>("Assets/Scenes/Ganimedes/items/scraps/mp3/boomboxmusic/BoomboxMusic5Zedfox.ogg"));
}
spawnPrefab.GetComponent<BoomboxItem>().musicAudios = list2.ToArray();
NetworkPrefabs.RegisterNetworkPrefab(spawnPrefab);
Items.RegisterScrap(val2, 0, (LevelTypes)1);
foreach (Item item in list)
{
NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
Utilities.FixMixerGroups(item.spawnPrefab);
Items.RegisterScrap(item, 0, (LevelTypes)1);
}
mls.LogInfo((object)"------- Ganimedes plugin loaded -------");
}
public static void CustomSongs(List<AudioClip> songsList)
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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)
//IL_00b4: Invalid comparison between Unknown and I4
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
string text = (cfg.mp3CustomSongsDirectory ? Path.Combine(Paths.BepInExRootPath, "Custom Songs", "Boombox Music") : Path.Combine(Paths.BepInExRootPath, "plugins", "Ganimedes", "CustomSongs"));
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
mls.LogInfo((object)("Created directory at " + text));
}
string[] files = Directory.GetFiles(text);
if (files.Length == 0)
{
mls.LogWarning((object)"No songs found");
return;
}
for (int i = 0; i < files.Length; i++)
{
AudioType audioType = GetAudioType(files[i]);
if ((int)audioType > 0)
{
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(files[i], audioType);
audioClip.SendWebRequest();
while (!audioClip.isDone && audioClip.error == null)
{
Thread.Sleep(50);
}
if (audioClip.error != null)
{
mls.LogWarning((object)("Error loading song: " + text));
}
else
{
songsList.Add(DownloadHandlerAudioClip.GetContent(audioClip));
}
}
}
}
public static AudioType GetAudioType(string path)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
string text = Path.GetExtension(path).ToLower();
switch (text)
{
case ".wav":
return (AudioType)20;
case ".ogg":
return (AudioType)14;
case ".mp3":
return (AudioType)13;
default:
mls.LogError((object)("Error loading song. Unsupported extension type: " + text));
return (AudioType)0;
}
}
}
[Serializable]
public class SyncedInstance<T>
{
[NonSerialized]
protected static int IntSize = 4;
internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;
internal static bool IsClient => NetworkManager.Singleton.IsClient;
internal static bool IsHost => NetworkManager.Singleton.IsHost;
public static T Default { get; private set; }
public static T Instance { get; private set; }
public static bool Synced { get; internal set; }
protected void InitInstance(T instance)
{
Default = instance;
Instance = instance;
IntSize = 4;
}
internal static void SyncInstance(byte[] data)
{
Instance = DeserializeFromBytes(data);
Synced = true;
}
internal static void RevertSync()
{
Instance = Default;
Synced = false;
}
public static byte[] SerializeToBytes(T val)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using MemoryStream memoryStream = new MemoryStream();
try
{
binaryFormatter.Serialize(memoryStream, val);
return memoryStream.ToArray();
}
catch (Exception arg)
{
Plugin.logger.LogError((object)$"Error serializing instance: {arg}");
return null;
}
}
public static T DeserializeFromBytes(byte[] data)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using MemoryStream serializationStream = new MemoryStream(data);
try
{
return (T)binaryFormatter.Deserialize(serializationStream);
}
catch (Exception arg)
{
Plugin.logger.LogError((object)$"Error deserializing instance: {arg}");
return default(T);
}
}
}
}
namespace Ganimedes.Patches
{
[HarmonyPatch]
public class BoomboxPatches
{
private static Dictionary<BoomboxItem, bool> seedSyncDictionary = new Dictionary<BoomboxItem, bool>();
private static FieldInfo playersManagerField = AccessTools.Field(typeof(BoomboxItem), "playersManager");
[HarmonyPatch(typeof(BoomboxItem), "StartMusic")]
[HarmonyPrefix]
public static void StartMusicPatch(BoomboxItem __instance)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
StartOfRound val = (StartOfRound)playersManagerField.GetValue(__instance);
if ((!seedSyncDictionary.TryGetValue(__instance, out var value) || !value) && val != null && val.randomMapSeed > 0)
{
int seed = val.randomMapSeed - 10;
__instance.musicRandomizer = new Random(seed);
seedSyncDictionary[__instance] = true;
}
}
[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
[HarmonyPrefix]
public static void OnPlayerConnectedPatch(StartOfRound __instance)
{
forceReinitialize(seedSyncDictionary);
}
[HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")]
[HarmonyPrefix]
public static void openingDoorsSequencePatch(StartOfRound __instance)
{
forceReinitialize(seedSyncDictionary);
}
private static void forceReinitialize(Dictionary<BoomboxItem, bool> seedSyncDictionary)
{
foreach (BoomboxItem item in seedSyncDictionary.Keys.ToList())
{
seedSyncDictionary[item] = false;
}
}
}
[HarmonyPatch(typeof(DoorLock))]
internal class DoorLockPatch
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static bool UpdatePatched(DoorLock __instance)
{
CustomGiftBoxItem componentInParent = ((Component)__instance).gameObject.GetComponentInParent<CustomGiftBoxItem>();
if ((Object)(object)componentInParent != (Object)null)
{
return false;
}
return true;
}
[HarmonyPatch("UnlockDoorSyncWithServer")]
[HarmonyPrefix]
public static bool UnlockDoorSyncWithServerPatched(DoorLock __instance)
{
CustomGiftBoxItem componentInParent = ((Component)__instance).gameObject.GetComponentInParent<CustomGiftBoxItem>();
if ((Object)(object)componentInParent != (Object)null)
{
componentInParent.UnlockChestSyncWithServer();
return false;
}
return true;
}
[HarmonyPatch("LockDoor")]
[HarmonyPrefix]
public static bool LockDoorPatched(DoorLock __instance)
{
CustomGiftBoxItem componentInParent = ((Component)__instance).gameObject.GetComponentInParent<CustomGiftBoxItem>();
if ((Object)(object)componentInParent != (Object)null)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(LockPicker))]
internal class LockPickerPatch
{
[HarmonyPatch("ItemActivate")]
[HarmonyPrefix]
public static bool ItemActivatePatched(LockPicker __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
__instance.ray = new Ray(((Component)((GrabbableObject)__instance).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)__instance).playerHeldBy.gameplayCamera).transform.forward);
if (Physics.Raycast(__instance.ray, ref __instance.hit, 3f, 2816))
{
DoorLock component = ((Component)((RaycastHit)(ref __instance.hit)).transform).GetComponent<DoorLock>();
CustomGiftBoxItem componentInParent = ((Component)component).gameObject.GetComponentInParent<CustomGiftBoxItem>();
if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)((GrabbableObject)componentInParent).playerHeldBy))
{
return false;
}
}
return true;
}
[HarmonyPatch("GetLockPickerDoorPosition")]
[HarmonyPrefix]
public static bool GetLockPickerDoorPositionPatched(ref Vector3 __result, DoorLock doorScript, LockPicker __instance)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
CustomGiftBoxItem componentInParent = ((Component)doorScript).gameObject.GetComponentInParent<CustomGiftBoxItem>();
if ((Object)(object)componentInParent != (Object)null)
{
__instance.placeOnLockPicker1 = true;
__result = doorScript.lockPickerPosition.localPosition;
return false;
}
return true;
}
[HarmonyPatch("PlaceOnDoor")]
[HarmonyPrefix]
public static bool PlaceOnDoorPatched(DoorLock doorScript, LockPicker __instance)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.isOnDoor)
{
CustomGiftBoxItem componentInParent = ((Component)doorScript).gameObject.GetComponentInParent<CustomGiftBoxItem>();
if (Object.op_Implicit((Object)(object)componentInParent))
{
((GrabbableObject)componentInParent).grabbable = false;
((GrabbableObject)componentInParent).grabbableToEnemies = false;
((Component)__instance).transform.localScale = componentInParent.doorLock.lockPickerPosition.localScale;
}
}
return true;
}
}
}
namespace Ganimedes.Configuration
{
[HarmonyPatch(typeof(Terminal))]
public class RouteCostPatch
{
[HarmonyPatch("LoadNewNode")]
[HarmonyPrefix]
private static void LoadNewNodePatchBefore(ref TerminalNode node)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
if (SyncedInstance<Config>.Instance.routeCost == 1200)
{
return;
}
Terminal val = Object.FindObjectOfType<Terminal>();
CompatibleNoun[] compatibleNouns = val.terminalNodes.allKeywords.First((TerminalKeyword terminalKeyword) => terminalKeyword.word == "route").compatibleNouns;
CompatibleNoun[] array = compatibleNouns;
foreach (CompatibleNoun val2 in array)
{
if (!((Object)val2.result == (Object)null) && ((Object)val2.result).name == "ganimedesRoute")
{
val2.result.itemCost = SyncedInstance<Config>.Instance.routeCost;
}
}
}
[HarmonyPatch("LoadNewNodeIfAffordable")]
[HarmonyPrefix]
private static void LoadNewNodeIfAffordablePatch(ref TerminalNode node)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
if (SyncedInstance<Config>.Instance.routeCost != 1200 && !((Object)node == (Object)null) && !(((Object)node).name != "ganimedesRouteConfirm"))
{
node.itemCost = Math.Abs(SyncedInstance<Config>.Instance.routeCost);
}
}
}
}
namespace Ganimedes.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}