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 BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("BluePlugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Blue Plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+dcfbd6e10d7ea6b239b04979f9534d55a0a30948")]
[assembly: AssemblyProduct("BluePlugin")]
[assembly: AssemblyTitle("BluePlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class PouicPouic : GrabbableObject
{
public int shovelHitForce = 1;
public bool reelingUp;
public bool isHoldingButton;
private RaycastHit rayHit;
private Coroutine reelingUpCoroutine;
private RaycastHit[] objectsHitByShovel;
private List<RaycastHit> objectsHitByShovelList = new List<RaycastHit>();
public AudioClip reelUp;
public AudioClip swing;
public AudioClip[] hitSFX;
public AudioSource shovelAudio;
private PlayerControllerB previousPlayerHeldBy;
private int shovelMask = 11012424;
public override void ItemActivate(bool used, bool buttonDown = true)
{
if ((Object)(object)base.playerHeldBy == (Object)null)
{
return;
}
isHoldingButton = buttonDown;
if (!reelingUp && buttonDown)
{
reelingUp = true;
previousPlayerHeldBy = base.playerHeldBy;
if (reelingUpCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(reelingUpCoroutine);
}
reelingUpCoroutine = ((MonoBehaviour)this).StartCoroutine(reelUpShovel());
}
}
private IEnumerator reelUpShovel()
{
base.playerHeldBy.activatingItem = true;
base.playerHeldBy.twoHanded = true;
base.playerHeldBy.playerBodyAnimator.ResetTrigger("shovelHit");
base.playerHeldBy.playerBodyAnimator.SetBool("reelingUp", true);
shovelAudio.PlayOneShot(reelUp);
ReelUpSFXServerRpc();
yield return (object)new WaitForSeconds(0.35f);
yield return (object)new WaitUntil((Func<bool>)(() => !isHoldingButton || !base.isHeld));
SwingShovel(!base.isHeld);
yield return (object)new WaitForSeconds(0.13f);
yield return (object)new WaitForEndOfFrame();
HitShovel(!base.isHeld);
yield return (object)new WaitForSeconds(0.3f);
reelingUp = false;
reelingUpCoroutine = null;
}
[ServerRpc]
public void ReelUpSFXServerRpc()
{
ReelUpSFXClientRpc();
}
[ClientRpc]
public void ReelUpSFXClientRpc()
{
if (!((NetworkBehaviour)this).IsOwner)
{
shovelAudio.PlayOneShot(reelUp);
}
}
public override void DiscardItem()
{
if ((Object)(object)base.playerHeldBy != (Object)null)
{
base.playerHeldBy.activatingItem = false;
}
((GrabbableObject)this).DiscardItem();
}
public void SwingShovel(bool cancel = false)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
previousPlayerHeldBy.playerBodyAnimator.SetBool("reelingUp", false);
if (!cancel)
{
shovelAudio.PlayOneShot(swing);
previousPlayerHeldBy.UpdateSpecialAnimationValue(true, (short)((Component)previousPlayerHeldBy).transform.localEulerAngles.y, 0.4f, false);
}
}
public void HitShovel(bool cancel = false)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)previousPlayerHeldBy == (Object)null)
{
Debug.LogError((object)"Previousplayerheldby is null on this client when HitShovel is called.");
return;
}
previousPlayerHeldBy.activatingItem = false;
bool flag = false;
bool flag2 = false;
int num = -1;
if (!cancel)
{
previousPlayerHeldBy.twoHanded = false;
objectsHitByShovel = Physics.SphereCastAll(((Component)previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, shovelMask, (QueryTriggerInteraction)2);
objectsHitByShovelList = objectsHitByShovel.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
IHittable val2 = default(IHittable);
RaycastHit val3 = default(RaycastHit);
for (int i = 0; i < objectsHitByShovelList.Count; i++)
{
RaycastHit val = objectsHitByShovelList[i];
if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 8)
{
val = objectsHitByShovelList[i];
if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer != 11)
{
val = objectsHitByShovelList[i];
if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
{
continue;
}
val = objectsHitByShovelList[i];
if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)previousPlayerHeldBy).transform)
{
continue;
}
val = objectsHitByShovelList[i];
if (!(((RaycastHit)(ref val)).point == Vector3.zero))
{
Vector3 position = ((Component)previousPlayerHeldBy.gameplayCamera).transform.position;
val = objectsHitByShovelList[i];
if (Physics.Linecast(position, ((RaycastHit)(ref val)).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
{
continue;
}
}
flag = true;
Vector3 forward = ((Component)previousPlayerHeldBy.gameplayCamera).transform.forward;
try
{
int num2 = calculateForce();
num2 = 0;
PlayerControllerB val4 = (PlayerControllerB)(object)((val2 is PlayerControllerB) ? val2 : null);
if ((Object)(object)val4 != (Object)null)
{
Debug.Log((object)("=========== =================== Pouic Pouic at " + ((Object)val4).GetInstanceID()));
TextMeshProUGUI componentInChildren = ((Component)val4).gameObject.GetComponentInChildren<TextMeshProUGUI>();
if ((Object)(object)componentInChildren != (Object)null)
{
num2 = (((TMP_Text)componentInChildren).text.ToLower().Contains("elika") ? 20 : 0);
}
}
else if (((object)val2).ToString().ToLower().Contains("hoarderbug"))
{
num2 = 20;
}
if (num2 > 0)
{
val2.Hit(num2, forward, previousPlayerHeldBy, true, 1);
}
flag2 = true;
}
catch (Exception arg)
{
Debug.Log((object)$"Exception caught when hitting object with shovel from player #{previousPlayerHeldBy.playerClientId}: {arg}");
}
continue;
}
}
flag = true;
val = objectsHitByShovelList[i];
string tag = ((Component)((RaycastHit)(ref val)).collider).gameObject.tag;
for (int j = 0; j < StartOfRound.Instance.footstepSurfaces.Length; j++)
{
if (StartOfRound.Instance.footstepSurfaces[j].surfaceTag == tag)
{
num = j;
break;
}
}
}
}
if (flag)
{
RoundManager.PlayRandomClip(shovelAudio, hitSFX, true, 1f, 0, 1000);
Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)this).transform.position, 17f, 0.8f, 0, false, 0);
if (!flag2 && num != -1)
{
shovelAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX);
WalkieTalkie.TransmitOneShotAudio(shovelAudio, StartOfRound.Instance.footstepSurfaces[num].hitSurfaceSFX, 1f);
}
base.playerHeldBy.playerBodyAnimator.SetTrigger("shovelHit");
}
}
public int calculateForce()
{
return 10;
}
[ServerRpc]
public void HitShovelServerRpc(int hitSurfaceID)
{
HitShovelClientRpc(hitSurfaceID);
}
[ClientRpc]
public void HitShovelClientRpc(int hitSurfaceID)
{
if (!((NetworkBehaviour)this).IsOwner)
{
RoundManager.PlayRandomClip(shovelAudio, hitSFX, true, 1f, 0, 1000);
if (hitSurfaceID != -1)
{
HitSurfaceWithShovel(hitSurfaceID);
}
}
}
private void HitSurfaceWithShovel(int hitSurfaceID)
{
shovelAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX);
WalkieTalkie.TransmitOneShotAudio(shovelAudio, StartOfRound.Instance.footstepSurfaces[hitSurfaceID].hitSurfaceSFX, 1f);
}
public static PouicPouic setupScript(Item item)
{
PouicPouic pouicPouic = item.spawnPrefab.AddComponent<PouicPouic>();
Shovel component = item.spawnPrefab.GetComponent<Shovel>();
((GrabbableObject)pouicPouic).grabbable = ((GrabbableObject)component).grabbable;
((GrabbableObject)pouicPouic).itemProperties = item;
pouicPouic.reelUp = component.reelUp;
pouicPouic.swing = component.swing;
pouicPouic.shovelAudio = component.shovelAudio;
pouicPouic.hitSFX = component.hitSFX;
((GrabbableObject)pouicPouic).isInFactory = ((GrabbableObject)component).isInFactory;
((GrabbableObject)pouicPouic).grabbableToEnemies = ((GrabbableObject)component).grabbableToEnemies;
pouicPouic.shovelHitForce = component.shovelHitForce;
Object.Destroy((Object)(object)component);
return pouicPouic;
}
}
namespace BluePlugin
{
[BepInPlugin("BluePlugin", "BluePlugin", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static Plugin instance;
private const bool loadFromFile = false;
private const string AssetBundleAssemblyLogicalName = "res.mod.bundle";
private const string AssetBundlePrefabDirectory = "Assets/LethalCompany/Mods/BlueItems/";
public static Material materialCube2;
public static GameObject prefabCube;
public static GameObject prefabCube2;
public static GameObject prefabCar;
public static GameObject prefabBigCar;
private void loadItems()
{
}
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
AssetBundle val = null;
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("res.mod.bundle"))
{
val = AssetBundle.LoadFromStream(stream);
}
string[] allAssetNames = val.GetAllAssetNames();
foreach (string text in allAssetNames)
{
Item val2 = val.LoadAsset<Item>(text);
if (!((Object)(object)val2 == (Object)null))
{
_ = val2.itemName;
int itemId = val2.itemId;
SetupScripts(val2);
if (val2.isScrap)
{
ConfigEntry<int> val3 = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Spawn Rate for all items", 30, "Spawn rate for all items. The higher the value, the more spawns.");
int num = ConvertRarity(itemId, val3.Value);
NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
Items.RegisterScrap(val2, num, (LevelTypes)(-1));
}
continue;
}
break;
}
}
public static void SetupScripts(Item item)
{
if (item.itemId == 117006)
{
PouicPouic.setupScript(item);
}
}
public static int ConvertRarity(int id, int baseRarity)
{
double num = 1.0;
switch (id)
{
case 117000:
num = 1.3;
break;
case 117001:
num = 1.0;
break;
case 117002:
num = 0.6;
break;
case 117003:
num = 1.3;
break;
case 117004:
num = 0.8;
break;
case 117005:
num = 0.7;
break;
case 117006:
num = 1.0;
break;
case 117007:
num = 0.6;
break;
case 117008:
num = 0.8;
break;
}
return (int)((double)baseRarity * num);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BluePlugin";
public const string PLUGIN_NAME = "BluePlugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}