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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using VGEditor;
using VGFunctions;
[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("PrefabOnAbsolutePos")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Example Custom Trigger")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b1ecd2008cd6968df0efc94fc73af5d4b75f0e35")]
[assembly: AssemblyProduct("PrefabOnAbsolutePos")]
[assembly: AssemblyTitle("PrefabOnAbsolutePos")]
[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 PrefabOnAbsolutePos
{
[BepInPlugin("me.ytarame.AbsolutePosPrefab1", "AbsolutePosPrefab", "1.1.0")]
[BepInProcess("Project Arrhythmia.exe")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Inst;
internal static ManualLogSource Logger;
private Harmony _harmony;
private const string Guid = "me.ytarame.AbsolutePosPrefab1";
private const string Name = "AbsolutePosPrefab";
private const string Version = "1.1.0";
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
Inst = this;
Logger = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("me.ytarame.AbsolutePosPrefab1");
_harmony.PatchAll();
Logger.LogInfo((object)"Plugin me.ytarame.AbsolutePosPrefab1 is loaded!");
}
}
[HarmonyPatch(typeof(ObjectManager))]
public class ObjectManagerPatch
{
public static bool QuickSpawn;
public static bool ShouldSpawnOnSelec;
public static bool ShouldSpawnOnCamera;
public static bool ShouldFollowRot;
public static float Xoffset;
public static float Yoffset;
public static float Zoffset;
private static readonly string ErrorMessage = "Selected Object Invalid\n[remember to expand a prefab if you're selecting it]";
[HarmonyPatch("HandlePrefabOffsetKeyframes")]
[HarmonyPrefix]
private static void PostSetup(ref ObjectManager __instance, string _id)
{
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: 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_01da: Unknown result type (might be due to invalid IL or missing references)
if ((!ShouldSpawnOnSelec && !ShouldSpawnOnCamera) || !QuickSpawn)
{
return;
}
_id = DataManager.inst.gameData.beatmapObjects[ObjectManager.inst.beatmapGameObjects[_id].index].prefabInstanceID;
PrefabObject val = DataManager.inst.gameData.prefabObjects.Find((PrefabObject x) => x.ID == _id);
if (val == null)
{
QuickSpawn = false;
return;
}
if (ShouldSpawnOnCamera)
{
val.GetEvent(0).SetVal(0, EventManager.inst.CamPos.x + Xoffset);
val.GetEvent(0).SetVal(1, EventManager.inst.CamPos.y + Yoffset);
if (ShouldFollowRot)
{
val.GetEvent(2).SetVal(0, EventManager.inst.camRot + Zoffset);
}
QuickSpawn = false;
return;
}
ObjectSelection mainSelectedObject = SingletonBase<ObjectEditor>.Inst.MainSelectedObject;
if (ObjectManager.inst.beatmapGameObjects.TryGetValue(mainSelectedObject.ID, out var value))
{
if (!Object.op_Implicit((Object)(object)value.VisualObject))
{
return;
}
val.GetEvent(0).SetVal(0, value.VisualObject.position.x + Xoffset);
val.GetEvent(0).SetVal(1, value.VisualObject.position.y + Yoffset);
if (ShouldFollowRot)
{
EventKeyframe @event = val.GetEvent(2);
Quaternion rotation = value.VisualObject.rotation;
@event.SetVal(0, ((Quaternion)(ref rotation)).eulerAngles.z + Zoffset);
}
}
else if (!EditorManager.inst.liveNotifTracking.ContainsKey(ErrorMessage))
{
EditorManager.inst.DisplayNotificationLoop(ErrorMessage, 3f, (NotificationType)1);
}
QuickSpawn = false;
}
}
[HarmonyPatch(typeof(PrefabQuickSpawner))]
public class PrefabQuickSpawnerPatch
{
[HarmonyPatch("CheckForPrefabSpawn")]
[HarmonyPrefix]
private static void PostSetup()
{
if (ObjectManagerPatch.ShouldSpawnOnSelec)
{
ObjectManagerPatch.QuickSpawn = true;
}
}
}
[HarmonyPatch(typeof(EditorManager))]
public class QsEditorPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void PostSetup(ref EditorManager __instance)
{
ObjectManagerPatch.QuickSpawn = false;
ObjectManagerPatch.ShouldSpawnOnCamera = false;
ObjectManagerPatch.ShouldFollowRot = false;
ObjectManagerPatch.ShouldSpawnOnSelec = false;
ObjectManagerPatch.Xoffset = 0f;
ObjectManagerPatch.Yoffset = 0f;
ObjectManagerPatch.Zoffset = 0f;
Transform val = ((Component)__instance).transform.parent.Find("Editor GUI/sizer/EditorDialogs/QuickSpawnDialog/Scroll View/Viewport/Content/settings");
Transform val2 = ((Component)__instance).transform.parent.Find("Editor GUI/sizer/EditorDialogs/GameObjectDialog/data/left/Scroll View/Viewport/Content/parent/parent_more");
Transform val3 = ((Component)__instance).transform.parent.Find("Editor GUI/sizer/EditorDialogs/GameObjectDialog/data/right/position/position");
Transform val4 = val.Find("1/content-wrapper/content");
Transform val5 = val4.Find("keycode-label");
Transform val6 = val4.Find("keycode/active");
Transform val7 = Object.Instantiate<Transform>(val5, val);
((TMP_Text)((Component)val7).GetComponentInChildren<TextMeshProUGUI>()).text = "Spawn On Selection?";
val7.SetSiblingIndex(1);
Transform val8 = Object.Instantiate<Transform>(val6, val);
((Component)val8).GetComponent<Toggle>().isOn = false;
((UnityEvent<bool>)(object)((Component)val8).GetComponent<Toggle>().onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
{
ObjectManagerPatch.ShouldSpawnOnSelec = x;
});
((TMP_Text)((Component)val8.Find("content/text")).GetComponent<TextMeshProUGUI>()).text = "Spawn";
TooltipTrigger component = ((Component)val8).GetComponent<TooltipTrigger>();
component.keyCodeTips.Clear();
component.title = "Spawn On Selection";
component.description = "if an quick spawned prefab should spawn on the position of the current selection \nDoes not work when the Camera toggle is ON";
val8.SetSiblingIndex(2);
val8 = Object.Instantiate<Transform>(val6, val);
((Component)val8).GetComponent<Toggle>().isOn = false;
((UnityEvent<bool>)(object)((Component)val8).GetComponent<Toggle>().onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
{
ObjectManagerPatch.ShouldFollowRot = x;
});
((TMP_Text)((Component)val8.Find("content/text")).GetComponent<TextMeshProUGUI>()).text = "Rotate";
component = ((Component)val8).GetComponent<TooltipTrigger>();
component.keyCodeTips.Clear();
component.title = "Follow Rotation";
component.description = "if an quick spawned prefab should copy the rotation of the current selection \nDoes not work when the Camera toggle is ON";
val8.SetSiblingIndex(3);
val8 = Object.Instantiate<Transform>(val6, val);
((Component)val8).GetComponent<Toggle>().isOn = false;
((UnityEvent<bool>)(object)((Component)val8).GetComponent<Toggle>().onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
{
ObjectManagerPatch.ShouldSpawnOnCamera = x;
});
((TMP_Text)((Component)val8.Find("content/text")).GetComponent<TextMeshProUGUI>()).text = "Camera";
component = ((Component)val8).GetComponent<TooltipTrigger>();
component.keyCodeTips.Clear();
component.title = "Spawn on Camera";
component.description = "if an quick spawned prefab should spawn on the center of the camera";
val8.SetSiblingIndex(4);
val8 = Object.Instantiate<Transform>(val2, val);
((TMP_Text)((Component)val8.Find("pos_label")).GetComponent<TextMeshProUGUI>()).text = "Spawn Offset";
Transform obj = val8.Find("sca_label");
if (obj != null)
{
((Component)obj).gameObject.SetActive(false);
}
Transform obj2 = val8.Find("rot_label");
if (obj2 != null)
{
((Component)obj2).gameObject.SetActive(false);
}
Object.Destroy((Object)(object)((Component)val8.Find("pos_row")).gameObject);
Object.Destroy((Object)(object)((Component)val8.Find("sca_row")).gameObject);
Object.Instantiate<Transform>(val3.parent.Find("value_label"), val8).SetSiblingIndex(2);
Transform val9 = Object.Instantiate<Transform>(val3, val8);
val9.SetSiblingIndex(3);
CompLib.InitInputFieldFloat(val9.Find("x"), (Func<float>)(() => ObjectManagerPatch.Xoffset), (Action<float>)delegate(float x)
{
ObjectManagerPatch.Xoffset = x;
}, (Func<bool>)(() => true), "Revert float input field", (InputFieldStyle)1, 0.1f, 1f, "f3", (Action)null);
CompLib.InitInputFieldFloat(val9.Find("y"), (Func<float>)(() => ObjectManagerPatch.Yoffset), (Action<float>)delegate(float x)
{
ObjectManagerPatch.Yoffset = x;
}, (Func<bool>)(() => true), "Revert float input field", (InputFieldStyle)1, 0.1f, 1f, "f3", (Action)null);
Transform val10 = Object.Instantiate<Transform>(val3.parent.Find("value_label"), val8);
val10.SetSiblingIndex(4);
((Component)val10.GetChild(1)).gameObject.SetActive(false);
((TMP_Text)((Component)val10).GetComponentInChildren<TextMeshProUGUI>()).text = "Rotation";
Transform val11 = val8.Find("rot_row");
CompLib.InitInputFieldFloat(val11.GetChild(0), (Func<float>)(() => ObjectManagerPatch.Zoffset), (Action<float>)delegate(float x)
{
ObjectManagerPatch.Zoffset = x;
}, (Func<bool>)(() => true), "Revert float input field", (InputFieldStyle)1, 0.1f, 1f, "f3", (Action)null);
val8.SetSiblingIndex(5);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "PrefabOnAbsolutePos";
public const string PLUGIN_NAME = "PrefabOnAbsolutePos";
public const string PLUGIN_VERSION = "1.0.0";
}
}