Decompiled source of StanielCup v1.0.3

TheChaosChimaera.StanielCupMod.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
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 HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using StanielCupMod.Behaviors;
using Unity.Netcode;
using UnityEngine;

[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("TheChaosChimaera.StanielCupMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StanielCupMod")]
[assembly: AssemblyTitle("TheChaosChimaera.StanielCupMod")]
[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.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 StanielCupMod
{
	[BepInPlugin("TheChaosChimaera.StanielCupMod", "StanielCupMod", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class StanielCupMod : BaseUnityPlugin
	{
		public static AssetBundle StanielAssets;

		public static StanielCupMod 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 text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "stanielcup");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			int num = 30;
			Item val2 = val.LoadAsset<Item>("Assets/StanielCup.asset");
			HydrationBoost hydrationBoost = val2.spawnPrefab.AddComponent<HydrationBoost>();
			((GrabbableObject)hydrationBoost).grabbable = true;
			((GrabbableObject)hydrationBoost).grabbableToEnemies = true;
			((GrabbableObject)hydrationBoost).itemProperties = val2;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, num, (LevelTypes)(-1));
			Item val3 = val.LoadAsset<Item>("Assets/StanielCupLimitedEdition.asset");
			HydrationBoost hydrationBoost2 = val3.spawnPrefab.AddComponent<HydrationBoost>();
			((GrabbableObject)hydrationBoost2).grabbable = true;
			((GrabbableObject)hydrationBoost2).grabbableToEnemies = true;
			((GrabbableObject)hydrationBoost2).itemProperties = val3;
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Utilities.FixMixerGroups(val3.spawnPrefab);
			Items.RegisterScrap(val3, 3, (LevelTypes)(-1));
			UnlockablesList val4 = val.LoadAsset<UnlockablesList>("Assets/LethalCompany/Mods/TutorialMod/Prefabs/HydrationTerminal/HydrationList.asset");
			UnlockableItem val5 = val4.unlockables[0];
			NetworkPrefabs.RegisterNetworkPrefab(val5.prefabObject);
			TerminalNode shopSelectionNode = val5.shopSelectionNode;
			Unlockables.RegisterUnlockable(val5, (StoreType)2, (TerminalNode)null, (TerminalNode)null, shopSelectionNode, shopSelectionNode.itemCost);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TheChaosChimaera.StanielCupMod";

		public const string PLUGIN_NAME = "StanielCupMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace StanielCupMod.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	public class ExampleTVPatch
	{
		[HarmonyPatch("SwitchTVLocalClient")]
		[HarmonyPrefix]
		private static void SwitchTVPrefix(TVScript __instance)
		{
			StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
		}
	}
}
namespace StanielCupMod.Behaviors
{
	internal class HydrationBoost : PhysicsProp
	{
		[CompilerGenerated]
		private sealed class <undoAnimation>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public HydrationBoost <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <undoAnimation>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (((NetworkBehaviour)<>4__this).IsOwner)
					{
						((GrabbableObject)<>4__this).playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", false);
						((GrabbableObject)<>4__this).playerHeldBy.activatingItem = false;
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private bool drank = false;

		private string tip = "Drink [LMB]";

		public override void GrabItem()
		{
			HUDManager.Instance.ClearControlTips();
			HUDManager.Instance.ChangeControlTipMultiple(new string[1] { tip }, true, ((GrabbableObject)this).itemProperties);
		}

		public override void EquipItem()
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				HUDManager.Instance.ClearControlTips();
				HUDManager.Instance.ChangeControlTipMultiple(new string[1] { tip }, true, ((GrabbableObject)this).itemProperties);
			}
			((GrabbableObject)this).EnableItemMeshes(true);
			((GrabbableObject)this).isPocketed = false;
			if (!((GrabbableObject)this).hasBeenHeld)
			{
				((GrabbableObject)this).hasBeenHeld = true;
				if (!((GrabbableObject)this).isInShipRoom && !StartOfRound.Instance.inShipPhase && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
				{
					RoundManager instance = RoundManager.Instance;
					instance.valueOfFoundScrapItems += ((GrabbableObject)this).scrapValue;
				}
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown)
			{
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && !drank)
				{
					((GrabbableObject)this).playerHeldBy.sprintMeter = 100f;
					drank = true;
					tip = "The Cup is Empty";
					((Component)this).gameObject.GetComponent<AudioSource>().PlayOneShot(((GrabbableObject)this).itemProperties.throwSFX, 1f);
					HUDManager.Instance.ChangeControlTipMultiple(new string[1] { tip }, true, ((GrabbableObject)this).itemProperties);
					((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", buttonDown);
				}
				((MonoBehaviour)this).StartCoroutine(undoAnimation());
			}
		}

		[IteratorStateMachine(typeof(<undoAnimation>d__5))]
		public IEnumerator undoAnimation()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <undoAnimation>d__5(0)
			{
				<>4__this = this
			};
		}
	}
	internal class Refill
	{
	}
}