Decompiled source of MapImageObjectsEditor v1.2.3

MapImageObjectsEditor.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using MapImageObjects.Core;
using MapImageObjects.Core.Components;
using MapImageObjects.Core.Properties;
using MapsExt;
using MapsExt.Editor.MapObjects;
using MapsExt.Editor.Properties;
using MapsExt.Editor.UI;
using MapsExt.Properties;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("MapImageObjectsEditor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds web image map objects to the editor!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+219b2d16f0660971686344513a60057f0b44a308")]
[assembly: AssemblyProduct("MapImageObjectsEditor")]
[assembly: AssemblyTitle("MapImageObjectsEditor")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MapImageObjectsEditor
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MapImageObjectsEditor";

		public const string PLUGIN_NAME = "MapImageObjectsEditor";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MapImageObjects.Editor
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.woukie.rounds.mapimageobjectseditor", "MapImageObjectsEditor", "1.2.3")]
	[BepInProcess("Rounds.exe")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.woukie.rounds.mapimageobjectseditor").PatchAll();
		}
	}
}
namespace MapImageObjects.Editor.Properties
{
	[EditorPropertySerializer(typeof(ColorProperty))]
	public class EditorColorPropertySerializer : ColorPropertySerializer, IPropertyReader<ColorProperty>
	{
		public ColorProperty ReadProperty(GameObject instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			SpriteRenderer componentInChildren = instance.GetComponentInChildren<SpriteRenderer>();
			Color val = Color32.op_Implicit(new Color32((byte)200, (byte)200, (byte)200, byte.MaxValue));
			if ((Object)(object)componentInChildren != (Object)null)
			{
				val = componentInChildren.color;
			}
			if ((Object)(object)componentInChildren == (Object)null && Object.op_Implicit((Object)(object)instance.GetComponentInChildren<LineRenderer>()))
			{
				val = instance.GetComponentInChildren<LineRenderer>().endColor;
			}
			ColorProperty val2 = new ColorProperty(val);
			ColorProperty.defaultColor = ColorProperty.op_Implicit(val2);
			return val2;
		}
	}
	[EditorPropertySerializer(typeof(URIProperty))]
	public class EditorURIPropertySerializer : URIPropertySerializer, IPropertyReader<URIProperty>
	{
		public virtual URIProperty ReadProperty(GameObject instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			return new URIProperty
			{
				uri = instance.GetComponent<URIComponent>().GetURI()
			};
		}
	}
}
namespace MapImageObjects.Editor.Properties.InspectorElements
{
	[InspectorElement(typeof(ColorProperty))]
	public class ColorElement : InspectorElement
	{
		private TextSliderInput _r;

		private TextSliderInput _g;

		private TextSliderInput _b;

		private TextSliderInput _a;

		public Color Value
		{
			get
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				return ColorProperty.op_Implicit(PropertyExtensions.ReadProperty<ColorProperty>(((InspectorElement)this).Context.InspectorTarget));
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				OnChange(value, (ChangeType)2);
			}
		}

		protected override GameObject GetInstance()
		{
			GameObject obj = Object.Instantiate<GameObject>(Assets.FoldoutPrefab);
			Foldout component = obj.GetComponent<Foldout>();
			component.Label.text = "Color";
			InspectorSliderInput component2 = Object.Instantiate<GameObject>(Assets.InspectorSliderInputPrefab, component.Content.transform).GetComponent<InspectorSliderInput>();
			component2.Label.text = "R";
			_r = component2.Input;
			_r.Slider.minValue = 0f;
			_r.Slider.maxValue = 255f;
			_r.Slider.wholeNumbers = true;
			TextSliderInput r = _r;
			r.OnChanged = (Action<float, ChangeType>)Delegate.Combine(r.OnChanged, new Action<float, ChangeType>(OnChange));
			component2 = Object.Instantiate<GameObject>(Assets.InspectorSliderInputPrefab, component.Content.transform).GetComponent<InspectorSliderInput>();
			component2.Label.text = "G";
			_g = component2.Input;
			_g.Slider.minValue = 0f;
			_g.Slider.maxValue = 255f;
			_g.Slider.wholeNumbers = true;
			TextSliderInput g = _g;
			g.OnChanged = (Action<float, ChangeType>)Delegate.Combine(g.OnChanged, new Action<float, ChangeType>(OnChange));
			component2 = Object.Instantiate<GameObject>(Assets.InspectorSliderInputPrefab, component.Content.transform).GetComponent<InspectorSliderInput>();
			component2.Label.text = "B";
			_b = component2.Input;
			_b.Slider.minValue = 0f;
			_b.Slider.maxValue = 255f;
			_b.Slider.wholeNumbers = true;
			TextSliderInput b = _b;
			b.OnChanged = (Action<float, ChangeType>)Delegate.Combine(b.OnChanged, new Action<float, ChangeType>(OnChange));
			component2 = Object.Instantiate<GameObject>(Assets.InspectorSliderInputPrefab, component.Content.transform).GetComponent<InspectorSliderInput>();
			component2.Label.text = "A";
			_a = component2.Input;
			_a.Slider.minValue = 0f;
			_a.Slider.maxValue = 255f;
			_a.Slider.wholeNumbers = true;
			TextSliderInput a = _a;
			a.OnChanged = (Action<float, ChangeType>)Delegate.Combine(a.OnChanged, new Action<float, ChangeType>(OnChange));
			return obj;
		}

		public override void OnUpdate()
		{
			//IL_0007: 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)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			_r.SetWithoutEvent((float)Mathf.RoundToInt(Value.r * 255f));
			_g.SetWithoutEvent((float)Mathf.RoundToInt(Value.g * 255f));
			_b.SetWithoutEvent((float)Mathf.RoundToInt(Value.b * 255f));
			_a.SetWithoutEvent((float)Mathf.RoundToInt(Value.a * 255f));
		}

		public void OnChange(Color color, ChangeType changeType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0037: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			if ((int)changeType == 1 || (int)changeType == 2)
			{
				PropertyExtensions.WriteProperty<ColorProperty>(((InspectorElement)this).Context.InspectorTarget, ColorProperty.op_Implicit(Color32.op_Implicit(color)));
			}
			if ((int)changeType == 2)
			{
				((InspectorElement)this).Context.Editor.TakeSnaphot();
			}
			ColorProperty.defaultColor = Color32.op_Implicit(color);
		}

		public void OnChange(float value, ChangeType changeType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Invalid comparison between Unknown and I4
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if ((int)changeType == 1 || (int)changeType == 2)
			{
				PropertyExtensions.WriteProperty<ColorProperty>(((InspectorElement)this).Context.InspectorTarget, ColorProperty.op_Implicit(Color32.op_Implicit(new Color(_r.Value / 255f, _g.Value / 255f, _b.Value / 255f, _a.Value / 255f))));
			}
			if ((int)changeType == 2)
			{
				((InspectorElement)this).Context.Editor.TakeSnaphot();
			}
			ColorProperty.defaultColor = Color32.op_Implicit(new Color(_r.Value / 255f, _g.Value / 255f, _b.Value / 255f, _a.Value / 255f));
		}
	}
	[InspectorElement(typeof(URIProperty))]
	public class URIElement : IInspectorElement
	{
		private InspectorContext context;

		private InputField input;

		public string Value
		{
			get
			{
				return PropertyExtensions.ReadProperty<URIProperty>(context.InspectorTarget).uri;
			}
			set
			{
				OnChanged(value);
			}
		}

		public GameObject Instantiate(InspectorContext context)
		{
			this.context = context;
			GameObject val = Object.Instantiate<GameObject>(Assets.InspectorVector2InputPrefab);
			Transform child = val.transform.GetChild(1);
			Transform child2 = child.GetChild(0);
			Transform child3 = val.transform.GetChild(0);
			Object.Destroy((Object)(object)val.GetComponent<Vector2Input>());
			Object.Destroy((Object)(object)val.GetComponent<InspectorVector2Input>());
			Object.Destroy((Object)(object)((Component)child.GetChild(1)).gameObject);
			Object.Destroy((Object)(object)((Component)child2.GetChild(0)).gameObject);
			((Component)child2.GetChild(1).GetChild(0)).GetComponent<Text>().text = "URL";
			((Component)child3).gameObject.GetComponent<Text>().text = "URL";
			input = val.GetComponentInChildren<InputField>();
			((UnityEvent<string>)(object)input.onValueChanged).AddListener((UnityAction<string>)OnChanged);
			return val;
		}

		public void OnUpdate()
		{
			input.text = Value;
		}

		private void OnChanged(string str)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			URIProperty val = new URIProperty();
			val.uri = str;
			Plugin.ImageCache.Clear();
			PropertyExtensions.WriteProperty<URIProperty>(context.InspectorTarget, val);
			context.Editor.TakeSnaphot();
		}
	}
}
namespace MapImageObjects.Editor.Objects
{
	[EditorMapObject(typeof(ImageBackgroundObjectData), "Image (Background)", Category = "Static")]
	public class EditorImageBackgroundObject : ImageBackgroundObject
	{
		public override void OnInstantiate(GameObject instance)
		{
			instance.AddComponent<BoxCollider2D>();
			((ImageBackgroundObject)this).OnInstantiate(instance);
		}
	}
	[EditorMapObject(typeof(ImageDestructibleObjectData), "Image (Destructible)", Category = "Dynamic")]
	public class EditorImageDestructibleObject : ImageDestructibleObject
	{
		public override void OnInstantiate(GameObject instance)
		{
			instance.GetComponent<Rigidbody2D>().isKinematic = true;
			((ImageDestructibleObject)this).OnInstantiate(instance);
		}
	}
	[EditorMapObject(typeof(ImageDynamicObjectData), "Image", Category = "Dynamic")]
	public class EditorImageDynamicObject : ImageDynamicObject
	{
		public override void OnInstantiate(GameObject instance)
		{
			instance.GetComponent<Rigidbody2D>().isKinematic = true;
			((ImageDynamicObject)this).OnInstantiate(instance);
		}
	}
	[EditorMapObject(typeof(ImageObjectData), "Image", Category = "Static")]
	public class EditorImageObject : ImageObject
	{
		public override void OnInstantiate(GameObject instance)
		{
			((ImageObject)this).OnInstantiate(instance);
		}
	}
}