Decompiled source of FatassTeto v2.5.0

LethalTeto.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
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("LethalTeto")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalTeto")]
[assembly: AssemblyTitle("LethalTeto")]
[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 TetoMod
{
	[BepInPlugin("com.kagan.tetomod", "Fatass Teto", "2.5.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private static readonly Dictionary<LevelTypes, int> SpawnRarityPerLevel = new Dictionary<LevelTypes, int>
		{
			{
				(LevelTypes)4,
				50
			},
			{
				(LevelTypes)8,
				50
			},
			{
				(LevelTypes)16,
				50
			},
			{
				(LevelTypes)32,
				50
			},
			{
				(LevelTypes)64,
				50
			},
			{
				(LevelTypes)2048,
				50
			},
			{
				(LevelTypes)128,
				50
			},
			{
				(LevelTypes)512,
				60
			},
			{
				(LevelTypes)4096,
				60
			},
			{
				(LevelTypes)8192,
				60
			},
			{
				(LevelTypes)1024,
				50
			}
		};

		public void Awake()
		{
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "teto.bundle");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load asset bundle!");
				return;
			}
			GameObject val2 = val.LoadAsset<GameObject>("assets/mods/teto/teto.prefab");
			if ((Object)(object)val2 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load teto prefab!");
				return;
			}
			SetupLayers(val2);
			Item item = CreateItemProperties(val, val2);
			SetupScanNode(val2);
			SetupNoisemakerProp(val, val2, item);
			RegisterNetworkPrefab(val2, item);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Fatass Teto v2.5.0 loaded successfully!");
		}

		private void SetupLayers(GameObject prefab)
		{
			prefab.layer = LayerMask.NameToLayer("Props");
			Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>();
			foreach (Transform val in componentsInChildren)
			{
				((Component)val).gameObject.layer = prefab.layer;
			}
		}

		private Item CreateItemProperties(AssetBundle bundle, GameObject prefab)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			Item val = ScriptableObject.CreateInstance<Item>();
			((Object)val).name = "FatassTetoItem";
			val.itemName = "Fatass Teto";
			val.spawnPrefab = prefab;
			val.isScrap = true;
			val.syncUseFunction = true;
			val.minValue = 100;
			val.maxValue = 300;
			val.weight = 1.35f;
			val.grabAnim = "HoldLunchbox";
			val.itemIcon = bundle.LoadAsset<Sprite>("assets/mods/teto/teto_icon.png");
			val.requiresBattery = false;
			val.grabSFX = bundle.LoadAsset<AudioClip>("assets/mods/teto/tetograb.wav");
			val.dropSFX = bundle.LoadAsset<AudioClip>("assets/mods/teto/tetodrop.wav");
			val.rotationOffset = new Vector3(0f, -270f, 180f);
			val.positionOffset = new Vector3(0f, 0f, 0f);
			val.restingRotation = new Vector3(-90f, 0f, 0f);
			val.verticalOffset = 0.3f;
			return val;
		}

		private void SetupScanNode(GameObject prefab)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in prefab.transform)
			{
				Transform val = item;
				if (((Object)val).name == "ScanNode")
				{
					Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
				}
			}
			GameObject val2 = new GameObject("ScanNode");
			val2.transform.SetParent(prefab.transform, false);
			val2.transform.localPosition = Vector3.zero;
			int num = LayerMask.NameToLayer("ScanNode");
			val2.layer = ((num != -1) ? num : 22);
			BoxCollider val3 = val2.AddComponent<BoxCollider>();
			((Collider)val3).isTrigger = true;
			val3.size = new Vector3(0.5f, 0.5f, 0.5f);
			val3.center = Vector3.zero;
			ScanNodeProperties val4 = val2.AddComponent<ScanNodeProperties>();
			val4.headerText = "Fatass Teto";
			val4.subText = "Value";
			val4.nodeType = 2;
			val4.maxRange = 13;
			val4.minRange = 1;
			val4.requiresLineOfSight = true;
			val4.creatureScanID = -1;
		}

		private void SetupNoisemakerProp(AssetBundle bundle, GameObject prefab, Item item)
		{
			NoisemakerProp val = prefab.GetComponent<NoisemakerProp>();
			if ((Object)(object)val == (Object)null)
			{
				val = prefab.AddComponent<NoisemakerProp>();
			}
			((GrabbableObject)val).itemProperties = item;
			((GrabbableObject)val).grabbable = true;
			((GrabbableObject)val).useCooldown = 0.5f;
			((GrabbableObject)val).mainObjectRenderer = prefab.GetComponentInChildren<MeshRenderer>();
			if ((Object)(object)((GrabbableObject)val).mainObjectRenderer == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"DİKKAT: Teto prefab'ında MeshRenderer bulunamadı! Bu eşya senkronizasyonunu bozabilir.");
			}
			List<Collider> list = new List<Collider>();
			Collider[] componentsInChildren = prefab.GetComponentsInChildren<Collider>();
			foreach (Collider val2 in componentsInChildren)
			{
				if (!val2.isTrigger && ((Object)((Component)val2).gameObject).name != "ScanNode")
				{
					list.Add(val2);
				}
			}
			((GrabbableObject)val).propColliders = list.ToArray();
			AudioSource val3 = prefab.GetComponent<AudioSource>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = prefab.AddComponent<AudioSource>();
			}
			val3.playOnAwake = false;
			val3.spatialBlend = 1f;
			val3.volume = 1f;
			val3.maxDistance = 30f;
			val.noiseAudio = val3;
			val.noiseRange = 15f;
			val.maxLoudness = 1f;
			val.minLoudness = 0.8f;
			val.minPitch = 0.9f;
			val.maxPitch = 1.1f;
			AudioClip val4 = bundle.LoadAsset<AudioClip>("assets/mods/teto/tetograb.wav");
			if ((Object)(object)val4 != (Object)null)
			{
				val.noiseSFX = (AudioClip[])(object)new AudioClip[1] { val4 };
				val.noiseSFXFar = (AudioClip[])(object)new AudioClip[1] { val4 };
			}
		}

		private void RegisterNetworkPrefab(GameObject prefab, Item item)
		{
			if ((Object)(object)prefab.GetComponent<NetworkObject>() == (Object)null)
			{
				prefab.AddComponent<NetworkObject>();
			}
			NetworkPrefabs.RegisterNetworkPrefab(prefab);
			Items.RegisterScrap(item, SpawnRarityPerLevel, (Dictionary<string, int>)null);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.kagan.tetomod";

		public const string PLUGIN_NAME = "Fatass Teto";

		public const string PLUGIN_VERSION = "2.5.0";
	}
}