using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Networking;
[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("McNutMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("McNutMod")]
[assembly: AssemblyTitle("McNutMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace McNutMod
{
public class McNutInputs : LcInputActions
{
[InputAction("<Keyboard>/k", Name = "Mode Manuel")]
public InputAction SuicideKey { get; set; }
[InputAction("<Keyboard>/h", Name = "Ronnie McNuttcracked")]
public InputAction RonnieKey { get; set; }
}
[BepInPlugin("McNut.RonnieMcNuttcracked", "Ronnie McNuttcracked", "9.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("McNut.RonnieMcNuttcracked");
internal static McNutInputs Inputs = new McNutInputs();
public static AudioClip SoundPreShot;
public static AudioClip SoundAfterShot;
public static bool IsLockingInventory = false;
public static Plugin Instance;
private void Awake()
{
Instance = this;
try
{
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"--- Ronnie McNuttcracked : V9.0 (AUDIO & NET FIX) ---");
((MonoBehaviour)this).StartCoroutine(LoadAllSounds());
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"ERREUR CRITIQUE AU LANCEMENT : {arg}");
}
}
private IEnumerator LoadAllSounds()
{
yield return LoadAudio("mcnutpreshot.ogg", delegate(AudioClip clip)
{
SoundPreShot = clip;
});
yield return LoadAudio("ringtoneaftershot.ogg", delegate(AudioClip clip)
{
SoundAfterShot = clip;
});
}
private IEnumerator LoadAudio(string filename, Action<AudioClip> onLoaded)
{
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), filename);
string text2 = "file://" + text;
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)14);
try
{
yield return www.SendWebRequest();
if ((int)www.result == 1)
{
AudioClip content = DownloadHandlerAudioClip.GetContent(www);
((Object)content).name = filename;
onLoaded(content);
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)("[Ronnie Audio] Impossible de charger : " + filename + ". Erreur : " + www.error));
}
}
finally
{
((IDisposable)www)?.Dispose();
}
}
}
[HarmonyPatch]
public class NetworkHandler
{
[HarmonyPatch(typeof(StartOfRound), "Awake")]
[HarmonyPostfix]
private static void RegisterMessages()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.CustomMessagingManager != null)
{
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Ronnie_Trigger_Server", new HandleNamedMessageDelegate(OnTriggerServer));
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Ronnie_Trigger_Client", new HandleNamedMessageDelegate(OnTriggerClient));
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Ronnie_State_Server", new HandleNamedMessageDelegate(OnStateServer));
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Ronnie_State_Client", new HandleNamedMessageDelegate(OnStateClient));
Debug.Log((object)"[Ronnie Net] SYSTÈME RÉSEAU INITIALISÉ AVEC SUCCÈS (StartOfRound)");
}
else
{
Debug.LogError((object)"[Ronnie Net] ERREUR FATALE : NetworkManager null dans StartOfRound !");
}
}
public static void RequestRonnieTrigger(ulong netId)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening)
{
return;
}
if (NetworkManager.Singleton.IsServer)
{
BroadcastTrigger(netId);
return;
}
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
try
{
((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref netId, default(ForPrimitives));
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Ronnie_Trigger_Server", 0uL, val, (NetworkDelivery)3);
Debug.Log((object)"[Ronnie Net] Client -> Serveur : Trigger");
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
}
private static void OnTriggerServer(ulong clientId, FastBufferReader reader)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsServer)
{
ulong netId = default(ulong);
((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref netId, default(ForPrimitives));
BroadcastTrigger(netId);
}
}
private static void BroadcastTrigger(ulong netId)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
try
{
((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref netId, default(ForPrimitives));
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Ronnie_Trigger_Client", val, (NetworkDelivery)3);
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
ExecuteTriggerLocally(netId);
}
private static void OnTriggerClient(ulong clientId, FastBufferReader reader)
{
//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)
ulong netId = default(ulong);
((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref netId, default(ForPrimitives));
if (!NetworkManager.Singleton.IsServer)
{
ExecuteTriggerLocally(netId);
}
}
private static void ExecuteTriggerLocally(ulong netId)
{
if (!NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(netId, out var value))
{
return;
}
ShotgunItem component = ((Component)value).GetComponent<ShotgunItem>();
if ((Object)(object)component != (Object)null)
{
SuicideModeController suicideModeController = ((Component)component).GetComponent<SuicideModeController>();
if ((Object)(object)suicideModeController == (Object)null)
{
suicideModeController = ((Component)component).gameObject.AddComponent<SuicideModeController>();
}
suicideModeController.StartSyncedSequence();
}
}
public static void RequestStateSync(ulong netId, bool newState)
{
//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_003a: 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_0057: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsServer)
{
BroadcastState(netId, newState);
return;
}
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
try
{
((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref netId, default(ForPrimitives));
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref newState, default(ForPrimitives));
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Ronnie_State_Server", 0uL, val, (NetworkDelivery)3);
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
}
private static void OnStateServer(ulong clientId, FastBufferReader reader)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsServer)
{
ulong netId = default(ulong);
((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref netId, default(ForPrimitives));
bool newState = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref newState, default(ForPrimitives));
BroadcastState(netId, newState);
}
}
private static void BroadcastState(ulong netId, bool newState)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
try
{
((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref netId, default(ForPrimitives));
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref newState, default(ForPrimitives));
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("Ronnie_State_Client", val, (NetworkDelivery)3);
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
ExecuteStateLocally(netId, newState);
}
private static void OnStateClient(ulong clientId, FastBufferReader reader)
{
//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)
ulong netId = default(ulong);
((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref netId, default(ForPrimitives));
bool newState = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref newState, default(ForPrimitives));
if (!NetworkManager.Singleton.IsServer)
{
ExecuteStateLocally(netId, newState);
}
}
private static void ExecuteStateLocally(ulong netId, bool newState)
{
if (!NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(netId, out var value))
{
return;
}
ShotgunItem component = ((Component)value).GetComponent<ShotgunItem>();
if ((Object)(object)component != (Object)null)
{
SuicideModeController suicideModeController = ((Component)component).GetComponent<SuicideModeController>();
if ((Object)(object)suicideModeController == (Object)null)
{
suicideModeController = ((Component)component).gameObject.AddComponent<SuicideModeController>();
}
suicideModeController.isSuicideMode = newState;
if ((Object)(object)((Component)suicideModeController).GetComponent<AudioSource>() != (Object)null && (Object)(object)component.noAmmoSFX != (Object)null)
{
((Component)suicideModeController).GetComponent<AudioSource>().PlayOneShot(component.noAmmoSFX);
}
}
}
}
public class SuicideModeController : MonoBehaviour
{
private ShotgunItem shotgun;
public bool isSuicideMode;
public Vector3 originalScale = Vector3.one;
private AudioSource gunAudioSource;
private AudioSource ronnieAudioSource;
private float originalVolume = 1f;
public bool isRonnieSequenceActive;
public bool hasFlippedDuringCinematic;
private bool isWaitingForConfirmation;
private float confirmationTimer;
private const float MAX_CONFIRM_TIME = 5f;
private void Start()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_006b: Unknown result type (might be due to invalid IL or missing references)
shotgun = ((Component)this).GetComponent<ShotgunItem>();
gunAudioSource = ((Component)this).GetComponent<AudioSource>();
if ((Object)(object)((Component)this).transform != (Object)null)
{
originalScale = new Vector3(Mathf.Abs(((Component)this).transform.localScale.x), Mathf.Abs(((Component)this).transform.localScale.y), Mathf.Abs(((Component)this).transform.localScale.z));
}
if ((Object)(object)gunAudioSource != (Object)null)
{
originalVolume = gunAudioSource.volume;
}
EnsureAudioSourceExists();
}
private void EnsureAudioSourceExists()
{
if ((Object)(object)ronnieAudioSource == (Object)null)
{
ronnieAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
ronnieAudioSource.playOnAwake = false;
ronnieAudioSource.priority = 0;
ronnieAudioSource.minDistance = 6f;
ronnieAudioSource.maxDistance = 50f;
ronnieAudioSource.rolloffMode = (AudioRolloffMode)1;
if ((Object)(object)gunAudioSource != (Object)null && (Object)(object)gunAudioSource.outputAudioMixerGroup != (Object)null)
{
ronnieAudioSource.outputAudioMixerGroup = gunAudioSource.outputAudioMixerGroup;
ronnieAudioSource.spatialBlend = 1f;
}
else
{
ronnieAudioSource.spatialBlend = 1f;
}
}
}
private void Update()
{
if ((Object)(object)shotgun == (Object)null || !((GrabbableObject)shotgun).isHeld)
{
if (isRonnieSequenceActive || isSuicideMode)
{
ResetGunLocal();
}
}
else if ((Object)(object)((GrabbableObject)shotgun).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
HandleInputs();
UpdateHUD();
}
}
private void HandleInputs()
{
if (isRonnieSequenceActive)
{
return;
}
if (isWaitingForConfirmation)
{
confirmationTimer -= Time.deltaTime;
if (confirmationTimer <= 0f)
{
isWaitingForConfirmation = false;
Debug.Log((object)"[Ronnie Input] Timer expiré.");
}
}
if (Plugin.Inputs.SuicideKey.triggered && !isWaitingForConfirmation)
{
ToggleMode();
}
if (Plugin.Inputs.RonnieKey.triggered)
{
TryTriggerRonnie();
}
}
private void TryTriggerRonnie()
{
if (shotgun.shellsLoaded <= 0 || shotgun.safetyOn || isSuicideMode)
{
return;
}
if (!isWaitingForConfirmation)
{
isWaitingForConfirmation = true;
confirmationTimer = 5f;
Debug.Log((object)"[Ronnie Input] Timer lancé (5s)");
return;
}
isWaitingForConfirmation = false;
if ((Object)(object)((NetworkBehaviour)shotgun).NetworkObject != (Object)null && ((NetworkBehaviour)shotgun).NetworkObject.IsSpawned)
{
Debug.Log((object)"[Ronnie Input] CONFIRMÉ ! Envoi réseau...");
NetworkHandler.RequestRonnieTrigger(((NetworkBehaviour)shotgun).NetworkObject.NetworkObjectId);
}
else
{
Debug.LogError((object)"[Ronnie Input] Erreur: Shotgun non spawn réseau");
}
}
public void StartSyncedSequence()
{
if ((Object)(object)shotgun != (Object)null && (Object)(object)((GrabbableObject)shotgun).playerHeldBy != (Object)null)
{
EnsureAudioSourceExists();
((MonoBehaviour)this).StartCoroutine(RunRonnieCinematic(((GrabbableObject)shotgun).playerHeldBy));
}
}
private IEnumerator RunRonnieCinematic(PlayerControllerB player)
{
bool isMe = (Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController;
isRonnieSequenceActive = true;
hasFlippedDuringCinematic = false;
if (isMe)
{
Plugin.IsLockingInventory = true;
}
float num = 2f;
if ((Object)(object)Plugin.SoundPreShot != (Object)null && (Object)(object)ronnieAudioSource != (Object)null)
{
ronnieAudioSource.Stop();
ronnieAudioSource.PlayOneShot(Plugin.SoundPreShot);
num = Plugin.SoundPreShot.length;
Debug.Log((object)("[Ronnie Audio] Lecture son sur " + player.playerUsername));
}
float num2 = Mathf.Max(0f, num - 2f);
yield return (object)new WaitForSeconds(num2);
hasFlippedDuringCinematic = true;
if ((Object)(object)gunAudioSource != (Object)null && (Object)(object)shotgun.noAmmoSFX != (Object)null)
{
gunAudioSource.PlayOneShot(shotgun.noAmmoSFX);
}
yield return (object)new WaitForSeconds(1.9f);
isRonnieSequenceActive = false;
if (isMe)
{
isSuicideMode = true;
if ((Object)(object)((NetworkBehaviour)shotgun).NetworkObject != (Object)null)
{
NetworkHandler.RequestStateSync(((NetworkBehaviour)shotgun).NetworkObject.NetworkObjectId, newState: true);
}
Plugin.IsLockingInventory = false;
shotgun.ShootGun(((Component)shotgun).transform.position, ((Component)shotgun).transform.forward);
}
else
{
yield return (object)new WaitForSeconds(1f);
}
if ((Object)(object)ronnieAudioSource != (Object)null)
{
ronnieAudioSource.Stop();
}
yield return (object)new WaitForSeconds(0.1f);
DeadBodyInfo val = null;
DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>();
foreach (DeadBodyInfo val2 in array)
{
if ((Object)(object)val2.playerScript == (Object)(object)player)
{
val = val2;
break;
}
}
if ((Object)(object)Plugin.SoundAfterShot != (Object)null)
{
if ((Object)(object)val != (Object)null)
{
PlaySoundAttached(Plugin.SoundAfterShot, ((Component)val).gameObject, 3f);
}
else
{
PlaySoundLoud(Plugin.SoundAfterShot, ((Component)player).transform.position, 3f);
}
}
}
private void PlaySoundAttached(AudioClip clip, GameObject target, float volumeMult)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
if (!((Object)(object)target == (Object)null))
{
GameObject val = new GameObject("McNutRingtone");
val.transform.SetParent(target.transform, false);
val.transform.localPosition = Vector3.zero;
AudioSource val2 = val.AddComponent<AudioSource>();
val2.clip = clip;
val2.volume = 1f * volumeMult;
val2.spatialBlend = 1f;
val2.minDistance = 8f;
val2.maxDistance = 60f;
if ((Object)(object)gunAudioSource != (Object)null)
{
val2.outputAudioMixerGroup = gunAudioSource.outputAudioMixerGroup;
}
val2.Play();
Object.Destroy((Object)val, clip.length + 0.5f);
}
}
private void PlaySoundLoud(AudioClip clip, Vector3 pos, float volumeMult)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
GameObject val = new GameObject("McNutRingtoneStatic");
val.transform.position = pos;
AudioSource val2 = val.AddComponent<AudioSource>();
val2.clip = clip;
val2.volume = 1f * volumeMult;
val2.spatialBlend = 1f;
val2.minDistance = 8f;
val2.maxDistance = 60f;
if ((Object)(object)gunAudioSource != (Object)null)
{
val2.outputAudioMixerGroup = gunAudioSource.outputAudioMixerGroup;
}
val2.Play();
Object.Destroy((Object)val, clip.length + 0.5f);
}
private void ToggleMode()
{
bool newState = !isSuicideMode;
if ((Object)(object)((NetworkBehaviour)shotgun).NetworkObject != (Object)null && ((NetworkBehaviour)shotgun).NetworkObject.IsSpawned)
{
NetworkHandler.RequestStateSync(((NetworkBehaviour)shotgun).NetworkObject.NetworkObjectId, newState);
}
}
public void ResetGunLocal()
{
isSuicideMode = false;
isRonnieSequenceActive = false;
hasFlippedDuringCinematic = false;
isWaitingForConfirmation = false;
Plugin.IsLockingInventory = false;
if ((Object)(object)ronnieAudioSource != (Object)null)
{
ronnieAudioSource.Stop();
}
if ((Object)(object)gunAudioSource != (Object)null)
{
gunAudioSource.volume = originalVolume;
}
if ((Object)(object)HUDManager.Instance != (Object)null)
{
HUDManager.Instance.ChangeControlTip(0, "Tirer", false);
}
}
public void ResetGunAndSync()
{
ResetGunLocal();
if ((Object)(object)((NetworkBehaviour)shotgun).NetworkObject != (Object)null && ((NetworkBehaviour)shotgun).NetworkObject.IsSpawned)
{
NetworkHandler.RequestStateSync(((NetworkBehaviour)shotgun).NetworkObject.NetworkObjectId, newState: false);
}
}
public void UpdateHUD()
{
if ((Object)(object)HUDManager.Instance == (Object)null)
{
return;
}
string bindingDisplayString = InputActionRebindingExtensions.GetBindingDisplayString(Plugin.Inputs.SuicideKey, (DisplayStringOptions)0, (string)null);
string bindingDisplayString2 = InputActionRebindingExtensions.GetBindingDisplayString(Plugin.Inputs.RonnieKey, (DisplayStringOptions)0, (string)null);
string text = "Tirer:[LMB]";
if (!isRonnieSequenceActive)
{
if (isWaitingForConfirmation)
{
int num = Mathf.CeilToInt(confirmationTimer);
HUDManager.Instance.ChangeControlTip(0, $"CONFIRMER RONNIE ? {bindingDisplayString2}:OUI ({num}s)", true);
}
else if (isSuicideMode)
{
HUDManager.Instance.ChangeControlTip(0, text + " | " + bindingDisplayString + ":Normal", false);
}
else
{
string text2 = ((shotgun.shellsLoaded > 0 && !shotgun.safetyOn) ? (bindingDisplayString + ":Inverser | " + bindingDisplayString2 + ":Ronnie") : (bindingDisplayString + ":Inverser"));
HUDManager.Instance.ChangeControlTip(0, text + " | " + text2, false);
}
}
}
public IEnumerator TriggerSuicideAndTP(PlayerControllerB player)
{
Vector3 deathPosition = ((Component)player).transform.position;
ResetGunAndSync();
yield return (object)new WaitForEndOfFrame();
Vector3 val = -((Component)player).transform.forward * 25f + Vector3.up * 5f;
player.DamagePlayer(100, true, true, (CauseOfDeath)7, 0, false, val);
yield return (object)new WaitForSeconds(0.25f);
DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>();
foreach (DeadBodyInfo val2 in array)
{
if ((Object)(object)val2.playerScript == (Object)(object)player)
{
if (Vector3.Distance(deathPosition, ((Component)val2).transform.position) > 15f)
{
((Component)val2).transform.position = deathPosition + Vector3.up * 0.6f;
}
break;
}
}
}
}
[HarmonyPatch(typeof(GrabbableObject))]
internal class VisualPatch
{
[HarmonyPatch("LateUpdate")]
[HarmonyPostfix]
private static void ForceRotation(GrabbableObject __instance)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if (!(__instance is ShotgunItem))
{
return;
}
SuicideModeController component = ((Component)__instance).GetComponent<SuicideModeController>();
if (!((Object)(object)component == (Object)null))
{
if (component.isSuicideMode || (component.isRonnieSequenceActive && component.hasFlippedDuringCinematic))
{
((Component)__instance).transform.localScale = new Vector3(Mathf.Abs(component.originalScale.x), Mathf.Abs(component.originalScale.y), 0f - Mathf.Abs(component.originalScale.z));
}
else
{
((Component)__instance).transform.localScale = new Vector3(Mathf.Abs(component.originalScale.x), Mathf.Abs(component.originalScale.y), Mathf.Abs(component.originalScale.z));
}
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerPatch
{
[HarmonyPatch("SwitchToItemSlot")]
[HarmonyPrefix]
private static bool PreventSlotSwitch(PlayerControllerB __instance)
{
if (Plugin.IsLockingInventory && (Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
return false;
}
return true;
}
[HarmonyPatch("Discard_performed")]
[HarmonyPrefix]
private static bool PreventDiscard(PlayerControllerB __instance)
{
if (Plugin.IsLockingInventory && (Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ShotgunItem))]
internal class ShotgunPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void OnShotgunSpawn(ShotgunItem __instance)
{
if ((Object)(object)((Component)__instance).gameObject.GetComponent<SuicideModeController>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<SuicideModeController>();
}
}
[HarmonyPatch("DiscardItem")]
[HarmonyPrefix]
private static bool OnDrop(ShotgunItem __instance)
{
SuicideModeController component = ((Component)__instance).gameObject.GetComponent<SuicideModeController>();
if ((Object)(object)component != (Object)null && component.isRonnieSequenceActive)
{
return false;
}
if ((Object)(object)component != (Object)null)
{
component.ResetGunAndSync();
}
return true;
}
[HarmonyPatch("ShootGun")]
[HarmonyPrefix]
private static bool OnShoot(ShotgunItem __instance, ref Vector3 shotgunPosition, ref Vector3 shotgunForward)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
SuicideModeController component = ((Component)__instance).gameObject.GetComponent<SuicideModeController>();
if ((Object)(object)component != (Object)null && component.isRonnieSequenceActive)
{
return false;
}
if ((Object)(object)component != (Object)null && component.isSuicideMode)
{
shotgunForward = -shotgunForward;
if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
((MonoBehaviour)component).StartCoroutine(component.TriggerSuicideAndTP(((GrabbableObject)__instance).playerHeldBy));
}
return true;
}
return true;
}
[HarmonyPatch("ItemInteractLeftRight")]
[HarmonyPrefix]
private static bool BlockInteraction(ShotgunItem __instance)
{
SuicideModeController component = ((Component)__instance).gameObject.GetComponent<SuicideModeController>();
if ((Object)(object)component != (Object)null && component.isRonnieSequenceActive)
{
return false;
}
return true;
}
}
}