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 LethalBoomba v1.2.0
BepInEx/plugins/LethalBommba.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalBommba.NetcodePatcher; using LethalBoomba.Behaviors; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalBommba")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("zhiyan114 © MIT License")] [assembly: AssemblyDescription("Explosion Item")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+eb5f44ceb20c78458bcaad0d08af57b3a787b36d")] [assembly: AssemblyProduct("LethalBommba")] [assembly: AssemblyTitle("LethalBommba")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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 LethalBoomba { public static class ConfigManager { [FloatValidation(0f)] public static ConfigEntry<float> Lotta_ZeroValueChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_ExplosionChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_RandEnemyChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_RandTrapChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_x1MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_x1_5MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_x2MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_x5MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Lotta_x10MultiChance; [FloatValidation(0f, 100f)] public static ConfigEntry<float> Druga_ExplodeChance; [FloatValidation(0f)] public static ConfigEntry<float> Druga_x0_5MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Druga_x0_75MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Druga_x1MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Druga_x1_5MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Druga_x2MultiChance; [FloatValidation(0f)] public static ConfigEntry<float> Druga_x3MultiChance; [RuntimeInitializeOnLoadMethod] private static void LoadConf() { Lotta_ZeroValueChance = Init.config.Bind<float>("lotta.host", "ZeroValueChance", 15f, "The weight/chance for a scratched lotta to have zero value"); Lotta_ExplosionChance = Init.config.Bind<float>("lotta.host", "ExplosionChance", 15f, "The weight/chance for a scratched lotta to explode"); Lotta_RandEnemyChance = Init.config.Bind<float>("lotta.host", "RandEnemyChance", 5f, "The weight/chance for a scratched lotta to spawn random enemy"); Lotta_RandTrapChance = Init.config.Bind<float>("lotta.host", "RandTrapChance", 5f, "The weight/chance for a scratched lotta to spawn random trap"); Lotta_x1MultiChance = Init.config.Bind<float>("lotta.host", "x1MultiChance", 25f, "The weight/chance for a scratched lotta to have unchanged value"); Lotta_x1_5MultiChance = Init.config.Bind<float>("lotta.host", "x1_5MultiChance", 20f, "The weight/chance for a scratched lotta to have x1.5 multiplier"); Lotta_x2MultiChance = Init.config.Bind<float>("lotta.host", "x2MultiChance", 10f, "The weight/chance for a scratched lotta to have x2 multiplier"); Lotta_x5MultiChance = Init.config.Bind<float>("lotta.host", "x5MultiChance", 3.5f, "The weight/chance for a scratched lotta to have x5 multiplier"); Lotta_x10MultiChance = Init.config.Bind<float>("lotta.host", "x10MultiChance", 1.5f, "The weight/chance for a scratched lotta to have x10 multiplier"); Druga_ExplodeChance = Init.config.Bind<float>("druga.host", "ExplodeChance", 30f, "The percentage (up to value of 100 + 2 dec place) for the in-take drug to explode"); Druga_x0_5MultiChance = Init.config.Bind<float>("druga.host", "x0_5MultiChance", 50f, "The weight/chance for the player stat to reduce by half"); Druga_x0_75MultiChance = Init.config.Bind<float>("druga.host", "x0_75MultiChance", 25f, "The weight/chance for the player stat to reduce by a quarter"); Druga_x1MultiChance = Init.config.Bind<float>("druga.host", "x1MultiChance", 15f, "The weight/chance for the player stat to have zero effects"); Druga_x1_5MultiChance = Init.config.Bind<float>("druga.host", "x1_5MultiChance", 5f, "The weight/chance for the player stat increase by half"); Druga_x2MultiChance = Init.config.Bind<float>("druga.host", "x2MultiChance", 3.5f, "The weight/chance for the player stat to double"); Druga_x3MultiChance = Init.config.Bind<float>("druga.host", "x3MultiChance", 1.5f, "The weight/chance for the player stat to triple"); CheckAllFieldAndSoftErrorOnFail(); } private static void CheckAllFieldAndSoftErrorOnFail() { FieldInfo[] fields = typeof(ConfigManager).GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); Init.logger.LogInfo((object)$"Checking {fields.Length} configs"); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (!fieldInfo.FieldType.IsGenericType || fieldInfo.FieldType.GetGenericTypeDefinition() != typeof(ConfigEntry<>)) { continue; } FloatValidation customAttribute = fieldInfo.GetCustomAttribute<FloatValidation>(inherit: false); if (customAttribute != null) { if (fieldInfo.FieldType.GetGenericArguments()[0] != typeof(float)) { throw new Exception("ConfigManager: FloatValidation applied to non-float config field (" + fieldInfo.Name + ")"); } if (customAttribute.checkMax && customAttribute.minVal > customAttribute.maxVal) { throw new Exception("ConfigManager: " + fieldInfo.Name + " contain valid validation (min value has higher number than max value)"); } ConfigEntry<float> val = (ConfigEntry<float>)fieldInfo.GetValue(null); if (val.Value < customAttribute.minVal) { Init.logger.LogError((object)$"ConfigManager: {((ConfigEntryBase)val).Definition.Key} ({((ConfigEntryBase)val).Definition.Section}) must have a min value of {customAttribute.minVal}, but got {val.Value}. Falling back to default value."); val.Value = (float)((ConfigEntryBase)val).DefaultValue; } else if (customAttribute.checkMax && val.Value > customAttribute.maxVal) { Init.logger.LogError((object)$"ConfigManager: {((ConfigEntryBase)val).Definition.Key} ({((ConfigEntryBase)val).Definition.Section}) can only have a max value of {customAttribute.maxVal}, but got {val.Value}. Falling back to default value."); val.Value = (float)((ConfigEntryBase)val).DefaultValue; } } } } } [AttributeUsage(AttributeTargets.Field)] public class FloatValidation : Attribute { public float minVal { get; private set; } public float maxVal { get; private set; } public bool checkMax { get; private set; } public FloatValidation(float minVal) { this.minVal = minVal; checkMax = false; } public FloatValidation(float minVal, float maxVal) { this.minVal = minVal; this.maxVal = maxVal; checkMax = true; } } [BepInPlugin("FurryNet.BoomBa", "BoomBa", "1.2.0")] public class Init : BaseUnityPlugin { public const string Guid = "FurryNet.BoomBa"; public const string Name = "BoomBa"; public const string Version = "1.2.0"; public static readonly ManualLogSource logger = Logger.CreateLogSource("FurryNet.BoomBa"); private static readonly Harmony harmony = new Harmony("FurryNet.BoomBa"); public static ConfigFile config { get; private set; } private void Awake() { config = ((BaseUnityPlugin)this).Config; Utils.ExecuteRuntimeInitAttr(typeof(ItemManager)); Utils.ExecuteRuntimeInitAttr(typeof(ConfigManager)); Utils.ExecuteRuntimeInitAttr(typeof(LottaOutcome)); Utils.ExecuteRuntimeInitAttr(typeof(DruGaHelper)); ItemManager.AddItem<BoomBaBehavior>("Assets/AssetBundles/BombToolkit/BoomBa/B00mbaProp.asset", 60); ItemManager.AddItem<NuKaBehavior>("Assets/AssetBundles/BombToolkit/NukeKa/NuKaProp.asset", 30); ItemManager.AddItem<LotTaBehavior>("Assets/AssetBundles/BombToolkit/LotTa/LottaProp.asset", 50); ItemManager.AddItem<DruGaBehavior>("Assets/AssetBundles/BombToolkit/DruGa/DruGaProp.asset", 50); harmony.PatchAll(typeof(ItemManager)); harmony.PatchAll(typeof(LottaOutcome)); harmony.PatchAll(typeof(UtilHelper)); harmony.PatchAll(typeof(DruGaHelper)); logger.LogInfo((object)"Patch Done..."); Utils.ExecuteRuntimeInitAttr(Assembly.GetExecutingAssembly().GetType("__GEN.NetworkVariableSerializationHelper")); logger.LogInfo((object)"NetVariable Init Done..."); } } public class ItemManager { private static Dictionary<string, ItemManager> _items; public static AssetBundle bundle { get; private set; } public static GameObject LargeExplosion { get; private set; } public static ItemManager[] items => _items.Values.ToArray(); public Item item { get; private set; } public int SpawnRate { get; private set; } private ItemManager() { } public static void AddItem(string assetPath, int spawnRate) { Item val = bundle.LoadAsset<Item>(assetPath); if ((Object)(object)val == (Object)null) { throw new Exception("Invalid asset bundle path: " + assetPath + "!"); } _items.Add(val.itemName, new ItemManager { item = val, SpawnRate = spawnRate }); PhysicsProp val2 = default(PhysicsProp); if (!val.spawnPrefab.TryGetComponent<PhysicsProp>(ref val2)) { PhysicsProp obj = val.spawnPrefab.AddComponent<PhysicsProp>(); ((GrabbableObject)obj).grabbable = true; ((GrabbableObject)obj).isInFactory = true; ((GrabbableObject)obj).grabbableToEnemies = true; ((GrabbableObject)obj).itemProperties = val; } Init.logger.LogInfo((object)("ItemManager: Added item " + val.itemName + " without custom behavior!")); } public static void AddItem<T>(string assetPath, int spawnRate) where T : GrabbableObject { Item val = bundle.LoadAsset<Item>(assetPath); if ((Object)(object)val == (Object)null) { throw new Exception("Invalid asset bundle path: " + assetPath + "!"); } _items.Add(val.itemName, new ItemManager { item = val, SpawnRate = spawnRate }); T val2 = default(T); if (!val.spawnPrefab.TryGetComponent<T>(ref val2)) { val.spawnPrefab.AddComponent<T>(); } Utils.ExecuteRuntimeInitAttr(typeof(T)); Init.logger.LogInfo((object)("ItemManager: Added item " + val.itemName + " with custom behavior!")); } public static Item? GetItem(string itemName) { return _items.GetValueOrDefault(itemName)?.item; } [RuntimeInitializeOnLoadMethod] private static void InitFirst() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bombpack"); if (!File.Exists(text)) { throw new Exception("bombpack asset missing!"); } _items = new Dictionary<string, ItemManager>(); bundle = AssetBundle.LoadFromFile(text); LargeExplosion = bundle.LoadAsset<GameObject>("Assets/AssetBundles/BombToolkit/NukeKa/Effect/NuKaBoomEffect.prefab"); Init.logger.LogInfo((object)"ItemManager: Successfully Loaded Bundle..."); } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] private static void SetupNetPrefab(GameNetworkManager __instance) { NetworkManager component = ((Component)__instance).GetComponent<NetworkManager>(); foreach (ItemManager value in _items.Values) { component.AddNetworkPrefab(value.item.spawnPrefab); } Init.logger.LogInfo((object)"ItemManager: Configured Network Prefabs"); } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void SetupItemSpawn(StartOfRound __instance) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown foreach (ItemManager itemMGR in _items.Values) { if (!__instance.allItemsList.itemsList.Contains(itemMGR.item)) { __instance.allItemsList.itemsList.Add(itemMGR.item); } SelectableLevel[] levels = __instance.levels; foreach (SelectableLevel val in levels) { if (!val.spawnableScrap.Any((SpawnableItemWithRarity k) => (Object)(object)k.spawnableItem == (Object)(object)itemMGR.item)) { val.spawnableScrap.Add(new SpawnableItemWithRarity(itemMGR.item, itemMGR.SpawnRate)); } } } Init.logger.LogInfo((object)"ItemManager: Successfully Loaded all items to all maps"); } } public static class Utils { public static List<EnemyType> globalEnemies = new List<EnemyType>(); public static List<IndoorMapHazardType> globalTraps = new List<IndoorMapHazardType>(); public static GameObject? confettiPrefab; public static void Explode(Vector3 position, float killRadius, float force = 10f) { //IL_0017: 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_0046: 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_008e: 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_00a1: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsClient) { return; } Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, position, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform).SetActive(true); Collider[] array = Physics.OverlapSphere(position, killRadius, LayerMask.GetMask(new string[2] { "Player", "Enemies" })); foreach (Collider obj in array) { PlayerControllerB componentInParent = ((Component)obj).GetComponentInParent<PlayerControllerB>(); if ((Object)(object)componentInParent != (Object)null) { float num = Vector3.Distance(((Component)componentInParent).transform.position, position); Vector3 val = ((Component)componentInParent).transform.position - position; Vector3 val2 = ((Vector3)(ref val)).normalized * (force / Mathf.Max(num, 0.1f)); if (num <= killRadius) { val = default(Vector3); componentInParent.KillPlayer(val2, true, (CauseOfDeath)3, 0, val, false); } } EnemyAI componentInParent2 = ((Component)obj).GetComponentInParent<EnemyAI>(); if ((Object)(object)componentInParent2 != (Object)null && Vector3.Distance(((Component)componentInParent2).transform.position, position) <= killRadius) { componentInParent2.KillEnemyServerRpc(componentInParent2.enemyType.destroyOnDeath || !componentInParent2.enemyType.canDie); } } if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { float num2 = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, position); HUDManager.Instance.ShakeCamera((ScreenShakeType)((num2 < killRadius) ? 1 : 0)); } } public static void HideNetObject(GameObject obj) { Renderer val = default(Renderer); if (obj.TryGetComponent<Renderer>(ref val)) { val.enabled = false; } Collider val2 = default(Collider); if (obj.TryGetComponent<Collider>(ref val2)) { val2.enabled = false; } } public static void ExecuteRuntimeInitAttr(Type type) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (((MemberInfo)methodInfo).GetCustomAttribute<RuntimeInitializeOnLoadMethodAttribute>(inherit: false) != null) { methodInfo.Invoke(null, null); } } } } public static class UtilHelper { [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] private static void FetchGameObjects() { Utils.globalEnemies = new List<EnemyType>(Resources.FindObjectsOfTypeAll<EnemyType>()); Utils.globalTraps = new List<IndoorMapHazardType>(Resources.FindObjectsOfTypeAll<IndoorMapHazardType>()); Init.logger.LogInfo((object)"Enemy/Trap data fetched!"); Utils.confettiPrefab = ((IEnumerable<StunGrenadeItem>)Resources.FindObjectsOfTypeAll<StunGrenadeItem>()).FirstOrDefault((Func<StunGrenadeItem, bool>)((StunGrenadeItem k) => ((GrabbableObject)k).itemProperties.itemName == "Easter egg"))?.stunGrenadeExplosion; Init.logger.LogInfo((object)$"Easter Egg Confetti found: {(Object)(object)Utils.confettiPrefab != (Object)null}"); } } } namespace LethalBoomba.Behaviors { public class BoomBaBehavior : GrabbableObject { [SerializeField] private AudioClip preExplodeSound; [SerializeField] private float countdownSec; [SerializeField] private float blastRadius; [SerializeField] private AnimationCurve grenadeFallCurve; [SerializeField] private AnimationCurve grenadeVerticalFallCurve; [SerializeField] private AnimationCurve grenadeVerticalFallCurveNoBounce; private AudioSource BombSrc; private int grenadeThrowMask = 268437761; private NetworkVariable<bool> isDetonated = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private void Awake() { BombSrc = ((Component)this).GetComponent<AudioSource>(); } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_0014: 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_0038: Unknown result type (might be due to invalid IL or missing references) if (buttonDown) { if (!isDetonated.Value) { StartBoomServerRpc(); } else if ((Object)(object)base.playerHeldBy != (Object)null) { base.playerHeldBy.DiscardHeldObject(true, (NetworkObject)null, GetGrenadeThrowDestination(), true); } } } public override void SetControlTipsForItem() { HUDManager.Instance.ChangeControlTipMultiple(new string[1] { isDetonated.Value ? "Throw Bomb : [LMB]" : "Detonate Bomb : [LMB]" }, true, base.itemProperties); } [Rpc(/*Could not decode attribute arguments.*/)] private void StartBoomServerRpc(RpcParams rpcParam = default(RpcParams)) { //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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0077: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(700783189u, rpcParam, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 700783189u, rpcParam, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!isDetonated.Value) { isDetonated.Value = true; ((MonoBehaviour)this).StartCoroutine(ManagedExecution()); } } } private IEnumerator ManagedExecution() { if (NetworkManager.Singleton.IsServer) { ExecuteStageClientRpc(); yield return (object)new WaitForSeconds(countdownSec + 3f); ((Component)this).GetComponent<NetworkObject>().Despawn(true); } } private IEnumerator CountdownRoutine() { if (!NetworkManager.Singleton.IsClient) { yield break; } if (!StartOfRound.Instance.shipHasLanded) { if (((NetworkBehaviour)this).IsOwner) { PlayerControllerB playerHeldBy = base.playerHeldBy; if (playerHeldBy != null) { playerHeldBy.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true); } } base.grabbable = false; } BombSrc.PlayOneShot(preExplodeSound); WalkieTalkie.TransmitOneShotAudio(BombSrc, preExplodeSound, 1f); yield return (object)new WaitForSeconds(countdownSec); Utils.Explode(((Component)this).GetComponent<Transform>().position, blastRadius); HUDManager.Instance.ShakeCamera((ScreenShakeType)1); Utils.HideNetObject(((Component)this).gameObject); } [Rpc(/*Could not decode attribute arguments.*/)] private void ExecuteStageClientRpc() { //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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0077: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(41736811u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 41736811u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ((MonoBehaviour)this).StartCoroutine(CountdownRoutine()); } } } private Vector3 GetGrenadeThrowDestination() { //IL_0014: 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) //IL_0029: 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_004e: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0087: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) Camera gameplayCamera = base.playerHeldBy.gameplayCamera; Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)gameplayCamera).transform.position, ((Component)gameplayCamera).transform.forward); RaycastHit val3 = default(RaycastHit); Vector3 val2 = ((!Physics.Raycast(val, ref val3, 12f, grenadeThrowMask, (QueryTriggerInteraction)1)) ? ((Ray)(ref val)).GetPoint(10f) : ((Ray)(ref val)).GetPoint(((RaycastHit)(ref val3)).distance - 0.05f)); ((Ray)(ref val))..ctor(val2, Vector3.down); if (Physics.Raycast(val, ref val3, 30f, grenadeThrowMask, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val3)).point + Vector3.up * (base.itemProperties.verticalOffset + 0.05f); } return ((Ray)(ref val)).GetPoint(30f); } public override void FallWithCurve() { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_005b: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) Vector3 val = base.startFallingPosition - base.targetFloorPosition; float magnitude = ((Vector3)(ref val)).magnitude; ((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(base.itemProperties.restingRotation.x, ((Component)this).transform.eulerAngles.y, base.itemProperties.restingRotation.z), 14f * Time.deltaTime / magnitude); ((Component)this).transform.localPosition = Vector3.Lerp(base.startFallingPosition, base.targetFloorPosition, grenadeFallCurve.Evaluate(base.fallTime)); if (magnitude > 5f) { ((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, base.startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, base.targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurveNoBounce.Evaluate(base.fallTime)); } else { ((Component)this).transform.localPosition = Vector3.Lerp(new Vector3(((Component)this).transform.localPosition.x, base.startFallingPosition.y, ((Component)this).transform.localPosition.z), new Vector3(((Component)this).transform.localPosition.x, base.targetFloorPosition.y, ((Component)this).transform.localPosition.z), grenadeVerticalFallCurve.Evaluate(base.fallTime)); } base.fallTime += Mathf.Abs(Time.deltaTime * 12f / magnitude); } protected override void __initializeVariables() { if (isDetonated == null) { throw new Exception("BoomBaBehavior.isDetonated cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)isDetonated).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isDetonated, "isDetonated"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isDetonated); ((GrabbableObject)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(700783189u, new RpcReceiveHandler(__rpc_handler_700783189), "StartBoomServerRpc"); ((NetworkBehaviour)this).__registerRpc(41736811u, new RpcReceiveHandler(__rpc_handler_41736811), "ExecuteStageClientRpc"); ((GrabbableObject)this).__initializeRpcs(); } private static void __rpc_handler_700783189(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { RpcParams ext = rpcParams.Ext; target.__rpc_exec_stage = (__RpcExecStage)1; ((BoomBaBehavior)(object)target).StartBoomServerRpc(ext); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_41736811(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; ((BoomBaBehavior)(object)target).ExecuteStageClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "BoomBaBehavior"; } } public class DruGaBehavior : GrabbableObject { private AudioSource AudioSrc; [SerializeField] private AudioClip EatSfx; private float eatCountDown; private NetworkVariable<ushort> RawState = new NetworkVariable<ushort>((ushort)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private DruGaHelper.ActionType ActionState; private DruGaHelper.MultiplierType MultiplierState; private void Awake() { AudioSrc = ((Component)this).GetComponent<AudioSource>(); eatCountDown = EatSfx.length + 0.25f; NetworkVariable<ushort> rawState = RawState; rawState.OnValueChanged = (OnValueChangedDelegate<ushort>)(object)Delegate.Combine((Delegate?)(object)rawState.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<ushort>)delegate(ushort _, ushort k) { ActionState = (DruGaHelper.ActionType)(k & 0xFF); MultiplierState = (DruGaHelper.MultiplierType)(k >> 8); }); } public override void ItemActivate(bool used, bool buttonDown = true) { if (base.playerHeldBy.activatingItem) { return; } if (!StartOfRound.Instance.shipHasLanded) { if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("DruGa Outcome", "This drug isn't tasty enough while in the ship :P", false, false, "LC_Tip1"); } return; } if (((NetworkBehaviour)this).IsOwner) { base.playerHeldBy.activatingItem = true; } ((MonoBehaviour)this).StartCoroutine(ProcessActivation()); } private IEnumerator ProcessActivation() { if (!NetworkManager.Singleton.IsClient) { yield break; } AudioSrc.PlayOneShot(EatSfx); WalkieTalkie.TransmitOneShotAudio(AudioSrc, EatSfx, 1f); yield return (object)new WaitForSeconds(eatCountDown); RequestUsageServerRpc(); yield return (object)new WaitUntil((Func<bool>)(() => ActionState != DruGaHelper.ActionType.Unused)); if (ActionState == DruGaHelper.ActionType.Explosion) { if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("DruGa Outcome", "Oops, you got unlucky :(", false, false, "LC_Tip1"); base.playerHeldBy.activatingItem = false; } Utils.Explode(((Component)this).transform.position, 10f); Utils.HideNetObject(((Component)this).gameObject); if (((NetworkBehaviour)this).IsOwner) { base.playerHeldBy.DespawnHeldObject(); } yield break; } float num = 0f; switch (MultiplierState) { case DruGaHelper.MultiplierType.Multi0_5: num = 0.5f; break; case DruGaHelper.MultiplierType.Multi0_75: num = 0.75f; break; case DruGaHelper.MultiplierType.Multi1: num = 1f; break; case DruGaHelper.MultiplierType.Multi1_5: num = 1.5f; break; case DruGaHelper.MultiplierType.Multi2: num = 2f; break; case DruGaHelper.MultiplierType.Multi3: num = 3f; break; } switch (ActionState) { case DruGaHelper.ActionType.Health: { PlayerControllerB playerHeldBy2 = base.playerHeldBy; playerHeldBy2.health *= Mathf.RoundToInt((float)base.playerHeldBy.health * num); if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("DruGa Outcome", $"You received a health multiplier of {num}x", false, false, "LC_Tip1"); } break; } case DruGaHelper.ActionType.Speed: { PlayerControllerB playerHeldBy3 = base.playerHeldBy; playerHeldBy3.movementSpeed *= num; if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("DruGa Outcome", $"You received a speed multiplier of {num}x", false, false, "LC_Tip1"); } break; } case DruGaHelper.ActionType.JumpPower: { PlayerControllerB playerHeldBy = base.playerHeldBy; playerHeldBy.jumpForce *= num; if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("DruGa Outcome", $"You received a jump power multiplier of {num}x", false, false, "LC_Tip1"); } break; } } if (((NetworkBehaviour)this).IsOwner) { base.playerHeldBy.activatingItem = false; } base.playerHeldBy.DespawnHeldObject(); Utils.HideNetObject(((Component)this).gameObject); } [Rpc(/*Could not decode attribute arguments.*/)] private void RequestUsageServerRpc() { //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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0077: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3359047376u, val3, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3359047376u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; RawState.Value = DruGaHelper.GetRNGState(); } } } protected override void __initializeVariables() { if (RawState == null) { throw new Exception("DruGaBehavior.RawState cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)RawState).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)RawState, "RawState"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)RawState); ((GrabbableObject)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 ((NetworkBehaviour)this).__registerRpc(3359047376u, new RpcReceiveHandler(__rpc_handler_3359047376), "RequestUsageServerRpc"); ((GrabbableObject)this).__initializeRpcs(); } private static void __rpc_handler_3359047376(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; ((DruGaBehavior)(object)target).RequestUsageServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "DruGaBehavior"; } } public class DruGaHelper { public enum ActionType : byte { Unused, Explosion, Health, Speed, JumpPower } public enum MultiplierType : byte { Unused, Multi0_5, Multi0_75, Multi1, Multi1_5, Multi2, Multi3 } public static IReadOnlyList<DruGaHelper> statsWeights; public static int totalWeights; public MultiplierType state; public int weights; public static ushort GetRNGState() { int num = Mathf.RoundToInt(ConfigManager.Druga_ExplodeChance.Value * 100f); int @int = RandomNumberGenerator.GetInt32(0, 10000); if (@int < num) { return 1; } ActionType actionType = ActionType.Unused; switch (RandomNumberGenerator.GetInt32(0, 3)) { case 0: actionType = ActionType.Health; break; case 1: actionType = ActionType.Speed; break; case 2: actionType = ActionType.JumpPower; break; } @int = RandomNumberGenerator.GetInt32(0, totalWeights); int num2 = 0; for (int i = 0; i < statsWeights.Count; i++) { int num3 = statsWeights[i].weights; if (num2 + num3 > @int) { return (ushort)((uint)actionType | ((uint)statsWeights[i].state << 8)); } num2 += num3; } throw new Exception("GetRNGState: Huh, this is here for control-flow purposes. If you see this, something is terribly wrong..."); } [RuntimeInitializeOnLoadMethod] private static void SetupWeights() { statsWeights = new List<DruGaHelper> { new DruGaHelper(MultiplierType.Multi0_5, ConfigManager.Druga_x0_5MultiChance.Value), new DruGaHelper(MultiplierType.Multi0_75, ConfigManager.Druga_x0_75MultiChance.Value), new DruGaHelper(MultiplierType.Multi1, ConfigManager.Druga_x1MultiChance.Value), new DruGaHelper(MultiplierType.Multi1_5, ConfigManager.Druga_x1_5MultiChance.Value), new DruGaHelper(MultiplierType.Multi2, ConfigManager.Druga_x2MultiChance.Value), new DruGaHelper(MultiplierType.Multi3, ConfigManager.Druga_x3MultiChance.Value) }; totalWeights = statsWeights.Sum((DruGaHelper k) => k.weights); } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> PatchHealth(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo method = typeof(Mathf).GetMethod("Clamp", new Type[3] { typeof(int), typeof(int), typeof(int) }); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], method) && i - 1 >= 0) { CodeInstruction val = list[i - 1]; if (val.opcode == OpCodes.Ldc_I4_S && val.operand is sbyte b && b == 100) { val.opcode = OpCodes.Ldc_I4; val.operand = int.MaxValue; break; } } } return list; } public DruGaHelper(MultiplierType multiState, float percentage) { state = multiState; weights = Mathf.RoundToInt(percentage * 100f); } } public class LotTaBehavior : GrabbableObject { private AudioSource AudioSrc; [SerializeField] private AudioClip ScratchSound; [SerializeField] private AudioClip WinnerSFX; [SerializeField] private float countdownSec; [HideInInspector] public static List<LotTaBehavior> UnscratchedTickets = new List<LotTaBehavior>(); [HideInInspector] public NetworkVariable<int> scrapVal = new NetworkVariable<int>(-1, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); [HideInInspector] public NetworkVariable<LottaOutcome.Opts> Result = new NetworkVariable<LottaOutcome.Opts>(LottaOutcome.Opts.Unselected, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public bool isScratched => Result.Value != LottaOutcome.Opts.Unselected; private void Awake() { AudioSrc = ((Component)this).GetComponent<AudioSource>(); NetworkVariable<int> obj = scrapVal; obj.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<int>)delegate(int _, int val) { ((GrabbableObject)this).SetScrapValue(val); }); NetworkVariable<LottaOutcome.Opts> result = Result; result.OnValueChanged = (OnValueChangedDelegate<LottaOutcome.Opts>)(object)Delegate.Combine((Delegate?)(object)result.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<LottaOutcome.Opts>(serverResUpdate)); } private void serverResUpdate(LottaOutcome.Opts old, LottaOutcome.Opts val) { if (old == LottaOutcome.Opts.Unselected && val != LottaOutcome.Opts.Unselected) { UnscratchedTickets.Remove(this); } } public override void OnNetworkSpawn() { UnscratchedTickets.Add(this); ((NetworkBehaviour)this).OnNetworkSpawn(); } public override void OnNetworkDespawn() { UnscratchedTickets.Remove(this); ((NetworkBehaviour)this).OnNetworkDespawn(); } public override void ItemActivate(bool used, bool buttonDown = true) { if (!isScratched && !base.playerHeldBy.activatingItem) { if (((NetworkBehaviour)this).IsOwner) { base.playerHeldBy.activatingItem = true; } ((MonoBehaviour)this).StartCoroutine(HandleTicketActivation()); } } private IEnumerator HandleTicketActivation() { if (!NetworkManager.Singleton.IsClient) { yield break; } AudioSrc.PlayOneShot(ScratchSound); WalkieTalkie.TransmitOneShotAudio(AudioSrc, ScratchSound, 1f); yield return (object)new WaitForSeconds(1f); if (((NetworkBehaviour)this).IsOwner) { StartScratchServerRpc(); } yield return (object)new WaitUntil((Func<bool>)(() => isScratched)); switch (Result.Value) { case LottaOutcome.Opts.NoState: HUDManager.Instance.DisplayTip("LotTa Outcome", "Invalid State Detected (The item was spawned by a mod while in an invalid state :p)", false, false, "LC_Tip1"); base.playerHeldBy.activatingItem = false; yield break; case LottaOutcome.Opts.Explosion: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", "Aww, you got explosion!", false, false, "LC_Tip1"); base.playerHeldBy.activatingItem = false; } Utils.Explode(((Component)this).transform.position, 10f); Utils.HideNetObject(((Component)this).gameObject); if (((NetworkBehaviour)this).IsOwner) { base.playerHeldBy.DespawnHeldObject(); } yield break; case LottaOutcome.Opts.RandEnemy: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", "Aww, you got random enemy spawned on you!", false, false, "LC_Tip1"); base.playerHeldBy.activatingItem = false; base.playerHeldBy.DespawnHeldObject(); } Utils.HideNetObject(((Component)this).gameObject); yield break; case LottaOutcome.Opts.RandTrap: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", "Aww, you got random trap spawned on you!", false, false, "LC_Tip1"); base.playerHeldBy.activatingItem = false; base.playerHeldBy.DespawnHeldObject(); } Utils.HideNetObject(((Component)this).gameObject); yield break; case LottaOutcome.Opts.ZeroValue: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", "Well, at least you only lose all the value of the ticket!", false, false, "LC_Tip1"); base.playerHeldBy.activatingItem = false; } yield break; case LottaOutcome.Opts.x1Multi: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", "Kinda lucky that you didnt lose any ticket value!", false, false, "LC_Tip1"); } break; case LottaOutcome.Opts.x1_5Multi: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", $"Congrat, you got x1.5 more value on the ticket! Total Value: {(isScratched ? ((float)base.scrapValue) : ((float)base.scrapValue * 1.5f))}", false, false, "LC_Tip1"); } break; case LottaOutcome.Opts.x2Multi: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", $"Wow, you got x2 more value on the ticket! Total Value: {(isScratched ? ((float)base.scrapValue) : ((float)base.scrapValue * 2f))}", false, false, "LC_Tip1"); } break; case LottaOutcome.Opts.x5Multi: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", $"Crazy luck, you got x5 more value on the ticket! Total Value: {(isScratched ? ((float)base.scrapValue) : ((float)base.scrapValue * 5f))}", false, false, "LC_Tip1"); } break; case LottaOutcome.Opts.x10Multi: if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.DisplayTip("LotTa Outcome", $"Insane luck, you got x10 more value on the ticket! Total Value: {(isScratched ? ((float)base.scrapValue) : ((float)base.scrapValue * 10f))}", false, false, "LC_Tip1"); } break; } if (((NetworkBehaviour)this).IsOwner) { base.playerHeldBy.activatingItem = false; } if (Object.op_Implicit((Object)(object)Utils.confettiPrefab) && (int)Result.Value > 5) { Object.Instantiate<GameObject>(Utils.confettiPrefab, ((Component)this).transform.position, Quaternion.identity, (!base.isInElevator) ? RoundManager.Instance.mapPropsContainer.transform : StartOfRound.Instance.elevatorTransform); AudioSrc.PlayOneShot(WinnerSFX); WalkieTalkie.TransmitOneShotAudio(AudioSrc, WinnerSFX, 1f); } } [Rpc(/*Could not decode attribute arguments.*/)] private void StartScratchServerRpc(RpcParams rpcParam = default(RpcParams)) { //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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0077: 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_00e5: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(574698563u, rpcParam, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 574698563u, rpcParam, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (isScratched) { return; } if (!StartOfRound.Instance.shipHasLanded) { scrapVal.Value = base.scrapValue; Result.Value = LottaOutcome.Opts.NoState; return; } ulong senderClientId = rpcParam.Receive.SenderClientId; PlayerControllerB owner = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => ((NetworkBehaviour)p).OwnerClientId == senderClientId)); ((MonoBehaviour)this).StartCoroutine(ExecuteReq(owner)); } private IEnumerator ExecuteReq(PlayerControllerB owner) { if (NetworkManager.Singleton.IsServer && !isScratched) { LottaOutcome.Opts randItem = LottaOutcome.getRandItem(); switch (randItem) { case LottaOutcome.Opts.Explosion: yield return ProcessState(randItem); break; case LottaOutcome.Opts.RandEnemy: yield return ProcessState(randItem); LottaOutcome.spawnRandEnemy(owner, ((Component)this).transform.position, !owner.isInsideFactory); break; case LottaOutcome.Opts.RandTrap: yield return ProcessState(randItem); LottaOutcome.spawnRandTrap(owner, ((Component)this).transform.position); break; default: yield return ProcessState(randItem); break; } } } private IEnumerator ProcessState(LottaOutcome.Opts opt) { if (NetworkManager.Singleton.IsServer) { switch (opt) { case LottaOutcome.Opts.x1Multi: scrapVal.Value = base.scrapValue; break; case LottaOutcome.Opts.x1_5Multi: scrapVal.Value = Mathf.RoundToInt((float)base.scrapValue * 1.5f); break; case LottaOutcome.Opts.x2Multi: scrapVal.Value = Mathf.RoundToInt((float)base.scrapValue * 2f); break; case LottaOutcome.Opts.x5Multi: scrapVal.Value = Mathf.RoundToInt((float)base.scrapValue * 5f); break; case LottaOutcome.Opts.x10Multi: scrapVal.Value = Mathf.RoundToInt((float)base.scrapValue * 10f); break; default: scrapVal.Value = 0; break; } Result.Value = opt; } yield break; } public override void SetControlTipsForItem() { bool flag = !isScratched && (StartOfRound.Instance?.shipHasLanded ?? false); HUDManager.Instance.ChangeControlTipMultiple(flag ? base.itemProperties.toolTips : new string[0], true, base.itemProperties); } public override int GetItemDataToSave() { ((GrabbableObject)this).GetItemDataToSave(); return (int)Result.Value; } public override void LoadItemSaveData(int saveData) { ((GrabbableObject)this).LoadItemSaveData(saveData); Result.Value = (LottaOutcome.Opts)saveData; } protected override void __initializeVariables() { if (scrapVal == null) { throw new Exception("LotTaBehavior.scrapVal cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)scrapVal).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)scrapVal, "scrapVal"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)scrapVal); if (Result == null) { throw new Exception("LotTaBehavior.Result cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)Result).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)Result, "Result"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)Result); ((GrabbableObject)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 ((NetworkBehaviour)this).__registerRpc(574698563u, new RpcReceiveHandler(__rpc_handler_574698563), "StartScratchServerRpc"); ((GrabbableObject)this).__initializeRpcs(); } private static void __rpc_handler_574698563(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { RpcParams ext = rpcParams.Ext; target.__rpc_exec_stage = (__RpcExecStage)1; ((LotTaBehavior)(object)target).StartScratchServerRpc(ext); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "LotTaBehavior"; } } public class LottaOutcome { public enum Opts : byte { Unselected, ZeroValue, Explosion, RandEnemy, RandTrap, x1Multi, x1_5Multi, x2Multi, x5Multi, x10Multi, NoState } private static int totalVal; public static IReadOnlyList<LottaOutcome> StatTable { get; private set; } private Opts option { get; set; } private int chance { get; set; } public static Opts getRandItem() { int @int = RandomNumberGenerator.GetInt32(0, totalVal); int num = 0; foreach (LottaOutcome item in StatTable) { if (item.chance + num > @int) { return item.option; } num += item.chance; } throw new Exception("getRandItem: Huh, this is here for control-flow purposes. If you see this, something is terribly wrong..."); } [RuntimeInitializeOnLoadMethod] private static void SetupOutcomeTable() { StatTable = new List<LottaOutcome> { new LottaOutcome(Opts.ZeroValue, ConfigManager.Lotta_ZeroValueChance.Value), new LottaOutcome(Opts.Explosion, ConfigManager.Lotta_ExplosionChance.Value), new LottaOutcome(Opts.RandEnemy, ConfigManager.Lotta_RandEnemyChance.Value), new LottaOutcome(Opts.RandTrap, ConfigManager.Lotta_RandTrapChance.Value), new LottaOutcome(Opts.x1Multi, ConfigManager.Lotta_x1MultiChance.Value), new LottaOutcome(Opts.x1_5Multi, ConfigManager.Lotta_x1_5MultiChance.Value), new LottaOutcome(Opts.x2Multi, ConfigManager.Lotta_x2MultiChance.Value), new LottaOutcome(Opts.x5Multi, ConfigManager.Lotta_x5MultiChance.Value), new LottaOutcome(Opts.x10Multi, ConfigManager.Lotta_x10MultiChance.Value) }; totalVal = StatTable.Sum((LottaOutcome k) => k.chance); } private LottaOutcome(Opts opt, float chance) { option = opt; this.chance = Mathf.FloorToInt(chance * 100f); } public static void spawnRandEnemy(PlayerControllerB owner, Vector3 objectPOS, bool outdoorEnemy = true) { //IL_0029: 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_0042: 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_0058: 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) EnemyType[] array = Utils.globalEnemies.Where((EnemyType k) => k.isOutsideEnemy == outdoorEnemy).ToArray(); RaycastHit val2 = default(RaycastHit); Vector3 val = (Physics.Raycast(objectPOS, Vector3.down, ref val2, 10f) ? ((RaycastHit)(ref val2)).point : objectPOS); GameObject obj = Object.Instantiate<GameObject>(array[RandomNumberGenerator.GetInt32(0, array.Length)].enemyPrefab, val, Quaternion.identity); obj.GetComponent<NetworkObject>().Spawn(true); EnemyAI component = obj.GetComponent<EnemyAI>(); RoundManager.Instance.SpawnedEnemies.Add(component); EnemyType enemyType = component.enemyType; enemyType.numberSpawned++; component.enemyType.hasSpawnedAtLeastOne = true; } public static void spawnRandTrap(PlayerControllerB owner, Vector3 objectPOS) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0014: 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_003e: 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_004b: 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) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) RaycastHit val2 = default(RaycastHit); Vector3 val = (Physics.Raycast(objectPOS, Vector3.down, ref val2, 10f) ? ((RaycastHit)(ref val2)).point : objectPOS); GameObject prefabToSpawn = Utils.globalTraps[RandomNumberGenerator.GetInt32(0, Utils.globalTraps.Count)].prefabToSpawn; Vector3 val3 = ((Component)owner).transform.position - val; Object.Instantiate<GameObject>(prefabToSpawn, val, Quaternion.LookRotation(((Vector3)(ref val3)).normalized), RoundManager.Instance.mapPropsContainer.transform).GetComponent<NetworkObject>().Spawn(true); } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] [HarmonyPostfix] public static void MarkAllLottoUnscratchable() { if (!NetworkManager.Singleton.IsServer) { return; } LotTaBehavior[] array = LotTaBehavior.UnscratchedTickets.ToArray(); foreach (LotTaBehavior lotTaBehavior in array) { if (((NetworkBehaviour)lotTaBehavior).IsSpawned && !lotTaBehavior.isScratched) { lotTaBehavior.scrapVal.Value = ((GrabbableObject)lotTaBehavior).scrapValue; lotTaBehavior.Result.Value = Opts.NoState; } } if (LotTaBehavior.UnscratchedTickets.Count > 0) { Init.logger.LogError((object)$"UnscratchedTickets expected zero item, but got {LotTaBehavior.UnscratchedTickets.Count}"); } } } public class NuKaBehavior : GrabbableObject { [SerializeField] private AudioClip preExplodeSound; [SerializeField] private float countdownSec; [SerializeField] private float beforeKillcdSec; private AudioSource BombSrc; private NetworkVariable<bool> isDetonated = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private void Awake() { BombSrc = ((Component)this).GetComponents<AudioSource>()[1]; } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_0014: 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) if (buttonDown && !isDetonated.Value) { StartBoomServerRpc(); } } [Rpc(/*Could not decode attribute arguments.*/)] private void StartBoomServerRpc(RpcParams rpcParam = default(RpcParams)) { //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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0077: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(4197946983u, rpcParam, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 4197946983u, rpcParam, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!isDetonated.Value) { isDetonated.Value = true; ((MonoBehaviour)this).StartCoroutine(ManagedExecution()); } } } private IEnumerator ManagedExecution() { if (NetworkManager.Singleton.IsServer) { ExecuteStageClientRpc(); yield return (object)new WaitForSeconds(countdownSec + beforeKillcdSec + 1f); ((Component)this).GetComponent<NetworkObject>().Despawn(true); } } private IEnumerator CountdownRoutine() { if (NetworkManager.Singleton.IsClient) { BombSrc.PlayOneShot(preExplodeSound); yield return (object)new WaitForSeconds(countdownSec); Object.Instantiate<GameObject>(ItemManager.LargeExplosion, ((Component)this).GetComponent<Transform>().position, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform).SetActive(true); HUDManager.Instance.ShakeCamera((ScreenShakeType)3); yield return (object)new WaitForSeconds(beforeKillcdSec); GameNetworkManager.Instance.localPlayerController.KillPlayer(Vector3.zero, true, (CauseOfDeath)3, 0, default(Vector3), false); Utils.HideNetObject(((Component)this).gameObject); } } [Rpc(/*Could not decode attribute arguments.*/)] private void ExecuteStageClientRpc() { //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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0077: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(107613353u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 107613353u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ((MonoBehaviour)this).StartCoroutine(CountdownRoutine()); } } } protected override void __initializeVariables() { if (isDetonated == null) { throw new Exception("NuKaBehavior.isDetonated cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)isDetonated).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isDetonated, "isDetonated"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isDetonated); ((GrabbableObject)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(4197946983u, new RpcReceiveHandler(__rpc_handler_4197946983), "StartBoomServerRpc"); ((NetworkBehaviour)this).__registerRpc(107613353u, new RpcReceiveHandler(__rpc_handler_107613353), "ExecuteStageClientRpc"); ((GrabbableObject)this).__initializeRpcs(); } private static void __rpc_handler_4197946983(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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { RpcParams ext = rpcParams.Ext; target.__rpc_exec_stage = (__RpcExecStage)1; ((NuKaBehavior)(object)target).StartBoomServerRpc(ext); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_107613353(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; ((NuKaBehavior)(object)target).ExecuteStageClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "NuKaBehavior"; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<LottaOutcome.Opts>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<LottaOutcome.Opts>(); } } } namespace LethalBommba.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }