using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Generics.Dynamics; using HG; using IDRSJsonLoader; using IDRSJsonLoader.Models; using ItemDisplayPlacementHelper.AnimatorEditing; using ItemDisplayPlacementHelper.Assets.ItemDisplayPlacementHelper; using ItemDisplayPlacementHelper.AxisEditing; using ItemDisplayPlacementHelper.Dialogs; using ItemDisplayPlacementHelper.Editable; using ItemDisplayPlacementHelper.Native; using ItemDisplayPlacementHelper.Native.Structs; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using RoR2; using RoR2.AddressableAssets; using RoR2.ContentManagement; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.ResourceManagement.ResourceLocations; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } public class InvariatCultureDecimalValidator : MonoBehaviour { private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown ((Component)this).GetComponent().onValidateInput = new OnValidateInput(Validate); } private char Validate(string text, int pos, char ch) { if ((pos != 0 || text.Length <= 0 || text[0] != '-') && ((ch >= '0' && ch <= '9') || (ch == '-' && pos == 0) || (ch == '.' && !text.Contains(".")))) { return ch; } return '\0'; } } namespace ItemDisplayPlacementHelper { public class AnimatorParametersController : MonoBehaviour { private CharacterModel currentModel; private Animator currentAnimator; public Transform container; private readonly List rows = new List(); [Space] public Button toggleButton; public GameObject itemPanel; public GameObject parametersPanel; [Space] public GameObject boolRowPrefab; public GameObject intRowPrefab; public GameObject floatRowPrefab; private void Awake() { ModelPicker.OnModelChanged += OnModelChanged; ModelPicker.OnModelWillChange += OnModelWillChange; } private void OnDestroy() { ModelPicker.OnModelChanged -= OnModelChanged; ModelPicker.OnModelWillChange -= OnModelWillChange; } private void OnModelWillChange() { foreach (AnimatorParameterField row in rows) { Object.Destroy((Object)(object)((Component)row).gameObject); } rows.Clear(); currentAnimator = null; } private void OnModelChanged(CharacterModel model) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected I4, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 currentModel = model; if (Object.op_Implicit((Object)(object)currentModel)) { currentAnimator = ((Component)currentModel).GetComponent(); } if (!Object.op_Implicit((Object)(object)currentAnimator)) { return; } AnimatorControllerParameter[] parameters = currentAnimator.parameters; foreach (AnimatorControllerParameter val in parameters) { GameObject val2 = null; AnimatorControllerParameterType type = val.type; switch (type - 1) { default: if ((int)type == 9) { continue; } break; case 0: val2 = Object.Instantiate(floatRowPrefab, container); break; case 2: val2 = Object.Instantiate(intRowPrefab, container); break; case 3: val2 = Object.Instantiate(boolRowPrefab, container); break; case 1: break; } AnimatorParameterField component = val2.GetComponent(); component.animator = currentAnimator; component.parameter = val; rows.Add(component); val2.SetActive(true); } } public void Toggle() { //IL_004a: 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_006b: Unknown result type (might be due to invalid IL or missing references) if (parametersPanel.activeSelf) { parametersPanel.SetActive(false); itemPanel.SetActive(true); } else { parametersPanel.SetActive(true); itemPanel.SetActive(false); } Vector3 localScale = ((Component)toggleButton).transform.localScale; localScale.y *= -1f; ((Component)toggleButton).transform.localScale = localScale; } } internal static class AssetsHelper { public static AssetBundle SceneBundle { get; private set; } public static void LoadAssetBundle() { SceneBundle = AssetBundle.LoadFromFile(GetBundlePath("kingenderbrine_idrs_editor")); } private static string GetBundlePath(string bundleName) { return Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)ItemDisplayPlacementHelperPlugin.Instance).Info.Location), bundleName); } } public class BepInExConfigController : MonoBehaviour { public SensitivityController sensitivityController; public ParentedPrefabDisplayController parentedPrefabDisplayController; private void Start() { sensitivityController.fastCoefficientInput.Value = ConfigHelper.FastCoefficient.Value; sensitivityController.slowCoefficientInput.Value = ConfigHelper.SlowCoefficient.Value; parentedPrefabDisplayController.CopyFormat = ConfigHelper.CopyFormat.Value; parentedPrefabDisplayController.customFormatInput.text = FromConfigFriendly(ConfigHelper.CustomFormat.Value); ((MonoBehaviour)this).StartCoroutine(SaveCurrentValues()); } private void OnDestroy() { ((MonoBehaviour)this).StopAllCoroutines(); } private IEnumerator SaveCurrentValues() { while (true) { yield return (object)new WaitForSeconds(10f); ConfigHelper.FastCoefficient.Value = sensitivityController.fastCoefficientInput.Value; ConfigHelper.SlowCoefficient.Value = sensitivityController.slowCoefficientInput.Value; ConfigHelper.CopyFormat.Value = parentedPrefabDisplayController.CopyFormat; ConfigHelper.CustomFormat.Value = ToConfigFriendly(parentedPrefabDisplayController.customFormatInput.text); } } private static string ToConfigFriendly(string str) { return Convert.ToBase64String(Encoding.UTF8.GetBytes(str)).Replace('=', '-'); } private static string FromConfigFriendly(string str) { return Encoding.UTF8.GetString(Convert.FromBase64String(str.Replace('-', '='))); } } public class CameraPostprocessEventHandler : MonoBehaviour { public static EventHandler onPostRender; private void OnPostRender() { onPostRender?.Invoke(this, null); } } public static class ConfigHelper { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry FastCoefficient { get; private set; } public static ConfigEntry SlowCoefficient { get; private set; } public static ConfigEntry CopyFormat { get; private set; } public static ConfigEntry CustomFormat { get; private set; } public static ConfigEntry FilePickerLastPath { get; private set; } public static ConfigEntry ExportNamespace { get; private set; } public static ConfigEntry ExportGenerateClass { get; private set; } public static ConfigEntry ExportAssetsToExport { get; private set; } public static ConfigEntry ImportImportType { get; private set; } public static ConfigEntry ExportWithSkin { get; private set; } internal static void InitConfigs(ConfigFile config) { ConfigFile = config; config.SaveOnConfigSet = false; FastCoefficient = config.Bind("EditorInputs", "FastCoefficient", 2.5f, (ConfigDescription)null); SlowCoefficient = config.Bind("EditorInputs", "SlowCoefficient", 0.1f, (ConfigDescription)null); CopyFormat = config.Bind("EditorInputs", "CopyFormat", ItemDisplayPlacementHelper.CopyFormat.Block, (ConfigDescription)null); CustomFormat = config.Bind("EditorInputs", "CustomFormat", "", (ConfigDescription)null); FilePickerLastPath = config.Bind("Cache", "FilePickerLastPath", "", (ConfigDescription)null); ExportGenerateClass = config.Bind("Cache", "ExportGenerateClass", false, (ConfigDescription)null); ExportNamespace = config.Bind("Cache", "ExportNamespace", "", (ConfigDescription)null); ExportAssetsToExport = config.Bind("Cache", "ExportAssetsToExport", AssetsToExport.All, (ConfigDescription)null); ExportWithSkin = config.Bind("Cache", "ExportWithSkin", false, (ConfigDescription)null); ImportImportType = config.Bind("Cache", "ImportImportType", ImportType.ReplaceSet, (ConfigDescription)null); config.SaveOnConfigSet = true; config.Save(); } } public class DisplayRuleGroupEditingController : MonoBehaviour { public delegate void OnDisplayRuleGroupChangedHandler(EditableDisplayRuleGroup keyAssetRuleGroup); public GameObject rowPrefab; public Transform container; public Button reapplyButton; public Button addButton; public Button deleteButton; private CharacterModel characterModel; public static OnDisplayRuleGroupChangedHandler OnDisplayRuleGroupChanged; private readonly List rows = new List(); public static DisplayRuleGroupEditingController Instance { get; private set; } public EditableDisplayRuleGroup DisplayRuleGroup { get; private set; } private void Awake() { Instance = this; ModelPicker.OnModelWillChange += OnModelWillChange; ModelPicker.OnModelChanged += OnModelChanged; } private void OnDestroy() { ModelPicker.OnModelWillChange -= OnModelWillChange; ModelPicker.OnModelChanged -= OnModelChanged; Instance = null; } private void Update() { bool flag = DisplayRuleGroup != null; ((Selectable)reapplyButton).interactable = flag; ((Selectable)addButton).interactable = flag; ((Selectable)deleteButton).interactable = flag && ParentedPrefabDisplayController.Instance.ItemDisplayRule != null; } private void OnModelWillChange() { SetDisplayRuleGroup(null); } private void OnModelChanged(CharacterModel characterModel) { this.characterModel = characterModel; } public void SetDisplayRuleGroup(EditableDisplayRuleGroup displayRuleGroup) { if (DisplayRuleGroup == displayRuleGroup) { return; } DisplayRuleGroup = displayRuleGroup; foreach (ItemDisplayRulePreviewController row in rows) { Object.Destroy((Object)(object)((Component)row).gameObject); } rows.Clear(); if (displayRuleGroup == null || !Object.op_Implicit((Object)(object)characterModel)) { OnDisplayRuleGroupChanged(displayRuleGroup); return; } List rules = displayRuleGroup.Rules; for (int i = 0; i < rules.Count; i++) { EditableItemDisplayRule rule = rules[i]; CreateRow(rule); } OnDisplayRuleGroupChanged(displayRuleGroup); } private void CreateRow(EditableItemDisplayRule rule) { GameObject obj = Object.Instantiate(rowPrefab, container); ItemDisplayRulePreviewController component = obj.GetComponent(); component.itemDisplayRule = rule; obj.SetActive(true); rows.Add(component); } public void ReapplyCurrentDisplayGroup() { DisplayRuleGroup.Disable(characterModel); DisplayRuleGroup.Enable(characterModel); } public void Add() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) EditableItemDisplayRule editableItemDisplayRule = new EditableItemDisplayRule(); editableItemDisplayRule.localScale = Vector3.one; DisplayRuleGroup.Rules.Add(editableItemDisplayRule); CreateRow(editableItemDisplayRule); editableItemDisplayRule.Enable(characterModel); } public void Delete() { EditableItemDisplayRule itemDisplayRule = ParentedPrefabDisplayController.Instance.ItemDisplayRule; ParentedPrefabDisplayController.Instance.SetItemDisplayRule(null); for (int i = 0; i < rows.Count; i++) { ItemDisplayRulePreviewController itemDisplayRulePreviewController = rows[i]; if (itemDisplayRulePreviewController.itemDisplayRule == itemDisplayRule) { itemDisplayRule.Disable(characterModel); rows.RemoveAt(i); DisplayRuleGroup.Rules.RemoveAt(i); Object.Destroy((Object)(object)((Component)itemDisplayRulePreviewController).gameObject); break; } } } } public class DisplayRuleGroupPreviewController : MonoBehaviour { [NonSerialized] [HideInInspector] public Sprite icon; [NonSerialized] [HideInInspector] public string nameText; [NonSerialized] [HideInInspector] public EditableDisplayRuleGroup displayRuleGroup; private CharacterModel characterModel; [SerializeField] private Image imageComponent; [SerializeField] private TextMeshProUGUI textComponent; [SerializeField] private Toggle toggleComponent; [SerializeField] private Button buttonComponent; [SerializeField] private ToggleGroup toggleGroupComponent; [SerializeField] private Image background; private void Awake() { characterModel = ModelPicker.Instance.CharacterModel; ModelPicker.OnModelChanged += OnModelChanged; } private void OnDestroy() { ModelPicker.OnModelChanged -= OnModelChanged; } private void OnModelChanged(CharacterModel characterModel) { this.characterModel = characterModel; } private void Start() { ((TMP_Text)textComponent).text = nameText; imageComponent.sprite = icon; toggleComponent.isOn = displayRuleGroup.Enabled; } public void EditDisplayRuleGroup() { if (DisplayRuleGroupEditingController.Instance.DisplayRuleGroup == displayRuleGroup) { DisplayRuleGroupEditingController.Instance.SetDisplayRuleGroup(null); return; } toggleComponent.isOn = true; DisplayRuleGroupEditingController.Instance.SetDisplayRuleGroup(displayRuleGroup); } public void ToggleDisplay(bool display) { if (toggleComponent.isOn != display) { toggleComponent.isOn = display; return; } if (display) { displayRuleGroup.Enable(characterModel); return; } displayRuleGroup.Disable(characterModel); if (DisplayRuleGroupEditingController.Instance.DisplayRuleGroup == displayRuleGroup) { DisplayRuleGroupEditingController.Instance.SetDisplayRuleGroup(null); } } private void Update() { ((Behaviour)background).enabled = DisplayRuleGroupEditingController.Instance.DisplayRuleGroup == displayRuleGroup; } } public class DropdownItem : MonoBehaviour, IEventSystemHandler, ICancelHandler { public TMP_Text text; public Image image; public RectTransform rectTransform; public Button button; [HideInInspector] public object Value { get; set; } public virtual void OnCancel(BaseEventData eventData) { SearchableDropdown componentInParent = ((Component)this).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { componentInParent.Hide(); } } } public class EditorConfigPanel : MonoBehaviour { private static readonly MethodInfo dynamicBonesLateUpdateMethod = typeof(DynamicBone).GetMethod("LateUpdate", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly MethodInfo timeGetUnscaledDeltaTimeMethod = typeof(Time).GetProperty("unscaledDeltaTime").GetGetMethod(); public CameraRigController cameraRigController; [Space] public Toggle fadeToggle; public Toggle timeToggle; public Toggle dynamicBonesTimeToggle; [Space] public Button editorSpaceButton; public TextMeshProUGUI editorSpaceText; [Space] public Toggle editorModeMove; public Toggle editorModeRotate; public Toggle editorModeScale; private bool skipNotification; private ILHook dynamicBonesHook; private void OnDestroy() { if (dynamicBonesHook != null) { dynamicBonesHook.Undo(); } } private void Update() { skipNotification = true; if (Object.op_Implicit((Object)(object)cameraRigController)) { fadeToggle.isOn = cameraRigController.enableFading; } timeToggle.isOn = Time.timeScale > 0f; ((Selectable)editorSpaceButton).interactable = !EditorAxisController.Instance.OverrideToLocalSpace; switch (EditorAxisController.Instance.EditSpace) { case EditSpace.Global: ((TMP_Text)editorSpaceText).text = "Global"; break; case EditSpace.Local: ((TMP_Text)editorSpaceText).text = "Local"; break; } editorModeMove.isOn = EditorAxisController.Instance.EditMode == EditMode.Move; editorModeRotate.isOn = EditorAxisController.Instance.EditMode == EditMode.Rotate; editorModeScale.isOn = EditorAxisController.Instance.EditMode == EditMode.Scale; skipNotification = false; } public void ToggleTime(bool enabled) { if (!skipNotification) { Time.timeScale = (enabled ? 1 : 0); } } public void ToggleFade(bool enabled) { if (!skipNotification && Object.op_Implicit((Object)(object)cameraRigController)) { cameraRigController.enableFading = enabled; } } public void ToggleEditModeMove(bool value) { if (!skipNotification && value) { EditorAxisController.Instance.EditMode = EditMode.Move; } } public void ToggleEditModeScale(bool value) { if (!skipNotification && value) { EditorAxisController.Instance.EditMode = EditMode.Scale; } } public void ToggleEditModeRotate(bool value) { if (!skipNotification && value) { EditorAxisController.Instance.EditMode = EditMode.Rotate; } } public void ToggleEditSpace() { switch (EditorAxisController.Instance.ActualEditSpace) { case EditSpace.Global: EditorAxisController.Instance.ActualEditSpace = EditSpace.Local; break; case EditSpace.Local: EditorAxisController.Instance.ActualEditSpace = EditSpace.Global; break; } } public void ToggleDynamicBonesTimeScale(bool enabled) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (skipNotification) { return; } if (enabled) { if (dynamicBonesHook == null) { dynamicBonesHook = new ILHook((MethodBase)dynamicBonesLateUpdateMethod, new Manipulator(DynamicBonesLateUpdateIL)); } } else if (dynamicBonesHook != null) { dynamicBonesHook.Undo(); dynamicBonesHook = null; } } private void DynamicBonesLateUpdateIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt