using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MoreCompany;
using MoreCompany.Cosmetics;
using Silly_Things.Codes.PortalGun;
using Silly_Things.NetcodePatcher;
using Silly_Things.codes.MorphingCase;
using Silly_Things.codes.SnakeCardboardBox;
using Steamworks;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Silly_Things")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+db6fd4a82b8fca251adba598a2938e8bcfbd427d")]
[assembly: AssemblyProduct("Silly_Things")]
[assembly: AssemblyTitle("Silly_Things")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace Silly_Things
{
internal class Config
{
public ConfigEntry<int> MorphingCaseItemRarity { get; private set; }
public ConfigEntry<int> SnakeCardboardBox { get; private set; }
public Config(ConfigFile configFile)
{
configFile.SaveOnConfigSet = false;
MorphingCaseItemRarity = configFile.Bind<int>("Spawn Rates", "MorphingCaseItemRarity", 10, "Rarity of the Morphing Case Item (higher = more common).");
SnakeCardboardBox = configFile.Bind<int>("Spawn Rates", "SnakeCardboardBoxItemRarity", 10, "Rarity of the Snake Card Box Item (higher = more common).");
configFile.Save();
configFile.SaveOnConfigSet = true;
}
}
[BepInPlugin("POUY.SILLY_THINGS", "Silly Things", "0.0.2")]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "POUY.SILLY_THINGS";
private const string NAME = "Silly Things";
private const string VERSION = "0.0.2";
public readonly Harmony harmony = new Harmony("POUY.SILLY_THINGS");
public GameObject? UI_MorphingCase;
public AudioClip SoundOpenUI = null;
public AudioClip SoundCloseUI = null;
public GameObject? UI_SnakeCardboardBox;
public GameObject? BigCardboardBoxPrefab;
public AudioClip SoundOpenCardboardBox = null;
public AudioClip SoundCloseCardboardBox = null;
public GameObject? PortalPrefab;
public static Plugin Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Config SillyThingsConfig { get; private set; }
internal ManageCosmetics CosmeticsManager { get; private set; } = null;
public void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
SillyThingsConfig = new Config(((BaseUnityPlugin)this).Config);
CosmeticsManager = new ManageCosmetics();
if (PlayerPrefs.HasKey("MorphingCase_PreviousCosmetics"))
{
CosmeticsManager.RestorePreviousCosmetics();
PlayerPrefs.DeleteKey("MorphingCase_PreviousCosmetics");
PlayerPrefs.DeleteKey("MorphingCase_PreviousSuit");
}
LoadAssetBundle();
Logger.LogMessage((object)"Silly things Loaded !");
harmony.PatchAll();
}
private void LoadAssetBundle()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "sillythings");
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
Logger.LogError((object)"Failed to load asset bundle");
return;
}
LoadAudioSource(val);
LoadMorphingCase(val);
LoadSnakeCardboardBox(val);
}
public void LoadAudioSource(AssetBundle bundle)
{
SoundOpenUI = bundle.LoadAsset<AudioClip>("Assets/LethalModding/MorphingCase/Case/open.ogg");
SoundCloseUI = bundle.LoadAsset<AudioClip>("Assets/LethalModding/MorphingCase/Case/close.ogg");
SoundOpenCardboardBox = bundle.LoadAsset<AudioClip>("Assets/LethalModding/SnakeCardboardBox/SnakeCardboardBox/open.ogg");
SoundCloseCardboardBox = bundle.LoadAsset<AudioClip>("Assets/LethalModding/SnakeCardboardBox/SnakeCardboardBox/close.ogg");
}
public void OnApplicationQuit()
{
CosmeticsManager.RestorePreviousCosmetics();
}
public void LoadMorphingCase(AssetBundle bundle)
{
UI_MorphingCase = bundle.LoadAsset<GameObject>("Assets/LethalModding/MorphingCase/UI/UICase.prefab");
Item val = bundle.LoadAsset<Item>("Assets/LethalModding/MorphingCase/Case/ShapeshiftCaseItem.asset");
MorphingCase morphingCase = val.spawnPrefab.AddComponent<MorphingCase>();
((Object)morphingCase).name = "Morphing Case";
((GrabbableObject)morphingCase).grabbable = true;
((GrabbableObject)morphingCase).grabbableToEnemies = true;
((GrabbableObject)morphingCase).itemProperties = val;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, SillyThingsConfig.MorphingCaseItemRarity.Value, (LevelTypes)(-1));
}
public void LoadSnakeCardboardBox(AssetBundle bundle)
{
BigCardboardBoxPrefab = bundle.LoadAsset<GameObject>("Assets/LethalModding/SnakeCardboardBox/BoxOnPlayer/CardBoardModel.prefab");
NetworkPrefabs.RegisterNetworkPrefab(BigCardboardBoxPrefab);
UI_SnakeCardboardBox = bundle.LoadAsset<GameObject>("Assets/LethalModding/SnakeCardboardBox/UI/CardboardBox.prefab");
Item val = bundle.LoadAsset<Item>("Assets/LethalModding/SnakeCardboardBox/SnakeCardboardBox/CardBoardBoxItem.asset");
SnakeCardboardBox snakeCardboardBox = val.spawnPrefab.AddComponent<SnakeCardboardBox>();
((GrabbableObject)snakeCardboardBox).grabbable = true;
((Object)snakeCardboardBox).name = "A simple cardboard";
((GrabbableObject)snakeCardboardBox).grabbableToEnemies = true;
((GrabbableObject)snakeCardboardBox).itemProperties = val;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, SillyThingsConfig.SnakeCardboardBox.Value, (LevelTypes)(-1));
}
public void LoadPortalGun(AssetBundle bundle)
{
LoadPortalPrefab(bundle);
Item val = bundle.LoadAsset<Item>("Assets/LethalModding/PortalGun/PortalGunItem.asset");
PortalGun portalGun = val.spawnPrefab.AddComponent<PortalGun>();
((GrabbableObject)portalGun).grabbable = true;
((Object)portalGun).name = "Portal Gun";
((GrabbableObject)portalGun).grabbableToEnemies = true;
((GrabbableObject)portalGun).itemProperties = val;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, SillyThingsConfig.SnakeCardboardBox.Value, (LevelTypes)(-1));
}
public void LoadPortalPrefab(AssetBundle bundle)
{
PortalPrefab = bundle.LoadAsset<GameObject>("Assets/LethalModding/PortalGun/portal/Portal.prefab");
if ((Object)(object)PortalPrefab == (Object)null)
{
Logger.LogError((object)"Portal prefab not found!");
return;
}
if ((Object)(object)PortalPrefab.GetComponent<Portal>() == (Object)null)
{
PortalPrefab.AddComponent<Portal>();
}
Rigidbody val = PortalPrefab.GetComponent<Rigidbody>();
if ((Object)(object)val == (Object)null)
{
val = PortalPrefab.AddComponent<Rigidbody>();
}
val.isKinematic = true;
val.useGravity = false;
Collider val2 = PortalPrefab.GetComponent<Collider>();
if ((Object)(object)val2 == (Object)null)
{
val2 = (Collider)(object)PortalPrefab.AddComponent<BoxCollider>();
}
val2.isTrigger = true;
NetworkPrefabs.RegisterNetworkPrefab(PortalPrefab);
}
}
}
namespace Silly_Things.Codes.PortalGun
{
public class Portal : NetworkBehaviour
{
private ulong linkedPortalId;
private Renderer portalRenderer;
private HashSet<PlayerControllerB> teleportingPlayers = new HashSet<PlayerControllerB>();
private bool isPortalA;
public Dictionary<PlayerControllerB, float> teleportTimers = new Dictionary<PlayerControllerB, float>();
public void Setup(bool portalType)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
isPortalA = portalType;
portalRenderer = ((Component)this).GetComponentInChildren<Renderer>();
if ((Object)(object)portalRenderer != (Object)null)
{
portalRenderer.material.color = (isPortalA ? new Color(0.2f, 0.4f, 1f) : new Color(1f, 0.5f, 0f));
}
}
public void SetLinkedPortal(ulong id)
{
linkedPortalId = id;
}
public void OnTriggerEnter(Collider other)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_00df: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)this).IsServer)
{
return;
}
PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
if (!((Object)(object)component == (Object)null) && !teleportingPlayers.Contains(component) && NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(linkedPortalId, out var value))
{
Portal component2 = ((Component)value).GetComponent<Portal>();
if (!((Object)(object)component2 == (Object)null))
{
Vector3 val = ((Component)this).transform.InverseTransformDirection(component.thisController.velocity);
Vector3 externalForces = ((Component)component2).transform.TransformDirection(val);
Vector3 val2 = ((Component)component2).transform.position + ((Component)component2).transform.forward * 1.5f;
component.TeleportPlayer(val2, false, 0f, false, true);
component.externalForces = externalForces;
component2.AddTeleportingPlayer(component);
AddTeleportingPlayer(component);
}
}
}
public void AddTeleportingPlayer(PlayerControllerB player)
{
teleportingPlayers.Add(player);
teleportTimers[player] = Time.time + 0.2f;
}
public void Update()
{
List<PlayerControllerB> list = new List<PlayerControllerB>();
foreach (KeyValuePair<PlayerControllerB, float> teleportTimer in teleportTimers)
{
if (Time.time >= teleportTimer.Value)
{
list.Add(teleportTimer.Key);
}
}
foreach (PlayerControllerB item in list)
{
teleportTimers.Remove(item);
teleportingPlayers.Remove(item);
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
((NetworkBehaviour)this).__initializeRpcs();
}
protected internal override string __getTypeName()
{
return "Portal";
}
}
public class PortalGun : PhysicsProp
{
private AudioSource audio;
private static NetworkObject portalA;
private static NetworkObject portalB;
private bool shootPortalA = true;
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
audio = ((Component)((Component)this).transform.Find("Audio")).GetComponent<AudioSource>();
}
public override void ItemInteractLeftRight(bool right)
{
((GrabbableObject)this).ItemInteractLeftRight(right);
if (right && !((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) && ((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner)
{
shootPortalA = !shootPortalA;
SyncSoundsClientRpc(1);
}
}
public override void EquipItem()
{
SetControlTips();
((GrabbableObject)this).EnableItemMeshes(true);
((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
((GrabbableObject)this).isPocketed = false;
if (!((GrabbableObject)this).hasBeenHeld)
{
((GrabbableObject)this).hasBeenHeld = true;
if (!((GrabbableObject)this).isInShipRoom && !StartOfRound.Instance.inShipPhase && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
{
RoundManager instance = RoundManager.Instance;
instance.valueOfFoundScrapItems += ((GrabbableObject)this).scrapValue;
}
}
}
public override void SetControlTipsForItem()
{
SetControlTips();
}
private void SetControlTips()
{
string[] array = new string[2] { "Place Portal : [LMB]", "Switch Portal (A/B) : [E]" };
if (((NetworkBehaviour)this).IsOwner)
{
HUDManager.Instance.ClearControlTips();
HUDManager.Instance.ChangeControlTipMultiple(array, true, ((GrabbableObject)this).itemProperties);
}
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
//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)
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner && buttonDown)
{
ShootPortalServerRpc(shootPortalA);
}
}
[ServerRpc]
private void ShootPortalServerRpc(bool isPortalA, ServerRpcParams rpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: 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))
{
if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
return;
}
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(4200387258u, rpcParams, (RpcDelivery)0);
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref isPortalA, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val, 4200387258u, rpcParams, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
if (!((NetworkBehaviour)this).IsServer)
{
return;
}
PlayerControllerB playerFromClient = GetPlayerFromClient(rpcParams.Receive.SenderClientId);
if (!((Object)(object)playerFromClient == (Object)null) && TryGetHitPoint(playerFromClient, out var hit))
{
NetworkObject val2 = SpawnPortal(hit, isPortalA);
if (!((Object)(object)val2 == (Object)null))
{
RegisterPortal(val2, isPortalA);
LinkPortalsIfReady();
SyncSoundsClientRpc(0);
}
}
}
private PlayerControllerB GetPlayerFromClient(ulong clientId)
{
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).OwnerClientId == clientId)
{
return val;
}
}
Plugin.Logger.LogError((object)("Player not found for clientId: " + clientId));
return null;
}
private bool TryGetHitPoint(PlayerControllerB player, out RaycastHit hit)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
hit = default(RaycastHit);
if ((Object)(object)player.gameplayCamera == (Object)null)
{
Plugin.Logger.LogError((object)"Player camera is null");
return false;
}
Ray val = default(Ray);
((Ray)(ref val))..ctor(((Component)player.gameplayCamera).transform.position, ((Component)player.gameplayCamera).transform.forward);
return Physics.Raycast(val, ref hit, 50f);
}
private NetworkObject SpawnPortal(RaycastHit hit, bool isPortalA)
{
//IL_0022: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Plugin.Instance.PortalPrefab == (Object)null)
{
return null;
}
Quaternion rotation = CalculatePortalRotation(((RaycastHit)(ref hit)).normal);
Vector3 position = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.01f;
GameObject val = CreatePortalObject(position, rotation);
if ((Object)(object)val == (Object)null)
{
return null;
}
Portal portal = SetupPortalComponent(val, isPortalA);
PortalView portalView = SetupPortalView(val, portal, isPortalA);
portalView.playerCameraTransform = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform;
Renderer componentInChildren = val.GetComponentInChildren<Renderer>();
if ((Object)(object)componentInChildren == (Object)null)
{
Plugin.Logger.LogError((object)"Portal prefab missing a child Renderer for the portal screen!");
}
portalView.portalScreenRenderer = componentInChildren;
return val.GetComponent<NetworkObject>();
}
private Quaternion CalculatePortalRotation(Vector3 normal)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_003b: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
if (Vector3.Dot(normal, Vector3.up) > 0.9f)
{
return Quaternion.Euler(0f, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.eulerAngles.y, 0f);
}
if (Vector3.Dot(normal, Vector3.down) > 0.9f)
{
return Quaternion.Euler(180f, ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform.eulerAngles.y, 0f);
}
Vector3 val = Vector3.Cross(Vector3.up, -normal);
return Quaternion.LookRotation(val, Vector3.up);
}
private GameObject CreatePortalObject(Vector3 position, Quaternion rotation)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(Plugin.Instance.PortalPrefab, position, rotation);
NetworkObject val2 = val.GetComponent<NetworkObject>();
if ((Object)(object)val2 == (Object)null)
{
val2 = val.AddComponent<NetworkObject>();
}
val2.Spawn(false);
return val;
}
private Portal SetupPortalComponent(GameObject obj, bool isPortalA)
{
Portal portal = obj.GetComponent<Portal>();
if ((Object)(object)portal == (Object)null)
{
portal = obj.AddComponent<Portal>();
}
portal.Setup(isPortalA);
return portal;
}
private PortalView SetupPortalView(GameObject obj, Portal portal, bool isPortalA)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
PortalView portalView = obj.GetComponent<PortalView>();
if ((Object)(object)portalView == (Object)null)
{
portalView = obj.AddComponent<PortalView>();
}
portalView.linkedPortal = ((isPortalA && (Object)(object)portalB != (Object)null) ? ((Component)portalB).GetComponent<Portal>() : ((!isPortalA && (Object)(object)portalA != (Object)null) ? ((Component)portalA).GetComponent<Portal>() : null));
GameObject val = new GameObject("PortalCamera");
val.transform.SetParent(obj.transform);
Camera val2 = val.AddComponent<Camera>();
val2.clearFlags = (CameraClearFlags)1;
val2.fieldOfView = 60f;
val2.targetTexture = new RenderTexture(512, 512, 16);
portalView.portalCamera = val2;
Renderer componentInChildren = obj.GetComponentInChildren<Renderer>();
portalView.portalScreenRenderer = componentInChildren;
return portalView;
}
private void RegisterPortal(NetworkObject netObj, bool isPortalA)
{
if (isPortalA)
{
if ((Object)(object)portalA != (Object)null && portalA.IsSpawned)
{
portalA.Despawn(true);
}
portalA = netObj;
}
else
{
if ((Object)(object)portalB != (Object)null && portalB.IsSpawned)
{
portalB.Despawn(true);
}
portalB = netObj;
}
}
private void LinkPortalsIfReady()
{
if (!((Object)(object)portalA == (Object)null) && !((Object)(object)portalB == (Object)null) && portalA.IsSpawned && portalB.IsSpawned)
{
Portal component = ((Component)portalA).GetComponent<Portal>();
Portal component2 = ((Component)portalB).GetComponent<Portal>();
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
{
Plugin.Logger.LogError((object)"Portal component missing when linking");
return;
}
component.SetLinkedPortal(portalB.NetworkObjectId);
component2.SetLinkedPortal(portalA.NetworkObjectId);
}
}
[ClientRpc]
private void SyncSoundsClientRpc(int idSound)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1908711745u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, idSound);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1908711745u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
switch (idSound)
{
case 0:
{
AudioSource obj2 = audio;
if (obj2 != null)
{
obj2.PlayOneShot(Plugin.Instance.SoundOpenCardboardBox);
}
break;
}
case 1:
{
AudioSource obj = audio;
if (obj != null)
{
obj.PlayOneShot(Plugin.Instance.SoundCloseCardboardBox);
}
break;
}
}
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(4200387258u, new RpcReceiveHandler(__rpc_handler_4200387258), "ShootPortalServerRpc");
((NetworkBehaviour)this).__registerRpc(1908711745u, new RpcReceiveHandler(__rpc_handler_1908711745), "SyncSoundsClientRpc");
((PhysicsProp)this).__initializeRpcs();
}
private static void __rpc_handler_4200387258(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
NetworkManager networkManager = target.NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
}
else
{
bool isPortalA = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isPortalA, default(ForPrimitives));
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((PortalGun)(object)target).ShootPortalServerRpc(isPortalA, server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1908711745(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int idSound = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref idSound);
target.__rpc_exec_stage = (__RpcExecStage)1;
((PortalGun)(object)target).SyncSoundsClientRpc(idSound);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "PortalGun";
}
}
public class PortalView : NetworkBehaviour
{
public Camera portalCamera;
public Renderer portalScreenRenderer;
public Portal linkedPortal;
public Transform playerCameraTransform;
public void LateUpdate()
{
//IL_0104: 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_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: 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_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)linkedPortal == (Object)null || (Object)(object)portalCamera == (Object)null || (Object)(object)portalScreenRenderer == (Object)null)
{
return;
}
if ((Object)(object)playerCameraTransform == (Object)null)
{
Plugin.Logger.LogError((object)"PortalView: playerCameraTransform is null");
return;
}
PortalView component = ((Component)linkedPortal).GetComponent<PortalView>();
if ((Object)(object)component == (Object)null || (Object)(object)component.portalCamera == (Object)null)
{
Plugin.Logger.LogError((object)"PortalView: targetView or targetView.portalCamera is null");
return;
}
if ((Object)(object)portalCamera.targetTexture != (Object)null && (Object)(object)portalScreenRenderer.material != (Object)null)
{
portalScreenRenderer.material.mainTexture = (Texture)(object)portalCamera.targetTexture;
}
Transform transform = ((Component)this).transform;
Transform transform2 = ((Component)linkedPortal).transform;
Vector3 val = transform.InverseTransformPoint(playerCameraTransform.position);
((Component)portalCamera).transform.position = transform2.TransformPoint(val);
Quaternion val2 = Quaternion.Inverse(transform.rotation) * playerCameraTransform.rotation;
((Component)portalCamera).transform.rotation = transform2.rotation * val2;
if ((Object)(object)portalCamera.targetTexture != (Object)null && (Object)(object)portalScreenRenderer.material != (Object)null)
{
portalScreenRenderer.material.mainTexture = (Texture)(object)portalCamera.targetTexture;
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
((NetworkBehaviour)this).__initializeRpcs();
}
protected internal override string __getTypeName()
{
return "PortalView";
}
}
}
namespace Silly_Things.codes.SnakeCardboardBox
{
public class SnakeCardboardBox : PhysicsProp
{
private readonly SnakeCardboardBoxUi ui = new SnakeCardboardBoxUi();
public bool PlayerHiddenByBox = false;
private ulong spawnedBoxId;
private AudioSource? audio;
public static List<SnakeCardboardBox> Instances { get; set; } = new List<SnakeCardboardBox>();
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
Instances.Add(this);
audio = ((Component)((Component)this).gameObject.transform.Find("Audio")).GetComponent<AudioSource>();
ui.box = this;
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (buttonDown && ((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner)
{
if (ui.IsOpen)
{
PlayerHiddenByBox = false;
ui.CloseUI();
RemoveBoxServerRpc();
SyncSoundsServerRpc(1);
}
else
{
ui.OpenUI();
PlayerHiddenByBox = true;
SpawnBoxOnPlayerServerRpc(((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).NetworkObjectId);
SyncSoundsServerRpc(0);
}
}
}
public override void DiscardItem()
{
((GrabbableObject)this).DiscardItem();
PlayerHiddenByBox = false;
ui.CloseUI();
RemoveBoxServerRpc();
}
public override void OnDestroy()
{
PlayerHiddenByBox = false;
((NetworkBehaviour)this).OnDestroy();
RemoveBoxServerRpc();
}
[ServerRpc(RequireOwnership = false)]
public void SyncSoundsServerRpc(int idSound)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2288866147u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, idSound);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2288866147u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
SyncSoundsClientRpc(idSound);
}
}
}
[ClientRpc]
public void SyncSoundsClientRpc(int idSound)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2013675865u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, idSound);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2013675865u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
switch (idSound)
{
case 0:
{
AudioSource? obj2 = audio;
if (obj2 != null)
{
obj2.PlayOneShot(Plugin.Instance.SoundOpenCardboardBox);
}
break;
}
case 1:
{
AudioSource? obj = audio;
if (obj != null)
{
obj.PlayOneShot(Plugin.Instance.SoundCloseCardboardBox);
}
break;
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SpawnBoxOnPlayerServerRpc(ulong playerId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: 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(3106080464u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3106080464u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
GameObject val3 = Object.Instantiate<GameObject>(Plugin.Instance.BigCardboardBoxPrefab);
NetworkObject component = val3.GetComponent<NetworkObject>();
component.Spawn(true);
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(playerId, out var value))
{
PlayerControllerB component2 = ((Component)value).GetComponent<PlayerControllerB>();
if ((Object)(object)component2 != (Object)null)
{
Transform val4 = (((Object)(object)component2.thisPlayerBody != (Object)null) ? component2.thisPlayerBody : ((Component)component2).transform);
component.TrySetParent(val4, false);
((Component)component).transform.localPosition = new Vector3(0f, 1.8f, 0f);
((Component)component).transform.localRotation = Quaternion.identity;
}
}
spawnedBoxId = component.NetworkObjectId;
HideBoxForOwnerClientRpc(component.NetworkObjectId, playerId);
}
[ClientRpc]
public void HideBoxForOwnerClientRpc(ulong boxId, ulong ownerId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2315715313u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, boxId);
BytePacker.WriteValueBitPacked(val2, ownerId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2315715313u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
if (ownerId == NetworkManager.Singleton.LocalClientId && NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(boxId, out var value))
{
Renderer[] componentsInChildren = ((Component)value).GetComponentsInChildren<Renderer>(true);
Renderer[] array = componentsInChildren;
foreach (Renderer val3 in array)
{
val3.enabled = false;
}
}
}
[ServerRpc(RequireOwnership = false)]
public void RemoveBoxServerRpc()
{
//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_00c1: 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(3420933785u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3420933785u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(spawnedBoxId, out var value))
{
value.Despawn(true);
}
}
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(2288866147u, new RpcReceiveHandler(__rpc_handler_2288866147), "SyncSoundsServerRpc");
((NetworkBehaviour)this).__registerRpc(2013675865u, new RpcReceiveHandler(__rpc_handler_2013675865), "SyncSoundsClientRpc");
((NetworkBehaviour)this).__registerRpc(3106080464u, new RpcReceiveHandler(__rpc_handler_3106080464), "SpawnBoxOnPlayerServerRpc");
((NetworkBehaviour)this).__registerRpc(2315715313u, new RpcReceiveHandler(__rpc_handler_2315715313), "HideBoxForOwnerClientRpc");
((NetworkBehaviour)this).__registerRpc(3420933785u, new RpcReceiveHandler(__rpc_handler_3420933785), "RemoveBoxServerRpc");
((PhysicsProp)this).__initializeRpcs();
}
private static void __rpc_handler_2288866147(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int idSound = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref idSound);
target.__rpc_exec_stage = (__RpcExecStage)1;
((SnakeCardboardBox)(object)target).SyncSoundsServerRpc(idSound);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2013675865(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int idSound = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref idSound);
target.__rpc_exec_stage = (__RpcExecStage)1;
((SnakeCardboardBox)(object)target).SyncSoundsClientRpc(idSound);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3106080464(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong playerId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((SnakeCardboardBox)(object)target).SpawnBoxOnPlayerServerRpc(playerId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2315715313(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong boxId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref boxId);
ulong ownerId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref ownerId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((SnakeCardboardBox)(object)target).HideBoxForOwnerClientRpc(boxId, ownerId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3420933785(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;
((SnakeCardboardBox)(object)target).RemoveBoxServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "SnakeCardboardBox";
}
}
internal class SnakeCardboardBoxUi
{
private bool isUIOpen;
private GameObject? uiInstance;
public SnakeCardboardBox? box;
public bool IsOpen => isUIOpen;
public bool CanOpenUI(bool buttonDown)
{
return buttonDown && !isUIOpen && (Object)(object)Plugin.Instance.UI_SnakeCardboardBox != (Object)null;
}
public void OpenUI()
{
uiInstance = Object.Instantiate<GameObject>(Plugin.Instance.UI_SnakeCardboardBox);
if ((Object)(object)uiInstance == (Object)null)
{
Plugin.Logger.LogError((object)"UI instance null");
return;
}
StartOfRound.Instance.localPlayerController.Crouch(true);
StartOfRound.Instance.localPlayerController.movementAudio.Pause();
if ((Object)(object)box != (Object)null)
{
box.SyncSoundsServerRpc(0);
box.PlayerHiddenByBox = true;
}
isUIOpen = true;
}
public void CloseUI()
{
if ((Object)(object)uiInstance != (Object)null)
{
Object.Destroy((Object)(object)uiInstance);
}
StartOfRound.Instance.localPlayerController.Crouch(false);
StartOfRound.Instance.localPlayerController.movementAudio.UnPause();
if ((Object)(object)box != (Object)null)
{
box.SyncSoundsServerRpc(1);
box.PlayerHiddenByBox = false;
}
uiInstance = null;
isUIOpen = false;
}
}
}
namespace Silly_Things.codes.patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PatchPlayerControllerB
{
[HarmonyPrefix]
[HarmonyPatch("Crouch")]
public static bool BlockUncrouchWhileUsingBox(PlayerControllerB __instance, bool crouch)
{
if (__instance.currentlyHeldObjectServer is Silly_Things.codes.SnakeCardboardBox.SnakeCardboardBox snakeCardboardBox && snakeCardboardBox.PlayerHiddenByBox)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(EnemyAI))]
internal class Patch_EnemyAI_PlayerIsTargetable
{
[HarmonyPostfix]
[HarmonyPatch("GetAllPlayersInLineOfSight")]
public static void BlockLOSWhenInSnakeBox(ref PlayerControllerB[] __result)
{
if (__result == null)
{
return;
}
foreach (Silly_Things.codes.SnakeCardboardBox.SnakeCardboardBox item in Silly_Things.codes.SnakeCardboardBox.SnakeCardboardBox.Instances)
{
if (item.PlayerHiddenByBox && (Object)(object)((GrabbableObject)item).playerHeldBy != (Object)null && __result.Contains(((GrabbableObject)item).playerHeldBy))
{
__result = __result.Where((PlayerControllerB player) => (Object)(object)player != (Object)(object)((GrabbableObject)item).playerHeldBy).ToArray();
}
}
}
[HarmonyPostfix]
[HarmonyPatch("CheckLineOfSightForPlayer")]
public static void CheckLineOfSightForPlayerPrefixPatch(ref PlayerControllerB __result)
{
if ((Object)(object)__result == (Object)null)
{
return;
}
foreach (Silly_Things.codes.SnakeCardboardBox.SnakeCardboardBox instance in Silly_Things.codes.SnakeCardboardBox.SnakeCardboardBox.Instances)
{
if (instance.PlayerHiddenByBox && (Object)(object)__result == (Object)(object)((GrabbableObject)instance).playerHeldBy)
{
__result = null;
break;
}
}
}
[HarmonyPostfix]
[HarmonyPatch("CheckLineOfSightForClosestPlayer")]
public static void CheckLineOfSightForClosestPlayerPrefixPatch(ref PlayerControllerB __result)
{
if ((Object)(object)__result == (Object)null)
{
return;
}
foreach (Silly_Things.codes.SnakeCardboardBox.SnakeCardboardBox instance in Silly_Things.codes.SnakeCardboardBox.SnakeCardboardBox.Instances)
{
if (instance.PlayerHiddenByBox && (Object)(object)__result == (Object)(object)((GrabbableObject)instance).playerHeldBy)
{
__result = null;
break;
}
}
}
}
}
namespace Silly_Things.codes.MorphingCase
{
internal class ManageCosmetics
{
private List<string>? previousCosmetics;
private int previousSuitId = -1;
public MorphingCase? morphingCase;
public bool HasStoredCosmetics => previousCosmetics != null;
public void MorphToPlayer(PlayerControllerB source)
{
PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
if (!((Object)(object)source == (Object)null) && !((Object)(object)localPlayerController == (Object)null) && localPlayerController.isPlayerControlled)
{
SavePreviousState(localPlayerController);
ApplyCosmetics(localPlayerController, source);
ApplySuit(localPlayerController, source);
}
}
public void RestorePreviousCosmetics()
{
PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
if (!((Object)(object)localPlayerController == (Object)null) && previousCosmetics != null)
{
RestoreCosmetics(localPlayerController);
RestoreSuit(localPlayerController);
previousCosmetics = null;
previousSuitId = -1;
}
}
private void SavePreviousState(PlayerControllerB target)
{
previousCosmetics = new List<string>(CosmeticRegistry.locallySelectedCosmetics);
previousSuitId = target.currentSuitID;
}
private void ApplyCosmetics(PlayerControllerB target, PlayerControllerB source)
{
if (MainClass.playerIdsAndCosmetics.TryGetValue((int)source.playerClientId, out var value))
{
CosmeticRegistry.locallySelectedCosmetics.Clear();
CosmeticRegistry.locallySelectedCosmetics.AddRange(value);
CosmeticSyncPatch.SyncCosmeticsToOtherClients((PlayerControllerB)null, false, false);
}
}
private void RestoreCosmetics(PlayerControllerB target)
{
target.movementAudio.PlayOneShot(StartOfRound.Instance.changeSuitSFX);
CosmeticRegistry.locallySelectedCosmetics.Clear();
CosmeticRegistry.locallySelectedCosmetics.AddRange(previousCosmetics);
CosmeticSyncPatch.SyncCosmeticsToOtherClients((PlayerControllerB)null, false, false);
}
private void ApplySuit(PlayerControllerB target, PlayerControllerB source)
{
target.currentSuitID = source.currentSuitID;
target.movementAudio.PlayOneShot(StartOfRound.Instance.changeSuitSFX);
morphingCase?.ChangeSuitServerRpc(target.playerClientId, source.currentSuitID);
}
private void RestoreSuit(PlayerControllerB target)
{
if (previousSuitId != -1)
{
morphingCase?.ChangeSuitServerRpc(target.playerClientId, previousSuitId);
}
}
public static bool IsValidPlayer(PlayerControllerB player)
{
return (Object)(object)player != (Object)null && player.isPlayerControlled && !string.IsNullOrEmpty(player.playerUsername);
}
}
public class MorphingCase : PhysicsProp
{
private readonly MorphingCaseUi ui = new MorphingCaseUi();
private AudioSource? audio;
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
ui.morphingCase = this;
audio = ((Component)((Component)this).gameObject.transform.Find("Audio")).GetComponent<AudioSource>();
if (ui.cosmeticsManager != null)
{
ui.cosmeticsManager.morphingCase = this;
}
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner && !ui.IsOpen)
{
ui.OpenUI();
}
}
public override void DiscardItem()
{
((GrabbableObject)this).DiscardItem();
Plugin.Instance.CosmeticsManager.RestorePreviousCosmetics();
ui.ForceCloseUI();
}
[ServerRpc(RequireOwnership = false)]
public void ChangeSuitServerRpc(ulong playerId, int sourceSuitId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(329689628u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerId);
BytePacker.WriteValueBitPacked(val2, sourceSuitId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 329689628u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
ChangeSuitClientRpc(playerId, sourceSuitId);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SyncSoundsServerRpc(int idSound)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2943084615u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, idSound);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2943084615u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
SyncSoundsClientRpc(idSound);
}
}
}
[ClientRpc]
public void SyncSoundsClientRpc(int idSound)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(215669224u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, idSound);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 215669224u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
switch (idSound)
{
case 0:
{
AudioSource? obj2 = audio;
if (obj2 != null)
{
obj2.PlayOneShot(Plugin.Instance.SoundOpenUI);
}
break;
}
case 1:
{
AudioSource? obj = audio;
if (obj != null)
{
obj.PlayOneShot(Plugin.Instance.SoundCloseUI);
}
break;
}
}
}
[ClientRpc]
public void ChangeSuitClientRpc(ulong playerId, int sourceSuitId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(880211545u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerId);
BytePacker.WriteValueBitPacked(val2, sourceSuitId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 880211545u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
PlayerControllerB val3 = StartOfRound.Instance.allPlayerScripts[playerId];
UnlockableSuit.SwitchSuitForPlayer(val3, sourceSuitId, true);
}
}
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(329689628u, new RpcReceiveHandler(__rpc_handler_329689628), "ChangeSuitServerRpc");
((NetworkBehaviour)this).__registerRpc(2943084615u, new RpcReceiveHandler(__rpc_handler_2943084615), "SyncSoundsServerRpc");
((NetworkBehaviour)this).__registerRpc(215669224u, new RpcReceiveHandler(__rpc_handler_215669224), "SyncSoundsClientRpc");
((NetworkBehaviour)this).__registerRpc(880211545u, new RpcReceiveHandler(__rpc_handler_880211545), "ChangeSuitClientRpc");
((PhysicsProp)this).__initializeRpcs();
}
private static void __rpc_handler_329689628(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong playerId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
int sourceSuitId = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref sourceSuitId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((MorphingCase)(object)target).ChangeSuitServerRpc(playerId, sourceSuitId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2943084615(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int idSound = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref idSound);
target.__rpc_exec_stage = (__RpcExecStage)1;
((MorphingCase)(object)target).SyncSoundsServerRpc(idSound);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_215669224(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int idSound = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref idSound);
target.__rpc_exec_stage = (__RpcExecStage)1;
((MorphingCase)(object)target).SyncSoundsClientRpc(idSound);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_880211545(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong playerId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
int sourceSuitId = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref sourceSuitId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((MorphingCase)(object)target).ChangeSuitClientRpc(playerId, sourceSuitId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "MorphingCase";
}
}
internal class MorphingCaseUi
{
public MorphingCase? morphingCase;
private bool isUIOpen;
private GameObject? uiInstance;
private Button? closeButton;
private Button? resetButton;
private Button? buttonLeft;
private Button? buttonRight;
private Transform? content;
private Transform? contentRight;
private Transform? playerTemplate;
public ManageCosmetics? cosmeticsManager;
private List<PlayerControllerB> overflowPlayers = new List<PlayerControllerB>();
private int currentPage = 0;
private const int playersPerPage = 6;
public bool IsOpen => isUIOpen;
public bool CanOpenUI(bool buttonDown)
{
return buttonDown && !isUIOpen && (Object)(object)Plugin.Instance.UI_MorphingCase != (Object)null;
}
public void OpenUI()
{
morphingCase?.SyncSoundsServerRpc(0);
uiInstance = Object.Instantiate<GameObject>(Plugin.Instance.UI_MorphingCase);
if ((Object)(object)uiInstance == (Object)null)
{
Plugin.Logger.LogError((object)"UI instance null");
return;
}
cosmeticsManager = Plugin.Instance.CosmeticsManager;
CacheUIRefs();
if ((Object)(object)resetButton != (Object)null)
{
((Selectable)resetButton).interactable = Plugin.Instance.CosmeticsManager.HasStoredCosmetics;
}
EnableCursor(state: true);
BuildPlayerList();
isUIOpen = true;
}
public void ForceCloseUI()
{
morphingCase?.SyncSoundsServerRpc(1);
if ((Object)(object)uiInstance != (Object)null)
{
Object.Destroy((Object)(object)uiInstance);
}
uiInstance = null;
isUIOpen = false;
EnableCursor(state: false);
}
private void CacheUIRefs()
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Expected O, but got Unknown
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Expected O, but got Unknown
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
Transform obj = uiInstance.transform.Find("Panel/Panel/ButtonClose");
closeButton = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null);
Transform obj2 = uiInstance.transform.Find("Panel/Panel/ButtonReset");
resetButton = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
Transform obj3 = uiInstance.transform.Find("Panel/ButtonLeft");
buttonLeft = ((obj3 != null) ? ((Component)obj3).GetComponent<Button>() : null);
Transform obj4 = uiInstance.transform.Find("Panel/ButtonRight");
buttonRight = ((obj4 != null) ? ((Component)obj4).GetComponent<Button>() : null);
content = uiInstance.transform.Find("Panel/Panel/PanelLeft/Viewport/Content");
contentRight = uiInstance.transform.Find("Panel/Panel/PanelRight/Viewport/Content");
playerTemplate = content.Find("PlayerNames");
if ((Object)(object)closeButton != (Object)null)
{
((UnityEvent)closeButton.onClick).AddListener(new UnityAction(ForceCloseUI));
}
if ((Object)(object)resetButton != (Object)null)
{
((UnityEvent)resetButton.onClick).AddListener((UnityAction)delegate
{
cosmeticsManager.RestorePreviousCosmetics();
((Selectable)resetButton).interactable = false;
});
((Selectable)resetButton).interactable = false;
}
if ((Object)(object)buttonLeft != (Object)null)
{
((UnityEvent)buttonLeft.onClick).AddListener((UnityAction)delegate
{
ChangePage(-1);
});
}
if ((Object)(object)buttonRight != (Object)null)
{
((UnityEvent)buttonRight.onClick).AddListener((UnityAction)delegate
{
ChangePage(1);
});
}
if ((Object)(object)playerTemplate != (Object)null)
{
((Component)playerTemplate).gameObject.SetActive(false);
}
}
private void BuildPlayerList()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
if ((Object)(object)content == (Object)null || (Object)(object)contentRight == (Object)null || (Object)(object)playerTemplate == (Object)null)
{
return;
}
foreach (Transform item in content)
{
Transform val = item;
if ((Object)(object)val != (Object)(object)playerTemplate)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
foreach (Transform item2 in contentRight)
{
Transform val2 = item2;
if ((Object)(object)val2 != (Object)(object)playerTemplate)
{
Object.Destroy((Object)(object)((Component)val2).gameObject);
}
}
overflowPlayers.Clear();
currentPage = 0;
PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val3 in allPlayerScripts)
{
if (ManageCosmetics.IsValidPlayer(val3) && !((Object)(object)val3 == (Object)(object)localPlayerController))
{
overflowPlayers.Add(val3);
}
}
RefreshPage();
}
private void CreatePlayerEntry(PlayerControllerB source, Transform parentContent)
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB source2 = source;
GameObject val = Object.Instantiate<GameObject>(((Component)playerTemplate).gameObject, parentContent);
val.SetActive(true);
Transform obj = val.transform.Find("ButtonPlayer/PlayerName");
TMP_Text val2 = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
if ((Object)(object)val2 != (Object)null)
{
val2.text = source2.playerUsername;
}
Transform obj2 = val.transform.Find("ButtonPlayer");
Button val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
if ((Object)(object)val3 != (Object)null)
{
((UnityEventBase)val3.onClick).RemoveAllListeners();
((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
{
cosmeticsManager.MorphToPlayer(source2);
if ((Object)(object)resetButton != (Object)null)
{
((Selectable)resetButton).interactable = true;
}
});
}
RawImage componentInChildren = val.GetComponentInChildren<RawImage>(true);
bool flag = !GameNetworkManager.Instance.disableSteam;
if ((Object)(object)componentInChildren != (Object)null)
{
if (flag)
{
HUDManager.FillImageWithSteamProfile(componentInChildren, SteamId.op_Implicit(source2.playerSteamId), true);
}
else
{
((Component)componentInChildren).gameObject.SetActive(false);
}
}
else
{
Plugin.Logger.LogError((object)"avatar fail to clone");
}
}
private void ChangePage(int delta)
{
int num = Mathf.Max(0, Mathf.CeilToInt((float)overflowPlayers.Count / 6f) - 1);
currentPage = Mathf.Clamp(currentPage + delta, 0, num);
RefreshPage();
}
private void RefreshPage()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
foreach (Transform item in content)
{
Transform val = item;
if ((Object)(object)val != (Object)(object)playerTemplate)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
foreach (Transform item2 in contentRight)
{
Transform val2 = item2;
if ((Object)(object)val2 != (Object)(object)playerTemplate)
{
Object.Destroy((Object)(object)((Component)val2).gameObject);
}
}
int num = currentPage * 6;
int num2 = Mathf.Min(num + 6, overflowPlayers.Count);
for (int i = num; i < num2; i++)
{
PlayerControllerB source = overflowPlayers[i];
Transform parentContent = ((i - num < 3) ? content : contentRight);
CreatePlayerEntry(source, parentContent);
}
int num3 = Mathf.Max(0, Mathf.CeilToInt((float)overflowPlayers.Count / 6f) - 1);
bool flag = num3 > 0;
if ((Object)(object)buttonLeft != (Object)null)
{
((Component)buttonLeft).gameObject.SetActive(flag);
((Selectable)buttonLeft).interactable = flag && currentPage > 0;
}
if ((Object)(object)buttonRight != (Object)null)
{
((Component)buttonRight).gameObject.SetActive(flag);
((Selectable)buttonRight).interactable = flag && currentPage < num3;
}
}
private static void EnableCursor(bool state)
{
Cursor.visible = state;
Cursor.lockState = (CursorLockMode)((!state) ? 1 : 0);
StartOfRound.Instance.localPlayerController.disableLookInput = state;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
}
}
}
namespace Silly_Things.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}