Decompiled source of CardboardMomoa v1.0.1

cardboardMomoa.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using cardboardMomoa.Behaviours;
using testMod;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("testMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("testMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("482e497d-a94a-4a11-b6e2-ee1a1d13054f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace templateMod
{
	[BepInPlugin("Alien.cardboardMomoa", "Cardboard Momoa", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CardboardMomoaBase : BaseUnityPlugin
	{
		private const string modGUID = "Alien.cardboardMomoa";

		private const string modName = "Cardboard Momoa";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Alien.cardboardMomoa");

		private static CardboardMomoaBase Instance;

		internal ManualLogSource mls;

		public static Configuration configuration { get; internal set; }

		private void Awake()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Alien.cardboardMomoa");
			mls.LogInfo((object)"hey buddy");
			configuration = new Configuration(((BaseUnityPlugin)this).Config);
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cardboardmomoaassets");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			EnemyType val2 = val.LoadAsset<EnemyType>("Assets/Unity/MOD_ASSETS/jasonmomoa/jasonMomoa.asset");
			Item val3 = val.LoadAsset<Item>("Assets/Unity/MOD_ASSETS/jasonmomoa/jasonMomoaScrap.asset");
			AudioClip yellSound = val.LoadAsset<AudioClip>("Assets/Unity/MOD_ASSETS/jasonmomoa/ussy.mp3");
			AudioClip scrapeSound = val.LoadAsset<AudioClip>("Assets/Unity/MOD_ASSETS/jasonmomoa/cadeboard.mp3");
			val2.enemyPrefab.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
			val3.spawnPrefab.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
			JasonMomoaBehaviour jasonMomoaBehaviour = val2.enemyPrefab.AddComponent<JasonMomoaBehaviour>();
			Transform val4 = val2.enemyPrefab.transform.Find("Mamoa");
			((Component)val4).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)jasonMomoaBehaviour;
			jasonMomoaBehaviour.shouldExplode = Configuration.configExplode.Value;
			val2.canDie = false;
			((EnemyAI)jasonMomoaBehaviour).AIIntervalTime = 0.02f;
			((EnemyAI)jasonMomoaBehaviour).enemyType = val2;
			jasonMomoaBehaviour.deathScrap = val3;
			val2.destroyOnDeath = false;
			((EnemyAI)jasonMomoaBehaviour).enemyHP = 3;
			((EnemyAI)jasonMomoaBehaviour).creatureVoice = null;
			((EnemyAI)jasonMomoaBehaviour).creatureSFX = null;
			jasonMomoaBehaviour.yellSound = yellSound;
			jasonMomoaBehaviour.scrapeSound = scrapeSound;
			((EnemyAI)jasonMomoaBehaviour).eye = ((Component)val4).transform.Find("Eye");
			((SpringManAI)jasonMomoaBehaviour).animStopPoints = ((Component)((Component)val4).transform.Find("AnimContainer")).GetComponent<AnimationStopPoints>();
			((Component)val4).GetComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)jasonMomoaBehaviour;
			((SpringManAI)jasonMomoaBehaviour).mainCollider = (Collider)(object)((Component)val4).GetComponent<BoxCollider>();
			NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab);
			Utilities.FixMixerGroups(val2.enemyPrefab);
			Enemies.RegisterEnemy(val2, Configuration.configSpawnWeight.Value, (LevelTypes)(-1), (TerminalNode)null, (TerminalKeyword)null);
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Utilities.FixMixerGroups(val3.spawnPrefab);
			Items.RegisterScrap(val3, 0, (LevelTypes)1);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Alien.cardboardMomoa is loaded! IRTHGRTUIGHOIERGHUEHGERHU");
		}
	}
}
namespace testMod
{
	public class Configuration
	{
		public static ConfigEntry<int> configSpawnWeight;

		public static ConfigEntry<bool> configExplode;

		public Configuration(ConfigFile config)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			configSpawnWeight = config.Bind<int>("Spawn Weight", "Cardboard Momoa Spawn Weight", 40, new ConfigDescription("The spawn weight/rarity of the Jason Momoa cardboard cutout on any moon.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			configExplode = config.Bind<bool>("Misc", "Kill Players with Explosion?", true, "Should Jason Momoa cause the player to explode when he kills them?");
		}
	}
}
namespace cardboardMomoa.Behaviours
{
	public class JasonMomoaBehaviour : SpringManAI
	{
		private bool spawnedScrap = false;

		private bool enemyDestroyed = false;

		public AudioSource audio;

		public AudioClip yellSound;

		public AudioClip scrapeSound;

		private bool isPlayingScrapeSound = false;

		public bool shouldExplode;

		private int hitsTaken = 0;

		public Item deathScrap;

		public ManualLogSource logger;

		public override void Start()
		{
			audio = ((Component)this).GetComponent<AudioSource>();
			((Component)this).GetComponent<NavMeshAgent>().speed = 1f;
			((Component)this).GetComponent<NavMeshAgent>().angularSpeed = 500f;
			((EnemyAI)this).Start();
		}

		public override void DoAIInterval()
		{
			//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)
			((SpringManAI)this).DoAIInterval();
			if ((Object)(object)((EnemyAI)this).agent != (Object)null)
			{
				Vector3 velocity = ((EnemyAI)this).agent.velocity;
				if (((Vector3)(ref velocity)).magnitude > 0.1f)
				{
					if (((EnemyAI)this).movingTowardsTargetPlayer)
					{
						audio.PlayOneShot(yellSound);
						WalkieTalkie.TransmitOneShotAudio(audio, yellSound, 1f);
					}
					if (!isPlayingScrapeSound)
					{
						audio.PlayOneShot(scrapeSound);
						WalkieTalkie.TransmitOneShotAudio(audio, scrapeSound, 1f);
						isPlayingScrapeSound = true;
					}
					return;
				}
			}
			if (isPlayingScrapeSound)
			{
				audio.Stop();
				isPlayingScrapeSound = false;
			}
		}

		private IEnumerator SpinAndInitiateDeath()
		{
			float spinDuration = 5f;
			float elapsedTime = 0f;
			float spinSpeed = 100f;
			float maxSpinSpeed = 1000f;
			((EnemyAI)this).isEnemyDead = true;
			audio.PlayOneShot(scrapeSound);
			WalkieTalkie.TransmitOneShotAudio(audio, scrapeSound, 1f);
			while (elapsedTime < spinDuration)
			{
				float currentSpinSpeed = Mathf.Lerp(spinSpeed, maxSpinSpeed, elapsedTime / spinDuration) * 2.5f;
				((Component)this).transform.Rotate(Vector3.up, currentSpinSpeed * Time.deltaTime);
				elapsedTime += Time.deltaTime;
				yield return null;
			}
			Landmine.SpawnExplosion(((Component)this).transform.position, true, 0f, 0f, 0, 0f, (GameObject)null);
			audio.Stop();
			GameObject instance = Object.Instantiate<GameObject>(deathScrap.spawnPrefab, ((Component)this).transform.position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
			instance.GetComponent<NetworkObject>().Spawn(false);
			PhysicsProp prop = instance.GetComponent<PhysicsProp>();
			int randomScrapValue = Random.Range(150, 300);
			((GrabbableObject)prop).SetScrapValue(randomScrapValue);
			enemyDestroyed = true;
			<>n__0(destroy: true);
		}

		private void initiateDeathStuff()
		{
			((MonoBehaviour)this).StartCoroutine(SpinAndInitiateDeath());
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			Debug.Log((object)("Force: " + force + ", PlayerWhoHit: " + ((object)playerWhoHit)?.ToString() + ", PlayHitSFX: " + playHitSFX + ", HitID: " + hitID));
			if (!enemyDestroyed && (hitID != -1 || Object.op_Implicit((Object)(object)playerWhoHit)))
			{
				hitsTaken++;
				if (hitsTaken >= ((EnemyAI)this).enemyHP)
				{
					initiateDeathStuff();
				}
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null)
			{
				if (shouldExplode)
				{
					val.DamagePlayer(100, true, true, (CauseOfDeath)3, 1, false, default(Vector3));
					Landmine.SpawnExplosion(((Component)this).transform.position, true, 4f, 5f, 100, 2f, (GameObject)null);
				}
				else
				{
					val.DamagePlayer(50, true, true, (CauseOfDeath)6, 1, false, default(Vector3));
				}
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
		}
	}
	public class JasonItemScrapBehaviour : PhysicsProp
	{
		public Item originalItemProperties;

		public float originalVertOffset;

		public Vector3 originalRestRot;

		public override void EquipItem()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Equipped item!");
			originalItemProperties.verticalOffset = originalVertOffset;
			originalItemProperties.restingRotation = originalRestRot;
			((PhysicsProp)this).EquipItem();
		}
	}
}