Decompiled source of DawnUltrasItems v1.2.2

DawnUltrasItems.dll

Decompiled 3 days ago
using System;
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.Tasks;
using BepInEx;
using BepInEx.Logging;
using DawnUltrasItems.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using YourThunderstoreTeam.patch;
using YourThunderstoreTeam.patch.Items;
using YourThunderstoreTeam.patch.enemies;
using YourThunderstoreTeam.service;
using YourThunderstoreTeam.util;

[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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("DawnUltrasItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3-alpha.0.70")]
[assembly: AssemblyProduct("DawnUltrasItems")]
[assembly: AssemblyTitle("DawnUltrasItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace YourThunderstoreTeam
{
	[BepInPlugin("DawnUltrasItems", "DawnUltrasItems", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("DawnUltrasItems");

		public TemplateService Service;

		public static AssetBundle DawnUltrasItemsAssets;

		public static Plugin Instance { get; set; }

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		public Plugin()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Instance = this;
		}

		private void Awake()
		{
			Service = new TemplateService();
			Log.LogInfo((object)"Applying patches...");
			ApplyPluginPatch();
			Log.LogInfo((object)"Patches applied");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			DawnUltrasItemsAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "dawnultrasitemsbundle"));
			if ((Object)(object)DawnUltrasItemsAssets == (Object)null)
			{
				Log.LogError((object)"Failed to load custom assets");
				return;
			}
			Log.LogInfo((object)"Adding Dawn Ultra's items...");
			AddItems();
			Log.LogInfo((object)"Dawn Ultra's items added");
		}

		private void ApplyPluginPatch()
		{
			_harmony.PatchAll(typeof(ShipLightsPatch));
			_harmony.PatchAll(typeof(PlayerControllerBPatch));
			_harmony.PatchAll(typeof(MaskedPlayerEnemyPatch));
			_harmony.PatchAll(typeof(ForestGiantPatch));
			_harmony.PatchAll(typeof(FlowermanPatch));
			_harmony.PatchAll(typeof(CaveDwellerAIPatch));
		}

		private void AddItems()
		{
			HealthpackItem.AddAsset(DawnUltrasItemsAssets);
			CheezburgerItem.AddAsset(DawnUltrasItemsAssets);
			RizzburgerItem.AddAsset(DawnUltrasItemsAssets);
			SpeedCoilItem.AddAsset(DawnUltrasItemsAssets);
			EnergySwordItem.AddAsset(DawnUltrasItemsAssets);
			PizzaItem.AddAsset(DawnUltrasItemsAssets);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DawnUltrasItems";

		public const string PLUGIN_NAME = "DawnUltrasItems";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace YourThunderstoreTeam.util
{
	public static class Utilities
	{
		public static void PrintToChat(string message)
		{
			HUDManager.Instance.AddTextToChatOnServer(message, -1);
		}
	}
}
namespace YourThunderstoreTeam.service
{
	public class TemplateService
	{
		public bool ReturnTrue()
		{
			return true;
		}

		public bool ReturnFalse()
		{
			return false;
		}
	}
}
namespace YourThunderstoreTeam.patch
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerBPatch
	{
		private static Dictionary<int, bool> InvinciblePlayerIDs { get; } = new Dictionary<int, bool>();


		private static Dictionary<int, bool> InvisiblePlayerIDs { get; } = new Dictionary<int, bool>();


		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnPlayerDamage(ref PlayerControllerB __instance)
		{
			return !IsPlayerInvincible(__instance);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnPlayerDeath(ref PlayerControllerB __instance, object[] __args)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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)
			CauseOfDeath causeOfDeath = (CauseOfDeath)__args[2];
			return !CanResistCauseOfDeath(causeOfDeath) || !IsPlayerInvincible(__instance);
		}

		private static bool CanResistCauseOfDeath(CauseOfDeath causeOfDeath)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			if ((int)causeOfDeath != 9)
			{
				if ((int)causeOfDeath == 10)
				{
					return false;
				}
				return true;
			}
			return false;
		}

		public static void TogglePlayerInvincibility(PlayerControllerB player, bool isInvincible)
		{
			if (IsPlayerInvincible(player) != isInvincible)
			{
				InvinciblePlayerIDs[((Object)player).GetInstanceID()] = isInvincible;
			}
		}

		public static bool IsPlayerInvincible(PlayerControllerB player)
		{
			return IsPlayerInvincible(((Object)player).GetInstanceID());
		}

		public static bool IsPlayerInvincible(int playerObjectId)
		{
			InvinciblePlayerIDs.TryGetValue(playerObjectId, out var value);
			if (!InvinciblePlayerIDs.ContainsKey(playerObjectId))
			{
				InvinciblePlayerIDs.Add(playerObjectId, value: false);
			}
			return value;
		}

		public static void TogglePlayerInvisiblity(PlayerControllerB player, bool isInvisible)
		{
			if (IsPlayerInvisible(player) != isInvisible)
			{
				InvisiblePlayerIDs[((Object)player).GetInstanceID()] = isInvisible;
			}
		}

		public static bool IsPlayerInvisible(PlayerControllerB player)
		{
			return IsPlayerInvisible(((Object)player).GetInstanceID());
		}

		public static bool IsPlayerInvisible(int playerObjectId)
		{
			InvisiblePlayerIDs.TryGetValue(playerObjectId, out var value);
			if (!InvisiblePlayerIDs.ContainsKey(playerObjectId))
			{
				InvisiblePlayerIDs.Add(playerObjectId, value: false);
			}
			return value;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnStart(ref PlayerControllerB __instance)
		{
			TogglePlayerInvincibility(__instance, isInvincible: false);
			TogglePlayerInvisiblity(__instance, isInvisible: true);
			return true;
		}
	}
	[HarmonyPatch(typeof(ShipLights))]
	public class ShipLightsPatch
	{
		[HarmonyPatch("ToggleShipLights")]
		[HarmonyPrefix]
		private static bool OnPowerSwitch(ref ShipLights __instance, object[] __args)
		{
			Plugin.Log.LogInfo((object)"The lights are now toggled!");
			return false;
		}
	}
}
namespace YourThunderstoreTeam.patch.Items
{
	public class CheezburgerItem : GrabbableObject
	{
		private const int RARITY = 80;

		private bool isActive = false;

		public AudioSource cheezburgerAudio;

		public AudioClip mmmCheezburgerSfx;

		public static void AddAsset(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Cheezburger");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 80, (LevelTypes)(-1));
			CheezburgerItem cheezburgerItem = val.spawnPrefab.AddComponent<CheezburgerItem>();
			((GrabbableObject)cheezburgerItem).grabbable = true;
			((GrabbableObject)cheezburgerItem).grabbableToEnemies = true;
			((GrabbableObject)cheezburgerItem).isInFactory = true;
			((GrabbableObject)cheezburgerItem).itemProperties = val;
			cheezburgerItem.cheezburgerAudio = val.spawnPrefab.GetComponent<AudioSource>();
			cheezburgerItem.mmmCheezburgerSfx = cheezburgerItem.cheezburgerAudio.clip;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && base.playerHeldBy != null && !isActive)
			{
				Vector3 positionOffset = base.itemProperties.positionOffset;
				Vector3 rotationOffset = base.itemProperties.rotationOffset;
				isActive = true;
				base.itemProperties.positionOffset = new Vector3(0.03f, -0.375f, -0.33f);
				base.itemProperties.rotationOffset = new Vector3(-90f, 9f, -90f);
				cheezburgerAudio.PlayOneShot(mmmCheezburgerSfx);
				ReturnToNormalOffsets(positionOffset, rotationOffset);
			}
		}

		private async void ReturnToNormalOffsets(Vector3 normalPos, Vector3 normalRot)
		{
			//IL_0019: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			await Task.Delay(1000);
			base.itemProperties.positionOffset = normalPos;
			base.itemProperties.rotationOffset = normalRot;
			isActive = false;
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "CheezburgerItem";
		}
	}
	public class EnergySwordItem : GrabbableObject
	{
		private const int PRICE = 220;

		private const string DESC = "A sword with a blade made of plasma used by high-ranking Covenant Elites. Allows the user to lunge from a distance towards their target to deliver a high-damage slash.\n\n";

		private const int _layerMask = 1084754248;

		private RaycastHit[] _scannedObjects;

		private List<RaycastHit> _scannedObjectsList;

		private IHittable _lungeHittable;

		private RaycastHit _lungeRayHit;

		private Vector3 _lungeOrigin;

		private bool _lunging = false;

		private GameObject _reticle;

		private GameObject _reticleTargetLocked;

		private bool _reticleEnabled = false;

		private bool _targetLocked = false;

		private bool _cooldownActive = false;

		private int _killCount = 0;

		private int _tempKillCount = 0;

		private float _lastKillTimestamp = Time.time;

		private Queue<AudioClip> _announcerQueue = new Queue<AudioClip>();

		private bool _announcing = false;

		public AudioSource AnnouncerAudioSource;

		public AudioClip DoubleKill;

		public AudioClip TripleKill;

		public AudioClip Overkill;

		public AudioClip Killtacular;

		public AudioClip Killtrocity;

		public AudioClip Killamanjaro;

		public AudioClip Killtastrophe;

		public AudioClip Killpocalypse;

		public AudioClip Killionaire;

		public AudioClip Betrayal;

		public AudioClip KillingSpree;

		public AudioClip KillingFrenzy;

		public AudioClip RunningRiot;

		public AudioClip Rampage;

		public AudioClip Untouchable;

		public AudioClip Invincible;

		public AudioClip Inconceivable;

		public AudioClip Unfrigginbelievable;

		public AudioSource AudioSource;

		public AudioClip SwordHitSfx;

		public AudioClip SwordHitEnvSfx;

		public AudioClip SwordSwingSfx;

		public static int Force => 4;

		public static int HitId => 7;

		public static float LungeMinDist => 2f;

		public static float LungeMaxDist => 12f;

		public static void AddAsset(AssetBundle assetBundle)
		{
			//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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Item val = assetBundle.LoadAsset<Item>("EnergySword");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, new TerminalNode
			{
				displayText = "A sword with a blade made of plasma used by high-ranking Covenant Elites. Allows the user to lunge from a distance towards their target to deliver a high-damage slash.\n\n",
				clearPreviousText = true
			}, 220);
			EnergySwordItem energySwordItem = val.spawnPrefab.AddComponent<EnergySwordItem>();
			((GrabbableObject)energySwordItem).grabbable = true;
			((GrabbableObject)energySwordItem).isInFactory = true;
			((GrabbableObject)energySwordItem).grabbableToEnemies = true;
			((GrabbableObject)energySwordItem).itemProperties = val;
			energySwordItem.AudioSource = val.spawnPrefab.GetComponent<AudioSource>();
			energySwordItem.AnnouncerAudioSource = ((Component)val.spawnPrefab.gameObject.transform.Find("Announcer")).gameObject.GetComponent<AudioSource>();
			energySwordItem.SwordSwingSfx = assetBundle.LoadAsset<AudioClip>("Energy_sword_melee.wav");
			energySwordItem.SwordHitSfx = assetBundle.LoadAsset<AudioClip>("Energy_sword_hit.wav");
			energySwordItem.SwordHitEnvSfx = assetBundle.LoadAsset<AudioClip>("Energy_sword_hit_env.wav");
			energySwordItem.DoubleKill = assetBundle.LoadAsset<AudioClip>("Double_Kill.mp3");
			energySwordItem.TripleKill = assetBundle.LoadAsset<AudioClip>("Triple_Kill.mp3");
			energySwordItem.Overkill = assetBundle.LoadAsset<AudioClip>("Overkill.mp3");
			energySwordItem.Killtacular = assetBundle.LoadAsset<AudioClip>("Killtacular.mp3");
			energySwordItem.Killtrocity = assetBundle.LoadAsset<AudioClip>("Killtrocity.mp3");
			energySwordItem.Killamanjaro = assetBundle.LoadAsset<AudioClip>("Killamanjaro.mp3");
			energySwordItem.Killtastrophe = assetBundle.LoadAsset<AudioClip>("Killtastrophe.mp3");
			energySwordItem.Killpocalypse = assetBundle.LoadAsset<AudioClip>("Killpocalypse.mp3");
			energySwordItem.Killionaire = assetBundle.LoadAsset<AudioClip>("Killionaire.mp3");
			energySwordItem.Betrayal = assetBundle.LoadAsset<AudioClip>("Betrayal.mp3");
			energySwordItem.KillingSpree = assetBundle.LoadAsset<AudioClip>("Killing_Spree.mp3");
			energySwordItem.KillingFrenzy = assetBundle.LoadAsset<AudioClip>("Killing_Frenzy.mp3");
			energySwordItem.RunningRiot = assetBundle.LoadAsset<AudioClip>("Running_Riot.mp3");
			energySwordItem.Rampage = assetBundle.LoadAsset<AudioClip>("Rampage.mp3");
			energySwordItem.Untouchable = assetBundle.LoadAsset<AudioClip>("Untouchable.mp3");
			energySwordItem.Invincible = assetBundle.LoadAsset<AudioClip>("Invincible.mp3");
			energySwordItem.Inconceivable = assetBundle.LoadAsset<AudioClip>("Inconceivable.mp3");
			energySwordItem.Unfrigginbelievable = assetBundle.LoadAsset<AudioClip>("Unfrigginbelievable.mp3");
		}

		public override void Update()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_009c: 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)
			((GrabbableObject)this).Update();
			PlayFirstAudioInQueue();
			float deltaTime = Time.deltaTime;
			if (base.playerHeldBy == null || base.playerHeldBy.isPlayerDead || !IsCurrentlyLocalPlayer())
			{
				return;
			}
			if (_lunging)
			{
				if (Vector3.Distance(((Component)base.playerHeldBy).transform.position, _lungeOrigin) >= ((RaycastHit)(ref _lungeRayHit)).distance - LungeMinDist)
				{
					_lunging = false;
					if (_lungeHittable.Hit(Force, ((Component)base.playerHeldBy).transform.forward, base.playerHeldBy, false, HitId))
					{
						AudioSource.PlayOneShot(SwordHitSfx);
						TryAddKill(_lungeRayHit);
					}
					SwingSword();
				}
				else
				{
					((Component)base.playerHeldBy).transform.position = Vector3.MoveTowards(((Component)base.playerHeldBy).transform.position, ((RaycastHit)(ref _lungeRayHit)).transform.position, 50f * deltaTime);
				}
			}
			else if (_reticle != null && _reticleTargetLocked != null)
			{
				(_targetLocked, _, _) = ScanForTarget();
				_reticle.SetActive(!_targetLocked && _reticleEnabled);
				_reticleTargetLocked.SetActive(_targetLocked && _reticleEnabled);
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			LoadReticle();
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			ToggleReticle(enabled: false);
		}

		public override void OnLostOwnership()
		{
			((NetworkBehaviour)this).OnLostOwnership();
			ToggleReticle(enabled: false);
			_killCount = 0;
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			ToggleReticle(enabled: false);
			_killCount = 0;
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
			Object.Destroy((Object)(object)_reticle);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!buttonDown || _cooldownActive || _lunging)
			{
				return;
			}
			(bool, IHittable?, RaycastHit?) tuple = ScanForTarget();
			bool item = tuple.Item1;
			IHittable item2 = tuple.Item2;
			RaycastHit? item3 = tuple.Item3;
			_cooldownActive = true;
			if (item && item2 != null && item3.HasValue)
			{
				_lungeHittable = item2;
				_lungeRayHit = item3.Value;
				_lungeOrigin = ((Component)base.playerHeldBy).transform.position;
				_lunging = true;
				Console.WriteLine("Lunging, dist: {0}", ((RaycastHit)(ref _lungeRayHit)).distance);
			}
			else
			{
				SwingSword();
				if (item3.HasValue)
				{
					AudioSource.PlayOneShot(SwordHitEnvSfx);
				}
			}
		}

		private (bool, IHittable?, RaycastHit?) ScanForTarget()
		{
			//IL_0011: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_00d5: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward = ((Component)base.playerHeldBy.gameplayCamera).transform.forward;
			RaycastHit? item = null;
			_scannedObjects = Physics.RaycastAll(((Component)base.playerHeldBy.gameplayCamera).transform.position, forward, LungeMaxDist, 1084754248);
			_scannedObjectsList = _scannedObjects.OrderBy((RaycastHit hit) => ((RaycastHit)(ref hit)).distance).ToList();
			IHittable item2 = default(IHittable);
			RaycastHit val = default(RaycastHit);
			EnemyAICollisionDetect val2 = default(EnemyAICollisionDetect);
			PlayerControllerB val3 = default(PlayerControllerB);
			for (int i = 0; i < _scannedObjectsList.Count; i++)
			{
				RaycastHit value = _scannedObjectsList[i];
				Collider collider = ((RaycastHit)(ref value)).collider;
				GameObject gameObject = ((Component)collider).gameObject;
				if (gameObject.TryGetComponent<IHittable>(ref item2) && (Object)(object)((RaycastHit)(ref value)).transform != (Object)(object)((Component)base.playerHeldBy).transform && !Physics.Linecast(((Component)base.playerHeldBy).transform.position, ((RaycastHit)(ref value)).point, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					bool item3 = true;
					if (((Component)((RaycastHit)(ref value)).transform).TryGetComponent<EnemyAICollisionDetect>(ref val2))
					{
						item3 = !val2.mainScript.isEnemyDead;
					}
					else if (((Component)((RaycastHit)(ref value)).transform).TryGetComponent<PlayerControllerB>(ref val3))
					{
						item3 = !val3.isPlayerDead;
					}
					return (item3, item2, value);
				}
				if ((Object)(object)((RaycastHit)(ref value)).transform != (Object)(object)((Component)base.playerHeldBy).transform && ((RaycastHit)(ref value)).distance <= LungeMinDist)
				{
					item = value;
				}
			}
			return (false, null, item);
		}

		private void ToggleReticle(bool enabled)
		{
			_reticleEnabled = IsCurrentlyLocalPlayer() && enabled;
			if (_reticle != null)
			{
				_reticle.SetActive(IsCurrentlyLocalPlayer() && enabled);
				_reticleTargetLocked.SetActive(false);
			}
		}

		private void LoadReticle()
		{
			if (_reticle == null)
			{
				GameObject gameObject = ((Component)((Component)GameObject.Find("Systems").gameObject.transform.Find("UI")).gameObject.transform.Find("Canvas")).gameObject;
				Transform val = ((Component)this).gameObject.transform.Find("Reticle");
				Transform val2 = ((Component)this).gameObject.transform.Find("ReticleTargetLocked");
				if (val != null)
				{
					_reticle = Object.Instantiate<GameObject>(((Component)val).gameObject, gameObject.transform);
					_reticleTargetLocked = Object.Instantiate<GameObject>(((Component)val2).gameObject, gameObject.transform);
					_reticle.SetActive(false);
					_reticleTargetLocked.SetActive(false);
					RectTransform component = _reticle.GetComponent<RectTransform>();
					RectTransform component2 = _reticleTargetLocked.GetComponent<RectTransform>();
					Vector2 val3 = default(Vector2);
					((Vector2)(ref val3))..ctor(30f, 30f);
					component.sizeDelta_Injected = ref val3;
					component2.sizeDelta_Injected = ref val3;
				}
			}
			ToggleReticle(enabled: true);
		}

		private async void SwingSword()
		{
			base.playerHeldBy.playerBodyAnimator.SetTrigger("UseHeldItem1");
			AudioSource.PlayOneShot(SwordSwingSfx);
			await Task.Delay(900);
			_cooldownActive = false;
		}

		private async void TryAddKill(RaycastHit rayHit)
		{
			//IL_0019: 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)
			float currentTime = Time.time;
			float timeBetweenLastKill = currentTime - _lastKillTimestamp;
			EnemyAICollisionDetect enemyAICollision = default(EnemyAICollisionDetect);
			((Component)((RaycastHit)(ref rayHit)).transform).TryGetComponent<EnemyAICollisionDetect>(ref enemyAICollision);
			PlayerControllerB player = default(PlayerControllerB);
			((Component)((RaycastHit)(ref rayHit)).transform).TryGetComponent<PlayerControllerB>(ref player);
			await Task.Delay(200);
			bool isEnemyDead = false;
			bool isAlly = false;
			if (enemyAICollision != null)
			{
				isEnemyDead = enemyAICollision.mainScript.isEnemyDead;
			}
			else if (player != null)
			{
				isEnemyDead = player.isPlayerDead;
				isAlly = true;
			}
			if (isEnemyDead)
			{
				_killCount++;
				_tempKillCount = ((!(timeBetweenLastKill <= 5f)) ? 1 : (_tempKillCount + 1));
				_lastKillTimestamp = currentTime;
				if (isAlly)
				{
					_announcerQueue.Enqueue(Betrayal);
				}
				switch (_tempKillCount)
				{
				case 2:
					_announcerQueue.Enqueue(DoubleKill);
					break;
				case 3:
					_announcerQueue.Enqueue(TripleKill);
					break;
				case 4:
					_announcerQueue.Enqueue(Overkill);
					break;
				case 5:
					_announcerQueue.Enqueue(Killtacular);
					break;
				case 6:
					_announcerQueue.Enqueue(Killtrocity);
					break;
				case 7:
					_announcerQueue.Enqueue(Killamanjaro);
					break;
				case 8:
					_announcerQueue.Enqueue(Killtastrophe);
					break;
				case 9:
					_announcerQueue.Enqueue(Killpocalypse);
					break;
				case 10:
					_announcerQueue.Enqueue(Killionaire);
					break;
				}
				switch (_killCount)
				{
				case 3:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is on a KILLING SPREE");
					_announcerQueue.Enqueue(KillingSpree);
					break;
				case 5:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is on a KILLING FRENZY");
					_announcerQueue.Enqueue(KillingFrenzy);
					break;
				case 7:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is a RUNNING RIOT");
					_announcerQueue.Enqueue(RunningRiot);
					break;
				case 9:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is on a RAMPAGE");
					_announcerQueue.Enqueue(Rampage);
					break;
				case 11:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is UNTOUCHABLE");
					_announcerQueue.Enqueue(Untouchable);
					break;
				case 13:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is INVINCIBLE");
					_announcerQueue.Enqueue(Invincible);
					break;
				case 15:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is INCONCEIVABLE");
					_announcerQueue.Enqueue(Inconceivable);
					break;
				case 17:
					AnnounceMsg($"{base.playerHeldBy.playerUsername} is UNFRIGGINBELIEVABLE");
					_announcerQueue.Enqueue(Unfrigginbelievable);
					break;
				case 4:
				case 6:
				case 8:
				case 10:
				case 12:
				case 14:
				case 16:
					break;
				}
			}
		}

		private async void PlayFirstAudioInQueue()
		{
			if (base.playerHeldBy != null && !base.playerHeldBy.isPlayerDead && base.isHeld)
			{
				if (!_announcing && _announcerQueue.Count > 0)
				{
					_announcing = true;
					AudioClip clipToAnnounce = _announcerQueue.Peek();
					AnnouncerAudioSource.PlayOneShot(clipToAnnounce);
					await Task.Delay((int)(clipToAnnounce.length * 1000f));
					_announcerQueue.Dequeue();
					_announcing = false;
				}
			}
			else if (!_announcing && _announcerQueue.Count > 0)
			{
				for (int i = 0; i < _announcerQueue.Count; i++)
				{
					_announcerQueue.Dequeue();
				}
			}
		}

		private void AnnounceMsg(string msg)
		{
			HUDManager.Instance.AddTextToChatOnServer(msg, -1);
		}

		private bool IsCurrentlyLocalPlayer()
		{
			return base.playerHeldBy != null && base.playerHeldBy.actualClientId == ((NetworkBehaviour)this).NetworkManager.LocalClientId;
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "EnergySwordItem";
		}
	}
	public class HealthpackItem : GrabbableObject
	{
		private const int HEALTHPACK_PRICE = 20;

		private const string HEALTHPACK_DESC = "A first aid kit containing the standard combat wound treatment, which is used by all UNSC combat personnel, ranging from Marines to Spartans.\n\nEach health pack contains biofoam, a stitch kit, polypseudomorphine, a sterile field generator, self-adhering antiseptic battle dressings, and other useful components.\n\nUse when you receive and injury (critical or not).\n\n";

		public AudioSource healthpackAudio;

		public AudioClip healSfx;

		public static void AddAsset(AssetBundle assetBundle)
		{
			//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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			Item val = assetBundle.LoadAsset<Item>("Healthpack");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, new TerminalNode
			{
				displayText = "A first aid kit containing the standard combat wound treatment, which is used by all UNSC combat personnel, ranging from Marines to Spartans.\n\nEach health pack contains biofoam, a stitch kit, polypseudomorphine, a sterile field generator, self-adhering antiseptic battle dressings, and other useful components.\n\nUse when you receive and injury (critical or not).\n\n",
				clearPreviousText = true
			}, 20);
			HealthpackItem healthpackItem = val.spawnPrefab.AddComponent<HealthpackItem>();
			((GrabbableObject)healthpackItem).grabbable = true;
			((GrabbableObject)healthpackItem).isInFactory = true;
			((GrabbableObject)healthpackItem).grabbableToEnemies = true;
			((GrabbableObject)healthpackItem).itemProperties = val;
			healthpackItem.healthpackAudio = val.spawnPrefab.GetComponent<AudioSource>();
			healthpackItem.healSfx = healthpackItem.healthpackAudio.clip;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && base.playerHeldBy != null && base.playerHeldBy.health < 100)
			{
				healthpackAudio.PlayOneShot(healSfx);
				base.playerHeldBy.DamagePlayer(-100, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				if (base.playerHeldBy.criticallyInjured)
				{
					base.playerHeldBy.MakeCriticallyInjured(false);
				}
				base.itemUsedUp = true;
				((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "HealthpackItem";
		}
	}
	public class PizzaItem : GrabbableObject
	{
		private const int RARITY = 80;

		private bool isActive = false;

		public AudioSource AudioSource;

		public AudioClip EatSfx;

		public static void AddAsset(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Pizza");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 80, (LevelTypes)(-1));
			PizzaItem pizzaItem = val.spawnPrefab.AddComponent<PizzaItem>();
			((GrabbableObject)pizzaItem).grabbable = true;
			((GrabbableObject)pizzaItem).grabbableToEnemies = true;
			((GrabbableObject)pizzaItem).isInFactory = true;
			((GrabbableObject)pizzaItem).itemProperties = val;
			pizzaItem.AudioSource = val.spawnPrefab.GetComponent<AudioSource>();
			pizzaItem.EatSfx = pizzaItem.AudioSource.clip;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && base.playerHeldBy != null && !isActive)
			{
				Vector3 positionOffset = base.itemProperties.positionOffset;
				Vector3 rotationOffset = base.itemProperties.rotationOffset;
				isActive = true;
				base.itemProperties.positionOffset = new Vector3(0.11f, -0.3f, -0.35f);
				base.itemProperties.rotationOffset = new Vector3(90f, 0f, -100f);
				AudioSource.PlayOneShot(EatSfx);
				ReturnToNormalOffsets(positionOffset, rotationOffset);
			}
		}

		private async void ReturnToNormalOffsets(Vector3 normalPos, Vector3 normalRot)
		{
			//IL_0019: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			await Task.Delay(1000);
			base.itemProperties.positionOffset = normalPos;
			base.itemProperties.rotationOffset = normalRot;
			isActive = false;
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "PizzaItem";
		}
	}
	public class RizzburgerItem : GrabbableObject
	{
		private const int RARITY = 30;

		private const float COOLDOWN = 10f;

		public AudioSource rizzburgerAudio;

		public AudioClip rizzSfx;

		public static void AddAsset(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Rizzburger");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 30, (LevelTypes)(-1));
			RizzburgerItem rizzburgerItem = val.spawnPrefab.AddComponent<RizzburgerItem>();
			((GrabbableObject)rizzburgerItem).grabbable = true;
			((GrabbableObject)rizzburgerItem).grabbableToEnemies = true;
			((GrabbableObject)rizzburgerItem).isInFactory = true;
			((GrabbableObject)rizzburgerItem).itemProperties = val;
			rizzburgerItem.rizzburgerAudio = val.spawnPrefab.GetComponent<AudioSource>();
			rizzburgerItem.rizzSfx = rizzburgerItem.rizzburgerAudio.clip;
			((GrabbableObject)rizzburgerItem).useCooldown = 10f;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && base.playerHeldBy != null)
			{
				rizzburgerAudio.PlayOneShot(rizzSfx);
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "RizzburgerItem";
		}
	}
	public class SpeedCoilItem : GrabbableObject
	{
		private const int RARITY = 70;

		private const float SPEED_INCREASE = 3f;

		private bool isSpeedBoostActive = false;

		public static void AddAsset(AssetBundle assetBundle)
		{
			Item val = assetBundle.LoadAsset<Item>("Speed Coil");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, 70, (LevelTypes)(-1));
			SpeedCoilItem speedCoilItem = val.spawnPrefab.AddComponent<SpeedCoilItem>();
			((GrabbableObject)speedCoilItem).grabbable = true;
			((GrabbableObject)speedCoilItem).grabbableToEnemies = true;
			((GrabbableObject)speedCoilItem).isInFactory = true;
			((GrabbableObject)speedCoilItem).itemProperties = val;
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if (base.playerHeldBy != null && !isSpeedBoostActive)
			{
				PlayerControllerB playerHeldBy = base.playerHeldBy;
				playerHeldBy.movementSpeed += 3f;
				isSpeedBoostActive = true;
			}
		}

		public override void DestroyObjectInHand(PlayerControllerB playerHolding)
		{
			DisableSpeedBoost();
			((GrabbableObject)this).DestroyObjectInHand(playerHolding);
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			DisableSpeedBoost();
		}

		public override void DiscardItem()
		{
			DisableSpeedBoost();
			((GrabbableObject)this).DiscardItem();
		}

		private void DisableSpeedBoost()
		{
			if (isSpeedBoostActive && base.playerHeldBy != null)
			{
				PlayerControllerB playerHeldBy = base.playerHeldBy;
				playerHeldBy.movementSpeed -= 3f;
				isSpeedBoostActive = false;
			}
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "SpeedCoilItem";
		}
	}
	public class NothingPersonnel : NetworkBehaviour
	{
		private const int PRICE = 0;

		private const string DESC = "Test";

		public static UnlockableItem UnlockableItem = new UnlockableItem
		{
			unlockableName = "Sword Skill: Nothing Personnel",
			shopSelectionNode = new TerminalNode
			{
				displayText = "test",
				clearPreviousText = true
			},
			alwaysInStock = true,
			IsPlaceable = false,
			unlockableType = -1
		};

		public static UnlockableItemDef ItemDef = new UnlockableItemDef
		{
			storeType = (StoreType)1,
			unlockable = UnlockableItem
		};

		public static void AddAsset(AssetBundle assetBundle)
		{
			UnlockableItem.prefabObject = assetBundle.LoadAsset<GameObject>("NothingPersonnel");
			Utilities.FixMixerGroups(UnlockableItem.prefabObject);
			NetworkPrefabs.RegisterNetworkPrefab(UnlockableItem.prefabObject);
			Unlockables.RegisterUnlockable(ItemDef, 0, (StoreType)1);
			UnlockableItem.prefabObject.AddComponent<NothingPersonnel>();
			RemoveWhenPurchased();
		}

		private static async void RemoveWhenPurchased()
		{
			while (!UnlockableItem.hasBeenUnlockedByPlayer)
			{
				await Task.Delay(100);
			}
			Console.WriteLine("Removed from shop");
			Unlockables.DisableUnlockable(ItemDef);
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "NothingPersonnel";
		}
	}
}
namespace YourThunderstoreTeam.patch.enemies
{
	[HarmonyPatch(typeof(CaveDwellerAI))]
	public class CaveDwellerAIPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnHitEnemy(ref CaveDwellerAI __instance, int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			Console.WriteLine("Hit ID: " + hitID);
			if (hitID == EnergySwordItem.HitId)
			{
				((EnemyAI)__instance).KillEnemyOnOwnerClient(false);
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	public class EnemyAIPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		public static PlayerControllerB PostGetClosestPlayer(ref EnemyAI __instance, PlayerControllerB __result, bool requireLineOfSight)
		{
			Utilities.PrintToChat($"LoS: {requireLineOfSight}, Invisible: {PlayerControllerBPatch.IsPlayerInvisible(__result)}");
			if (requireLineOfSight && PlayerControllerBPatch.IsPlayerInvisible(__result))
			{
				return null;
			}
			return __result;
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	public class FlowermanPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnKillPlayerAnimationServerRpc(ref FlowermanAI __instance)
		{
			PlayerControllerB targetPlayer = ((EnemyAI)__instance).targetPlayer;
			if (targetPlayer != null)
			{
				bool flag = PlayerControllerBPatch.IsPlayerInvincible(targetPlayer);
				return !flag;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI))]
	public class ForestGiantPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnGrabPlayerServerRpc(ref ForestGiantAI __instance)
		{
			PlayerControllerB targetPlayer = ((EnemyAI)__instance).targetPlayer;
			if (targetPlayer != null)
			{
				bool flag = PlayerControllerBPatch.IsPlayerInvincible(targetPlayer);
				return !flag;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	public class MaskedPlayerEnemyPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnKillAnimation(ref MaskedPlayerEnemy __instance)
		{
			PlayerControllerB targetPlayer = ((EnemyAI)__instance).targetPlayer;
			if (targetPlayer != null)
			{
				bool flag = PlayerControllerBPatch.IsPlayerInvincible(targetPlayer);
				return !flag;
			}
			return true;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool OnKillPlayerAnimationServerRpc(ref MaskedPlayerEnemy __instance)
		{
			PlayerControllerB targetPlayer = ((EnemyAI)__instance).targetPlayer;
			if (targetPlayer != null)
			{
				bool flag = PlayerControllerBPatch.IsPlayerInvincible(targetPlayer);
				return !flag;
			}
			Utilities.PrintToChat("Returned true");
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace DawnUltrasItems.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}