Decompiled source of Poster v1.0.1

BepInEx/plugins/Poster/Poster.dll

Decompiled 2 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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CUCoreLib.Data;
using CUCoreLib.Helpers;
using CUCoreLib.Registries;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b118c36e5c5a89a3303fed7bf91f640f5138c319")]
[assembly: AssemblyProduct("Template description")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Poster
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Poster";

		public const string PLUGIN_NAME = "Template description";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ModNamespace
{
	[BepInPlugin("org.seedoflight.poster", "Poster", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "org.seedoflight.poster";

		public const string ModName = "Poster";

		public const string ModVersion = "1.0.0";

		internal static ManualLogSource Logger;

		public static Plugin Instance { get; private set; }

		public void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			PosterManager posterManager = new PosterManager();
			Instance = this;
			posterManager.loadPosters();
			registrations.register();
		}
	}
	public class registrations
	{
		public sealed class posterScript : MonoBehaviour
		{
			private UsableObject usable;

			private SpriteRenderer spriteRenderer;

			private BoxCollider2D collider;

			private int sel = 0;

			private void Start()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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)
				((Component)this).TryGetComponent<SpriteRenderer>(ref spriteRenderer);
				((Component)this).TryGetComponent<BoxCollider2D>(ref collider);
				BoxCollider2D obj = collider;
				Rect rect = PosterManager.Posters[sel].rect;
				obj.size = ((Rect)(ref rect)).size / 128f;
				spriteRenderer.sprite = PosterManager.Posters[sel];
				usable = ((Component)this).gameObject.AddComponent<UsableObject>();
				usable.didLangString = true;
				usable.toggleString = "Cycle image";
			}

			public void OnUse()
			{
				//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_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				sel = (sel + 1) % PosterManager.Posters.Count;
				BoxCollider2D obj = collider;
				Rect rect = PosterManager.Posters[sel].rect;
				obj.size = ((Rect)(ref rect)).size / 128f;
				spriteRenderer.sprite = PosterManager.Posters[sel];
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Use <>9__0_0;

			internal void <register>b__0_0(Body body, Item item)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				Vector3 position = ((Component)body).transform.position;
				Vector3 val = body.targetLookPos - ((Component)body).transform.position;
				Vector3 val2 = position + ((Vector3)(ref val)).normalized * 5f;
				val2.z = ((Component)body).transform.position.z;
				BuildingEntityRegistry.Spawn("posterBuild", val2);
				body.attackCooldown = 0.5f;
				item.condition = 0f;
				body.armsAnimator.Play("ArmsSwing", -1, 0f);
				Sound.Play("rustle", Vector2.op_Implicit(val2), false, true, (Transform)null, 1f, 1f, false, false);
			}
		}

		public static void register()
		{
			//IL_0017: 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_0027: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Expected O, but got Unknown
			//IL_029e: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			Sprite val = AssetLoader.LoadEmbeddedSprite("poster.png", 32f, (Assembly)null);
			ItemInfo val2 = new ItemInfo
			{
				fullName = "Poster",
				description = "Displays a picture",
				category = "trash",
				weight = 0.5f,
				value = 4,
				usable = true,
				usableWithLMB = true,
				decayMinutes = 60f,
				tags = "cangetwet",
				qualities = new List<CraftingQuality>(1)
				{
					new CraftingQuality("rippable", 1f)
				},
				rec = new Recognition(3)
			};
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				Use val3 = delegate(Body body, Item item)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: Unknown result type (might be due to invalid IL or missing references)
					//IL_0039: Unknown result type (might be due to invalid IL or missing references)
					//IL_0042: Unknown result type (might be due to invalid IL or missing references)
					//IL_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_008f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0090: Unknown result type (might be due to invalid IL or missing references)
					Vector3 position = ((Component)body).transform.position;
					Vector3 val5 = body.targetLookPos - ((Component)body).transform.position;
					Vector3 val6 = position + ((Vector3)(ref val5)).normalized * 5f;
					val6.z = ((Component)body).transform.position.z;
					BuildingEntityRegistry.Spawn("posterBuild", val6);
					body.attackCooldown = 0.5f;
					item.condition = 0f;
					body.armsAnimator.Play("ArmsSwing", -1, 0f);
					Sound.Play("rustle", Vector2.op_Implicit(val6), false, true, (Transform)null, 1f, 1f, false, false);
				};
				<>c.<>9__0_0 = val3;
				obj = (object)val3;
			}
			val2.useAction = (Use)obj;
			ItemRegistry.Register("poster", val2, val, 0);
			CustomBuildingEntityDefinition val4 = new CustomBuildingEntityDefinition();
			val4.Name = "Poster";
			val4.Description = "A piece of paper that displays pictures.";
			val4.Sprite = PosterManager.Posters[0];
			val4.Health = 57f;
			val4.HitSoundReferenceId = "geotree";
			val4.RandomFlip = false;
			val4.Placement = (BuildingPlacementType)0;
			val4.SpawnMinPerChunk = 0f;
			val4.SpawnMaxPerChunk = 0.05f;
			val4.SortingOrder = -999;
			val4.SpawnLayers = BuildingEntityRegistry.LayersToMask(new int[5] { 1, 2, 3, 4, 5 });
			val4.SurfaceOffset = 5f;
			val4.Components = new Type[1] { typeof(posterScript) };
			val4.ItemsDropOnDestroy = (ItemDrop[])(object)new ItemDrop[1] { BuildingEntityRegistry.AddDrop("poster", 1f, 0.8f, 1f) };
			BuildingEntityRegistry.Register("posterBuild", val4);
			RecipeRegistry.Register(new Recipe
			{
				INT = 2,
				category = (RecipeCategory)3,
				result = new RecipeResult
				{
					id = "poster",
					amount = 1,
					isLiquid = false,
					resultCondition = 1f
				},
				items = new List<RecipeItem>(4)
				{
					new RecipeItem(1f)
					{
						specific = true,
						specificId = "canvas"
					},
					new RecipeItem(1f)
					{
						specific = true,
						specificId = "canvas"
					},
					new RecipeItem(1f)
					{
						specific = true,
						specificId = "canvas"
					},
					new RecipeItem(0.9f)
					{
						isLiquid = true,
						specificId = "biochem",
						minimumCondition = 25f
					}
				}
			});
		}
	}
	public class PosterManager
	{
		private string postersPath = Path.Combine(new string[2]
		{
			Paths.GameRootPath,
			"Posters"
		});

		public const int posterResolution = 128;

		public static List<Sprite> Posters = new List<Sprite>();

		public void loadPosters()
		{
			Posters.Clear();
			if (!Directory.Exists(postersPath))
			{
				Directory.CreateDirectory(postersPath);
			}
			string[] files = Directory.GetFiles(postersPath);
			foreach (string text in files)
			{
				Sprite item = AssetLoader.LoadSpriteFromFile(text, 128f);
				Posters.Add(item);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}