using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using R0B0.GreatestMod.Monobehaviours;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("R0B0.GreatestMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("GreatestMod")]
[assembly: AssemblyTitle("R0B0.GreatestMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 R0B0.GreatestMod
{
[BepInPlugin("R0B0.GreatestMod", "GreatestMod", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static AssetBundle MyCustomAssets;
public static AudioClip carLights;
public static Plugin Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
MyCustomAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "greatestmod"));
if ((Object)(object)MyCustomAssets == (Object)null)
{
Logger.LogError((object)"Failed to load custom assets.");
return;
}
carLights = MyCustomAssets.LoadAsset<AudioClip>("Assets/GreatestMod/CompanyCruiserToy/Cruiser_HeadlightsOn.ogg");
int num = 30;
Item val = MyCustomAssets.LoadAsset<Item>("Assets/GreatestMod/CompanyCruiserToy/CompanyCruiserToy.asset");
GameObject val2 = MyCustomAssets.LoadAsset<GameObject>("Assets/GreatestMod/CompanyCruiserToy/ToyCar.prefab");
((GrabbableObject)val2.AddComponent<PhysicsPropWithLights>()).itemProperties = val;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Items.RegisterScrap(val, num, (LevelTypes)4096);
Patch();
Logger.LogInfo((object)"R0B0.GreatestMod v0.0.1 has loaded!");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("R0B0.GreatestMod");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "R0B0.GreatestMod";
public const string PLUGIN_NAME = "GreatestMod";
public const string PLUGIN_VERSION = "0.0.1";
}
}
namespace R0B0.GreatestMod.Patches
{
[HarmonyPatch(typeof(PlayerControllerB), "Update")]
internal class ExhaustionPatch
{
[HarmonyPostfix]
private static void PlayerControllerB_Update(PlayerControllerB __instance)
{
if (!__instance.isExhausted)
{
}
}
}
[HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")]
internal class PlayerInteractionPatch
{
[HarmonyPostfix]
private static void PlayerControllerB_Interact_performed(PlayerControllerB __instance, CallbackContext context)
{
if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject))
{
if (!StartOfRound.Instance.overrideSpectateCamera && (Object)(object)__instance.spectatedPlayerScript != (Object)null && !__instance.spectatedPlayerScript.isPlayerDead)
{
__instance.SpectateNextPlayer(false);
}
}
else
{
if (((!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || (((NetworkBehaviour)__instance).IsServer && !__instance.isHostPlayerObject)) && !__instance.isTestingPlayer) || !((CallbackContext)(ref context)).performed || __instance.timeSinceSwitchingSlots < 0.2f || __instance.inSpecialMenu)
{
return;
}
ShipBuildModeManager.Instance.CancelBuildMode(true);
if (!__instance.isGrabbingObjectAnimation && !__instance.isTypingChat && !__instance.inTerminalMenu && !__instance.throwingObject && !__instance.IsInspectingItem && !((Object)(object)__instance.inAnimationWithEnemy != (Object)null) && !__instance.jetpackControls && !__instance.disablingJetpackControls && !StartOfRound.Instance.suckingPlayersOutOfShip)
{
if (!__instance.activatingItem && !__instance.waitingToDropItem)
{
__instance.BeginGrabObject();
}
if (!((Object)(object)__instance.hoveringOverTrigger == (Object)null) && !__instance.hoveringOverTrigger.holdInteraction && (!__instance.isHoldingObject || __instance.hoveringOverTrigger.oneHandedItemAllowed) && (!__instance.twoHanded || (__instance.hoveringOverTrigger.twoHandedItemAllowed && !__instance.hoveringOverTrigger.specialCharacterAnimation) || (__instance.hoveringOverTrigger.twoHandedItemAllowed && __instance.hoveringOverTrigger.hoverTip == "Charge item : [LMB]")) && __instance.InteractTriggerUseConditionsMet())
{
__instance.hoveringOverTrigger.Interact(__instance.thisPlayerBody);
}
}
}
}
}
[HarmonyPatch(typeof(ItemCharger))]
internal class PowerOutletStun
{
private const int DAMAGEAMOUNT = 50;
private const float BODYTHROWMULTIPLIER = 0.5f;
private const int DAMAGEDISTRIBUTION = 3;
[HarmonyPatch("ChargeItem")]
[HarmonyPrefix]
private static void ItemCharger_ChargeItem(ItemCharger __instance)
{
Plugin.Logger.LogDebug((object)"------------- Charged item!! ------------------------");
GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
if (!((Object)(object)currentlyHeldObjectServer == (Object)null) && (currentlyHeldObjectServer.itemProperties.requiresBattery || currentlyHeldObjectServer.itemProperties.isConductiveMetal))
{
__instance.PlayChargeItemEffectServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
if (__instance.chargeItemCoroutine != null)
{
((MonoBehaviour)__instance).StopCoroutine(__instance.chargeItemCoroutine);
}
if (currentlyHeldObjectServer.itemProperties.requiresBattery)
{
__instance.chargeItemCoroutine = ((MonoBehaviour)__instance).StartCoroutine(__instance.chargeItemDelayed(currentlyHeldObjectServer));
}
else if (currentlyHeldObjectServer.itemProperties.isConductiveMetal && !currentlyHeldObjectServer.itemProperties.twoHanded)
{
__instance.chargeItemCoroutine = ((MonoBehaviour)__instance).StartCoroutine(chargeItemDelayedButBetter(currentlyHeldObjectServer, __instance.zapAudio, __instance.chargeStationAnimator, 1f));
}
else if (currentlyHeldObjectServer.itemProperties.isConductiveMetal && currentlyHeldObjectServer.itemProperties.twoHanded)
{
__instance.chargeItemCoroutine = ((MonoBehaviour)__instance).StartCoroutine(chargeItemDelayedButBetter(currentlyHeldObjectServer, __instance.zapAudio, __instance.chargeStationAnimator, 2f));
}
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void ItemCharger_Update(ItemCharger __instance)
{
if (__instance.updateInterval == 0f)
{
__instance.updateInterval = 0f;
if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
{
__instance.triggerScript.interactable = (Object)(object)GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer != (Object)null && (GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties.isConductiveMetal || GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer.itemProperties.requiresBattery);
}
}
}
private static IEnumerator chargeItemDelayedButBetter(GrabbableObject itemToCharge, AudioSource zapAudio, Animator chargeStationAnimator, float damageMultiplier)
{
zapAudio.Play();
yield return (object)new WaitForSeconds(0.6f);
chargeStationAnimator.SetTrigger("zap");
if ((Object)(object)itemToCharge != (Object)null)
{
for (int i = 0; i < 3; i++)
{
GameNetworkManager.Instance.localPlayerController.DamagePlayer(Mathf.RoundToInt(16f * damageMultiplier), true, true, (CauseOfDeath)11, 0, false, default(Vector3));
yield return (object)new WaitForSeconds(0.1f);
}
}
}
}
}
namespace R0B0.GreatestMod.Monobehaviours
{
public class PhysicsPropWithLights : PhysicsProp
{
[Space(15f)]
public int flashlightInterferenceLevel;
public static int globalFlashlightInterferenceLevel;
public bool changeMaterial = true;
public Light flashlightBulb { get; set; }
public Light flashlightBulbGlow { get; set; }
public AudioSource flashlightAudio { get; set; }
public AudioClip[] flashlightClips { get; set; }
public AudioClip outOfBatteriesClip { get; set; }
public AudioClip flashlightFlicker { get; set; }
public Material bulbLight { get; set; }
public Material bulbDark { get; set; }
public MeshRenderer flashlightMesh { get; set; }
public int flashlightTypeID { get; set; }
private float initialIntensity { get; set; }
private PlayerControllerB previousPlayerHeldBy { get; set; }
public void Awake()
{
((GrabbableObject)this).grabbable = true;
((GrabbableObject)this).isInFactory = true;
((GrabbableObject)this).grabbableToEnemies = true;
changeMaterial = false;
flashlightBulb = ((Component)this).GetComponentsInChildren<Light>()[0];
flashlightBulbGlow = ((Component)this).GetComponentsInChildren<Light>()[1];
flashlightAudio = ((Component)this).GetComponent<AudioSource>();
flashlightClips = (AudioClip[])(object)new AudioClip[1];
flashlightClips[0] = Plugin.carLights;
((GrabbableObject)this).insertedBattery.empty = false;
((GrabbableObject)this).insertedBattery.charge = 100f;
}
public override void Start()
{
((GrabbableObject)this).Start();
initialIntensity = flashlightBulb.intensity;
}
public override void UseUpBatteries()
{
((GrabbableObject)this).UseUpBatteries();
SwitchFlashlight(on: false);
}
public override void PocketItem()
{
Plugin.Logger.LogError((object)"Truck pocketed");
if (!((NetworkBehaviour)this).IsOwner)
{
((GrabbableObject)this).PocketItem();
return;
}
if ((Object)(object)previousPlayerHeldBy != (Object)null)
{
((Behaviour)flashlightBulb).enabled = false;
((Behaviour)flashlightBulbGlow).enabled = false;
if (((GrabbableObject)this).isBeingUsed && ((Object)(object)previousPlayerHeldBy.ItemSlots[previousPlayerHeldBy.currentItemSlot] == (Object)null || previousPlayerHeldBy.ItemSlots[previousPlayerHeldBy.currentItemSlot].itemProperties.itemId != 1 || previousPlayerHeldBy.ItemSlots[previousPlayerHeldBy.currentItemSlot].itemProperties.itemId != 6))
{
previousPlayerHeldBy.pocketedFlashlight = (GrabbableObject)(object)this;
PocketFlashlightServerRpc(stillUsingFlashlight: true);
}
else
{
((GrabbableObject)this).isBeingUsed = false;
((Behaviour)flashlightBulbGlow).enabled = false;
SwitchFlashlight(on: false);
PocketFlashlightServerRpc();
}
}
else
{
Debug.Log((object)"Could not find what player was holding this flashlight item");
}
((GrabbableObject)this).PocketItem();
}
[ServerRpc]
public void PocketFlashlightServerRpc(bool stillUsingFlashlight = false)
{
PocketFlashlightClientRpc(stillUsingFlashlight);
}
[ClientRpc]
public void PocketFlashlightClientRpc(bool stillUsingFlashlight)
{
if (((NetworkBehaviour)this).IsOwner)
{
return;
}
((Behaviour)flashlightBulb).enabled = false;
((Behaviour)flashlightBulbGlow).enabled = false;
if (stillUsingFlashlight)
{
if (!((Object)(object)previousPlayerHeldBy == (Object)null))
{
previousPlayerHeldBy.pocketedFlashlight = (GrabbableObject)(object)this;
}
}
else
{
((GrabbableObject)this).isBeingUsed = false;
((Behaviour)flashlightBulbGlow).enabled = false;
SwitchFlashlight(on: false);
}
}
public override void DiscardItem()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).DiscardItem();
RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 25f, 0.95f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
}
public override void EquipItem()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
previousPlayerHeldBy = ((GrabbableObject)this).playerHeldBy;
SwitchFlashlight(on: true);
RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 15f, 0.65f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
((PhysicsProp)this).EquipItem();
}
public void SwitchFlashlight(bool on)
{
((GrabbableObject)this).isBeingUsed = on;
if (!((NetworkBehaviour)this).IsOwner)
{
Debug.Log((object)$"Flashlight click. playerheldby null?: {(Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null}");
Debug.Log((object)$"Flashlight being disabled or enabled: {on}");
Plugin.Logger.LogInfo((object)"If not owner or something?");
}
else
{
((Behaviour)flashlightBulb).enabled = on;
((Behaviour)flashlightBulbGlow).enabled = on;
}
if (changeMaterial)
{
Material[] sharedMaterials = ((Renderer)flashlightMesh).sharedMaterials;
if (on)
{
sharedMaterials[1] = bulbLight;
}
else
{
sharedMaterials[1] = bulbDark;
}
((Renderer)flashlightMesh).sharedMaterials = sharedMaterials;
}
}
public override void Update()
{
((GrabbableObject)this).Update();
int num = ((flashlightInterferenceLevel <= globalFlashlightInterferenceLevel) ? globalFlashlightInterferenceLevel : flashlightInterferenceLevel);
if (num >= 2)
{
flashlightBulb.intensity = 0f;
}
else if (num == 1)
{
flashlightBulb.intensity = Random.Range(0f, 200f);
}
else
{
flashlightBulb.intensity = initialIntensity;
}
}
}
}