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 TrepidPerks v1.3.1
TrepidPerks.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.UI; [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("Trepidrock")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Trepidrock")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: AssemblyInformationalVersion("1.3.1")] [assembly: AssemblyProduct("TrepidPerks")] [assembly: AssemblyTitle("TrepidPerks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] [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 TrepidPerks { public static class TrepidPerksAPI { public static float ReloadSpeedMultiplier { get { if (!SpeedCola.Active) { return 1f; } return SpeedCola.ReloadMult; } } public static float MeleeSpeedMultiplier { get { if (!SpeedCola.Active) { return 1f; } return SpeedCola.Mult; } } public static bool HasPerk(string name) { foreach (PerkDef item in Perks.All) { if (item.Name == name) { return item.LocalHasPerk; } } return false; } } public class BottleDrink : MonoBehaviour { private PlayerControllerB player; private bool isLocal; private float t; private float duration; private float size; private bool applied; private PerkDef perk; private static readonly Vector3 Rest = new Vector3(0.24f, -0.45f, 0.4f); private static readonly Vector3 Mouth = new Vector3(0f, -0.07f, 0.17f); internal static void Begin(PlayerControllerB p, bool local, PerkDef perk) { //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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null || (Object)(object)p.gameplayCamera == (Object)null || (Object)(object)perk.BottleMesh == (Object)null) { if (local) { PerkNet.LocalApplyPerk(perk); PerkNet.Drinking = false; } return; } GameObject val = new GameObject("JuggernogBottleDrink"); val.transform.SetParent(((Component)p.gameplayCamera).transform, false); val.AddComponent<MeshFilter>().sharedMesh = perk.BottleMesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = perk.BottleMaterial; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; val.layer = 0; BottleDrink bottleDrink = val.AddComponent<BottleDrink>(); bottleDrink.player = p; bottleDrink.isLocal = local; bottleDrink.perk = perk; bottleDrink.duration = Mathf.Max(0.5f, Plugin.DuracionTrago.Value); bottleDrink.size = Plugin.TamanoBotella.Value; Vector3 lossyScale = ((Component)p.gameplayCamera).transform.lossyScale; val.transform.localScale = new Vector3(bottleDrink.size / lossyScale.x, bottleDrink.size / lossyScale.y, bottleDrink.size / lossyScale.z); bottleDrink.Pose(0f); } private static float Smooth(float u) { u = Mathf.Clamp01(u); return u * u * (3f - 2f * u); } private void Pose(float k) { //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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) float num2; float num3; if (k < 0.22f) { float num = Smooth(k / 0.22f); num2 = Mathf.Lerp(10f, 60f, num); num3 = num; } else if (k < 0.78f) { float num4 = Smooth((k - 0.22f) / 0.56f); num2 = Mathf.Lerp(60f, 128f, num4); num3 = 1f; } else { float num5 = Smooth((k - 0.78f) / 0.22f); num2 = Mathf.Lerp(128f, 25f, num5); num3 = 1f - num5; } Quaternion val = Quaternion.Euler(0f - num2, -8f, 6f); Vector3 val2 = Mouth - val * Vector3.up * (size * 0.97f); ((Component)this).transform.localRotation = val; ((Component)this).transform.localPosition = Vector3.Lerp(Rest, val2, num3); } private void Update() { if ((Object)(object)player == (Object)null || player.isPlayerDead) { Finish(); return; } t += Time.deltaTime / duration; if (isLocal && !applied && t >= 0.72f) { applied = true; PerkNet.LocalApplyPerk(perk); } if (t >= 1f) { Finish(); } else { Pose(t); } } private void Finish() { if (isLocal) { PerkNet.Drinking = false; } Object.Destroy((Object)(object)((Component)this).gameObject); } } internal static class ElementalPop { [HarmonyPatch(typeof(EnemyAI), "HitEnemyOnLocalClient")] private static class HitPatch { [HarmonyPostfix] private static void Postfix(EnemyAI __instance, PlayerControllerB playerWhoHit) { try { PlayerControllerB local = Local; if (!((Object)(object)playerWhoHit == (Object)null) && !((Object)(object)playerWhoHit != (Object)(object)local) && Active && CooldownReady && !((Object)(object)__instance == (Object)null) && !__instance.isEnemyDead && IsMeleeWeapon(local.currentlyHeldObjectServer) && !(Random.value >= Perks.EPopHitChance.Value / 100f)) { int num = ((!(Random.value < Perks.EPopZapChance.Value / 100f)) ? 1 : 0); StartCooldown(); Plugin.Log.LogInfo((object)("[Elemental Pop] Golpe especial: " + ((num == 0) ? "zap" : "stun") + " a " + __instance.enemyType?.enemyName)); SendToHost("TrepidPerks.EPopFx", (long)((NetworkBehaviour)__instance).NetworkObjectId, num, (int)local.playerClientId); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Elemental Pop] " + ex.Message)); } } } [HarmonyPatch(typeof(ShotgunItem), "ShootGunAndSync")] private static class ShotgunPatch { [HarmonyPrefix] private static void Prefix(ShotgunItem __instance, out int __state) { __state = -1; if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)Local && Active) { __state = __instance.shellsLoaded; } } [HarmonyPostfix] private static void Postfix(ShotgunItem __instance, int __state) { if (__state >= 0 && __instance.shellsLoaded < __state && CooldownReady && !(Random.value >= Perks.EPopAmmoChance.Value / 100f)) { StartCooldown(); __instance.shellsLoaded = __state; Plugin.Log.LogInfo((object)$"[Elemental Pop] Disparo sin gastar bala (balas: {__state})"); SpeedColaRunner speedColaRunner = (((Object)(object)StartOfRound.Instance != (Object)null) ? ((Component)StartOfRound.Instance).GetComponent<SpeedColaRunner>() : null); if ((Object)(object)speedColaRunner != (Object)null) { ((MonoBehaviour)speedColaRunner).StartCoroutine(SyncAmmoLater(__instance, __state)); } } } } [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnEffectMsg; public static HandleNamedMessageDelegate <1>__OnAmmoMsg; } private const string MsgEffect = "TrepidPerks.EPopFx"; private const string MsgAmmo = "TrepidPerks.EPopAmmo"; private const int Zap = 0; private const int Stun = 1; private static float nextEffectTime; internal static GameObject StunParticles; internal static AudioClip StunSfx; internal static AudioClip ZapSfx; private static readonly Dictionary<Item, float> originalUsage = new Dictionary<Item, float>(); private static bool batteryApplied; private static readonly string[] GunWords = new string[10] { "gun", "rifle", "pistol", "revolver", "shotgun", "launcher", "blaster", "zap", "patcher", "knife" }; private static readonly HashSet<string> loggedTypes = new HashSet<string>(); private static NetworkManager NM => NetworkManager.Singleton; private static PlayerControllerB Local { get { if (!((Object)(object)GameNetworkManager.Instance != (Object)null)) { return null; } return GameNetworkManager.Instance.localPlayerController; } } internal static bool Active { get { PlayerControllerB local = Local; if (Perks.EPop != null && Perks.EPop.LocalHasPerk && (Object)(object)local != (Object)null) { return !local.isPlayerDead; } return false; } } internal static bool CooldownReady => Time.time >= nextEffectTime; private static void StartCooldown() { nextEffectTime = Time.time + Perks.EPopCooldown.Value; } internal static void FindResources(List<GameObject> prefabs) { foreach (GameObject prefab in prefabs) { StunGrenadeItem component = prefab.GetComponent<StunGrenadeItem>(); if ((Object)(object)component != (Object)null && (Object)(object)StunParticles == (Object)null) { StunParticles = component.stunGrenadeExplosion; StunSfx = component.explodeSFX; } PatcherTool component2 = prefab.GetComponent<PatcherTool>(); if ((Object)(object)component2 != (Object)null && (Object)(object)ZapSfx == (Object)null && component2.beginShockClips != null && component2.beginShockClips.Length != 0) { ZapSfx = component2.beginShockClips[0]; } } Plugin.Log.LogInfo((object)$"[Elemental Pop] Recursos: particulas stun={(Object)(object)StunParticles != (Object)null} sonido stun={(Object)(object)StunSfx != (Object)null} sonido zap={(Object)(object)ZapSfx != (Object)null}"); } internal static void Register() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown NetworkManager nM = NM; CustomMessagingManager val = ((nM != null) ? nM.CustomMessagingManager : null); if (val != null) { object obj = <>O.<0>__OnEffectMsg; if (obj == null) { HandleNamedMessageDelegate val2 = OnEffectMsg; <>O.<0>__OnEffectMsg = val2; obj = (object)val2; } val.RegisterNamedMessageHandler("TrepidPerks.EPopFx", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnAmmoMsg; if (obj2 == null) { HandleNamedMessageDelegate val3 = OnAmmoMsg; <>O.<1>__OnAmmoMsg = val3; obj2 = (object)val3; } val.RegisterNamedMessageHandler("TrepidPerks.EPopAmmo", (HandleNamedMessageDelegate)obj2); nextEffectTime = 0f; } } internal static void Tick(PlayerControllerB me) { bool active = Active; if (active == batteryApplied) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.allItemsList == (Object)null) { return; } if (originalUsage.Count == 0) { foreach (Item items in instance.allItemsList.itemsList) { if ((Object)(object)items != (Object)null && items.requiresBattery) { originalUsage[items] = items.batteryUsage; } } } float num = 1f + Perks.EPopBatteryPercent.Value / 100f; foreach (KeyValuePair<Item, float> item in originalUsage) { item.Key.batteryUsage = (active ? (item.Value * num) : item.Value); } batteryApplied = active; Plugin.Log.LogInfo((object)string.Format("[Elemental Pop] {0}: duracion de baterias x{1:0.00} ({2} objetos con bateria)", active ? "Activo" : "Inactivo", active ? num : 1f, originalUsage.Count)); } internal static void ResetBatteries() { foreach (KeyValuePair<Item, float> item in originalUsage) { item.Key.batteryUsage = item.Value; } batteryApplied = false; } internal static bool IsMeleeWeapon(GrabbableObject g) { if ((Object)(object)g == (Object)null || g is ShotgunItem || g is KnifeItem) { return false; } if (g is Shovel) { return true; } string text = ((object)g).GetType().Name.ToLowerInvariant(); string text2 = (((Object)(object)g.itemProperties != (Object)null) ? g.itemProperties.itemName : "").ToLowerInvariant(); string[] gunWords = GunWords; foreach (string value in gunWords) { if (text.Contains(value) || text2.Contains(value)) { return false; } } if (loggedTypes.Add(text)) { Plugin.Log.LogInfo((object)("[Elemental Pop] Arma cuerpo a cuerpo de otro mod reconocida: " + ((object)g).GetType().FullName + " (" + text2 + ")")); } return true; } private static void OnEffectMsg(ulong sender, FastBufferReader r) { //IL_0006: 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_0018: 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_002a: 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) long num = default(long); ((FastBufferReader)(ref r)).ReadValueSafe<long>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); int num3 = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); if (NM.IsServer && sender != NM.LocalClientId) { Broadcast("TrepidPerks.EPopFx", num, num2, num3); } else { ApplyEffect((ulong)num, num2, num3); } } private static void ApplyEffect(ulong id, int type, int playerIndex) { //IL_0078: 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_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if (NM.SpawnManager == null || !NM.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) || (Object)(object)value == (Object)null) { return; } EnemyAI component = ((Component)value).GetComponent<EnemyAI>(); if ((Object)(object)component == (Object)null || component.isEnemyDead) { return; } StartOfRound instance = StartOfRound.Instance; PlayerControllerB val = (((Object)(object)instance != (Object)null && playerIndex >= 0 && playerIndex < instance.allPlayerScripts.Length) ? instance.allPlayerScripts[playerIndex] : null); Vector3 val2 = ((Component)component).transform.position + Vector3.up * 1f; if (type == 0) { component.SetEnemyStunned(true, Perks.EPopZapSeconds.Value, val); if ((Object)(object)ZapSfx != (Object)null) { AudioSource.PlayClipAtPoint(ZapSfx, val2, 0.9f); } FlashLight(val2, new Color(0.45f, 0.75f, 1f), 0.35f); return; } component.SetEnemyStunned(true, Perks.EPopStunSeconds.Value, val); if ((Object)(object)StunParticles != (Object)null) { GameObject val3 = Object.Instantiate<GameObject>(StunParticles, val2, Quaternion.identity); HDAdditionalLightData[] componentsInChildren = val3.GetComponentsInChildren<HDAdditionalLightData>(true); foreach (HDAdditionalLightData val4 in componentsInChildren) { try { val4.EnableShadows(false); } catch { } } Light[] componentsInChildren2 = val3.GetComponentsInChildren<Light>(true); foreach (Light obj2 in componentsInChildren2) { obj2.shadows = (LightShadows)0; ((Behaviour)obj2).enabled = false; } Object.Destroy((Object)(object)val3, 4f); } if ((Object)(object)StunSfx != (Object)null) { AudioSource.PlayClipAtPoint(StunSfx, val2, 0.6f); } FlashLight(val2, new Color(1f, 0.95f, 0.85f), 0.25f); } private static void FlashLight(Vector3 pos, Color c, float seconds) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: 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) try { GameObject val = new GameObject("EPopFlash"); val.transform.position = pos; HDAdditionalLightData val2 = GameObjectExtension.AddHDLight(val, (HDLightTypeAndShape)0); val2.SetColor(c, -1f); val2.SetIntensity(800f); val2.SetRange(5f); try { val2.EnableShadows(false); } catch { } Light component = val.GetComponent<Light>(); if ((Object)(object)component != (Object)null) { component.shadows = (LightShadows)0; } Object.Destroy((Object)(object)val, seconds); } catch { } } private static IEnumerator SyncAmmoLater(ShotgunItem gun, int shells) { yield return (object)new WaitForSeconds(0.5f); if (!((Object)(object)gun == (Object)null)) { gun.shellsLoaded = Mathf.Max(gun.shellsLoaded, shells); SendToHost("TrepidPerks.EPopAmmo", (long)((NetworkBehaviour)gun).NetworkObjectId, shells, 0); } } private static void OnAmmoMsg(ulong sender, FastBufferReader r) { //IL_0006: 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_0018: 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_002a: 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) long num = default(long); ((FastBufferReader)(ref r)).ReadValueSafe<long>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); int num3 = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); NetworkObject value; if (NM.IsServer && sender != NM.LocalClientId) { Broadcast("TrepidPerks.EPopAmmo", num, num2, 0); } else if (NM.SpawnManager != null && NM.SpawnManager.SpawnedObjects.TryGetValue((ulong)num, out value) && (Object)(object)value != (Object)null) { ShotgunItem component = ((Component)value).GetComponent<ShotgunItem>(); if ((Object)(object)component != (Object)null) { component.shellsLoaded = num2; } } } private unsafe static void SendToHost(string msg, long a, int b, int c) { //IL_0027: 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_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_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_0064: Unknown result type (might be due to invalid IL or missing references) if (NM.IsServer) { Broadcast(msg, a, b, c); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<long>(ref a, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref c, default(ForPrimitives)); NM.CustomMessagingManager.SendNamedMessage(msg, 0uL, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe static void Broadcast(string msg, long a, int b, int c) { //IL_0093: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00bf: 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) NetworkObject value; if (msg == "TrepidPerks.EPopFx") { ApplyEffect((ulong)a, b, c); } else if (NM.SpawnManager != null && NM.SpawnManager.SpawnedObjects.TryGetValue((ulong)a, out value) && (Object)(object)value != (Object)null) { ShotgunItem component = ((Component)value).GetComponent<ShotgunItem>(); if ((Object)(object)component != (Object)null) { component.shellsLoaded = b; } } FastBufferWriter val = default(FastBufferWriter); foreach (ulong connectedClientsId in NM.ConnectedClientsIds) { if (connectedClientsId != NM.LocalClientId) { ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<long>(ref a, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref c, default(ForPrimitives)); NM.CustomMessagingManager.SendNamedMessage(msg, connectedClientsId, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } } } internal static class L { internal const bool EN = true; private static readonly Dictionary<string, string> Sections = new Dictionary<string, string> { { "Chapas", "BottleCaps" } }; private static readonly Dictionary<string, string> Keys = new Dictionary<string, string> { { "PrecioMaquina", "MachinePrice" }, { "PrecioBotella", "DrinkPrice" }, { "Altura", "Height" }, { "RotacionModelo", "ModelRotation" }, { "AjusteAltura", "HeightOffset" }, { "IntervaloCancion", "JingleInterval" }, { "CancionAlComprar", "JingleOnPurchase" }, { "BrilloCartel", "SignGlow" }, { "LuzCartelIntensidad", "SignLightIntensity" }, { "LuzCartelRango", "SignLightRange" }, { "LuzBaseIntensidad", "BaseLightIntensity" }, { "LuzBaseRango", "BaseLightRange" }, { "Vida", "Health" }, { "AlturaRelativaJuggernog", "HeightRelativeToJuggernog" }, { "BrilloLogo", "LogoGlow" }, { "LuzLogoIntensidad", "LogoLightIntensity" }, { "LuzLogoRango", "LogoLightRange" }, { "CuracionPorcentaje", "HealPercent" }, { "SaludCritica", "CriticalHealth" }, { "AumentoVelocidad", "SpeedBonusPercent" }, { "ReduccionPesoArmas", "WeaponWeightReductionLb" }, { "BrilloLuces", "LightsGlow" }, { "LuzVentanaIntensidadV2", "WindowLightIntensity" }, { "LuzVentanaRango", "WindowLightRange" }, { "RecuperacionStamina", "StaminaRegenPercent" }, { "Valor", "Value" }, { "Rareza", "Rarity" }, { "Tamano", "Size" }, { "MostrarIconos", "ShowIcons" }, { "TamanoIcono", "IconSize" }, { "MargenIzquierdo", "MarginLeft" }, { "MargenInferior", "MarginBottom" }, { "PlantillaMueble", "FurnitureTemplate" }, { "TamanoBotella", "BottleSize" }, { "DuracionAnimacion", "DrinkAnimationSeconds" }, { "VolumenCancion", "JingleVolume" }, { "VolumenCompra", "PurchaseVolume" }, { "Distancia", "SoundDistance" }, { "AumentoRecarga", "ReloadSpeedBonusPercent" }, { "BrilloNeon", "NeonGlow" }, { "LuzPantallaIntensidad", "ScreenLightIntensity" }, { "LuzPantallaRango", "ScreenLightRange" }, { "DuracionBaterias", "BatteryLifeBonusPercent" }, { "ProbabilidadGolpe", "HitEffectChance" }, { "ProbabilidadZap", "ZapChance" }, { "DuracionZap", "ZapSeconds" }, { "DuracionStun", "StunSeconds" }, { "ProbabilidadBala", "FreeShellChance" }, { "Enfriamiento", "EffectCooldown" }, { "RegeneracionSegundos", "RegenIntervalSeconds" }, { "RegeneracionCantidad", "RegenAmount" }, { "SlotsExtra", "ExtraSlots" }, { "ReduccionCaida", "FallDamageReductionPercent" }, { "LuzEmblemaIntensidad", "EmblemLightIntensity" }, { "LuzEmblemaRango", "EmblemLightRange" } }; internal static string T(string es, string en) { return en; } internal static ConfigEntry<T> Bind<T>(ConfigFile c, string section, string key, T def, string descEs, string descEn) { if (Sections.TryGetValue(section, out var value)) { section = value; } if (Keys.TryGetValue(key, out var value2)) { key = value2; } return c.Bind<T>(section, key, def, descEn); } } internal static class ModelLoader { public static Mesh LoadMesh(string file) { //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_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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown string text = Plugin.FindFile(file); if (text == null) { return null; } using BinaryReader binaryReader = new BinaryReader(File.OpenRead(text)); if (new string(binaryReader.ReadChars(4)) != "TSM1") { Plugin.Log.LogError((object)("[TrepidPerks] " + file + " no es un modelo valido")); return null; } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector2[] array3 = (Vector2[])(object)new Vector2[num]; for (int i = 0; i < num; i++) { array[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[i] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array4 = new int[num2]; for (int j = 0; j < num2; j++) { array4[j] = binaryReader.ReadInt32(); } Mesh val = new Mesh { name = Path.GetFileNameWithoutExtension(file) }; if (num > 65000) { val.indexFormat = (IndexFormat)1; } val.vertices = array; val.normals = array2; val.uv = array3; val.triangles = array4; val.RecalculateBounds(); val.RecalculateTangents(); return val; } public static Texture2D LoadTexture(string file, bool linear, bool optional = false) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_002f: Expected O, but got Unknown //IL_0030: 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_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_004e: Expected O, but got Unknown string text = Plugin.FindFile(file, optional); if (text == null) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = Path.GetFileNameWithoutExtension(file) }; ImageConversion.LoadImage(val, File.ReadAllBytes(text)); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)2; ((Texture)val).anisoLevel = 4; val.Apply(true, true); return val; } public static Material CreateMaterial(string baseName, Shader shader, Color emissive) { //IL_0028: 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_003f: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)shader == (Object)null || ((Object)shader).name != "HDRP/Lit") { shader = Shader.Find("HDRP/Lit"); } Material val = new Material(shader) { name = baseName + "_Mat" }; Texture2D val2 = LoadTexture(baseName + "_BaseColor.jpg", linear: false); Texture2D val3 = LoadTexture(baseName + "_Normal.png", linear: true, optional: true); Texture2D val4 = LoadTexture(baseName + "_MaskMap.png", linear: true, optional: true); val.SetColor("_BaseColor", Color.white); if (Object.op_Implicit((Object)(object)val2)) { val.SetTexture("_BaseColorMap", (Texture)(object)val2); } if (Object.op_Implicit((Object)(object)val3)) { val.SetTexture("_NormalMap", (Texture)(object)val3); val.SetFloat("_NormalScale", 1f); val.EnableKeyword("_NORMALMAP"); val.EnableKeyword("_NORMALMAP_TANGENT_SPACE"); } if (Object.op_Implicit((Object)(object)val4)) { val.SetTexture("_MaskMap", (Texture)(object)val4); val.EnableKeyword("_MASKMAP"); val.SetFloat("_Metallic", 1f); val.SetFloat("_MetallicRemapMin", 0f); val.SetFloat("_MetallicRemapMax", 1f); val.SetFloat("_SmoothnessRemapMin", 0f); val.SetFloat("_SmoothnessRemapMax", 1f); val.SetFloat("_AORemapMin", 0f); val.SetFloat("_AORemapMax", 1f); } string text = baseName + "_Emissive.jpg"; if (((Color)(ref emissive)).maxColorComponent > 0f && Directory.GetFiles(Plugin.Folder, text, SearchOption.AllDirectories).Length != 0) { Texture2D val5 = LoadTexture(text, linear: false); val.SetTexture("_EmissiveColorMap", (Texture)(object)val5); val.EnableKeyword("_EMISSIVE_COLOR_MAP"); val.SetFloat("_UseEmissiveIntensity", 0f); val.SetColor("_EmissiveColor", emissive); val.SetFloat("_EmissiveExposureWeight", 0f); } try { HDMaterial.ValidateMaterial(val); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[TrepidPerks] ValidateMaterial fallo: " + ex.Message)); } return val; } } internal static class MuleKick { [HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")] private static class ScrollPatch { [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance, out GrabbableObject __state) { __state = null; if (!((Object)(object)__instance != (Object)(object)Local) && Active && __instance.twoHanded && !__instance.isGrabbingObjectAnimation && !__instance.throwingObject && !__instance.inSpecialInteractAnimation) { __state = __instance.currentlyHeldObjectServer; __instance.twoHanded = false; } } [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance, GrabbableObject __state) { if (!((Object)(object)__state == (Object)null)) { if ((Object)(object)__instance.currentlyHeldObjectServer == (Object)(object)__state && (Object)(object)__state.itemProperties != (Object)null && __state.itemProperties.twoHanded) { __instance.twoHanded = true; } else { Plugin.Log.LogInfo((object)("[Mule Kick] Cambio de slot con objeto de dos manos (" + __state.itemProperties?.itemName + ")")); } } } } [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnSlotsMsg; } private const string MsgSlots = "TrepidPerks.MuleSlots"; private static float rebroadcastAt; private static int localExtra; private static readonly Dictionary<int, int> remoteExtra = new Dictionary<int, int>(); private static readonly Dictionary<int, int> remoteWanted = new Dictionary<int, int>(); private static readonly List<GameObject> extraFrames = new List<GameObject>(); private static readonly List<Vector3> originalFramePos = new List<Vector3>(); private static readonly List<Vector3> originalIconPos = new List<Vector3>(); private static int vanillaFrames = -1; private static NetworkManager NM => NetworkManager.Singleton; private static PlayerControllerB Local { get { if (!((Object)(object)GameNetworkManager.Instance != (Object)null)) { return null; } return GameNetworkManager.Instance.localPlayerController; } } internal static bool Active { get { PlayerControllerB local = Local; if (Perks.Mule != null && Perks.Mule.LocalHasPerk && (Object)(object)local != (Object)null) { return !local.isPlayerDead; } return false; } } internal static void Register() { //IL_002b: 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_0036: Expected O, but got Unknown NetworkManager nM = NM; if (nM != null) { CustomMessagingManager customMessagingManager = nM.CustomMessagingManager; if (customMessagingManager != null) { object obj = <>O.<0>__OnSlotsMsg; if (obj == null) { HandleNamedMessageDelegate val = OnSlotsMsg; <>O.<0>__OnSlotsMsg = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("TrepidPerks.MuleSlots", (HandleNamedMessageDelegate)obj); } } remoteExtra.Clear(); remoteWanted.Clear(); rebroadcastAt = 0f; localExtra = 0; extraFrames.Clear(); originalFramePos.Clear(); originalIconPos.Clear(); vanillaFrames = -1; } internal static void Tick(PlayerControllerB me) { if ((Object)(object)me == (Object)null || me.ItemSlots == null) { return; } int num = (Active ? Mathf.Max(0, Perks.MuleExtraSlots.Value) : 0); if (localExtra != num) { if (ChangeSlots(me, num - localExtra)) { localExtra = num; Broadcast((int)me.playerClientId, num); rebroadcastAt = Time.time + 10f; } } else if (num > 0 && Time.time >= rebroadcastAt) { rebroadcastAt = Time.time + 10f; Broadcast((int)me.playerClientId, num); } if (remoteWanted.Count <= 0) { return; } StartOfRound instance = StartOfRound.Instance; foreach (KeyValuePair<int, int> item in new List<KeyValuePair<int, int>>(remoteWanted)) { if ((Object)(object)instance == (Object)null || item.Key >= instance.allPlayerScripts.Length) { remoteWanted.Remove(item.Key); continue; } remoteExtra.TryGetValue(item.Key, out var value); if (value == item.Value || ChangeSlots(instance.allPlayerScripts[item.Key], item.Value - value)) { remoteExtra[item.Key] = item.Value; remoteWanted.Remove(item.Key); } } } private static int NormalEnd(PlayerControllerB p) { HUDManager instance = HUDManager.Instance; if ((Object)(object)instance != (Object)null && instance.itemSlotIconFrames != null) { for (int i = 0; i < instance.itemSlotIconFrames.Length; i++) { if ((Object)(object)instance.itemSlotIconFrames[i] != (Object)null && ((Object)instance.itemSlotIconFrames[i]).name.ToLower().Contains("reserved")) { return Mathf.Min(i, p.ItemSlots.Length); } } } return p.ItemSlots.Length; } private static bool ChangeSlots(PlayerControllerB p, int delta) { if ((Object)(object)p == (Object)null || p.ItemSlots == null || delta == 0) { return true; } int num = p.ItemSlots.Length; int num2 = NormalEnd(p); GrabbableObject[] array; if (delta > 0) { array = (GrabbableObject[])(object)new GrabbableObject[num + delta]; for (int i = 0; i < num; i++) { array[(i < num2) ? i : (i + delta)] = p.ItemSlots[i]; } if (p.currentItemSlot >= num2) { p.currentItemSlot += delta; } } else { int num3 = -delta; int num4 = num2 - num3; if (num4 < 1) { return false; } for (int j = num4; j < num2; j++) { if ((Object)(object)p.ItemSlots[j] != (Object)null) { return false; } } if (p.currentItemSlot >= num4 && p.currentItemSlot < num2) { if ((Object)(object)p == (Object)(object)Local) { p.SwitchToItemSlot(0, (GrabbableObject)null); } else { p.currentItemSlot = 0; } } array = (GrabbableObject[])(object)new GrabbableObject[num - num3]; for (int k = 0; k < num; k++) { if (k < num4) { array[k] = p.ItemSlots[k]; } else if (k >= num2) { array[k - num3] = p.ItemSlots[k]; } } if (p.currentItemSlot >= num2) { p.currentItemSlot -= num3; } } p.ItemSlots = array; if ((Object)(object)p == (Object)(object)Local) { ResizeHud(delta, num2); } Plugin.Log.LogInfo((object)$"[Mule Kick] {p.playerUsername}: {num} -> {array.Length} slots (insertados en el indice {num2})"); return true; } private static void ResizeHud(int delta, int at) { //IL_00b2: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null || instance.itemSlotIconFrames == null || instance.itemSlotIcons == null) { return; } List<Image> list = new List<Image>(instance.itemSlotIconFrames); List<Image> list2 = new List<Image>(instance.itemSlotIcons); if (vanillaFrames < 0) { vanillaFrames = Mathf.Min(at, list.Count); for (int i = 0; i < vanillaFrames; i++) { originalFramePos.Add(((Graphic)list[i]).rectTransform.anchoredPosition3D); originalIconPos.Add(((Graphic)list2[i]).rectTransform.anchoredPosition3D); } } if (vanillaFrames < 2) { return; } Vector3 val = originalFramePos[vanillaFrames - 1] - originalFramePos[vanillaFrames - 2]; Image val2 = list[vanillaFrames - 1]; Image val3 = list2[vanillaFrames - 1]; if (delta > 0) { for (int j = 0; j < delta; j++) { GameObject val4 = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)val2).transform.parent); ((Object)val4).name = "TrepidMuleSlot" + (extraFrames.Count + 1); Image component = val4.GetComponent<Image>(); Image val5 = null; if (((Component)val3).transform.IsChildOf(((Component)val2).transform)) { Transform val6 = val4.transform.Find(GetPath(((Component)val3).transform, ((Component)val2).transform)); val5 = (((Object)(object)val6 != (Object)null) ? ((Component)val6).GetComponent<Image>() : null); } else { GameObject val7 = Object.Instantiate<GameObject>(((Component)val3).gameObject, ((Component)val3).transform.parent); ((Object)val7).name = ((Object)val4).name + "Icon"; val5 = val7.GetComponent<Image>(); extraFrames.Add(val7); } if ((Object)(object)val5 != (Object)null) { ((Behaviour)val5).enabled = false; val5.sprite = null; } extraFrames.Add(val4); list.Insert(at + j, component); list2.Insert(at + j, val5); } } else { int num = -delta; for (int k = 0; k < num && at - 1 - k >= vanillaFrames; k++) { int index = at - 1 - k; Image val8 = list[index]; Image val9 = list2[index]; list.RemoveAt(index); list2.RemoveAt(index); if ((Object)(object)val9 != (Object)null && !((Component)val9).transform.IsChildOf(((Component)val8).transform)) { extraFrames.Remove(((Component)val9).gameObject); Object.Destroy((Object)(object)((Component)val9).gameObject); } extraFrames.Remove(((Component)val8).gameObject); Object.Destroy((Object)(object)((Component)val8).gameObject); } } int num2 = vanillaFrames + extraFrames.FindAll((GameObject g) => (Object)(object)g != (Object)null && (Object)(object)g.GetComponent<Image>() != (Object)null && ((Object)g).name.StartsWith("TrepidMuleSlot") && !((Object)g).name.EndsWith("Icon")).Count; int num3 = num2 - vanillaFrames; for (int num4 = 0; num4 < num2 && num4 < list.Count; num4++) { Vector3 val10 = ((num4 < vanillaFrames) ? originalFramePos[num4] : (originalFramePos[vanillaFrames - 1] + val * (float)(num4 - vanillaFrames + 1))); ((Graphic)list[num4]).rectTransform.anchoredPosition3D = val10 - val * ((float)num3 * 0.5f); if ((Object)(object)list2[num4] != (Object)null && !((Component)list2[num4]).transform.IsChildOf(((Component)list[num4]).transform)) { Vector3 val11 = ((num4 < vanillaFrames) ? originalIconPos[num4] : (originalIconPos[vanillaFrames - 1] + val * (float)(num4 - vanillaFrames + 1))); ((Graphic)list2[num4]).rectTransform.anchoredPosition3D = val11 - val * ((float)num3 * 0.5f); } } instance.itemSlotIconFrames = list.ToArray(); instance.itemSlotIcons = list2.ToArray(); } private static string GetPath(Transform t, Transform root) { List<string> list = new List<string>(); while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)root) { list.Insert(0, ((Object)t).name); t = t.parent; } return string.Join("/", list); } private static void Broadcast(int playerIndex, int extra) { if (!((Object)(object)NM == (Object)null) && NM.CustomMessagingManager != null) { if (NM.IsServer) { Relay(playerIndex, extra, NM.LocalClientId); } else { Send(0uL, playerIndex, extra); } } } private static void OnSlotsMsg(ulong sender, FastBufferReader r) { //IL_0006: 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_0018: 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) int idx = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref idx, default(ForPrimitives)); int extra = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref extra, default(ForPrimitives)); if (NM.IsServer) { Relay(idx, extra, sender); } else { ApplyRemote(idx, extra); } } private static void Relay(int idx, int extra, ulong from) { if (from != NM.LocalClientId) { ApplyRemote(idx, extra); } foreach (ulong connectedClientsId in NM.ConnectedClientsIds) { if (connectedClientsId != NM.LocalClientId && connectedClientsId != from) { Send(connectedClientsId, idx, extra); } } } private static void ApplyRemote(int idx, int extra) { StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && idx >= 0 && idx < instance.allPlayerScripts.Length && !((Object)(object)instance.allPlayerScripts[idx] == (Object)(object)Local)) { remoteWanted[idx] = extra; } } private unsafe static void Send(ulong target, int idx, int extra) { //IL_0010: 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_0022: 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_003e: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref idx, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref extra, default(ForPrimitives)); NM.CustomMessagingManager.SendNamedMessage("TrepidPerks.MuleSlots", target, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } public class PerkCap : MonoBehaviour { public int perkIndex; private bool logged; private void Start() { GrabbableObject component = ((Component)this).GetComponent<GrabbableObject>(); ScanNodeProperties componentInChildren = ((Component)this).GetComponentInChildren<ScanNodeProperties>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.nodeType = 2; if ((Object)(object)component != (Object)null && component.scrapValue > 0) { componentInChildren.scrapValue = component.scrapValue; } } } private void Update() { GrabbableObject component = ((Component)this).GetComponent<GrabbableObject>(); if (!((Object)(object)component == (Object)null)) { if ((Object)(object)component.radarIcon == (Object)null && !component.isHeld && (Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.itemRadarIconPrefab != (Object)null) { component.radarIcon = Object.Instantiate<GameObject>(StartOfRound.Instance.itemRadarIconPrefab, RoundManager.Instance.mapPropsContainer.transform).transform; } if (!logged) { logged = true; ScanNodeProperties componentInChildren = ((Component)this).GetComponentInChildren<ScanNodeProperties>(true); Plugin.Log.LogInfo((object)string.Format("[Chapas] {0}: chatarra={1} valor={2} nodoEscaneo={3} radar={4}", component.itemProperties?.itemName, component.itemProperties?.isScrap, component.scrapValue, ((Object)(object)componentInChildren != (Object)null) ? $"{((Component)componentInChildren).gameObject.activeInHierarchy}/tipo {componentInChildren.nodeType}/renderer {(Object)(object)((Component)componentInChildren).GetComponent<Renderer>() != (Object)null}" : "no", (Object)(object)component.radarIcon != (Object)null)); } } } } internal static class PerkCaps { private const float ScrapMultiplier = 0.4f; private static readonly string[] Templates = new string[5] { "Pill bottle", "Toy cube", "Rubber Ducky", "Perfume bottle", "Ring" }; internal static void Build(List<GameObject> prefabs) { GameObject val = null; string[] templates = Templates; foreach (string name in templates) { val = ((IEnumerable<GameObject>)prefabs).FirstOrDefault((Func<GameObject, bool>)delegate(GameObject p) { GrabbableObject component = p.GetComponent<GrabbableObject>(); return (Object)(object)component != (Object)null && ((object)component).GetType() == typeof(PhysicsProp) && (Object)(object)component.itemProperties != (Object)null && component.itemProperties.itemName == name; }); if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { val = ((IEnumerable<GameObject>)prefabs).FirstOrDefault((Func<GameObject, bool>)delegate(GameObject p) { GrabbableObject component = p.GetComponent<GrabbableObject>(); return (Object)(object)component != (Object)null && ((object)component).GetType() == typeof(PhysicsProp) && (Object)(object)component.itemProperties != (Object)null && component.itemProperties.isScrap && !component.itemProperties.twoHanded; }); } if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"[Chapas] No se encontro un objeto base para las chapas"); return; } Plugin.Log.LogInfo((object)("[Chapas] Objeto base: " + ((Object)val).name + " (" + val.GetComponent<GrabbableObject>().itemProperties.itemName + ")")); Mesh val2 = ModelLoader.LoadMesh("PerkCap.tsm"); if ((Object)(object)val2 == (Object)null) { return; } foreach (PerkDef item in Perks.All) { try { BuildOne(item, val, val2); } catch (Exception arg) { Plugin.Log.LogError((object)$"[Chapas] Error creando la chapa de {item.Name}: {arg}"); } } } private static void BuildOne(PerkDef perk, GameObject template, Mesh capMesh) { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) string text = perk.ModelBase.Replace("Machine", ""); GameObject val = NetworkPrefabs.CloneNetworkPrefab(template, "TrepidPerkCap" + text); GrabbableObject component = val.GetComponent<GrabbableObject>(); Item val2 = Object.Instantiate<Item>(component.itemProperties); ((Object)val2).name = "TrepidPerkCap" + text; val2.itemName = L.T("Chapa " + perk.Name, perk.Name + " Bottle Cap"); val2.maxValue = (val2.minValue = Mathf.Max(1, Mathf.RoundToInt((float)Perks.CapValue.Value / 0.4f))) + 1; val2.weight = 1f; val2.isScrap = true; val2.twoHanded = false; val2.requiresBattery = false; val2.spawnPrefab = val; if ((Object)(object)perk.Icon != (Object)null) { val2.itemIcon = perk.Icon; } component.itemProperties = val2; int num = LayerMask.NameToLayer("ScanNode"); MeshFilter[] componentsInChildren = val.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val3 in componentsInChildren) { if (!((Object)(object)((Component)val3).GetComponent<ScanNodeProperties>() != (Object)null) && ((Component)val3).gameObject.layer != num) { val3.sharedMesh = null; } } SkinnedMeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren<SkinnedMeshRenderer>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Renderer)componentsInChildren2[i]).enabled = false; } float value = Perks.CapSize.Value; Vector3 lossyScale = val.transform.lossyScale; GameObject val4 = new GameObject("CapModel"); val4.transform.SetParent(val.transform, false); val4.transform.localScale = new Vector3(value / lossyScale.x, value / lossyScale.y, value / lossyScale.z); val4.transform.localRotation = Quaternion.Inverse(Quaternion.Euler(val2.restingRotation.x, 0f, val2.restingRotation.z)); val4.AddComponent<MeshFilter>().sharedMesh = capMesh; MeshRenderer obj = val4.AddComponent<MeshRenderer>(); MeshRenderer componentInChildren = template.GetComponentInChildren<MeshRenderer>(true); ((Renderer)obj).sharedMaterial = ModelLoader.CreateMaterial(shader: ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial != (Object)null) ? ((Renderer)componentInChildren).sharedMaterial.shader : null, baseName: "PerkCap" + text, emissive: Color.black); val4.layer = val.layer; BoxCollider component2 = val.GetComponent<BoxCollider>(); if ((Object)(object)component2 != (Object)null) { Bounds val5 = PerkRegistration.TransformBounds(capMesh.bounds, val.transform.worldToLocalMatrix * val4.transform.localToWorldMatrix); component2.center = ((Bounds)(ref val5)).center; component2.size = Vector3.Max(((Bounds)(ref val5)).size, Vector3.one * (0.08f / Mathf.Max(lossyScale.x, 0.0001f))); } val2.verticalOffset = Mathf.Max(0.02f, value * 0.15f); ScanNodeProperties componentInChildren2 = val.GetComponentInChildren<ScanNodeProperties>(true); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.headerText = val2.itemName; componentInChildren2.subText = L.T("Canjeala en su maquina", "Redeem it at its machine"); } val.AddComponent<PerkCap>().perkIndex = perk.Index; perk.CapItem = val2; Items.RegisterScrap(val2, Perks.CapRarity.Value, (LevelTypes)(-1)); Plugin.Log.LogInfo((object)$"[Chapas] {val2.itemName} registrada: rareza {Perks.CapRarity.Value}, valor ~{Perks.CapValue.Value}"); } internal static GrabbableObject HeldCap(PlayerControllerB me, PerkDef perk) { GrabbableObject val = (((Object)(object)me != (Object)null) ? me.currentlyHeldObjectServer : null); if ((Object)(object)val == (Object)null) { return null; } PerkCap component = ((Component)val).GetComponent<PerkCap>(); if (!((Object)(object)component != (Object)null) || component.perkIndex != perk.Index) { return null; } return val; } } internal static class PerkHUD { private static RectTransform container; private static readonly Dictionary<int, Image> icons = new Dictionary<int, Image>(); internal static void Tick(PlayerControllerB me) { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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) if (!Perks.HudEnabled.Value) { if ((Object)(object)container != (Object)null) { ((Component)container).gameObject.SetActive(false); } } else { if ((Object)(object)container == (Object)null && !Create()) { return; } ((Component)container).gameObject.SetActive(true); bool flag = (Object)(object)me != (Object)null && !me.isPlayerDead; float value = Perks.HudIconSize.Value; float num = value * 0.15f; int num2 = 0; for (int i = 0; i < Perks.All.Count; i++) { PerkDef perkDef = Perks.All[i]; if (!icons.TryGetValue(i, out var value2) || (Object)(object)value2 == (Object)null) { continue; } bool flag2 = flag && perkDef.LocalHasPerk; if (((Component)value2).gameObject.activeSelf != flag2) { ((Component)value2).gameObject.SetActive(flag2); } if (flag2) { Color val = (Color)((perkDef.Kind == PerkKind.ElementalPop && !ElementalPop.CooldownReady) ? new Color(0.35f, 0.35f, 0.35f, 0.75f) : Color.white); if (((Graphic)value2).color != val) { ((Graphic)value2).color = val; } RectTransform rectTransform = ((Graphic)value2).rectTransform; rectTransform.sizeDelta = new Vector2(value, value); rectTransform.anchoredPosition = new Vector2((float)num2 * (value + num), 0f); num2++; } } } } private static bool Create() { //IL_0037: 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_007d: 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_00b5: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.HUDContainer == (Object)null) { return false; } container = new GameObject("TrepidPerkIcons", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)container).SetParent(instance.HUDContainer.transform, false); RectTransform obj = container; RectTransform obj2 = container; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 0f); obj2.anchorMax = val; obj.anchorMin = val; container.pivot = new Vector2(0f, 0f); container.anchoredPosition = new Vector2(Perks.HudMarginX.Value, Perks.HudMarginY.Value); container.sizeDelta = new Vector2(10f, 10f); icons.Clear(); foreach (PerkDef item in Perks.All) { if (!((Object)(object)item.Icon == (Object)null)) { GameObject val2 = new GameObject("Icon_" + item.ModelBase, new Type[1] { typeof(RectTransform) }); RectTransform component = val2.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)container, false); val = (component.anchorMin = (component.anchorMax = new Vector2(0f, 0f))); component.pivot = new Vector2(0f, 0f); Image val5 = val2.AddComponent<Image>(); val5.sprite = item.Icon; val5.preserveAspect = true; ((Graphic)val5).raycastTarget = false; val2.SetActive(false); icons[item.Index] = val5; } } Plugin.Log.LogInfo((object)$"[TrepidPerks] Iconos de perks creados en el HUD ({icons.Count})"); return true; } } public class PerkMachine : MonoBehaviour { internal static readonly Dictionary<int, PerkMachine> Current = new Dictionary<int, PerkMachine>(); public int perkIndex; public InteractTrigger trigger; public Vector3 signLightLocal; public Vector3 baseLightLocal; public Vector3 audioLocal; private PerkDef perk; private AudioSource jingleSource; private AudioSource buySource; private float jingleTimer; private bool lastCanConfirm = true; private void Awake() { Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Object)((Component)componentsInChildren[i]).gameObject).hideFlags = (HideFlags)0; } } private void Start() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) perk = Perks.Get(perkIndex); Current[perkIndex] = this; if ((Object)(object)trigger != (Object)null) { ((UnityEventBase)trigger.onInteract).RemoveAllListeners(); ((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)OnInteract); } MakeLight("PerkLuzLogo", signLightLocal, perk.SignLight.Value, perk.SignRange.Value); MakeLight("PerkLuzBase", baseLightLocal, perk.BaseLight.Value, perk.BaseRange.Value); GameObject val = new GameObject("PerkAudio"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = audioLocal; jingleSource = MakeSource(val, Plugin.VolumenCancion.Value); buySource = MakeSource(val, Plugin.VolumenCompra.Value); bool flag = Time.time - PerkNet.SessionStartTime > 10f; jingleTimer = 0f; if (flag && perk.JingleOnBuy.Value) { PlayJingle(); } Plugin.Log.LogInfo((object)$"[TrepidPerks] Maquina {perk.Name} aparecio en {((Component)this).transform.position} (recien comprada={flag})"); } private void OnEnable() { if (perk != null) { Current[perkIndex] = this; } } private void OnDestroy() { if (Current.TryGetValue(perkIndex, out var value) && (Object)(object)value == (Object)(object)this) { Current.Remove(perkIndex); } } private void MakeLight(string name, Vector3 local, float intensity, float range) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0028: 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_0035: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (intensity <= 0f) { return; } try { GameObject val = new GameObject(name); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = local; HDAdditionalLightData obj = GameObjectExtension.AddHDLight(val, (HDLightTypeAndShape)0); obj.SetColor(perk.GlowColor, -1f); obj.SetIntensity(intensity); obj.SetRange(range); Light component = val.GetComponent<Light>(); if ((Object)(object)component != (Object)null) { component.shadows = (LightShadows)0; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[TrepidPerks] No se pudo crear la luz " + name + ": " + ex.Message)); } } private AudioSource MakeSource(GameObject go, float volume) { AudioSource val = go.AddComponent<AudioSource>(); val.playOnAwake = false; val.spatialBlend = 1f; val.rolloffMode = (AudioRolloffMode)1; val.minDistance = 2f; val.maxDistance = Plugin.DistanciaSonido.Value; val.dopplerLevel = 0f; val.volume = volume; try { AudioSource val2 = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.ship3DAudio : null); if ((Object)(object)val2 != (Object)null) { val.outputAudioMixerGroup = val2.outputAudioMixerGroup; } } catch { } return val; } private void Update() { if ((Object)(object)StartOfRound.Instance == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { if (perk == null) { return; } UpdateHoverTip(); try { BuildDiagnostics(); } catch { } NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsServer) { jingleTimer += Time.deltaTime; float value = perk.JingleInterval.Value; if (value > 0f && jingleTimer >= value) { jingleTimer = 0f; PerkNet.ServerPlayJingle(perk); } } } } private void UpdateHoverTip() { if (!((Object)(object)trigger == (Object)null)) { bool flag = (Object)(object)PerkCaps.HeldCap(((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null, perk) != (Object)null; string text = (perk.LocalHasPerk ? L.T("Ya tienes " + perk.Name, "You already have " + perk.Name) : ((flag && !PerkNet.Drinking) ? L.T("Canjear chapa de " + perk.Name + " : [E]", "Redeem " + perk.Name + " cap : [E]") : (perk.LocalBoughtToday ? L.T("Limite diario alcanzado", "Daily limit reached") : ((!PerkNet.Drinking) ? L.T($"Comprar {perk.Name} (${perk.DrinkPrice.Value}) : [E]", $"Buy {perk.Name} (${perk.DrinkPrice.Value}) : [E]") : "")))); if (trigger.hoverTip != text) { trigger.hoverTip = text; } } } private void BuildDiagnostics() { //IL_0143: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) ShipBuildModeManager instance = ShipBuildModeManager.Instance; if ((Object)(object)instance == (Object)null || !instance.InBuildMode || (Object)(object)instance.placingObject == (Object)null || !((Component)instance.placingObject).transform.IsChildOf(((Component)this).transform) || instance.CanConfirmPosition == lastCanConfirm) { return; } lastCanConfirm = instance.CanConfirmPosition; if (instance.CanConfirmPosition) { return; } List<string> list = new List<string>(); if ((Object)(object)instance.ghostObject != (Object)null && (Object)(object)instance.currentCollider != (Object)null) { Vector3 val = instance.currentCollider.size * 0.5f * 0.57f; Collider[] array = Physics.OverlapBox(instance.ghostObject.position, val, Quaternion.Euler(instance.ghostObject.eulerAngles), instance.placementMaskAndBlockers, (QueryTriggerInteraction)1); foreach (Collider val2 in array) { list.Add(((Object)val2).name + "(" + LayerMask.LayerToName(((Component)val2).gameObject.layer) + ")"); } } ManualLogSource log = Plugin.Log; string name = perk.Name; Transform ghostObject = instance.ghostObject; log.LogInfo((object)string.Format("[{0}] Construccion bloqueada: fantasma={1} choca con: {2}", name, (ghostObject != null) ? new Vector3?(ghostObject.position) : ((Vector3?)null), string.Join(", ", list))); } private void OnInteract(PlayerControllerB player) { if (!((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { PerkNet.LocalTryBuy(perk); } } internal void PlayJingle() { if (!((Object)(object)perk.Jingle == (Object)null) && !((Object)(object)jingleSource == (Object)null) && (!((Object)(object)buySource != (Object)null) || !buySource.isPlaying)) { jingleSource.Stop(); jingleSource.clip = perk.Jingle; jingleSource.Play(); } } internal void PlayBuy() { if (!((Object)(object)perk.Buy == (Object)null) && !((Object)(object)buySource == (Object)null)) { if ((Object)(object)jingleSource != (Object)null && jingleSource.isPlaying) { jingleSource.Stop(); } buySource.clip = perk.Buy; buySource.Play(); } } } internal static class PerkNet { [HarmonyPatch(typeof(StartOfRound), "Start")] private static class StartPatch { [HarmonyPostfix] private static void Postfix(StartOfRound __instance) { SessionStartTime = Time.time; Perks.BaseMaxHealth = 100; ResetAll(); Register(); ElementalPop.Register(); MuleKick.Register(); PerkSave.OnSessionStart(); if ((Object)(object)((Component)__instance).GetComponent<SpeedColaRunner>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SpeedColaRunner>(); } } } [HarmonyPatch(typeof(StartOfRound), "ReviveDeadPlayers")] private static class RevivePatch { [HarmonyPostfix] private static void Postfix() { foreach (PerkDef item in Perks.All) { item.ServerBoughtToday.Clear(); item.LocalBoughtToday = false; } PlayerControllerB local = Local; if ((Object)(object)local != (Object)null && !local.isPlayerDead && !Perks.Jug.LocalHasPerk) { Perks.BaseMaxHealth = Mathf.Max(100, local.health); } if (Perks.Jug.LocalHasPerk && (Object)(object)local != (Object)null && !local.isPlayerDead && local.health < Perks.MaxHealth) { local.health = Perks.MaxHealth; HUDManager instance = HUDManager.Instance; if (instance != null) { instance.UpdateHealthUI(local.health, false); } } Plugin.Log.LogInfo((object)$"[TrepidPerks] Nuevo dia. Juggernog={Perks.Jug.LocalHasPerk} QuickRevive={Perks.Quick.LocalHasPerk} SpeedCola={Perks.Speed.LocalHasPerk} StaminUp={Perks.Stamin.LocalHasPerk} ElementalPop={Perks.EPop.LocalHasPerk} MuleKick={Perks.Mule.LocalHasPerk} PhD={Perks.PhD.LocalHasPerk} vida={(((Object)(object)local != (Object)null) ? local.health : (-1))}"); } } [HarmonyPatch(typeof(StartOfRound), "ResetShip")] private static class ResetShipPatch { [HarmonyPostfix] private static void Postfix() { ResetAll(); PerkSave.ClearAll(); } } [HarmonyPatch(typeof(AutoParentToShip), "LateUpdate")] private static class AutoParentPatch { [HarmonyPrefix] private static bool Prefix(AutoParentToShip __instance) { if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.elevatorTransform != (Object)null) { return true; } if ((Object)(object)((Component)__instance).GetComponent<PerkMachine>() != (Object)null) { Object.Destroy((Object)(object)((Component)__instance).gameObject); } return false; } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] private static class KillPatch { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { if ((Object)(object)__instance != (Object)(object)Local || !__instance.isPlayerDead) { return; } foreach (PerkDef item in Perks.All) { if (item.LocalHasPerk) { item.LocalHasPerk = false; Plugin.Log.LogInfo((object)("[" + item.Name + "] Moriste: perdiste el efecto")); } } } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] private static class DamagePatch { [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance, ref int damageNumber, out int __state) { __state = -1; if ((Object)(object)__instance != (Object)(object)Local || !((NetworkBehaviour)__instance).IsOwner || __instance.isPlayerDead || __instance.health <= 100 || damageNumber <= 0) { return; } bool flag = true; try { flag = __instance.AllowPlayerDeath(); } catch { } if (flag) { int health = __instance.health; int num = health - damageNumber; if (num > 100) { __state = num; damageNumber = 0; } else { damageNumber = 100 - num; __instance.health = 100; } Plugin.Log.LogInfo((object)$"[Juggernog] Golpe con vida extra: {health} -> {Mathf.Max(num, 0)} (dano al juego: {damageNumber})"); } } [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance, int __state) { if ((Object)(object)__instance != (Object)(object)Local || __instance.isPlayerDead) { return; } if (__state > 0) { __instance.health = __state; HUDManager instance = HUDManager.Instance; if (instance != null) { instance.UpdateHealthUI(__instance.health, false); } } TryQuickRevive(__instance); } } [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnBuyMsg; public static HandleNamedMessageDelegate <1>__OnResultMsg; public static HandleNamedMessageDelegate <2>__OnFxMsg; public static HandleNamedMessageDelegate <3>__OnJingleMsg; } private const string MsgBuy = "TrepidPerks.PerkBuy"; private const string MsgResult = "TrepidPerks.PerkResult"; private const string MsgFx = "TrepidPerks.PerkFx"; private const string MsgJingle = "TrepidPerks.PerkJingle"; internal static bool Drinking; internal static float SessionStartTime; private static float pendingUntil; private static NetworkManager NM => NetworkManager.Singleton; private static PlayerControllerB Local { get { if (!((Object)(object)GameNetworkManager.Instance != (Object)null)) { return null; } return GameNetworkManager.Instance.localPlayerController; } } internal static void Register() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //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_0092: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown NetworkManager nM = NM; CustomMessagingManager val = ((nM != null) ? nM.CustomMessagingManager : null); if (val == null) { Plugin.Log.LogWarning((object)"[TrepidPerks] CustomMessagingManager no disponible"); return; } object obj = <>O.<0>__OnBuyMsg; if (obj == null) { HandleNamedMessageDelegate val2 = OnBuyMsg; <>O.<0>__OnBuyMsg = val2; obj = (object)val2; } val.RegisterNamedMessageHandler("TrepidPerks.PerkBuy", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnResultMsg; if (obj2 == null) { HandleNamedMessageDelegate val3 = OnResultMsg; <>O.<1>__OnResultMsg = val3; obj2 = (object)val3; } val.RegisterNamedMessageHandler("TrepidPerks.PerkResult", (HandleNamedMessageDelegate)obj2); object obj3 = <>O.<2>__OnFxMsg; if (obj3 == null) { HandleNamedMessageDelegate val4 = OnFxMsg; <>O.<2>__OnFxMsg = val4; obj3 = (object)val4; } val.RegisterNamedMessageHandler("TrepidPerks.PerkFx", (HandleNamedMessageDelegate)obj3); object obj4 = <>O.<3>__OnJingleMsg; if (obj4 == null) { HandleNamedMessageDelegate val5 = OnJingleMsg; <>O.<3>__OnJingleMsg = val5; obj4 = (object)val5; } val.RegisterNamedMessageHandler("TrepidPerks.PerkJingle", (HandleNamedMessageDelegate)obj4); } internal static void ResetAll() { Drinking = false; pendingUntil = 0f; foreach (PerkDef item in Perks.All) { item.LocalHasPerk = false; item.LocalBoughtToday = false; item.ServerBoughtToday.Clear(); } } private unsafe static void Send(string msg, ulong target, int a, int b) { //IL_0010: 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_0022: 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_003a: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref a, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref b, default(ForPrimitives)); NM.CustomMessagingManager.SendNamedMessage(msg, target, val, (NetworkDelivery)2); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal static void LocalTryBuy(PerkDef perk) { PlayerControllerB local = Local; if ((Object)(object)local == (Object)null || local.isPlayerDead || Drinking) { return; } if (perk.LocalHasPerk) { Tip(perk.Name, L.T("Ya tienes el efecto activo.", "You already have this perk.")); return; } bool flag = (Object)(object)PerkCaps.HeldCap(local, perk) != (Object)null; if (!flag && perk.LocalBoughtToday) { Tip(perk.Name, L.T("Solo 1 botella por dia.", "Only 1 drink per day.")); } else if (!(Time.time < pendingUntil)) { pendingUntil = Time.time + 3f; Plugin.Log.LogInfo((object)("[" + perk.Name + "] Pidiendo " + (flag ? "canje de chapa" : "compra") + " al host")); if (NM.IsServer) { ServerHandleBuy(NM.LocalClientId, perk, flag); } else { Send("TrepidPerks.PerkBuy", 0uL, perk.Index, flag ? 1 : 0); } } } private static void OnResultMsg(ulong sender, FastBufferReader r) { //IL_0006: 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_0018: 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) int i = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref i, default(ForPrimitives)); int code = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref code, default(ForPrimitives)); PerkDef perkDef = Perks.Get(i); if (perkDef != null) { HandleResult(perkDef, code); } } private static void HandleResult(PerkDef perk, int code) { pendingUntil = 0f; Plugin.Log.LogInfo((object)$"[{perk.Name}] Resultado de compra: {code}"); switch (code) { case 0: case 10: { PlayerControllerB local = Local; if (code == 0) { perk.LocalBoughtToday = true; } else { if ((Object)(object)PerkCaps.HeldCap(local, perk) != (Object)null) { local.DestroyItemInSlotAndSync(local.currentItemSlot); } Tip(perk.Name, L.T("Chapa canjeada: bebida gratis.", "Cap redeemed: free drink.")); } if ((Object)(object)local != (Object)null && !local.isPlayerDead) { Drinking = true; BottleDrink.Begin(local, local: true, perk); } break; } case 1: Tip(perk.Name, L.T($"No hay creditos suficientes (${perk.DrinkPrice.Value}).", $"Not enough credits (${perk.DrinkPrice.Value}).")); break; case 2: perk.LocalBoughtToday = true; Tip(perk.Name, L.T("Solo 1 botella por dia.", "Only 1 drink per day.")); break; default: Tip(perk.Name, L.T("No se pudo comprar.", "Purchase failed.")); break; } } internal static void LocalApplyPerk(PerkDef perk) { PlayerControllerB local = Local; if ((Object)(object)local == (Object)null || local.isPlayerDead) { return; } perk.LocalHasPerk = true; if (perk.Kind == PerkKind.Juggernog) { local.health = Mathf.Max(local.health, Perks.MaxHealth); if (local.criticallyInjured) { local.MakeCriticallyInjured(false); } HUDManager instance = HUDManager.Instance; if (instance != null) { instance.UpdateHealthUI(local.health, false); } Tip("Juggernog", L.T($"Vida maxima: {Perks.MaxHealth}", $"Max health: {Perks.MaxHealth}")); } else if (perk.Kind == PerkKind.PhDFlopper) { Tip("PhD Flopper", L.T($"Inmune a explosiones y {Perks.PhDFallReduction.Value:0}% menos dano por caida.", $"Immune to explosions and {Perks.PhDFallReduction.Value:0}% less fall damage.")); } else if (perk.Kind == PerkKind.MuleKick) { Tip("Mule Kick", L.T("Slot extra de inventario y cambio de slot con objetos de dos manos.", "Extra inventory slot and slot switching with two-handed items.")); } else if (perk.Kind == PerkKind.ElementalPop) { Tip("Elemental Pop", L.T("Baterias que duran mas y golpes y disparos con efectos.", "Longer battery life and special hit and shot effects.")); } else if (perk.Kind == PerkKind.StaminUp) { Tip("Stamin-Up", L.T($"{Perks.StaminSpeedPercent.Value:0}% mas velocidad, sin freno en pendientes y stamina mas rapida.", $"{Perks.StaminSpeedPercent.Value:0}% faster, no slowdown on slopes and faster stamina.")); } else if (perk.Kind == PerkKind.SpeedCola) { Tip("Speed Cola", L.T($"Golpes, puertas y escaleras {Perks.SpeedPercent.Value:0}% mas rapido.", $"Swings, doors and ladders {Perks.SpeedPercent.Value:0}% faster.")); } else { Tip("Quick Revive", L.T($"Regeneras vida y al llegar a salud critica te curaras el {Perks.QuickHealPercent.Value}% de tu vida.", $"You regenerate health, and at critical health you will heal {Perks.QuickHealPercent.Value}% of your max health.")); TryQuickRevive(local); } Plugin.Log.LogInfo((object)$"[{perk.Name}] Perk aplicado, vida = {local.health}"); } private static void TryQuickRevive(PlayerControllerB me) { PerkDef quick = Perks.Quick; if (quick.LocalHasPerk && !((Object)(object)me == (Object)null) && !me.isPlayerDead && me.health <= Perks.QuickCriticalHealth.Value) { int maxHealth = Perks.MaxHealth; int num = Mathf.RoundToInt((float)(maxHealth * Perks.QuickHealPercent.Value) / 100f); int health = me.health; me.health = Mathf.Min(maxHealth, me.health + num); quick.LocalHasPerk = false; if (me.criticallyInjured) { me.MakeCriticallyInjured(false); } HUDManager instance = HUDManager.Instance; if (instance != null) { instance.UpdateHealthUI(me.health, false); } Tip("Quick Revive", L.T($"Te curaste {me.health - health} de vida.", $"You healed {me.health - health} health.")); Plugin.Log.LogInfo((object)$"[Quick Revive] Activado: vida {health} -> {me.health} (se consumio)"); } } private static void Tip(string h, string b) { try { HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip(h, b, false, false, "LC_Tip1"); } } catch { } } private static void OnBuyMsg(ulong sender, FastBufferReader r) { //IL_0006: 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_0018: 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) int i = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref i, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num, default(ForPrimitives)); PerkDef perkDef = Perks.Get(i); if (NM.IsServer && perkDef != null) { ServerHandleBuy(sender, perkDef, num == 1); } } private static void ServerHandleBuy(ulong clientId, PerkDef perk, bool useCap = false) { int num = 0; int value = -1; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || !instance.ClientPlayerList.TryGetValue(clientId, out value)) { num = 3; } Terminal val = Object.FindObjectOfType<Terminal>(); int value2 = perk.DrinkPrice.Value; if (num == 0 && (Object)(object)val == (Object)null) { num = 3; } if (num == 0 && useCap) { num = 10; } if (num == 0 && perk.ServerBoughtToday.Contains(clientId)) { num = 2; } if (num == 0 && val.groupCredits < value2) { num = 1; } if (num == 0) { perk.ServerBoughtToday.Add(clientId); val.groupCredits = Mathf.Max(0, val.groupCredits - value2); val.SyncGroupCreditsClientRpc(val.groupCredits, val.numberOfItemsInDropship); } Plugin.Log.LogInfo((object)$"[{perk.Name}] Host: compra de cliente {clientId} (jugador {value}) -> codigo {num}, creditos {(((Object)(object)val != (Object)null) ? val.groupCredits : (-1))}"); if (clientId == NM.LocalClientId) { HandleResult(perk, num); } else { Send("TrepidPerks.PerkResult", clientId, perk.Index, num); } if (num == 0 || num == 10) { Broadcast("TrepidPerks.PerkFx", perk.Index, value); } } internal static void ServerPlayJingle(PerkDef perk) { Broadcast("TrepidPerks.PerkJingle", perk.Index, 0); } private static void Broadcast(string msg, int perkIdx, int value) { Handle(msg, perkIdx, value); foreach (ulong connectedClientsId in NM.ConnectedClientsIds) { if (connectedClientsId != NM.LocalClientId) { Send(msg, connectedClientsId, perkIdx, value); } } } private static void OnFxMsg(ulong sender, FastBufferReader r) { //IL_0006: 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_0018: 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) int perkIdx = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref perkIdx, default(ForPrimitives)); int value = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref value, default(ForPrimitives)); Handle("TrepidPerks.PerkFx", perkIdx, value); } private static void OnJingleMsg(ulong sender, FastBufferReader r) { //IL_0006: 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_0018: 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) int perkIdx = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref perkIdx, default(ForPrimitives)); int value = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref value, default(ForPrimitives)); Handle("TrepidPerks.PerkJingle", perkIdx, value); } private static void Handle(string msg, int perkIdx, int value) { PerkDef perkDef = Perks.Get(perkIdx); if (perkDef == null) { return; } PerkMachine.Current.TryGetValue(perkIdx, out var value2); if (msg == "TrepidPerks.PerkJingle") { if ((Object)(object)value2 != (Object)null) { value2.PlayJingle(); } return; } if ((Object)(object)value2 != (Object)null) { value2.PlayBuy(); } StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && value >= 0 && value < instance.allPlayerScripts.Length) { PlayerControllerB val = instance.allPlayerScripts[value]; if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)Local && !val.isPlayerDead) { BottleDrink.Begin(val, local: false, perkDef); } } } } internal class MachineGeometry { public Transform Root; public MeshFilter Mesh; public PlaceableShipObject Pso; public BoxCollider PlaceCol; public BoxCollider Solid; public BoxCollider Trigger; public PerkMachine Machine; public AutoParentToShip Apts; public Matrix4x4 ShipToRoot; public Mesh Model; public MeshFilter Screen; public Mesh ScreenModel; public Vector3 BasePositionOffset; public float BuiltHeight; } [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class PerkRegistration { private static bool done; private static readonly string[] Preferred = new string[6] { "PlushiePJManContainer", "DogHouse", "FishBowlContainer", "SofaChairContainer", "PumpkinUnlockableContainer", "WelcomeMatContainer" }; [HarmonyPostfix] private static void Postfix() { //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) if (done) { return; } done = true; Plugin.PlaceClip = Plugin.LoadClip("Juggernog_Colocar.ogg"); List<GameObject> list = (from p in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs select p.Prefab into p where (Object)(object)p != (Object)null select p).ToList(); Sprite hoverIcon = null; foreach (GameObject item in list) { InteractTrigger componentInChildren = item.GetComponentInChildren<InteractTrigger>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.hoverIcon != (Object)null) { hoverIcon = componentInChildren.hoverIcon; break; } } GameObject val = PickTemplate(list); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"[TrepidPerks] No se encontro ningun mueble del juego para usar de base."); return; } Plugin.Log.LogInfo((object)("[TrepidPerks] Mueble base: " + ((Object)val).name)); foreach (PerkDef item2 in Perks.All) { Texture2D val2 = ModelLoader.LoadTexture("Icon_" + item2.Id + ".png", linear: false, optional: true); if ((Object)(object)val2 != (Object)null) { item2.Icon = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f); } } foreach (PerkDef item3 in Perks.All) { try { Build(item3, val, hoverIcon); } catch (Exception arg) { Plugin.Log.LogError((object)$"[TrepidPerks] Error creando {item3.Name}: {arg}"); } } ElementalPop.FindResources(list); try { PerkCaps.Build(list); } catch (Exception arg2) { Plugin.Log.LogError((object)$"[Chapas] Error: {arg2}"); } } private static void Build(PerkDef perk, GameObject template, Sprite hoverIcon) { //IL_0714: Unknown result type (might be due to invalid IL or missing references) //IL_0719: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: 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_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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_081d: Unknown result type (might be due to invalid IL or missing references) //IL_0829: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Unknown result type (might be due to invalid IL or missing references) //IL_0837: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0845: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Expected O, but got Unknown //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Expected O, but got Unknown //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Expected O, but got Unknown //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Expected O, but got Unknown //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Expected O, but got Unknown //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Expected O, but got Unknown //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Expected O, but got Unknown //IL_0584: Unknown result