Decompiled source of XyphireLethalWonderworld v0.0.1

XyphireLethalWonderworld.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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("XyphireLethalWonderworld")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("XyphireLethalWonderworld")]
[assembly: AssemblyTitle("XyphireLethalWonderworld")]
[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 XyphireLethalWonderworld
{
	internal class DogToy : ThrowableItem
	{
		private bool isPlaying = false;

		private float timer = 0f;

		public float maxTimer = 10f;

		private bool changedMoon = false;

		private SpawnableEnemyWithRarity? enemySaved;

		private int enemiesSpawned = 0;

		public int enemiesToSpawn = 2;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((Component)((Component)this).transform).gameObject.GetComponent<Animator>().SetTrigger("Squish");
			base.ItemActivate(used, buttonDown);
			isPlaying = true;
		}

		public override void Start()
		{
			((NoisemakerProp)this).Start();
			if (!((NetworkBehaviour)this).IsServer || StartOfRound.Instance.inShipPhase)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity outsideEnemy in RoundManager.Instance.currentLevel.OutsideEnemies)
			{
				if (outsideEnemy.enemyType.enemyName == "MouthDog")
				{
					enemySaved = outsideEnemy;
					EnemyType enemyType = outsideEnemy.enemyType;
					enemyType.MaxCount += 3;
					SelectableLevel currentLevel = RoundManager.Instance.currentLevel;
					currentLevel.maxOutsideEnemyPowerCount *= 2;
					outsideEnemy.rarity *= 10;
					changedMoon = true;
					break;
				}
			}
			if (enemySaved != null)
			{
				return;
			}
			SelectableLevel[] moonsCatalogueList = Object.FindObjectOfType<Terminal>().moonsCatalogueList;
			foreach (SelectableLevel val in moonsCatalogueList)
			{
				foreach (SpawnableEnemyWithRarity outsideEnemy2 in val.OutsideEnemies)
				{
					if (outsideEnemy2.enemyType.enemyName == "MouthDog")
					{
						enemySaved = outsideEnemy2;
						break;
					}
				}
				if (enemySaved != null)
				{
					break;
				}
			}
		}

		public static NetworkObjectReference Spawn(SpawnableEnemyWithRarity enemy, Vector3 position, float yRot = 0f)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(enemy.enemyType.enemyPrefab, position, Quaternion.Euler(new Vector3(0f, yRot, 0f)));
			val.GetComponentInChildren<NetworkObject>().Spawn(true);
			RoundManager.Instance.SpawnedEnemies.Add(val.GetComponent<EnemyAI>());
			return new NetworkObjectReference(val);
		}

		public override void Update()
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (isPlaying)
			{
				timer += Time.deltaTime;
				if (timer > maxTimer || (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					isPlaying = false;
					timer = 0f;
					return;
				}
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, ((NoisemakerProp)this).noiseRange, 1f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			if (((NetworkBehaviour)this).IsServer && enemySaved != null && TimeOfDay.Instance.currentDayTime > 780f && (double)Random.Range(0f, 1f) > 0.99 && enemiesSpawned < enemiesToSpawn)
			{
				Spawn(enemySaved, RoundManager.Instance.outsideAINodes[Random.Range(0, RoundManager.Instance.outsideAINodes.Length - 1)].transform.position);
				enemiesSpawned++;
			}
			if (((NetworkBehaviour)this).IsServer && enemySaved != null && changedMoon && StartOfRound.Instance.shipIsLeaving)
			{
				EnemyType enemyType = enemySaved.enemyType;
				enemyType.MaxCount -= 3;
				SelectableLevel currentLevel = RoundManager.Instance.currentLevel;
				currentLevel.maxOutsideEnemyPowerCount /= 2;
				SpawnableEnemyWithRarity? obj = enemySaved;
				obj.rarity /= 10;
				changedMoon = false;
			}
		}

		public override void OnHitGround()
		{
			((Component)((Component)this).transform).gameObject.GetComponent<Animator>().SetTrigger("Squish");
			((GrabbableObject)this).OnHitGround();
			base.ItemActivate(used: true, buttonDown: true);
			isPlaying = true;
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (!right && ((NetworkBehaviour)this).IsOwner)
			{
				DiscardHeld();
			}
		}

		public override void PocketItem()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
			((GrabbableObject)this).PocketItem();
		}

		public override void DiscardItem()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
			((GrabbableObject)this).DiscardItem();
		}

		public override void OnNetworkDespawn()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
			}
			((NetworkBehaviour)this).OnNetworkDespawn();
		}
	}
	[BepInPlugin("Xyphire.XyphireLethalWonderworld", "Xyphire Lethal Wonderworld", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "Xyphire.XyphireLethalWonderworld";

		private const string NAME = "Xyphire Lethal Wonderworld";

		private const string VERSION = "0.1.1";

		public static Plugin instance;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "xyphirelethalwonderworld");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/MyItems/Baton/SO_Baton.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 25, (LevelTypes)(-1));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Xyphire Lethal Wonderworld loaded.");
		}
	}
	public class ThrowableItem : NoisemakerProp
	{
		public AnimationCurve itemFallCurve;

		public AnimationCurve itemVerticalFallCurve;

		public AnimationCurve itemVerticalFallCurveNoBounce;

		public RaycastHit itemHit;

		public Ray itemThrowRay;

		public float throwForce = 2f;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((NoisemakerProp)this).ItemActivate(used, buttonDown);
		}

		public void DiscardHeld()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner)
			{
				GameNetworkManager.Instance.localPlayerController.DiscardHeldObject(true, (NetworkObject)null, GetItemThrowDestination(((GrabbableObject)this).playerHeldBy, throwForce), true);
			}
		}

		public override void FallWithCurve()
		{
			ItemFall((GrabbableObject)(object)this, itemFallCurve, itemVerticalFallCurve, itemVerticalFallCurveNoBounce);
		}

		public static void ItemFall(GrabbableObject item, AnimationCurve? itemFallCurve = null, AnimationCurve? itemVerticalFallCurve = null, AnimationCurve? itemVerticalFallCurveNoBounce = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			AnimationCurve val = (AnimationCurve)(((object)itemFallCurve) ?? ((object)new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.5f, 0.75f),
				new Keyframe(1f, 1f)
			})));
			AnimationCurve val2 = (AnimationCurve)(((object)itemVerticalFallCurve) ?? ((object)new AnimationCurve((Keyframe[])(object)new Keyframe[6]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.5f, 1f),
				new Keyframe(0.6f, 0.9f),
				new Keyframe(0.75f, 1f),
				new Keyframe(0.85f, 0.95f),
				new Keyframe(1f, 1f)
			})));
			AnimationCurve val3 = (AnimationCurve)(((object)itemVerticalFallCurveNoBounce) ?? ((object)new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.5f, 1f),
				new Keyframe(1f, 1f)
			})));
			Vector3 val4 = item.startFallingPosition - item.targetFloorPosition;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			((Component)item).transform.rotation = Quaternion.Lerp(((Component)item).transform.rotation, Quaternion.Euler(item.itemProperties.restingRotation.x, ((Component)item).transform.eulerAngles.y, item.itemProperties.restingRotation.z), 14f * Time.deltaTime / magnitude);
			((Component)item).transform.localPosition = Vector3.Lerp(item.startFallingPosition, item.targetFloorPosition, val.Evaluate(item.fallTime));
			if (magnitude > 5f)
			{
				((Component)item).transform.localPosition = Vector3.Lerp(new Vector3(((Component)item).transform.localPosition.x, item.startFallingPosition.y, ((Component)item).transform.localPosition.z), new Vector3(((Component)item).transform.localPosition.x, item.targetFloorPosition.y, ((Component)item).transform.localPosition.z), val3.Evaluate(item.fallTime));
			}
			else
			{
				((Component)item).transform.localPosition = Vector3.Lerp(new Vector3(((Component)item).transform.localPosition.x, item.startFallingPosition.y, ((Component)item).transform.localPosition.z), new Vector3(((Component)item).transform.localPosition.x, item.targetFloorPosition.y, ((Component)item).transform.localPosition.z), val2.Evaluate(item.fallTime));
			}
			item.fallTime += Mathf.Abs(Time.deltaTime * 12f / magnitude);
		}

		public static Vector3 GetItemThrowDestination(PlayerControllerB player, float throwForce = 1f)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			Debug.DrawRay(((Component)player.gameplayCamera).transform.position, ((Component)player.gameplayCamera).transform.forward, Color.yellow, 15f);
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)player.gameplayCamera).transform.position, ((Component)player.gameplayCamera).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			Vector3 val3 = ((!Physics.Raycast(val, ref val2, 12f * throwForce, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) ? ((Ray)(ref val)).GetPoint(10f * throwForce) : ((Ray)(ref val)).GetPoint(((RaycastHit)(ref val2)).distance - 0.05f));
			Debug.DrawRay(val3, Vector3.down, Color.blue, 15f);
			((Ray)(ref val))..ctor(val3, Vector3.down);
			if (Physics.Raycast(val, ref val2, 30f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref val2)).point + Vector3.up * 0.05f;
			}
			return ((Ray)(ref val)).GetPoint(30f);
		}
	}
}