Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CoinOfDeath v1.0.0
CoinOfDeath.dll
Decompiled 4 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CoinOfDeath")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CoinOfDeath")] [assembly: AssemblyTitle("CoinOfDeath")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CoinOfDeath { [BepInPlugin("Votrepseudo.CoinOfDeath", "Coin Of Death", "1.0.0")] public class CoinPlugin : BaseUnityPlugin { public const string PluginGuid = "Votrepseudo.CoinOfDeath"; internal static ManualLogSource mls; internal static ConfigEntry<string> HideMaterials; private void Awake() { //IL_0035: 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_004b: Expected O, but got Unknown mls = ((BaseUnityPlugin)this).Logger; HideMaterials = ((BaseUnityPlugin)this).Config.Bind<string>("Casque", "MateriauxACacher", "helm,visor,casque", "Parties de noms de materiaux (separees par des virgules) a rendre invisibles sur le skin pendant la scene. Le casque fait souvent partie du meme maillage que le corps : repere le nom de son materiau dans le log (lignes MATERIAU) et ajoute-le ici. Vide = rien n'est cache."); new Harmony("Votrepseudo.CoinOfDeath").PatchAll(); GameObject val = new GameObject("CoinOfDeath_UI"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<CoinUI>(); val.AddComponent<CoinCinematic>(); mls.LogInfo((object)"Coin Of Death 3.0 charge !"); } } public static class Players { public static PlayerControllerB Local => GameNetworkManager.Instance.localPlayerController; public static PlayerControllerB GetById(ulong id) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled && val.actualClientId == id) { return val; } } return null; } } public static class CoinModel { public static readonly Color Gold = new Color(1f, 0.78f, 0.1f); public static readonly Color Silver = new Color(0.8f, 0.85f, 0.95f); public static readonly Color Skin = new Color(0.9f, 0.7f, 0.55f); public static Texture2D PileTex; public static Texture2D FaceTex; public static Transform Create() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0090: 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_00a0: 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_00b4: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (PileTex == null) { PileTex = Engrave(Gold, skull: true); } if (FaceTex == null) { FaceTex = Engrave(Silver, skull: false); } Transform transform = new GameObject("CoinModel").transform; Vector3 scale = default(Vector3); ((Vector3)(ref scale))..ctor(0.18f, 0.0075f, 0.18f); Vector3 scale2 = default(Vector3); ((Vector3)(ref scale2))..ctor(0.18f, 0.0003f, 0.18f); Part((PrimitiveType)2, transform, scale, Gold, Vector3.up * 0.0075f); Part((PrimitiveType)2, transform, scale, Silver, Vector3.down * 0.0075f); Part((PrimitiveType)2, transform, scale2, Color.white, Vector3.up * 0.0153f, (Texture)(object)PileTex); Part((PrimitiveType)2, transform, scale2, Color.white, Vector3.down * 0.0153f, (Texture)(object)FaceTex); return transform; } public static Transform Part(PrimitiveType type, Transform parent, Vector3 scale, Color color, Vector3 pos = default(Vector3), Texture tex = null, float glow = 2f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0053: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(type); Object.Destroy((Object)(object)val.GetComponent<Collider>()); val.transform.SetParent(parent, false); val.transform.localScale = scale; val.transform.localPosition = pos; Material val2 = new Material(Shader.Find("HDRP/Lit")); val2.SetColor("_BaseColor", color); val2.SetColor("_EmissiveColor", color * (((Object)(object)tex != (Object)null) ? 0.4f : glow)); val2.SetFloat("_Metallic", ((Object)(object)tex != (Object)null) ? 0f : 0.6f); val2.SetFloat("_Smoothness", 0.6f); if ((Object)(object)tex != (Object)null) { val2.SetTexture("_BaseColorMap", tex); } val.GetComponent<Renderer>().sharedMaterial = val2; return val.transform; } private static Texture2D Engrave(Color metal, bool skull) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) Color val = metal * 0.3f; val.a = 1f; Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = (float)j / 128f - 0.5f; float num2 = (float)i / 128f - 0.5f; float num3 = Mathf.Sqrt(num * num + num2 * num2); bool flag = num3 > 0.4f && num3 < 0.44f; flag = ((!skull) ? (flag | (In(num, num2, 0f, 0.02f, 0.24f) && !In(num, num2, -0.08f, 0.07f, 0.035f) && !In(num, num2, 0.08f, 0.07f, 0.035f) && (!(Mathf.Abs(num) < 0.12f) || !(Mathf.Abs(num2 - (-0.12f + 2f * num * num)) < 0.012f)))) : (flag | ((In(num, num2, 0f, 0.06f, 0.22f) || In(num, num2, 0f, -0.1f, 0.13f)) && !In(num, num2, -0.08f, 0.04f, 0.055f) && !In(num, num2, 0.08f, 0.04f, 0.055f) && !In(num, num2, 0f, -0.05f, 0.025f)))); array[i * 128 + j] = (flag ? val : metal); } } Texture2D val2 = new Texture2D(128, 128); val2.SetPixels(array); val2.Apply(); return val2; } private static bool In(float u, float v, float cx, float cy, float r) { return (u - cx) * (u - cx) + (v - cy) * (v - cy) < r * r; } } public static class CoinItem { public static GameObject Prefab; public static Item Data; private static Sprite icon; private static bool finished; public static void Build() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("CoinOfDeath_Prefabs"); val.SetActive(false); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); GameObject val2 = new GameObject("CoinOfDeathItem"); val2.transform.SetParent(val.transform, false); val2.tag = "PhysicsProp"; val2.layer = LayerMask.NameToLayer("Props"); BoxCollider val3 = val2.AddComponent<BoxCollider>(); val3.size = new Vector3(0.24f, 0.12f, 0.24f); ((Collider)val3).isTrigger = true; val2.AddComponent<AudioSource>(); Transform val4 = CoinModel.Create(); val4.SetParent(val2.transform, false); Data = ScriptableObject.CreateInstance<Item>(); Prefab = val2; Configure(); NetworkObject val5 = val2.AddComponent<NetworkObject>(); val5.AutoObjectParentSync = false; uint num = 2166136261u; string text = "CoinOfDeath.Item"; foreach (char c in text) { num = (num ^ c) * 16777619; } typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(val5, num); PhysicsProp val6 = val2.AddComponent<PhysicsProp>(); ((GrabbableObject)val6).itemProperties = Data; ((GrabbableObject)val6).grabbable = true; ((GrabbableObject)val6).mainObjectRenderer = ((Component)val4).GetComponentInChildren<MeshRenderer>(); val2.AddComponent<CoinBehavior>(); } public static void Finish(Item template) { if (!finished && !((Object)(object)Data == (Object)null) && !((Object)(object)template == (Object)null)) { finished = true; JsonUtility.FromJsonOverwrite(JsonUtility.ToJson((object)template), (object)Data); Configure(); } } private static void Configure() { Data.itemName = "Piece du Destin"; Data.spawnPrefab = Prefab; Data.canBeGrabbedBeforeGameStart = true; Data.weight = 1f; Data.itemSpawnsOnGround = true; Data.toolTips = new string[1] { "Defier quelqu'un : [LMB]" }; Data.itemIcon = icon ?? (icon = MakeIcon()); JsonUtility.FromJsonOverwrite("{\"verticalOffset\":0.02,\"restingRotation\":{\"x\":0,\"y\":0,\"z\":0},\"rotationOffset\":{\"x\":0,\"y\":0,\"z\":0},\"positionOffset\":{\"x\":0,\"y\":0,\"z\":0}}", (object)Data); } private static Sprite MakeIcon() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[16384]; Color val = CoinModel.Gold * 0.55f; val.a = 1f; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = (float)j / 128f; float num2 = (float)i / 128f; float num3 = (num - 0.5f) / 0.42f; float num4 = (num2 - 0.58f) / 0.32f; float num5 = (num2 - 0.46f) / 0.32f; if (num3 * num3 + num4 * num4 < 1f) { array[i * 128 + j] = CoinModel.PileTex.GetPixelBilinear(num3 * 0.5f + 0.5f, num4 * 0.5f + 0.5f); } else if (num3 * num3 + num5 * num5 < 1f || (Mathf.Abs(num3) < 1f && num2 < 0.58f && num2 > 0.46f)) { array[i * 128 + j] = val; } } } Texture2D val2 = new Texture2D(128, 128); val2.SetPixels(array); val2.Apply(); return Sprite.Create(val2, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f)); } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] public class RegisterItemPatch { private static void Postfix() { if (!((Object)(object)CoinItem.Prefab != (Object)null)) { CoinItem.Build(); NetworkManager.Singleton.AddNetworkPrefab(CoinItem.Prefab); } } } [HarmonyPatch(typeof(StartOfRound), "Awake")] public class AddToItemListPatch { private static void Postfix(StartOfRound __instance) { List<Item> itemsList = __instance.allItemsList.itemsList; if (!((Object)(object)CoinItem.Data == (Object)null)) { CoinItem.Finish(itemsList.Find((Item i) => (Object)(object)i != (Object)(object)CoinItem.Data && i.itemName.ToLower().Contains("key"))); if (!itemsList.Contains(CoinItem.Data)) { itemsList.Add(CoinItem.Data); } } } } [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] public class TerminalCoinCommandPatch { private static bool Prefix(Terminal __instance, ref TerminalNode __result) { string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower().Trim(); if (text != "coin") { return true; } bool flag = NetworkManager.Singleton.IsServer && (Object)(object)Players.Local != (Object)null && (Object)(object)CoinItem.Prefab != (Object)null; if (flag) { ((MonoBehaviour)CoinCinematic.Instance).StartCoroutine(GiveCoin(Players.Local)); } TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>(); val.displayText = (flag ? "La piece du destin rejoint votre inventaire (au sol s'il est plein).\n\n" : "Impossible : seul l'hote peut utiliser cette commande.\n\n"); val.clearPreviousText = true; __result = val; return false; } private static IEnumerator GiveCoin(PlayerControllerB lp) { while (lp.inTerminalMenu) { yield return null; } Transform cam = ((Component)lp.gameplayCamera).transform; GameObject obj = Object.Instantiate<GameObject>(CoinItem.Prefab, cam.position + cam.forward * 0.3f, Quaternion.identity, StartOfRound.Instance.propsContainer); obj.GetComponent<NetworkObject>().Spawn(false); yield return null; Physics.SyncTransforms(); MethodInfo grab = AccessTools.Method(typeof(PlayerControllerB), "BeginGrabObject", (Type[])null, (Type[])null); if (grab == null) { CoinPlugin.mls.LogWarning((object)"BeginGrabObject introuvable : la piece reste devant le joueur."); } else { try { grab.Invoke(lp, null); } catch (Exception ex) { CoinPlugin.mls.LogError((object)("Ramassage automatique : " + ex)); } } yield return (object)new WaitForSeconds(2f); if (Array.IndexOf(lp.ItemSlots, obj.GetComponent<GrabbableObject>()) < 0) { HUDManager.Instance.DisplayTip("Piece du Destin", "Ramassage automatique impossible (inventaire plein ?) : la piece est devant toi.", false, false, "LC_Tip1"); } } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public class RegisterHandlersPatch { private static void Postfix() { CoinNet.RegisterHandlers(); } } public static class CoinNet { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnPrompt; public static HandleNamedMessageDelegate <1>__OnChoice; public static HandleNamedMessageDelegate <2>__OnCinematic; } private const string PromptMsg = "COD_Prompt"; private const string ChoiceMsg = "COD_Choice"; private const string ShotMsg = "COD_Cinematic"; public static void RegisterHandlers() { //IL_0046: 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_0051: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; customMessagingManager.UnregisterNamedMessageHandler("COD_Prompt"); customMessagingManager.UnregisterNamedMessageHandler("COD_Choice"); customMessagingManager.UnregisterNamedMessageHandler("COD_Cinematic"); object obj = <>O.<0>__OnPrompt; if (obj == null) { HandleNamedMessageDelegate val = OnPrompt; <>O.<0>__OnPrompt = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("COD_Prompt", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnChoice; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnChoice; <>O.<1>__OnChoice = val2; obj2 = (object)val2; } customMessagingManager.RegisterNamedMessageHandler("COD_Choice", (HandleNamedMessageDelegate)obj2); object obj3 = <>O.<2>__OnCinematic; if (obj3 == null) { HandleNamedMessageDelegate val3 = OnCinematic; <>O.<2>__OnCinematic = val3; obj3 = (object)val3; } customMessagingManager.RegisterNamedMessageHandler("COD_Cinematic", (HandleNamedMessageDelegate)obj3); CoinPlugin.mls.LogInfo((object)"Handlers reseau enregistres."); } public unsafe static void SendPrompt(ulong targetId, ulong holderId) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) if (targetId == NetworkManager.Singleton.LocalClientId) { CoinUI.Instance.OpenChoose(holderId); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref holderId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("COD_Prompt", targetId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } public unsafe static void SendChoice(int choice) { //IL_003e: 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_005c: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer) { if ((Object)(object)CoinBehavior.Current != (Object)null) { CoinBehavior.Current.OnChoice(choice); } return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref choice, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("COD_Choice", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } public unsafe static void SendCinematic(ulong targetId, ulong holderId, int side, int choice) { //IL_0026: 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_0039: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) if (targetId == NetworkManager.Singleton.LocalClientId) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref holderId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref side, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref choice, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("COD_Cinematic", targetId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void OnPrompt(ulong sender, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ulong holder = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref holder, default(ForPrimitives)); CoinUI.Instance.OpenChoose(holder); } private static void OnChoice(ulong sender, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) int c = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref c, default(ForPrimitives)); if ((Object)(object)CoinBehavior.Current != (Object)null) { CoinBehavior.Current.OnChoice(c); } } private static void OnCinematic(ulong sender, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //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) ulong holderId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref holderId, default(ForPrimitives)); int side = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref side, default(ForPrimitives)); int choice = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref choice, default(ForPrimitives)); if (CoinUI.Instance.IsOpen) { CoinUI.Instance.Close(); } CoinCinematic.Instance.Play(holderId, Players.Local.actualClientId, side, choice); } } public class CoinUI : MonoBehaviour { private enum Mode { None, Select, Choose } public static CoinUI Instance; private Mode mode = Mode.None; private CoinBehavior coin; private ulong selectedId; private bool hasSelection; private ulong holderId; public bool IsOpen => mode != Mode.None; private void Awake() { Instance = this; } public void OpenSelect(CoinBehavior c) { coin = c; hasSelection = false; mode = Mode.Select; SetGameInput(gameActive: false); } public void OpenChoose(ulong holder) { holderId = holder; mode = Mode.Choose; SetGameInput(gameActive: false); } public void Close() { mode = Mode.None; SetGameInput(gameActive: true); } private void SetGameInput(bool gameActive) { Cursor.lockState = (CursorLockMode)(gameActive ? 1 : 0); Cursor.visible = !gameActive; PlayerControllerB local = Players.Local; if ((Object)(object)local != (Object)null) { local.disableLookInput = !gameActive; } } private void OnGUI() { //IL_0039: 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_0054: Expected O, but got Unknown //IL_004f: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (mode == Mode.Select) { GUI.Window(999, new Rect((float)(Screen.width / 2 - 200), (float)(Screen.height / 2 - 200), 400f, 400f), new WindowFunction(DrawSelect), "Choix de la cible - Pile ou Face"); } else if (mode == Mode.Choose) { GUI.Window(998, new Rect((float)(Screen.width / 2 - 200), (float)(Screen.height / 2 - 100), 400f, 200f), new WindowFunction(DrawChoose), "Le Destin t'a designe !"); } } private void DrawSelect(int id) { GUILayout.Space(10f); GUILayout.Label("Selectionne un joueur :", Array.Empty<GUILayoutOption>()); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled && !val.isPlayerDead) { bool flag = hasSelection && selectedId == val.actualClientId; string text = val.playerUsername + (((Object)(object)val == (Object)(object)Players.Local) ? " (toi)" : "") + (flag ? " [SELECTIONNE]" : ""); if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { selectedId = val.actualClientId; hasSelection = true; } } } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Valider", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }) && hasSelection) { CoinBehavior coinBehavior = coin; ulong targetId = selectedId; Close(); if ((Object)(object)coinBehavior != (Object)null) { coinBehavior.StartChallenge(targetId); } } if (GUILayout.Button("Annuler", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { Close(); } GUILayout.EndHorizontal(); } private void DrawChoose(int id) { PlayerControllerB byId = Players.GetById(holderId); string text = (((Object)(object)byId != (Object)null) ? byId.playerUsername : "Quelqu'un"); GUILayout.Space(10f); GUILayout.Label(text + " te defie ! Si la piece montre l'autre cote, tu meurs.", Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("PILE", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(60f) })) { CoinNet.SendChoice(0); Close(); } if (GUILayout.Button("FACE", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(60f) })) { CoinNet.SendChoice(1); Close(); } GUILayout.EndHorizontal(); } } public class CoinCinematic : MonoBehaviour { private class SavedRenderer { public Renderer R; public bool Enabled; public bool Offscreen; public bool ForceOff; public int Layer; public ShadowCastingMode Shadow; public SavedRenderer(Renderer r) { //IL_003a: 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) R = r; Enabled = r.enabled; ForceOff = r.forceRenderingOff; Layer = ((Component)r).gameObject.layer; Shadow = r.shadowCastingMode; SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null); Offscreen = val != null && val.updateWhenOffscreen; } } public static CoinCinematic Instance; private bool playing; private Camera cam; private Transform coin; private Transform fist; private Vector3 camPos; private Vector3 lookAt; private float fov = 60f; private float shake; private float roll; private float tension; private float beat = 3f; private string title = ""; private string sub = ""; private Color titleColor = Color.white; private GUIStyle style; private const float ThrowDuration = 1.3f; private const float SlowMoMinSpeed = 0.07f; private const float SlowMoWidth = 0.09f; private const float SfxVolume = 1f; private const float AmbienceVolume = 0.8f; private AudioSource sfx; private AudioSource amb; private readonly List<Renderer> forceShow = new List<Renderer>(); private readonly List<Renderer> forceHide = new List<Renderer>(); private int showLayer = 3; private const bool DumpRenderers = false; private static Material invisible; private void Awake() { Instance = this; sfx = ((Component)this).gameObject.AddComponent<AudioSource>(); sfx.playOnAwake = false; sfx.spatialBlend = 0f; amb = ((Component)this).gameObject.AddComponent<AudioSource>(); amb.playOnAwake = false; amb.spatialBlend = 0f; amb.loop = true; } private void OnEnable() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown RenderPipelineManager.beginCameraRendering += OnBeginCamera; Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCullCamera)); } private void OnDisable() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown RenderPipelineManager.beginCameraRendering -= OnBeginCamera; Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCullCamera)); } private void OnBeginCamera(ScriptableRenderContext ctx, Camera c) { if (playing && (Object)(object)c == (Object)(object)cam) { ApplyForced(); } } private void OnPreCullCamera(Camera c) { if (playing && (Object)(object)c == (Object)(object)cam) { ApplyForced(); } } private void ApplyForced() { foreach (Renderer item in forceShow) { if (!((Object)(object)item == (Object)null)) { item.enabled = true; item.forceRenderingOff = false; item.shadowCastingMode = (ShadowCastingMode)1; ((Component)item).gameObject.layer = showLayer; SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((item is SkinnedMeshRenderer) ? item : null); if (val != null) { val.updateWhenOffscreen = true; } } } foreach (Renderer item2 in forceHide) { if ((Object)(object)item2 != (Object)null) { item2.enabled = false; } } } private static float SlowMoBump(float p) { return Mathf.Exp(0f - Mathf.Pow((p - 0.5f) / 0.09f, 2f)); } public Coroutine Play(ulong holderId, ulong targetId, int side, int choice) { return playing ? null : ((MonoBehaviour)this).StartCoroutine(Run(holderId, targetId, side, choice)); } private static string SideName(int s) { return (s == 0) ? "PILE" : "FACE"; } private Coroutine T(float duration, Action<float> step) { return ((MonoBehaviour)this).StartCoroutine(Tween(duration, step)); } private static IEnumerator Tween(float duration, Action<float> step) { for (float t = 0f; t < duration; t += Time.deltaTime) { step(t / duration); yield return null; } step(1f); } private Action ShowFullBody(PlayerControllerB p) { //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Invalid comparison between Unknown and I4 FindReplacement(p, out var model, out var viewModel); Renderer[] componentsInChildren = ((Component)p).GetComponentsInChildren<Renderer>(true); HashSet<Renderer> vanilla = new HashSet<Renderer>(); Renderer[] array = (Renderer[])(object)new Renderer[4] { (Renderer)p.thisPlayerModel, (Renderer)p.thisPlayerModelLOD1, (Renderer)p.thisPlayerModelLOD2, (Renderer)p.thisPlayerModelArms }; foreach (Renderer val in array) { if ((Object)(object)val != (Object)null) { vanilla.Add(val); } } HashSet<Renderer> view = new HashSet<Renderer>(); if ((Object)(object)viewModel != (Object)null) { Renderer[] componentsInChildren2 = viewModel.GetComponentsInChildren<Renderer>(true); foreach (Renderer item in componentsInChildren2) { view.Add(item); } } HashSet<Renderer> show = new HashSet<Renderer>(); List<Action> restores = new List<Action>(); List<string> roots = new List<string>(); if ((Object)(object)model != (Object)null) { CollectUnder(model.transform, model.transform.parent); } Renderer[] array2 = componentsInChildren; foreach (Renderer val2 in array2) { if (val2 is SkinnedMeshRenderer && !vanilla.Contains(val2) && !view.Contains(val2) && !show.Contains(val2) && !((Object)(object)((Component)val2).GetComponentInParent<GrabbableObject>() != (Object)null)) { Transform val3 = ((Component)val2).transform; while ((Object)(object)val3.parent != (Object)null && (Object)(object)val3.parent != (Object)(object)((Component)p).transform) { val3 = val3.parent; } bool flag = (Object)(object)p.thisPlayerModel != (Object)null && ((Component)p.thisPlayerModel).transform.IsChildOf(val3); if ((Object)(object)val3.parent == (Object)(object)((Component)p).transform && !flag) { CollectUnder(val3, ((Component)p).transform); } else if (flag && (Object)(object)p.thisPlayerModel != (Object)null && (Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)p.thisPlayerModel).transform.parent) { vanilla.Add(val2); } else if (show.Add(val2)) { Activate(((Component)val2).transform, ((Component)p).transform); } } } List<Renderer> list = new List<Renderer>(); if (show.Count > 0) { list.AddRange(vanilla); list.AddRange(view); HashSet<Renderer> hashSet = new HashSet<Renderer>(componentsInChildren); foreach (Renderer item2 in show) { hashSet.Add(item2); } foreach (Renderer item3 in hashSet) { if (!((Object)(object)item3 == (Object)null) && (item3 is SkinnedMeshRenderer || item3 is MeshRenderer) && !vanilla.Contains(item3) && !view.Contains(item3) && !list.Contains(item3) && !((Object)(object)((Component)item3).GetComponentInParent<GrabbableObject>() != (Object)null) && LooksLikeHelmet(item3, ((Component)p).transform)) { show.Remove(item3); list.Add(item3); } } } else { Renderer[] array3 = componentsInChildren; foreach (Renderer val4 in array3) { if ((val4 is SkinnedMeshRenderer || val4 is MeshRenderer) && (int)val4.shadowCastingMode == 3) { show.Add(val4); } } if ((Object)(object)p.thisPlayerModelArms != (Object)null) { show.Remove((Renderer)(object)p.thisPlayerModelArms); list.Add((Renderer)(object)p.thisPlayerModelArms); } } bool flag2 = false; CoinPlugin.mls.LogInfo((object)("[Cinematique] " + p.playerUsername + " : skin = " + ((roots.Count > 0) ? string.Join(", ", roots.ToArray()) : "aucun (corps d'origine)") + " | vue 1ere personne = " + (((Object)(object)viewModel != (Object)null) ? ((Object)viewModel).name : "aucune") + " | rendus montres = " + show.Count + ", caches = " + list.Count)); List<string> list2 = new List<string>(); string[] array4 = (CoinPlugin.HideMaterials.Value ?? "").ToLowerInvariant().Split(',', ';'); foreach (string text in array4) { if (text.Trim().Length > 0) { list2.Add(text.Trim()); } } foreach (Renderer item4 in show) { Material[] mats = item4.sharedMaterials; Material[] array5 = (Material[])mats.Clone(); bool flag3 = false; for (int n = 0; n < array5.Length; n++) { if ((Object)(object)array5[n] == (Object)null) { continue; } string text2 = ((Object)array5[n]).name.ToLowerInvariant(); bool flag4 = false; foreach (string item5 in list2) { if (text2.Contains(item5)) { flag4 = true; break; } } bool flag5 = false; if (flag4) { array5[n] = InvisibleMaterial(); flag3 = true; } } if (!flag3) { continue; } item4.sharedMaterials = array5; Renderer r2 = item4; restores.Add(delegate { if ((Object)(object)r2 != (Object)null) { r2.sharedMaterials = mats; } }); } List<SavedRenderer> saved = new List<SavedRenderer>(); foreach (Renderer item6 in show) { saved.Add(new SavedRenderer(item6)); } foreach (Renderer item7 in list) { saved.Add(new SavedRenderer(item7)); } forceShow.AddRange(show); forceHide.AddRange(list); showLayer = (((Object)(object)p.thisPlayerModel != (Object)null) ? ((Component)p.thisPlayerModel).gameObject.layer : 3); Camera obj = cam; obj.cullingMask |= 1 << showLayer; ApplyForced(); LODGroup[] lods = ((Component)p).GetComponentsInChildren<LODGroup>(true); LODGroup[] array6 = lods; foreach (LODGroup val5 in array6) { val5.ForceLOD(0); } return delegate { //IL_0059: Unknown result type (might be due to invalid IL or missing references) foreach (SavedRenderer item8 in saved) { if (!((Object)(object)item8.R == (Object)null)) { item8.R.enabled = item8.Enabled; item8.R.forceRenderingOff = item8.ForceOff; item8.R.shadowCastingMode = item8.Shadow; ((Component)item8.R).gameObject.layer = item8.Layer; Renderer r3 = item8.R; SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)(object)((r3 is SkinnedMeshRenderer) ? r3 : null); if (val6 != null) { val6.updateWhenOffscreen = item8.Offscreen; } } } foreach (Action item9 in restores) { item9(); } LODGroup[] array7 = lods; foreach (LODGroup val7 in array7) { if ((Object)(object)val7 != (Object)null) { val7.ForceLOD(-1); } } }; void Activate(Transform t, Transform stop) { while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)stop) { GameObject g = ((Component)t).gameObject; if (!g.activeSelf) { g.SetActive(true); restores.Add(delegate { if ((Object)(object)g != (Object)null) { g.SetActive(false); } }); } t = t.parent; } } void CollectUnder(Transform root, Transform stop) { roots.Add(((Object)root).name); Renderer[] componentsInChildren3 = ((Component)root).GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren3) { if ((val6 is SkinnedMeshRenderer || val6 is MeshRenderer) && !vanilla.Contains(val6) && !view.Contains(val6) && show.Add(val6)) { Activate(((Component)val6).transform, stop); } } } } private static void FindReplacement(PlayerControllerB p, out GameObject model, out GameObject viewModel) { model = null; viewModel = null; MonoBehaviour[] componentsInChildren = ((Component)p).GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } bool flag = false; Type type = ((object)val).GetType(); while (type != null) { if (type.Name.Contains("Replacement")) { flag = true; break; } type = type.BaseType; } if (!flag) { continue; } Type type2 = ((object)val).GetType(); while (type2 != null) { if ((Object)(object)model == (Object)null) { model = ReadObject(val, type2, "replacementModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if ((Object)(object)viewModel == (Object)null) { viewModel = ReadObject(val, type2, "replacementViewModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } type2 = type2.BaseType; } if ((Object)(object)model != (Object)null) { break; } } } private static Material InvisibleMaterial() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)invisible != (Object)null) { return invisible; } invisible = new Material(Shader.Find("HDRP/Lit")) { name = "CoinOfDeath_Invisible" }; invisible.SetFloat("_SurfaceType", 1f); invisible.SetFloat("_BlendMode", 0f); invisible.SetFloat("_SrcBlend", 1f); invisible.SetFloat("_DstBlend", 10f); invisible.SetFloat("_ZWrite", 0f); invisible.SetFloat("_AlphaCutoffEnable", 0f); invisible.SetFloat("_EnableBlendModePreserveSpecularLighting", 0f); invisible.SetFloat("_Metallic", 0f); invisible.SetFloat("_Smoothness", 0f); invisible.SetColor("_BaseColor", new Color(0f, 0f, 0f, 0f)); invisible.SetColor("_EmissiveColor", Color.black); invisible.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); invisible.DisableKeyword("_BLENDMODE_PRESERVE_SPECULAR_LIGHTING"); invisible.SetOverrideTag("RenderType", "Transparent"); invisible.SetShaderPassEnabled("ShadowCaster", false); invisible.renderQueue = 3000; return invisible; } private static string PathOf(Transform t) { string text = ((Object)t).name; for (int i = 0; i < 8; i++) { if (!((Object)(object)t.parent != (Object)null)) { break; } t = t.parent; text = ((Object)t).name + "/" + text; } return text; } private static bool LooksLikeHelmet(Renderer rd, Transform stop) { int num = 0; Transform val = ((Component)rd).transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)stop && num < 12) { if (HelmetName(((Object)val).name)) { return true; } val = val.parent; num++; } Material[] sharedMaterials = rd.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null && HelmetName(((Object)val2).name)) { return true; } } return false; } private static bool HelmetName(string n) { n = n.ToLowerInvariant(); return n.Contains("helm") || n.Contains("visor"); } private static GameObject ReadObject(object o, Type t, string name, BindingFlags f) { object obj = t.GetField(name, f)?.GetValue(o); if (obj == null) { try { obj = t.GetProperty(name, f)?.GetValue(o, null); } catch { } } return (GameObject)((obj is GameObject) ? obj : null); } private IEnumerator Run(ulong holderId, ulong targetId, int side, int choice) { PlayerControllerB lp = Players.Local; PlayerControllerB holder = Players.GetById(holderId); PlayerControllerB target = Players.GetById(targetId); if ((Object)(object)holder == (Object)null || (Object)(object)target == (Object)null) { yield break; } playing = true; bool dies = side != choice; string hName = holder.playerUsername; string tName = target.playerUsername; Vector3 hp = ((Component)holder).transform.position; Vector3 f = ((Component)target).transform.position - hp; if (((Vector3)(ref f)).sqrMagnitude < 0.01f) { f = ((Component)holder).transform.forward; } f.y = 0f; ((Vector3)(ref f)).Normalize(); Vector3 tp = (((Object)(object)holder == (Object)(object)target) ? (hp + f * 1.6f) : ((Component)target).transform.position); Vector3 r = Vector3.Cross(Vector3.up, f); Vector3 hHead = ((Component)holder.gameplayCamera).transform.position; Vector3 tHead = (((Object)(object)holder == (Object)(object)target) ? (hHead + f * 1.6f) : ((Component)target.gameplayCamera).transform.position); float height = hHead.y - hp.y; Vector3 mid = (hp + tp) / 2f + Vector3.up * height * 0.5f; Vector3 bodyMid = hp + Vector3.up * height * 0.55f; Vector3 hand = holder.serverItemHolder.position; float floorY = hp.y + 0.02f; Vector3 land = new Vector3(hand.x, floorY, hand.z); Vector3 throwCam = hp + f * 0.8f + r * 2.4f + Vector3.up * height * 0.6f; Vector3 fallCam = land + r * 1.1f + f * 0.3f + Vector3.up * 0.7f; if ((Object)(object)coin == (Object)null) { coin = CoinModel.Create(); coin.localScale = Vector3.one * 1.3f; fist = CoinModel.Part((PrimitiveType)0, null, Vector3.zero, CoinModel.Skin, default(Vector3), null, 0.5f); } coin.SetPositionAndRotation(hand, Quaternion.identity); ((Component)coin).gameObject.SetActive(true); ((Component)fist).gameObject.SetActive(false); cam = StartOfRound.Instance.spectateCamera; Vector3 oldPos = ((Component)cam).transform.position; Quaternion oldRot = ((Component)cam).transform.rotation; float oldFov = cam.fieldOfView; int oldMask = cam.cullingMask; bool oldLook = lp.disableLookInput; bool oldMove = lp.disableMoveInput; GrabbableObject held = holder.currentlyHeldObjectServer; Renderer[] heldMeshes = (Renderer[])(((Object)(object)held != (Object)null) ? ((Array)((Component)held).GetComponentsInChildren<Renderer>()) : ((Array)new Renderer[0])); Action showHolder = null; Action showTarget = null; try { bool disableLookInput = true; lp.disableMoveInput = true; lp.disableLookInput = disableLookInput; showHolder = ShowFullBody(holder); if ((Object)(object)target != (Object)(object)holder) { showTarget = ShowFullBody(target); } Renderer[] array = heldMeshes; foreach (Renderer m in array) { m.enabled = false; } Shot(mid + r * 4.2f, mid, 60f); StartOfRound.Instance.SwitchCamera(cam); sub = hName + " lance la piece..."; yield return T(1.6f, delegate(float p) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Shot(mid + r * Mathf.Lerp(4.2f, 3.2f, p) + Vector3.up * 0.2f, mid, 60f); shake = 0.003f * p; tension = 0.3f * p; }); float spins = 5f + (float)side * 0.5f; sfx.PlayOneShot(CoinSounds.Throw, 1f); amb.clip = CoinSounds.Ambience; amb.volume = 0f; amb.Play(); float prog = 0f; while (prog < 1f) { prog = Mathf.Min(1f, prog + Time.deltaTime * Mathf.Lerp(1f, 0.07f, SlowMoBump(prog)) / 1.3f); float y = 3.6f * prog * (1f - prog); coin.position = hand + Vector3.up * y; coin.rotation = Quaternion.AngleAxis(spins * 360f * prog, r); float z = Mathf.SmoothStep(0f, 1f, Mathf.Exp(0f - Mathf.Pow((prog - 0.5f) / 0.2f, 2f))); Vector3 closeCam = coin.position + r * 1.2f + Vector3.up * 0.1f; Vector3 baseLook = Vector3.Lerp(bodyMid, coin.position, 0.6f); Shot(Vector3.Lerp(throwCam, closeCam, z), Vector3.Lerp(baseLook, coin.position, z), Mathf.Lerp(55f, 32f, z)); shake = 0.004f + 0.012f * z; tension = 0.3f + 0.2f * prog + 0.3f * z; amb.volume = 0.8f * Mathf.Exp(0f - Mathf.Pow((prog - 0.5f) / 0.25f, 2f)); yield return null; } ((Component)coin).gameObject.SetActive(false); fist.position = hand; fist.localScale = Vector3.one * 0.13f; ((Component)fist).gameObject.SetActive(true); float ambFrom = amb.volume; yield return T(0.4f, delegate(float p) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_006e: Unknown result type (might be due to invalid IL or missing references) Shot(Vector3.Lerp(throwCam, hHead + f * 1.1f + r * 0.9f, p), Vector3.Lerp(bodyMid, hHead, p), Mathf.Lerp(55f, 40f, p)); shake = Mathf.Lerp(0.025f, 0.008f, p); tension = 0.5f + 0.2f * p; amb.volume = Mathf.Lerp(ambFrom, 0f, p); }); amb.Stop(); sub = ""; yield return T(3.6f, delegate(float p) { //IL_0042: 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_0047: 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) //IL_004c: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a0: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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) int num2 = ((!(p < 0.3f)) ? ((p < 0.55f) ? 1 : ((p < 0.75f) ? 2 : ((p < 0.9f) ? 3 : 4))) : 0); bool flag = num2 % 2 == 0; Vector3 val = (flag ? tHead : hHead); Vector3 val2 = (flag ? hHead : tHead); Vector3 val3 = val2 - val; val3.y = 0f; ((Vector3)(ref val3)).Normalize(); Shot(val - val3 * 0.5f + Vector3.Cross(Vector3.up, val3) * 0.35f + Vector3.up * 0.05f, val2, Mathf.Lerp(42f, 22f, p)); shake = Mathf.Lerp(0.006f, 0.02f, p); roll = 4f * p; beat = Mathf.Lerp(3f, 7f, p); tension = 1f; }); Quaternion rest = Quaternion.AngleAxis((float)side * 180f, r); ((Component)coin).gameObject.SetActive(true); yield return T(0.5f, delegate(float p) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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) fist.localScale = Vector3.one * 0.13f * Mathf.Clamp01(1f - p * 3f); coin.position = new Vector3(hand.x, Mathf.Lerp(hand.y, floorY, p * p), hand.z); coin.rotation = Quaternion.AngleAxis(720f * (1f - p), r) * rest; Shot(fallCam, Vector3.Lerp(hand, land + Vector3.up * 0.05f, p), 45f); shake = 0.012f * (1f - p); roll = 4f * (1f - p); }); sfx.PlayOneShot(CoinSounds.Landing, 1f); ((Component)fist).gameObject.SetActive(false); title = SideName(side); titleColor = ((side == 0) ? CoinModel.Gold : CoinModel.Silver); sub = tName + " avait choisi " + SideName(choice) + "\n" + (dies ? ("<color=#ff5050>" + tName + " meurt...</color>") : ("<color=#6aff6a>" + tName + " est epargne.</color>")); yield return T(0.25f, delegate(float p) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) coin.position = land + Vector3.up * 0.24f * p * (1f - p); shake = 0.03f * (1f - p); }); yield return T(2.3f, delegate(float p) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0043: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Shot(Vector3.Lerp(fallCam, land + r * 0.5f + Vector3.up * 0.3f, p), land + Vector3.up * 0.05f, 45f); tension = Mathf.Clamp01(3f * (1f - p)); }); } finally { playing = false; title = (sub = ""); tension = (shake = (roll = 0f)); beat = 3f; lp.disableLookInput = oldLook; lp.disableMoveInput = oldMove; amb.Stop(); showHolder?.Invoke(); showTarget?.Invoke(); forceShow.Clear(); forceHide.Clear(); cam.cullingMask = oldMask; Renderer[] array2 = heldMeshes; foreach (Renderer m2 in array2) { if ((Object)(object)m2 != (Object)null) { m2.enabled = true; } } if ((Object)(object)coin != (Object)null) { ((Component)coin).gameObject.SetActive(false); } if ((Object)(object)fist != (Object)null) { ((Component)fist).gameObject.SetActive(false); } cam.fieldOfView = oldFov; if ((Object)(object)StartOfRound.Instance.activeCamera == (Object)(object)cam) { StartOfRound.Instance.SwitchCamera(lp.gameplayCamera); ((Component)cam).transform.SetPositionAndRotation(oldPos, oldRot); } if (dies && lp.actualClientId == targetId && !lp.isPlayerDead) { lp.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 0, default(Vector3), false); } } void Shot(Vector3 pos, Vector3 look, float fieldOfView) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) camPos = pos; lookAt = look; fov = fieldOfView; } } private void LateUpdate() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b8: 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) //IL_0054: 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_0063: Unknown result type (might be due to invalid IL or missing references) if (playing && !((Object)(object)cam == (Object)null)) { ApplyForced(); Vector3 val = camPos; RaycastHit val2 = default(RaycastHit); if (Physics.Linecast(lookAt, val, ref val2, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { val = Vector3.Lerp(lookAt, ((RaycastHit)(ref val2)).point, 0.9f); } cam.fieldOfView = fov; ((Component)cam).transform.SetPositionAndRotation(val + Random.insideUnitSphere * shake, Quaternion.LookRotation(lookAt - val) * Quaternion.AngleAxis(roll, Vector3.forward)); } } private void OnGUI() { //IL_0086: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown if (playing) { float num = Screen.width; float num2 = Screen.height; if (style == null) { style = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1, richText = true }; } Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, num, num2); GUI.color = new Color(0f, 0f, 0f, tension * 0.3f); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture); float num3 = Mathf.Pow(Mathf.Abs(Mathf.Sin(Time.time * beat)), 12f); GUI.color = new Color(0.6f, 0f, 0f, tension * 0.35f * num3); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.black; float num4 = num2 * 0.12f * tension; GUI.DrawTexture(new Rect(0f, 0f, num, num4), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(0f, num2 - num4, num, num4), (Texture)(object)Texture2D.whiteTexture); DrawText(new Rect(0f, num2 * 0.14f, num, num2 * 0.2f), title, (int)(num2 * 0.14f), titleColor); DrawText(new Rect(0f, num2 * 0.74f, num, num2 * 0.13f), sub, (int)(num2 * 0.04f), Color.white); GUI.color = Color.white; } } private void DrawText(Rect r, string text, int size, Color c) { //IL_000e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) style.fontSize = size; GUI.color = Color.black; GUI.Label(new Rect(((Rect)(ref r)).x + 3f, ((Rect)(ref r)).y + 3f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style); GUI.color = c; GUI.Label(r, text, style); } } public static class CoinSounds { private const int SR = 44100; private static AudioClip throwClip; private static AudioClip ambClip; private static AudioClip landClip; public static AudioClip Throw => throwClip ?? (throwClip = MakeThrow()); public static AudioClip Ambience => ambClip ?? (ambClip = MakeAmbience()); public static AudioClip Landing => landClip ?? (landClip = MakeLanding()); private static AudioClip Make(string name, float[] d, float peak) { float num = 0.0001f; foreach (float num2 in d) { num = Mathf.Max(num, Mathf.Abs(num2)); } for (int j = 0; j < d.Length; j++) { d[j] *= peak / num; } AudioClip val = AudioClip.Create(name, d.Length, 1, 44100, false); val.SetData(d, 0); return val; } private static AudioClip MakeThrow() { float[] array = new float[22050]; Random random = new Random(1); float num = 0f; for (int i = 0; i < array.Length; i++) { float num2 = (float)i / 44100f; float num3 = (float)(random.NextDouble() * 2.0 - 1.0); num += (num3 - num) * Mathf.Lerp(0.04f, 0.45f, num2 / 0.5f); float num4 = Mathf.Sin(MathF.PI * Mathf.Clamp01(num2 / 0.5f)); float num5 = num * num4 * num4 * 1.6f; float num6 = num2 - 0.02f; if (num6 >= 0f) { num5 += (Mathf.Sin(MathF.PI * 5274f * num6) * Mathf.Exp((0f - num6) * 10f) + 0.6f * Mathf.Sin(MathF.PI * 7902f * num6) * Mathf.Exp((0f - num6) * 14f) + 0.3f * Mathf.Sin(MathF.PI * 10548f * num6) * Mathf.Exp((0f - num6) * 18f)) * 0.35f; } array[i] = num5; } return Make("CoinThrow", array, 0.9f); } private static AudioClip MakeAmbience() { float[] array = new float[88200]; float num = MathF.PI * 2f; for (int i = 0; i < array.Length; i++) { float num2 = (float)i / 44100f; float num3 = Mathf.Sin(num * 55f * num2) * 0.5f + Mathf.Sin(num * 58.5f * num2) * 0.4f; float num4 = 0.6f + 0.4f * Mathf.Sin(num * 3f * num2); num3 += (Mathf.Sin(num * 440f * num2) + Mathf.Sin(num * 466.5f * num2)) * 0.12f * num4; for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { float num5 = num2 - ((float)j * 1f + (float)k * 0.2f); if (num5 >= 0f) { num3 += Mathf.Sin(num * 48f * num5) * Mathf.Exp((0f - num5) * 16f) * ((k == 0) ? 1.1f : 0.8f); } } } array[i] = num3; } return Make("CoinAmbience", array, 0.8f); } private static AudioClip MakeLanding() { float num = MathF.PI * 2f; float[] array = new float[70560]; float[] array2 = new float[8] { 0f, 0.21f, 0.36f, 0.47f, 0.55f, 0.61f, 0.655f, 0.69f }; float[] array3 = new float[4] { 4180f, 6350f, 8720f, 11300f }; float[] array4 = new float[4] { 1f, 0.8f, 0.55f, 0.3f }; float[] array5 = new float[4] { 9f, 14f, 20f, 30f }; Random random = new Random(2); for (int i = 0; i < array2.Length; i++) { int num2 = (int)(array2[i] * 44100f); float num3 = Mathf.Pow(0.65f, (float)i); float num4 = 1f + (float)(random.NextDouble() - 0.5) * 0.08f; float num5 = 0f; for (int j = num2; j < array.Length && j < num2 + 22050; j++) { float num6 = (float)(j - num2) / 44100f; float num7 = (float)(random.NextDouble() * 2.0 - 1.0); float num8 = (num7 - num5) * Mathf.Exp((0f - num6) * 900f) * 0.35f; num5 = num7; for (int k = 0; k < array3.Length; k++) { num8 += Mathf.Sin(num * array3[k] * num4 * num6) * Mathf.Exp((0f - num6) * array5[k]) * array4[k]; } array[j] += num8 * num3; } } int num9 = 31752; for (int l = num9; l < array.Length; l++) { float num10 = (float)(l - num9) / 44100f; float num11 = Mathf.Exp((0f - num10) * 3.2f) * Mathf.Clamp01(num10 * 40f) * Mathf.Clamp01((float)(array.Length - l) / 2205f); float num12 = 0.55f + 0.45f * Mathf.Sin(num * (22f * num10 + 55f * num10 * num10)); float num13 = Mathf.Sin(num * 5250f * num10) + 0.6f * Mathf.Sin(num * 7900f * num10); array[l] += num13 * num12 * num11 * 0.22f; } return Make("CoinLanding", array, 0.9f); } } public class CoinBehavior : MonoBehaviour { public static CoinBehavior Current; private const float ChoiceTimeout = 20f; private GrabbableObject grabbable; private bool busy; private int choice = -1; private void Awake() { grabbable = ((Component)this).GetComponent<GrabbableObject>(); } private void Update() { if (!busy && !((Object)(object)grabbable == (Object)null) && NetworkManager.Singleton.IsServer && !((Object)(object)CoinUI.Instance == (Object)null) && !CoinUI.Instance.IsOpen) { PlayerControllerB local = Players.Local; if (!((Object)(object)local == (Object)null) && Mouse.current != null && grabbable.isHeld && !grabbable.isPocketed && (Object)(object)grabbable.playerHeldBy == (Object)(object)local && Mouse.current.leftButton.wasPressedThisFrame) { CoinUI.Instance.OpenSelect(this); } } } public void StartChallenge(ulong targetId) { if (!busy) { PlayerControllerB byId = Players.GetById(targetId); if (!((Object)(object)byId == (Object)null) && !byId.isPlayerDead) { ((MonoBehaviour)this).StartCoroutine(Challenge(byId)); } } } public void OnChoice(int c) { choice = c; } private IEnumerator Challenge(PlayerControllerB target) { busy = true; Current = this; choice = -1; PlayerControllerB lp = Players.Local; if ((Object)(object)target != (Object)(object)lp) { Vector3 pos = ((Component)target).transform.position + ((Component)target).transform.forward * 1.6f; lp.TeleportPlayer(pos, true, ((Component)target).transform.eulerAngles.y + 180f, false, true); lp.isInsideFactory = target.isInsideFactory; lp.isInHangarShipRoom = target.isInHangarShipRoom; lp.isInElevator = target.isInElevator; yield return (object)new WaitForSeconds(0.3f); } HUDManager.Instance.DisplayTip("Pile ou Face", target.playerUsername + " choisit son cote...", false, false, "LC_Tip1"); CoinNet.SendPrompt(target.actualClientId, lp.actualClientId); float t = 0f; while (choice == -1 && t < 20f) { t += Time.deltaTime; yield return null; } if (choice == -1) { choice = Random.Range(0, 2); } int side = Random.Range(0, 2); CoinNet.SendCinematic(target.actualClientId, lp.actualClientId, side, choice); yield return CoinCinematic.Instance.Play(lp.actualClientId, target.actualClientId, side, choice); busy = false; Current = null; } } }