using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DebugMod; using DebugMod.SaveStates; using HarmonyLib; using HutongGames.PlayMaker; using InControl; using Microsoft.CodeAnalysis; using Silksong.FsmUtil; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FsmMaster")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.7.0")] [assembly: AssemblyInformationalVersion("0.2.7+db1c73b7555f357914b93cf3353e622ac4772f86")] [assembly: AssemblyProduct("FsmMaster")] [assembly: AssemblyTitle("FsmMaster")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ConstructiveCynicism/FsmMaster")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace FsmMaster { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency("org.silksong-modding.modlist", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("io.github.constructivecynicism.fsmmaster", "FsmMaster", "0.2.7")] public class FsmMasterPlugin : BaseUnityPlugin { private FsmEditManager? _editManager; private DebugModCompat? _debugModCompat; private FsmVariableTracker? _variableTracker; private FsmTabManager? _tabManager; private FsmGraphOverlay? _graphOverlay; private UICommon? _uiCommon; private GameObject? _canvasGameObject; private bool _ownsEventSystem; private FsmRightPanel? _rightPanel; private FsmMonitorPanel? _monitorPanel; private FsmPanelLayoutConfig? _rightPanelLayout; private FsmPanelLayoutConfig? _monitorPanelLayout; private ConfigEntry? _autoLoadConfig; private ConfigFile? _uiStateConfig; private readonly List _rightPanelSubtreeBuffer = new List(); private readonly List _monitorPanelSubtreeBuffer = new List(); private int _rightPanelSubtreeVersion = -1; private int _monitorPanelSubtreeVersion = -1; private static Harmony? _harmony; public const string Id = "io.github.constructivecynicism.fsmmaster"; internal static FsmEditManager? ActiveEditManagerForPatches { get; private set; } internal static bool ForceCursorVisible { get; private set; } internal FsmVariableTracker? VariableTracker => _variableTracker; public static string Name => "FsmMaster"; public static string Version => "0.2.7"; private void Awake() { //IL_0053: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.constructivecynicism.fsmmaster) has loaded!")); _harmony = Harmony.CreateAndPatchAll(typeof(FsmMasterPlugin).Assembly, (string)null); ConfigEntry val = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "Toggle Overlay", new KeyboardShortcut((KeyCode)284, Array.Empty()), "Shows or hides the FSM graph overlay and its right-side panel."); ConfigEntry toggleMinimalViewHotkey = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "Toggle Minimal View", KeyboardShortcut.Empty, "While the overlay is visible, switches between the full selection UI and a minimal graph-only view. Unbound by default."); FsmGraphColorConfig colors = FsmGraphColorConfig.Bind(((BaseUnityPlugin)this).Config); FsmGraphPerformanceConfig performance = FsmGraphPerformanceConfig.Bind(((BaseUnityPlugin)this).Config); _autoLoadConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Auto Load Last Configuration", true, "When enabled, each FSM's most recently saved/loaded named configuration is automatically reapplied whenever a scene containing that FSM loads. Toggled in-game by the panel's Auto button."); Directory.CreateDirectory(FsmSaveDataStore.DataDirectory); _uiStateConfig = new ConfigFile(Path.Combine(FsmSaveDataStore.DataDirectory, "io.github.constructivecynicism.fsmmaster.UIState.cfg"), false); _rightPanelLayout = FsmPanelLayoutConfig.Bind(_uiStateConfig, "FsmMaster Panel"); _monitorPanelLayout = FsmPanelLayoutConfig.Bind(_uiStateConfig, "Monitor Panel"); ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Browsable = false }; ConfigEntry val2 = _uiStateConfig.Bind("General", "First Run Complete", false, new ConfigDescription("Set automatically once the mod has shown its first-run hotkey hint. Not meant to be hand-edited.", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); bool flag = !val2.Value; _editManager = new FsmEditManager(((BaseUnityPlugin)this).Logger); ActiveEditManagerForPatches = _editManager; _debugModCompat = DebugModCompat.TryCreate(_editManager, RescanLiveFsmsForDebugModLoad, ((BaseUnityPlugin)this).Logger); _variableTracker = new FsmVariableTracker((string fsmKey) => _editManager.GetLiveInstances(fsmKey)); _tabManager = new FsmTabManager(); _graphOverlay = new FsmGraphOverlay(((BaseUnityPlugin)this).Logger, _editManager, _tabManager, val, toggleMinimalViewHotkey, colors, performance, flag); Scene activeScene = SceneManager.GetActiveScene(); string sceneName = ((Scene)(ref activeScene)).name ?? string.Empty; PlayMakerFSM[] components = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); Dictionary> groupsByFsmKey = ApplyPersistedEditsForScene(sceneName, components); _graphOverlay.RefreshSnapshot(sceneName, components); _tabManager.RebindAfterRefresh(groupsByFsmKey); BuildRightPanel(); if (flag) { _rightPanel.ShowStatus($"{val.Value} to toggle UI", _uiCommon.AccentColor, 12f); val2.Value = true; } SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; _debugModCompat?.Unhook(); _debugModCompat = null; _editManager?.RevertAllForUnload(); _editManager = null; ActiveEditManagerForPatches = null; _variableTracker = null; _tabManager = null; _graphOverlay?.Shutdown(); _graphOverlay = null; ForceCursorVisible = false; DestroyRightPanel(); Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; _uiStateConfig = null; } private void Update() { _editManager?.PollPendingActivations(); _graphOverlay?.Update(); ForceCursorVisible = _graphOverlay?.IsVisible ?? false; if (_rightPanel != null) { _rightPanel.ActiveSelf = _graphOverlay != null && _graphOverlay.IsVisible && _graphOverlay.SelectionUiVisible; FsmTabState fsmTabState = _tabManager?.GetActive(); FsmInfo fsm = ((fsmTabState == null || !fsmTabState.IsLive) ? null : _graphOverlay?.ResolveFsmInfo(fsmTabState.FsmKey)); _rightPanel.ActiveStatePanel.Refresh(fsm, fsmTabState?.SelectedStateName, fsmTabState?.FsmKey); int? num = fsmTabState?.PendingScrollActionIndex; if (num.HasValue) { int valueOrDefault = num.GetValueOrDefault(); _rightPanel.ActiveStatePanel.ScrollToAction(valueOrDefault); fsmTabState.PendingScrollActionIndex = null; } _rightPanel.ActiveStatePanel.RefreshLiveValues(); if (_rightPanelSubtreeVersion != CanvasPanel.StructureVersion) { _rightPanelSubtreeBuffer.Clear(); _rightPanel.CollectSubtree(_rightPanelSubtreeBuffer); _rightPanelSubtreeVersion = CanvasPanel.StructureVersion; } foreach (CanvasNode item in _rightPanelSubtreeBuffer) { if (item.ActiveInHierarchy) { item.Update(); } } } if (_monitorPanel == null) { return; } _monitorPanel.ActiveSelf = _graphOverlay != null && _graphOverlay.IsVisible; _monitorPanel.Locked = _graphOverlay != null && !_graphOverlay.SelectionUiVisible; _monitorPanel.RefreshRows(_variableTracker); if (_monitorPanelSubtreeVersion != CanvasPanel.StructureVersion) { _monitorPanelSubtreeBuffer.Clear(); _monitorPanel.CollectSubtree(_monitorPanelSubtreeBuffer); _monitorPanelSubtreeVersion = CanvasPanel.StructureVersion; } foreach (CanvasNode item2 in _monitorPanelSubtreeBuffer) { if (item2.ActiveInHierarchy) { item2.Update(); } } } private void OnGUI() { //IL_0022: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00bb: 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) Rect? rightPanelScreenRect = null; FsmRightPanel rightPanel = _rightPanel; if (rightPanel != null && rightPanel.ActiveInHierarchy) { rightPanelScreenRect = new Rect(_rightPanel.Position.x, _rightPanel.Position.y, _rightPanel.Size.x, _rightPanel.Size.y); } Rect? monitorPanelScreenRect = null; FsmMonitorPanel monitorPanel = _monitorPanel; if (monitorPanel != null && monitorPanel.ActiveInHierarchy) { monitorPanelScreenRect = new Rect(_monitorPanel.Position.x, _monitorPanel.Position.y, _monitorPanel.Size.x, _monitorPanel.Size.y); } Rect? openDropdownScreenRect = _rightPanel?.OpenDropdownScreenRect; _graphOverlay?.OnGUI(_tabManager?.GetActive(), rightPanelScreenRect, monitorPanelScreenRect, openDropdownScreenRect); } private void BuildRightPanel() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Object.FindFirstObjectByType() == (Object)null) { GameObject val = new GameObject("FsmMasterEventSystem"); val.AddComponent(); val.AddComponent(); _ownsEventSystem = true; } _canvasGameObject = new GameObject("FsmMasterCanvas"); _canvasGameObject.transform.SetParent(((Component)this).transform, false); _canvasGameObject.AddComponent().renderMode = (RenderMode)0; _canvasGameObject.AddComponent(); _uiCommon = new UICommon(); _rightPanel = new FsmRightPanel(_uiCommon, _tabManager, _editManager, _variableTracker, () => _graphOverlay?.CurrentSnapshot, () => _graphOverlay?.GraphVisible ?? true, delegate(bool visible) { if (_graphOverlay != null) { _graphOverlay.GraphVisible = visible; } }, ((BaseUnityPlugin)this).Logger, _rightPanelLayout, _autoLoadConfig); _rightPanel.Build(_canvasGameObject.transform); _monitorPanel = new FsmMonitorPanel(_uiCommon, _variableTracker, _monitorPanelLayout); _monitorPanel.Build(_canvasGameObject.transform); } private void DestroyRightPanel() { _rightPanel?.Destroy(); _rightPanel = null; _monitorPanel?.Destroy(); _monitorPanel = null; if ((Object)(object)_canvasGameObject != (Object)null) { Object.Destroy((Object)(object)_canvasGameObject); _canvasGameObject = null; } if (_ownsEventSystem) { EventSystem val = Object.FindFirstObjectByType(); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } _ownsEventSystem = false; } _uiCommon?.Destroy(); _uiCommon = null; } internal void RescanLiveFsmsForDebugModLoad() { //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) Scene activeScene = SceneManager.GetActiveScene(); string sceneName = ((Scene)(ref activeScene)).name ?? string.Empty; PlayMakerFSM[] components = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); Dictionary> groupsByFsmKey = ApplyPersistedEditsForScene(sceneName, components); _graphOverlay?.RefreshSnapshot(sceneName, components); _tabManager?.RebindAfterRefresh(groupsByFsmKey); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) PlayMakerFSM[] components = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); Dictionary> groupsByFsmKey = ApplyPersistedEditsForScene(((Scene)(ref scene)).name, components); FsmGraphOverlay? graphOverlay = _graphOverlay; if (graphOverlay != null) { Scene activeScene = SceneManager.GetActiveScene(); graphOverlay.RefreshSnapshot(((Scene)(ref activeScene)).name ?? string.Empty, components); } _tabManager?.RebindAfterRefresh(groupsByFsmKey); } private Dictionary> ApplyPersistedEditsForScene(string sceneName, PlayMakerFSM[] components) { if (_editManager == null || _tabManager == null) { return new Dictionary>(); } Dictionary> dictionary = FsmIdentity.DiscoverFsmGroups(components); _editManager.ReplaceLiveInstances(dictionary.ToDictionary((KeyValuePair> g) => g.Key, (KeyValuePair> g) => g.Value.Select((PlayMakerFSM c) => c.Fsm).ToList())); ConfigEntry autoLoadConfig = _autoLoadConfig; if (autoLoadConfig == null || !autoLoadConfig.Value) { return dictionary; } IEnumerable fsmKeysPresent = _tabManager.Tabs.Select((FsmTabState tab) => tab.FsmKey).Where(dictionary.ContainsKey); foreach (FsmEditSet item in FsmSaveDataStore.LoadLastChosenForScene(sceneName, fsmKeysPresent)) { _editManager.ApplyEditSet(item); } return dictionary; } public void ResetFsm(string sceneName, string fsmKey) { _editManager?.ResetFsm(fsmKey); FsmSaveDataStore.ClearAllSavesForFsm(sceneName, fsmKey); } } [HarmonyPatch(typeof(Fsm), "Preprocess", new Type[] { })] internal static class FsmActivatedPatch { [HarmonyPostfix] private static void Postfix(Fsm __instance) { FsmEditManager activeEditManagerForPatches = FsmMasterPlugin.ActiveEditManagerForPatches; if (activeEditManagerForPatches == null) { return; } PlayMakerFSM fsmComponent = __instance.FsmComponent; if (!((Object)(object)fsmComponent == (Object)null)) { string fsmKey = FsmIdentity.GetFsmKey(fsmComponent); activeEditManagerForPatches.ReconcileLiveInstance(fsmKey, __instance); FsmEditSet activeEditSet = activeEditManagerForPatches.GetActiveEditSet(fsmKey); if (activeEditSet != null) { activeEditManagerForPatches.ApplyEditSet(activeEditSet); } } } } [HarmonyPatch(typeof(InputHandler), "SetCursorVisible")] internal static class ForceCursorVisiblePatch { [HarmonyPrefix] private static void Prefix(ref bool value) { if (FsmMasterPlugin.ForceCursorVisible) { value = true; } } } internal sealed class ConfigurationManagerAttributes { public bool? Browsable; public bool? IsAdvanced; } internal sealed class DebugModCompat { private const string ActiveEditsCustomDataKey = "FsmMaster.ActiveEdits"; private readonly FsmEditManager _editManager; private readonly Action _rescanLiveFsms; private readonly ManualLogSource _logger; private DebugModCompat(FsmEditManager editManager, Action rescanLiveFsms, ManualLogSource logger) { _editManager = editManager; _rescanLiveFsms = rescanLiveFsms; _logger = logger; } public static DebugModCompat? TryCreate(FsmEditManager editManager, Action rescanLiveFsms, ManualLogSource logger) { if (!Chainloader.PluginInfos.ContainsKey("io.github.hk-speedrunning.debugmod")) { return null; } DebugModCompat debugModCompat = new DebugModCompat(editManager, rescanLiveFsms, logger); debugModCompat.Hook(); return debugModCompat; } private void Hook() { SaveState.OnSave += HandleSave; SaveState.AfterLoad += HandleAfterLoad; DebugMod.Log("FsmMaster detected DebugMod - hooking savestate save/load to persist active FSM edits."); } public void Unhook() { SaveState.OnSave -= HandleSave; SaveState.AfterLoad -= HandleAfterLoad; } private void HandleSave(SaveState state) { try { List list = new List(); foreach (string editedFsmKey in _editManager.GetEditedFsmKeys()) { FsmEditSet activeEditSet = _editManager.GetActiveEditSet(editedFsmKey); if (activeEditSet != null) { list.Add(activeEditSet); } } if (list.Count != 0) { state.data.customData["FsmMaster.ActiveEdits"] = FsmSaveDataStore.SerializeEditSets(list); DebugMod.Log($"FsmMaster saved {list.Count} active FSM edit set(s) into this savestate."); } } catch (Exception ex) { _logger.LogWarning((object)("[FsmMaster] Failed to save FSM edits into DebugMod savestate: " + ex.Message)); } } private void HandleAfterLoad(SaveState state) { try { _rescanLiveFsms(); if (!state.data.customData.TryGetValue("FsmMaster.ActiveEdits", out var value) || string.IsNullOrEmpty(value)) { return; } List list = FsmSaveDataStore.DeserializeEditSets(value); foreach (FsmEditSet item in list) { _editManager.ApplyEditSet(item); } DebugMod.Log($"FsmMaster restored {list.Count} FSM edit set(s) from this savestate."); } catch (Exception ex) { _logger.LogWarning((object)("[FsmMaster] Failed to restore FSM edits from DebugMod savestate: " + ex.Message)); } } } internal sealed class FsmActiveStateTracker { private sealed class TrackedFsm { public Fsm Instance; public Action Handler; public readonly HashSet EnteredSinceCommit = new HashSet(); public readonly Dictionary FadingStates = new Dictionary(); } private const float FadeDurationSeconds = 1f; private readonly Dictionary _tracked = new Dictionary(); private readonly HashSet _visibleThisFrame = new HashSet(); public void EnsureTracked(string fsmKey, Fsm instance) { _visibleThisFrame.Add(fsmKey); if (_tracked.TryGetValue(fsmKey, out TrackedFsm value)) { if (value.Instance == instance) { return; } Fsm instance2 = value.Instance; instance2.StateChanged = (Action)Delegate.Remove(instance2.StateChanged, value.Handler); _tracked.Remove(fsmKey); } TrackedFsm entry = new TrackedFsm { Instance = instance }; entry.Handler = delegate(FsmState state) { entry.EnteredSinceCommit.Add(state.Name); }; instance.StateChanged = (Action)Delegate.Combine(instance.StateChanged, entry.Handler); _tracked[fsmKey] = entry; } public void CommitFrame() { List list = null; foreach (KeyValuePair item in _tracked) { string key = item.Key; TrackedFsm value = item.Value; if ((Object)(object)value.Instance.FsmComponent == (Object)null || !_visibleThisFrame.Contains(key)) { Fsm instance = value.Instance; instance.StateChanged = (Action)Delegate.Remove(instance.StateChanged, value.Handler); (list ?? (list = new List())).Add(key); continue; } string activeStateName = value.Instance.ActiveStateName; foreach (string item2 in value.EnteredSinceCommit) { if (item2 == activeStateName) { value.FadingStates.Remove(item2); } else { value.FadingStates[item2] = Time.unscaledTime; } } value.EnteredSinceCommit.Clear(); if (value.FadingStates.Count <= 0) { continue; } List list2 = null; foreach (KeyValuePair fadingState in value.FadingStates) { if (Time.unscaledTime - fadingState.Value >= 1f) { (list2 ?? (list2 = new List())).Add(fadingState.Key); } } if (list2 == null) { continue; } foreach (string item3 in list2) { value.FadingStates.Remove(item3); } } if (list != null) { foreach (string item4 in list) { _tracked.Remove(item4); } } _visibleThisFrame.Clear(); } public float? GetFadeProgress(string fsmKey, string stateName) { if (!_tracked.TryGetValue(fsmKey, out TrackedFsm value) || !value.FadingStates.TryGetValue(stateName, out var value2)) { return null; } return Mathf.Clamp01((Time.unscaledTime - value2) / 1f); } public bool HasAnyFading(string fsmKey) { if (_tracked.TryGetValue(fsmKey, out TrackedFsm value)) { return value.FadingStates.Count > 0; } return false; } public void UnsubscribeAll() { foreach (TrackedFsm value in _tracked.Values) { Fsm instance = value.Instance; instance.StateChanged = (Action)Delegate.Remove(instance.StateChanged, value.Handler); } _tracked.Clear(); _visibleThisFrame.Clear(); } } internal sealed class FsmConsoleLogger { private readonly ManualLogSource _logger; public FsmConsoleLogger(ManualLogSource logger) { _logger = logger; } public void LogSnapshot(FsmSnapshot snapshot) { _logger.LogInfo((object)$"[FsmMaster] Scene \"{snapshot.SceneName}\": {snapshot.Fsms.Count} live PlayMakerFSM instance(s)"); foreach (FsmIdentityInfo fsm in snapshot.Fsms) { if (!((Object)(object)fsm.Component == (Object)null)) { LogFsm(FsmDataCollector.CollectFsmInfo(fsm.Component)); } } } public void LogFsm(FsmInfo fsm) { _logger.LogInfo((object)("[FsmMaster] FSM \"" + fsm.FsmName + "\" on \"" + fsm.GameObjectName + "\" - state \"" + fsm.ActiveStateName + "\"")); LogFsmDetails(fsm); } private void LogFsmDetails(FsmInfo fsm) { //IL_0063: 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) _logger.LogInfo((object)$"[FsmMaster] {fsm.States.Count} state(s)"); foreach (FsmStateInfo state in fsm.States) { _logger.LogInfo((object)("[FsmMaster] State \"" + state.Name + "\"")); Rect position = state.State.Position; _logger.LogInfo((object)FormattableString.Invariant($"[FsmMaster] Position=({((Rect)(ref position)).x:F1}, {((Rect)(ref position)).y:F1}, {((Rect)(ref position)).width:F1}, {((Rect)(ref position)).height:F1}) ColorIndex={state.State.ColorIndex}")); LogActions(state.Actions); foreach (FsmTransitionInfo transition in state.Transitions) { _logger.LogInfo((object)("[FsmMaster] \"" + transition.EventName + "\" -> \"" + transition.ToState + "\"")); } } if (fsm.GlobalTransitions.Count > 0) { _logger.LogInfo((object)$"[FsmMaster] {fsm.GlobalTransitions.Count} global transition(s)"); foreach (FsmTransitionInfo globalTransition in fsm.GlobalTransitions) { _logger.LogInfo((object)("[FsmMaster] \"" + globalTransition.EventName + "\" -> \"" + globalTransition.ToState + "\"")); } } LogFsmVariables(fsm.Fsm.Variables); } private void LogActions(IReadOnlyList actions) { _logger.LogInfo((object)$"[FsmMaster] {actions.Count} action(s)"); for (int i = 0; i < actions.Count; i++) { FsmActionInfo fsmActionInfo = actions[i]; _logger.LogInfo((object)$"[FsmMaster] [{i}] {fsmActionInfo.ActionType.Name}"); foreach (FsmActionFieldInfo field in fsmActionInfo.Fields) { LogActionField(fsmActionInfo.Action, field.FieldName, field.FieldValue); } } } private void LogActionField(FsmStateAction action, string fieldName, object? fieldValue) { FsmArray val = (FsmArray)((fieldValue is FsmArray) ? fieldValue : null); if (val == null) { Array array = fieldValue as Array; if (array != null) { LogActionFieldArray(action, fieldName, array.Length, (int i) => array.GetValue(i)); } else { _logger.LogInfo((object)("[FsmMaster] " + fieldName + ": " + FormatActionFieldValue(action, fieldValue))); } } else { LogActionFieldArray(action, WithVariableName(fieldName, ((NamedVariable)val).Name), val.Length, (int i) => val.Values[i]); } } private static string WithVariableName(string fieldName, string variableName) { if (string.IsNullOrEmpty(variableName)) { return fieldName; } return fieldName + " (\"" + variableName + "\")"; } private void LogActionFieldArray(FsmStateAction action, string fieldName, int length, Func getElement) { _logger.LogInfo((object)$"[FsmMaster] {fieldName}: {length} element(s)"); for (int i = 0; i < length; i++) { object fieldValue = getElement(i); _logger.LogInfo((object)$"[FsmMaster] [{i}]: {FormatActionFieldValue(action, fieldValue)}"); } } internal static string FormatActionFieldValue(FsmStateAction action, object? fieldValue) { if (fieldValue != null) { NamedVariable val = (NamedVariable)((fieldValue is NamedVariable) ? fieldValue : null); if (val == null) { FsmEvent val2 = (FsmEvent)((fieldValue is FsmEvent) ? fieldValue : null); if (val2 == null) { FsmOwnerDefault val3 = (FsmOwnerDefault)((fieldValue is FsmOwnerDefault) ? fieldValue : null); if (val3 == null) { FsmEventTarget val4 = (FsmEventTarget)((fieldValue is FsmEventTarget) ? fieldValue : null); if (val4 != null) { return FormatEventTarget(action.Fsm, val4); } return fieldValue.ToString(); } return FormatOwnerDefault(action.Fsm, val3); } return val2.Name; } string text = val.RawValue?.ToString() ?? "null"; if (string.IsNullOrEmpty(val.Name)) { return text; } return "\"" + val.Name + "\": " + text; } return "null"; } internal static string FormatOwnerDefault(Fsm? fsm, FsmOwnerDefault ownerDefault) { if (fsm == null) { return "[uninitialized]"; } GameObject ownerDefaultTarget = fsm.GetOwnerDefaultTarget(ownerDefault); if (!((Object)(object)ownerDefaultTarget != (Object)null)) { return "[none]"; } return "[" + ((Object)ownerDefaultTarget).name + "]"; } internal static string FormatEventTarget(Fsm? fsm, FsmEventTarget eventTarget) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) EventTarget target = eventTarget.target; switch ((int)target) { case 0: return "EventTarget(Self)"; case 1: return "EventTarget(GameObject): " + FormatOwnerDefault(fsm, eventTarget.gameObject); case 2: { string text2 = eventTarget.fsmName.Value ?? ""; return "EventTarget(GameObjectFSM): " + FormatOwnerDefault(fsm, eventTarget.gameObject) + "." + text2; } case 3: { PlayMakerFSM fsmComponent = eventTarget.fsmComponent; string text = (((Object)(object)fsmComponent != (Object)null) ? (((Object)((Component)fsmComponent).gameObject).name + "." + fsmComponent.FsmName) : "none"); return "EventTarget(FSMComponent): [" + text + "]"; } default: return $"EventTarget({eventTarget.target})"; } } private void LogFsmVariables(FsmVariables variables) { _logger.LogInfo((object)"[FsmMaster] Variables"); LogVariableArray("Float", variables.FloatVariables, (Func)((FsmFloat v) => v.Value)); LogVariableArray("Int", variables.IntVariables, (Func)((FsmInt v) => v.Value)); LogVariableArray("Bool", variables.BoolVariables, (Func)((FsmBool v) => v.Value)); LogVariableArray("String", variables.StringVariables, (Func)((FsmString v) => v.Value)); LogVariableArray("Vector2", variables.Vector2Variables, (Func)((FsmVector2 v) => v.Value)); LogVariableArray("Vector3", variables.Vector3Variables, (Func)((FsmVector3 v) => v.Value)); LogVariableArray("Rect", variables.RectVariables, (Func)((FsmRect v) => v.Value)); LogVariableArray("Quaternion", variables.QuaternionVariables, (Func)((FsmQuaternion v) => v.Value)); LogVariableArray("Color", variables.ColorVariables, (Func)((FsmColor v) => v.Value)); LogVariableArray("GameObject", variables.GameObjectVariables, (Func)((FsmGameObject v) => v.Value)); LogVariableArray("Object", variables.ObjectVariables, (Func)((FsmObject v) => v.Value)); LogVariableArray("Material", variables.MaterialVariables, (Func)((FsmMaterial v) => v.Value)); LogVariableArray("Texture", variables.TextureVariables, (Func)((FsmTexture v) => v.Value)); LogVariableArray("Enum", variables.EnumVariables, (Func)((FsmEnum v) => v.Value)); LogVariableArray("Array", variables.ArrayVariables, (Func)((FsmArray v) => string.Join(", ", v.Values))); } private void LogVariableArray(string typeName, T[] items, Func getValue) where T : NamedVariable { if (items.Length != 0) { foreach (T val in items) { _logger.LogInfo((object)$"[FsmMaster] {typeName} \"{((NamedVariable)val).Name}\": {getValue(val)}"); } } } } internal sealed class FsmSnapshot { public string SceneName { get; set; } = ""; public IReadOnlyList Fsms { get; set; } = Array.Empty(); } internal sealed class FsmIdentityInfo { public PlayMakerFSM Component { get; set; } public string FsmName { get; set; } = ""; public string GameObjectName { get; set; } = ""; } internal sealed class FsmInfo { public PlayMakerFSM Component { get; set; } public Fsm Fsm { get; set; } public string FsmName { get; set; } = ""; public string GameObjectName { get; set; } = ""; public string ActiveStateName { get; set; } = ""; public IReadOnlyList States { get; set; } = Array.Empty(); public IReadOnlyList GlobalTransitions { get; set; } = Array.Empty(); } internal sealed class FsmStateInfo { public FsmState State { get; set; } public string Name { get; set; } = ""; public IReadOnlyList Actions { get; set; } = Array.Empty(); public IReadOnlyList Transitions { get; set; } = Array.Empty(); } internal sealed class FsmActionInfo { public FsmStateAction Action { get; set; } public Type ActionType { get; set; } public IReadOnlyList Fields { get; set; } = Array.Empty(); } internal sealed class FsmActionFieldInfo { public string FieldName { get; set; } = ""; public object? FieldValue { get; set; } public FieldInfo Field { get; set; } public bool IsHidden { get; set; } } internal sealed class FsmTransitionInfo { public string EventName { get; set; } = ""; public string ToState { get; set; } = ""; } internal static class FsmDataCollector { private static readonly Dictionary RelevantFieldsByActionType = new Dictionary(); public static FsmSnapshot CollectSnapshot(string sceneName, PlayMakerFSM[] components) { List list = new List(components.Length); foreach (PlayMakerFSM val in components) { list.Add(new FsmIdentityInfo { Component = val, FsmName = val.FsmName, GameObjectName = ((Object)((Component)val).gameObject).name }); } return new FsmSnapshot { SceneName = sceneName, Fsms = list }; } public static FsmInfo CollectFsmInfo(PlayMakerFSM component) { Fsm fsm = component.Fsm; List list = new List(fsm.States.Length); FsmState[] states = fsm.States; foreach (FsmState state in states) { list.Add(CollectStateInfo(state)); } return new FsmInfo { Component = component, Fsm = fsm, FsmName = component.FsmName, GameObjectName = ((Object)((Component)component).gameObject).name, ActiveStateName = component.ActiveStateName, States = list, GlobalTransitions = CollectTransitions(fsm.GlobalTransitions) }; } private static FsmStateInfo CollectStateInfo(FsmState state) { return new FsmStateInfo { State = state, Name = state.Name, Actions = CollectActions(state.Actions), Transitions = CollectTransitions(state.Transitions) }; } private static FieldInfo[] GetRelevantFields(Type actionType) { if (RelevantFieldsByActionType.TryGetValue(actionType, out FieldInfo[] value)) { return value; } List list = new List(); FieldInfo[] fields = actionType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.DeclaringType == typeof(FsmStateAction)) && !fieldInfo.IsDefined(typeof(CompilerGeneratedAttribute), inherit: false)) { list.Add(fieldInfo); } } FieldInfo[] array = list.ToArray(); RelevantFieldsByActionType[actionType] = array; return array; } private static IReadOnlyList CollectActions(FsmStateAction[] actions) { List list = new List(actions.Length); foreach (FsmStateAction val in actions) { Type type = ((object)val).GetType(); FieldInfo[] relevantFields = GetRelevantFields(type); List list2 = new List(relevantFields.Length); FieldInfo[] array = relevantFields; foreach (FieldInfo fieldInfo in array) { list2.Add(new FsmActionFieldInfo { FieldName = fieldInfo.Name, FieldValue = fieldInfo.GetValue(val), Field = fieldInfo, IsHidden = !fieldInfo.IsPublic }); } list.Add(new FsmActionInfo { Action = val, ActionType = type, Fields = list2 }); } return list; } private static IReadOnlyList CollectTransitions(FsmTransition[] transitions) { List list = new List(transitions.Length); foreach (FsmTransition val in transitions) { list.Add(new FsmTransitionInfo { EventName = val.EventName, ToState = val.ToState }); } return list; } } internal static class FsmIdentity { private static readonly Regex DuplicateSuffixPattern = new Regex("^(?.+) \\(\\d+\\)$", RegexOptions.Compiled); public static string GetObjectBaseName(string gameObjectName) { Match match = DuplicateSuffixPattern.Match(gameObjectName); if (!match.Success) { return gameObjectName; } return match.Groups["base"].Value; } public static string GetFsmKey(string baseObjectName, string fsmName) { return baseObjectName + "::" + fsmName; } public static string GetFsmKey(PlayMakerFSM component) { return GetFsmKey(GetObjectBaseName(((Object)((Component)component).gameObject).name), component.FsmName); } public static Dictionary> DiscoverFsmGroups(IEnumerable components) { Dictionary> dictionary = new Dictionary>(); foreach (PlayMakerFSM component in components) { string fsmKey = GetFsmKey(component); if (!dictionary.TryGetValue(fsmKey, out var value)) { value = (dictionary[fsmKey] = new List()); } value.Add(component); } return dictionary; } } internal sealed class FsmPristineSnapshot { public FsmEditSet OriginalValues { get; } = new FsmEditSet(); public Dictionary> NeuteredActionIndices { get; } = new Dictionary>(); public List InjectedExitActions { get; } = new List(); public List<(FsmStateAction Original, FsmStateAction Sequencer)> InstalledSequencers { get; } = new List<(FsmStateAction, FsmStateAction)>(); } internal static class FsmSaveDataStore { [Serializable] private sealed class FsmEditSetListWire { public List EditSets = new List(); } [Serializable] private sealed class FsmEditSetWire { public string FsmKey = ""; public List VariableOverrides = new List(); public List ActionFieldOverrides = new List(); public List DisabledStates = new List(); public List TransitionRetargets = new List(); public List SequencerOverrides = new List(); } internal static readonly string DataDirectory = Path.Combine(Application.persistentDataPath, "FsmMasterData"); private static readonly Dictionary> LastChosenByScene = new Dictionary>(); private const string PairSeparator = "; "; private const string KeyValueSeparator = "="; private const string PatternSeparator = ", "; private static string SanitizeForFileName(string value) { if (string.IsNullOrEmpty(value)) { return string.Empty; } char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { value = value.Replace(oldChar, '_'); } return value; } private static string GetSceneDirectory(string sceneName) { return Path.Combine(DataDirectory, SanitizeForFileName(sceneName)); } private static string GetFsmDirectory(string sceneName, string fsmKey) { return Path.Combine(GetSceneDirectory(sceneName), SanitizeForFileName(fsmKey)); } public static string GetFilePath(string sceneName, string fsmKey, string saveName) { return Path.Combine(GetFsmDirectory(sceneName, fsmKey), SanitizeForFileName(saveName) + ".json"); } public static FsmEditSet? Load(string sceneName, string fsmKey, string saveName) { string filePath = GetFilePath(sceneName, fsmKey, saveName); if (!File.Exists(filePath)) { return null; } return FromWire(JsonUtility.FromJson(File.ReadAllText(filePath))); } public static List ListSaveNames(string sceneName, string fsmKey) { List list = new List(); string fsmDirectory = GetFsmDirectory(sceneName, fsmKey); if (!Directory.Exists(fsmDirectory)) { return list; } foreach (string item in Directory.EnumerateFiles(fsmDirectory, "*.json")) { list.Add(Path.GetFileNameWithoutExtension(item)); } list.Sort(StringComparer.OrdinalIgnoreCase); return list; } public static string Save(string sceneName, string saveName, FsmEditSet edits) { string fsmDirectory = GetFsmDirectory(sceneName, edits.FsmKey); if (!Directory.Exists(fsmDirectory)) { Directory.CreateDirectory(fsmDirectory); } string text = JsonUtility.ToJson((object)ToWire(edits), true); File.WriteAllText(GetFilePath(sceneName, edits.FsmKey, saveName), text); return text; } public static void ClearAllSavesForFsm(string sceneName, string fsmKey) { string fsmDirectory = GetFsmDirectory(sceneName, fsmKey); if (Directory.Exists(fsmDirectory)) { Directory.Delete(fsmDirectory, recursive: true); } if (LastChosenByScene.TryGetValue(sceneName, out Dictionary value)) { value.Remove(fsmKey); } } public static List LoadLastChosenForScene(string sceneName, IEnumerable fsmKeysPresent) { List list = new List(); List list2 = ((fsmKeysPresent is List list3) ? list3 : fsmKeysPresent.ToList()); if (list2.Count == 0 || !LastChosenByScene.TryGetValue(sceneName, out Dictionary value)) { return list; } foreach (string item in list2) { if (value.TryGetValue(item, out var value2)) { FsmEditSet fsmEditSet = Load(sceneName, item, value2); if (fsmEditSet != null) { list.Add(fsmEditSet); } } } return list; } public static string? GetLastChosenSaveName(string sceneName, string fsmKey) { if (!LastChosenByScene.TryGetValue(sceneName, out Dictionary value) || !value.TryGetValue(fsmKey, out var value2)) { return null; } return value2; } public static void SetLastChosenSaveName(string sceneName, string fsmKey, string saveName) { if (!LastChosenByScene.TryGetValue(sceneName, out Dictionary value)) { value = new Dictionary(); LastChosenByScene[sceneName] = value; } value[fsmKey] = saveName; } public static string SerializeEditSets(IEnumerable editSets) { FsmEditSetListWire fsmEditSetListWire = new FsmEditSetListWire(); foreach (FsmEditSet editSet in editSets) { fsmEditSetListWire.EditSets.Add(JsonUtility.ToJson((object)ToWire(editSet))); } return JsonUtility.ToJson((object)fsmEditSetListWire); } public static List DeserializeEditSets(string json) { List list = new List(); FsmEditSetListWire fsmEditSetListWire = JsonUtility.FromJson(json); if (fsmEditSetListWire == null) { return list; } foreach (string editSet in fsmEditSetListWire.EditSets) { list.Add(FromWire(JsonUtility.FromJson(editSet))); } return list; } private static string JoinPairs(params string[] keysAndValues) { List list = new List(keysAndValues.Length / 2); for (int i = 0; i + 1 < keysAndValues.Length; i += 2) { list.Add(keysAndValues[i] + "=" + keysAndValues[i + 1]); } return string.Join("; ", list); } private static Dictionary SplitPairs(string joined) { Dictionary dictionary = new Dictionary(); string[] array = joined.Split("; "); foreach (string text in array) { int num = text.IndexOf("=", StringComparison.Ordinal); if (num >= 0) { dictionary[text.Substring(0, num)] = text.Substring(num + 1); } } return dictionary; } private static FsmEditSetWire ToWire(FsmEditSet edits) { FsmEditSetWire fsmEditSetWire = new FsmEditSetWire { FsmKey = edits.FsmKey }; foreach (VariableOverride variableOverride in edits.VariableOverrides) { fsmEditSetWire.VariableOverrides.Add(JoinPairs("type", variableOverride.VariableType, "name", variableOverride.Name, "array", variableOverride.ArrayIndex.ToString(CultureInfo.InvariantCulture), "value", variableOverride.StringValue)); } foreach (ActionFieldOverride actionFieldOverride in edits.ActionFieldOverrides) { fsmEditSetWire.ActionFieldOverrides.Add(JoinPairs("state", actionFieldOverride.StateName, "action", actionFieldOverride.ActionIndex.ToString(CultureInfo.InvariantCulture), "type", actionFieldOverride.ExpectedActionTypeName, "field", actionFieldOverride.FieldName, "array", actionFieldOverride.ArrayIndex.ToString(CultureInfo.InvariantCulture), "value", actionFieldOverride.StringValue)); } fsmEditSetWire.DisabledStates.AddRange(edits.DisabledStates); foreach (TransitionRetarget transitionRetarget in edits.TransitionRetargets) { fsmEditSetWire.TransitionRetargets.Add(JoinPairs("state", transitionRetarget.StateName, "event", transitionRetarget.EventName, "newState", transitionRetarget.NewStateName, "newTo", transitionRetarget.NewToState, "newEvent", transitionRetarget.NewEventName)); } foreach (SequencerOverride sequencerOverride in edits.SequencerOverrides) { fsmEditSetWire.SequencerOverrides.Add(JoinPairs("state", sequencerOverride.StateName, "action", sequencerOverride.ActionIndex.ToString(CultureInfo.InvariantCulture), "repeat", sequencerOverride.RepeatCount.ToString(CultureInfo.InvariantCulture), "pattern", string.Join(", ", sequencerOverride.Pattern))); } return fsmEditSetWire; } private static FsmEditSet FromWire(FsmEditSetWire? wire) { FsmEditSet fsmEditSet = new FsmEditSet(); if (wire == null) { return fsmEditSet; } fsmEditSet.FsmKey = wire.FsmKey; foreach (string variableOverride in wire.VariableOverrides) { Dictionary dictionary = SplitPairs(variableOverride); fsmEditSet.VariableOverrides.Add(new VariableOverride { VariableType = dictionary["type"], Name = dictionary["name"], ArrayIndex = (dictionary.TryGetValue("array", out var value) ? int.Parse(value, CultureInfo.InvariantCulture) : (-1)), StringValue = dictionary["value"] }); } foreach (string actionFieldOverride in wire.ActionFieldOverrides) { Dictionary dictionary2 = SplitPairs(actionFieldOverride); fsmEditSet.ActionFieldOverrides.Add(new ActionFieldOverride { StateName = dictionary2["state"], ActionIndex = int.Parse(dictionary2["action"], CultureInfo.InvariantCulture), ExpectedActionTypeName = dictionary2["type"], FieldName = dictionary2["field"], ArrayIndex = (dictionary2.TryGetValue("array", out var value2) ? int.Parse(value2, CultureInfo.InvariantCulture) : (-1)), StringValue = dictionary2["value"] }); } fsmEditSet.DisabledStates.AddRange(wire.DisabledStates); foreach (string transitionRetarget in wire.TransitionRetargets) { Dictionary dictionary3 = SplitPairs(transitionRetarget); fsmEditSet.TransitionRetargets.Add(new TransitionRetarget { StateName = dictionary3["state"], EventName = dictionary3["event"], NewStateName = dictionary3["newState"], NewToState = dictionary3["newTo"], NewEventName = (dictionary3.TryGetValue("newEvent", out var value3) ? value3 : "") }); } foreach (string sequencerOverride2 in wire.SequencerOverrides) { Dictionary dictionary4 = SplitPairs(sequencerOverride2); SequencerOverride sequencerOverride = new SequencerOverride { StateName = dictionary4["state"], ActionIndex = int.Parse(dictionary4["action"], CultureInfo.InvariantCulture), RepeatCount = int.Parse(dictionary4["repeat"], CultureInfo.InvariantCulture) }; if (dictionary4.TryGetValue("pattern", out var value4) && value4.Length > 0) { sequencerOverride.Pattern.AddRange(value4.Split(", ")); } fsmEditSet.SequencerOverrides.Add(sequencerOverride); } return fsmEditSet; } } internal sealed class FsmVariableTracker { private readonly Func> _getLiveInstances; private readonly List _tracked = new List(); private readonly List _resultBuffer = new List(); public int Version { get; private set; } public FsmVariableTracker(Func> getLiveInstances) { _getLiveInstances = getLiveInstances; } public void TrackVariable(string fsmKey, string variableName) { AddIfAbsent(new TrackedVariablePath(fsmKey, variableName, null, -1, null)); } public void TrackActionField(string fsmKey, string stateName, int actionIndex, string fieldName) { AddIfAbsent(new TrackedVariablePath(fsmKey, null, stateName, actionIndex, fieldName)); } public void TrackState(string fsmKey, string stateName) { AddIfAbsent(new TrackedVariablePath(fsmKey, null, stateName, -1, null)); } public void TrackVariableArrayElement(string fsmKey, string variableName, int arrayIndex) { AddIfAbsent(new TrackedVariablePath(fsmKey, variableName, null, -1, null, arrayIndex)); } public void TrackActionFieldArrayElement(string fsmKey, string stateName, int actionIndex, string fieldName, int arrayIndex) { AddIfAbsent(new TrackedVariablePath(fsmKey, null, stateName, actionIndex, fieldName, arrayIndex)); } private void AddIfAbsent(TrackedVariablePath path) { if (!_tracked.Contains(path)) { _tracked.Add(path); Version++; } } public void UntrackVariable(string fsmKey, string variableName) { if (_tracked.Remove(new TrackedVariablePath(fsmKey, variableName, null, -1, null))) { Version++; } } public void UntrackActionField(string fsmKey, string stateName, int actionIndex, string fieldName) { if (_tracked.Remove(new TrackedVariablePath(fsmKey, null, stateName, actionIndex, fieldName))) { Version++; } } public void UntrackState(string fsmKey, string stateName) { if (_tracked.Remove(new TrackedVariablePath(fsmKey, null, stateName, -1, null))) { Version++; } } public void UntrackVariableArrayElement(string fsmKey, string variableName, int arrayIndex) { if (_tracked.Remove(new TrackedVariablePath(fsmKey, variableName, null, -1, null, arrayIndex))) { Version++; } } public void UntrackActionFieldArrayElement(string fsmKey, string stateName, int actionIndex, string fieldName, int arrayIndex) { if (_tracked.Remove(new TrackedVariablePath(fsmKey, null, stateName, actionIndex, fieldName, arrayIndex))) { Version++; } } public bool IsVariableTracked(string fsmKey, string variableName) { return _tracked.Contains(new TrackedVariablePath(fsmKey, variableName, null, -1, null)); } public bool IsActionFieldTracked(string fsmKey, string stateName, int actionIndex, string fieldName) { return _tracked.Contains(new TrackedVariablePath(fsmKey, null, stateName, actionIndex, fieldName)); } public bool IsStateTracked(string fsmKey, string stateName) { return _tracked.Contains(new TrackedVariablePath(fsmKey, null, stateName, -1, null)); } public bool IsVariableArrayElementTracked(string fsmKey, string variableName, int arrayIndex) { return _tracked.Contains(new TrackedVariablePath(fsmKey, variableName, null, -1, null, arrayIndex)); } public bool IsActionFieldArrayElementTracked(string fsmKey, string stateName, int actionIndex, string fieldName, int arrayIndex) { return _tracked.Contains(new TrackedVariablePath(fsmKey, null, stateName, actionIndex, fieldName, arrayIndex)); } public IReadOnlyList GetTracked() { while (_resultBuffer.Count < _tracked.Count) { _resultBuffer.Add(new TrackedVariableValue()); } if (_resultBuffer.Count > _tracked.Count) { _resultBuffer.RemoveRange(_tracked.Count, _resultBuffer.Count - _tracked.Count); } for (int i = 0; i < _tracked.Count; i++) { TrackedVariablePath trackedVariablePath = _tracked[i]; IReadOnlyList readOnlyList = _getLiveInstances(trackedVariablePath.FsmKey); Fsm val = ((readOnlyList.Count > 0) ? readOnlyList[0] : null); TrackedVariableValue trackedVariableValue = _resultBuffer[i]; trackedVariableValue.FsmKey = trackedVariablePath.FsmKey; trackedVariableValue.DisplayLabel = trackedVariablePath.DisplayLabel; trackedVariableValue.CurrentValue = ((val == null) ? "" : ResolveCurrentValue(val, trackedVariablePath)); } return _resultBuffer; } private static string ResolveCurrentValue(Fsm fsm, TrackedVariablePath path) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) int? arrayIndex; if (path.VariableName != null) { NamedVariable val = fsm.Variables.FindVariable(path.VariableName); if (val == null) { return ""; } arrayIndex = path.ArrayIndex; if (arrayIndex.HasValue) { int valueOrDefault = arrayIndex.GetValueOrDefault(); FsmArray val2 = (FsmArray)(object)((val is FsmArray) ? val : null); if (val2 == null || valueOrDefault >= val2.Length) { return ""; } return FsmEditManager.FormatArrayElement(val2.ElementType, val2.Get(valueOrDefault)); } return FormatValue(val.RawValue); } if (path.ActionIndex < 0 && path.FieldName == null) { if (fsm.GetState(path.StateName) != null) { if (!(fsm.ActiveStateName == path.StateName)) { return "Inactive"; } return "Active"; } return ""; } FsmState state = fsm.GetState(path.StateName); if (state == null || path.ActionIndex < 0 || path.ActionIndex >= state.Actions.Length) { return ""; } FsmStateAction val3 = state.Actions[path.ActionIndex]; FieldInfo field = ((object)val3).GetType().GetField(path.FieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return ""; } object value = field.GetValue(val3); arrayIndex = path.ArrayIndex; if (arrayIndex.HasValue) { int valueOrDefault2 = arrayIndex.GetValueOrDefault(); if (!(value is Array array) || valueOrDefault2 >= array.Length) { return ""; } object value2 = array.GetValue(valueOrDefault2); NamedVariable val4 = (NamedVariable)((value2 is NamedVariable) ? value2 : null); return FormatValue((val4 != null) ? val4.RawValue : value2); } NamedVariable val5 = (NamedVariable)((value is NamedVariable) ? value : null); return FormatValue((val5 != null) ? val5.RawValue : value); } private static string FormatValue(object? value) { return value?.ToString() ?? "null"; } } internal sealed class TrackedVariablePath : IEquatable { public string FsmKey { get; } public string? VariableName { get; } public string? StateName { get; } public int ActionIndex { get; } public string? FieldName { get; } public int? ArrayIndex { get; } public string DisplayLabel { get; } public TrackedVariablePath(string fsmKey, string? variableName, string? stateName, int actionIndex, string? fieldName, int? arrayIndex = null) { FsmKey = fsmKey; VariableName = variableName; StateName = stateName; ActionIndex = actionIndex; FieldName = fieldName; ArrayIndex = arrayIndex; string text; if (VariableName == null) { if (FieldName == null) { text = fsmKey + " / " + stateName + " (state)"; } else if (arrayIndex.HasValue) { int valueOrDefault = arrayIndex.GetValueOrDefault(); text = $"{fsmKey} / {stateName}[{actionIndex}].{fieldName}[{valueOrDefault}]"; } else { text = $"{fsmKey} / {stateName}[{actionIndex}].{fieldName}"; } } else if (arrayIndex.HasValue) { int valueOrDefault2 = arrayIndex.GetValueOrDefault(); text = $"{fsmKey} / {variableName}[{valueOrDefault2}]"; } else { text = fsmKey + " / " + variableName; } DisplayLabel = text; } public bool Equals(TrackedVariablePath? other) { if (other != null && FsmKey == other.FsmKey && VariableName == other.VariableName && StateName == other.StateName && ActionIndex == other.ActionIndex && FieldName == other.FieldName) { return ArrayIndex == other.ArrayIndex; } return false; } public override bool Equals(object? obj) { return Equals(obj as TrackedVariablePath); } public override int GetHashCode() { return HashCode.Combine(FsmKey, VariableName, StateName, ActionIndex, FieldName, ArrayIndex); } } internal sealed class TrackedVariableValue { public string FsmKey = ""; public string DisplayLabel = ""; public string CurrentValue = ""; } internal sealed class SequenceSendEventAction : FsmStateAction { private readonly FsmEvent[] _sequence; private readonly int _repeatCount; private readonly FsmStateAction _originalAction; private readonly FsmState _state; private int _index; private int _completedCycles; public SequenceSendEventAction(FsmEvent[] sequence, int repeatCount, FsmStateAction originalAction, FsmState state) { if (sequence.Length == 0) { throw new ArgumentException("Sequence must contain at least one event.", "sequence"); } _sequence = sequence; _repeatCount = repeatCount; _originalAction = originalAction; _state = state; } public override void OnEnter() { if (_repeatCount > 0 && _completedCycles >= _repeatCount) { RestoreOriginalAction(); _originalAction.OnEnter(); return; } ((FsmStateAction)this).Fsm.Event(_sequence[_index]); _index++; if (_index >= _sequence.Length) { _index = 0; _completedCycles++; } ((FsmStateAction)this).Finish(); } private void RestoreOriginalAction() { _originalAction.Enabled = true; int num = Array.IndexOf(_state.Actions, (FsmStateAction)(object)this); if (num >= 0) { FsmUtil.RemoveAction(_state, num); } } } internal static class FsmActionSequencer { public static int IndexRandomEventAction(FsmState state, int rank) { int num = 0; for (int i = 0; i < state.Actions.Length; i++) { if (((object)state.Actions[i]).GetType().Name.Contains("Random")) { if (num == rank) { return i; } num++; } } return -1; } public static FsmEvent[] ExtractEventCandidates(FsmStateAction sourceAction, FsmState state) { FieldInfo fieldInfo = ((object)sourceAction).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault((FieldInfo f) => f.FieldType == typeof(FsmEvent[])); if (fieldInfo != null && fieldInfo.GetValue(sourceAction) is FsmEvent[] result) { return result; } return state.Transitions.Select((FsmTransition t) => t.FsmEvent).ToArray(); } public static FsmEvent[] ExpandPattern(FsmEvent[] events, int[] repeatCounts) { List list = new List(); for (int i = 0; i < repeatCounts.Length; i++) { for (int j = 0; j < repeatCounts[i]; j++) { list.Add(events[i]); } } return list.ToArray(); } } internal sealed class FsmEditManager { private sealed class SendExitEventAction : FsmStateAction { private readonly FsmEvent _exitEvent; public SendExitEventAction(FsmEvent exitEvent) { _exitEvent = exitEvent; } public override void OnEnter() { ((FsmStateAction)this).Fsm.Event(_exitEvent); ((FsmStateAction)this).Finish(); } } private static readonly string[] ExitEventPriority = new string[3] { "CANCEL", "FINISHED", "NEXT" }; private static readonly HashSet SupportedVariableTypes = new HashSet { (VariableType)0, (VariableType)1, (VariableType)2, (VariableType)4, (VariableType)5, (VariableType)6, (VariableType)8, (VariableType)11, (VariableType)7, (VariableType)14 }; private static readonly HashSet SupportedArrayElementTypes = new HashSet { (VariableType)0, (VariableType)1, (VariableType)2, (VariableType)4 }; private readonly ManualLogSource _logger; private readonly Dictionary> _liveInstances = new Dictionary>(); private readonly Dictionary _pristine = new Dictionary(); private readonly Dictionary _activeEdits = new Dictionary(); private readonly Dictionary> _undoStacks = new Dictionary>(); private bool _isUndoing; private readonly HashSet _pendingActivationFsmKeys = new HashSet(); public int EditGeneration { get; private set; } private void BumpEditGeneration() { EditGeneration++; } public FsmEditManager(ManualLogSource logger) { _logger = logger; } public void ReplaceLiveInstances(IReadOnlyDictionary> instancesByKey) { _liveInstances.Clear(); foreach (KeyValuePair> item in instancesByKey) { _liveInstances[item.Key] = item.Value; } PruneStaleSnapshotEntries(); } private void PruneStaleSnapshotEntries() { foreach (KeyValuePair item in _pristine) { HashSet alive = new HashSet(GetLiveInstances(item.Key)); item.Value.InjectedExitActions.RemoveAll((FsmStateAction action) => !alive.Contains(action.State.Fsm)); item.Value.InstalledSequencers.RemoveAll(((FsmStateAction Original, FsmStateAction Sequencer) pair) => !alive.Contains(pair.Sequencer.State.Fsm)); } } public IReadOnlyList GetLiveInstances(string fsmKey) { if (!_liveInstances.TryGetValue(fsmKey, out List value)) { return Array.Empty(); } return value; } public void ReconcileLiveInstance(string fsmKey, Fsm fsm) { if (!_liveInstances.TryGetValue(fsmKey, out List value)) { value = new List(); _liveInstances[fsmKey] = value; } value.RemoveAll((Fsm existing) => existing != fsm && (Object)(object)existing.FsmComponent == (Object)(object)fsm.FsmComponent); if (!value.Contains(fsm)) { value.Add(fsm); } } public void PollPendingActivations() { if (_pendingActivationFsmKeys.Count == 0) { return; } string[] array = _pendingActivationFsmKeys.ToArray(); foreach (string text in array) { _pendingActivationFsmKeys.Remove(text); FsmEditSet activeEditSet = GetActiveEditSet(text); if (activeEditSet == null) { continue; } Fsm[] array2 = GetLiveInstances(text).ToArray(); for (int j = 0; j < array2.Length; j++) { PlayMakerFSM fsmComponent = array2[j].FsmComponent; if (fsmComponent != null) { Fsm fsm = fsmComponent.Fsm; if (fsm != null) { ReconcileLiveInstance(text, fsm); } } } ApplyEditSet(activeEditSet); } } public IReadOnlyCollection GetEditedFsmKeys() { return _activeEdits.Keys; } public FsmEditSet? GetActiveEditSet(string fsmKey) { if (!_activeEdits.TryGetValue(fsmKey, out FsmEditSet value)) { return null; } return value; } public void ApplyEditSet(FsmEditSet editSet) { if (!_liveInstances.TryGetValue(editSet.FsmKey, out List value) || value.Count == 0) { _logger.LogWarning((object)("[FsmMaster] No live instances found for fsm key '" + editSet.FsmKey + "'; skipping edit set.")); return; } VariableOverride[] array = editSet.VariableOverrides.ToArray(); ActionFieldOverride[] array2 = editSet.ActionFieldOverrides.ToArray(); string[] array3 = editSet.DisabledStates.ToArray(); TransitionRetarget[] array4 = editSet.TransitionRetargets.ToArray(); SequencerOverride[] array5 = editSet.SequencerOverrides.ToArray(); foreach (Fsm item in value) { VariableOverride[] array6 = array; foreach (VariableOverride ov in array6) { ApplyVariableOverride(editSet.FsmKey, item, ov); } ActionFieldOverride[] array7 = array2; foreach (ActionFieldOverride ov2 in array7) { ApplyActionFieldOverride(editSet.FsmKey, item, ov2); } string[] array8 = array3; foreach (string stateName in array8) { DisableState(editSet.FsmKey, item, stateName); } TransitionRetarget[] array9 = array4; foreach (TransitionRetarget retarget in array9) { ApplyTransitionRetarget(editSet.FsmKey, item, retarget); } SequencerOverride[] array10 = array5; foreach (SequencerOverride seq in array10) { InstallSequencer(editSet.FsmKey, item, seq); } } } public void ResetFsm(string fsmKey) { if (_pristine.TryGetValue(fsmKey, out FsmPristineSnapshot value)) { _liveInstances.TryGetValue(fsmKey, out List value2); RestoreSnapshot(value, value2 ?? new List()); _pristine.Remove(fsmKey); _activeEdits.Remove(fsmKey); _undoStacks.Remove(fsmKey); BumpEditGeneration(); } } public void RevertAllForUnload() { foreach (KeyValuePair item in _pristine) { _liveInstances.TryGetValue(item.Key, out List value); RestoreSnapshot(item.Value, value ?? new List()); } _pristine.Clear(); _liveInstances.Clear(); _activeEdits.Clear(); _undoStacks.Clear(); } public bool HasUndo(string fsmKey) { if (_undoStacks.TryGetValue(fsmKey, out Stack value)) { return value.Count > 0; } return false; } public void Undo(string fsmKey) { if (!_undoStacks.TryGetValue(fsmKey, out Stack value) || value.Count == 0) { return; } Action action = value.Pop(); _isUndoing = true; try { action(); } finally { _isUndoing = false; } } private void PushUndo(string fsmKey, Action undo) { if (!_isUndoing) { if (!_undoStacks.TryGetValue(fsmKey, out Stack value)) { value = new Stack(); _undoStacks[fsmKey] = value; } value.Push(undo); } } public void SetVariable(string fsmKey, string variableName, string variableType, string stringValue) { string previousValue = GetCurrentVariableValue(fsmKey, variableName); VariableOverride ov = new VariableOverride { VariableType = variableType, Name = variableName, StringValue = stringValue }; foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { ApplyVariableOverride(fsmKey, liveInstance, ov); } if (previousValue != null) { PushUndo(fsmKey, delegate { SetVariable(fsmKey, variableName, variableType, previousValue); }); } } public void SetActionField(string fsmKey, string stateName, int actionIndex, string expectedActionTypeName, string fieldName, string stringValue) { string previousValue = GetCurrentActionFieldValue(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName); ActionFieldOverride ov = new ActionFieldOverride { StateName = stateName, ActionIndex = actionIndex, ExpectedActionTypeName = expectedActionTypeName, FieldName = fieldName, StringValue = stringValue }; foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { ApplyActionFieldOverride(fsmKey, liveInstance, ov); } if (previousValue != null) { PushUndo(fsmKey, delegate { SetActionField(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName, previousValue); }); } } public void SetVariableArrayElement(string fsmKey, string variableName, int arrayIndex, string elementStringValue) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) string previousValue = GetCurrentVariableArrayElementValue(fsmKey, variableName, arrayIndex); VariableOverride ov = new VariableOverride { VariableType = ((object)(VariableType)13/*cast due to .constrained prefix*/).ToString(), Name = variableName, ArrayIndex = arrayIndex, StringValue = elementStringValue }; foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { ApplyVariableOverride(fsmKey, liveInstance, ov); } if (previousValue != null) { PushUndo(fsmKey, delegate { SetVariableArrayElement(fsmKey, variableName, arrayIndex, previousValue); }); } } public void SetActionFieldArrayElement(string fsmKey, string stateName, int actionIndex, string expectedActionTypeName, string fieldName, int arrayIndex, string elementStringValue) { string previousValue = GetCurrentActionFieldArrayElementValue(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName, arrayIndex); ActionFieldOverride ov = new ActionFieldOverride { StateName = stateName, ActionIndex = actionIndex, ExpectedActionTypeName = expectedActionTypeName, FieldName = fieldName, ArrayIndex = arrayIndex, StringValue = elementStringValue }; foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { ApplyActionFieldOverride(fsmKey, liveInstance, ov); } if (previousValue != null) { PushUndo(fsmKey, delegate { SetActionFieldArrayElement(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName, arrayIndex, previousValue); }); } } private string? GetCurrentVariableValue(string fsmKey, string variableName) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { NamedVariable val = liveInstance.Variables.FindVariable(variableName); if (val != null && SupportedVariableTypes.Contains(val.VariableType)) { return FormatNamedVariable(val); } } return null; } private string? GetCurrentVariableArrayElementValue(string fsmKey, string variableName, int arrayIndex) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { NamedVariable obj = liveInstance.Variables.FindVariable(variableName); FsmArray val = (FsmArray)(object)((obj is FsmArray) ? obj : null); if (val != null && arrayIndex < val.Length) { return FormatArrayElement(val.ElementType, val.Get(arrayIndex)); } } return null; } private string? GetCurrentActionFieldValue(string fsmKey, string stateName, int actionIndex, string expectedActionTypeName, string fieldName) { foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { if (TryFindActionField(liveInstance, stateName, actionIndex, expectedActionTypeName, fieldName, out FsmStateAction action, out FieldInfo field) && TryFormatValue(field.GetValue(action), out string formatted)) { return formatted; } } return null; } private string? GetCurrentActionFieldArrayElementValue(string fsmKey, string stateName, int actionIndex, string expectedActionTypeName, string fieldName, int arrayIndex) { foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { if (TryFindActionField(liveInstance, stateName, actionIndex, expectedActionTypeName, fieldName, out FsmStateAction action, out FieldInfo field) && field.GetValue(action) is Array array && arrayIndex < array.Length && TryFormatValue(array.GetValue(arrayIndex), out string formatted)) { return formatted; } } return null; } private static bool TryFindActionField(Fsm fsm, string stateName, int actionIndex, string expectedActionTypeName, string fieldName, [NotNullWhen(true)] out FsmStateAction? action, [NotNullWhen(true)] out FieldInfo? field) { action = null; field = null; FsmState state = fsm.GetState(stateName); if (state == null || actionIndex < 0 || actionIndex >= state.Actions.Length) { return false; } FsmStateAction val = state.Actions[actionIndex]; if (((object)val).GetType().Name != expectedActionTypeName) { return false; } FieldInfo field2 = ((object)val).GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 == null) { return false; } action = val; field = field2; return true; } public void ApplyVariableOverride(string fsmKey, Fsm fsm, VariableOverride ov) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) NamedVariable val = fsm.Variables.FindVariable(ov.Name); if (val == null) { _logger.LogWarning((object)("[FsmMaster] Variable '" + ov.Name + "' not found on fsm '" + fsm.Name + "'; skipping.")); return; } if (ov.ArrayIndex >= 0) { ApplyVariableArrayElementOverride(fsmKey, fsm, val, ov); return; } if (!SupportedVariableTypes.Contains(val.VariableType)) { _logger.LogWarning((object)$"[FsmMaster] Variable '{ov.Name}' on fsm '{fsm.Name}' has unsupported type '{val.VariableType}' (object/array-reference variables are out of scope for this pass); skipping."); return; } if (((object)val.VariableType/*cast due to .constrained prefix*/).ToString() != ov.VariableType) { _logger.LogWarning((object)$"[FsmMaster] Variable '{ov.Name}' on fsm '{fsm.Name}' is now type '{val.VariableType}', expected '{ov.VariableType}'; skipping."); return; } FsmPristineSnapshot orCreateSnapshot = GetOrCreateSnapshot(fsmKey); if (!orCreateSnapshot.OriginalValues.VariableOverrides.Exists((VariableOverride v) => v.Name == ov.Name && v.ArrayIndex == -1)) { orCreateSnapshot.OriginalValues.VariableOverrides.Add(new VariableOverride { VariableType = ((object)val.VariableType/*cast due to .constrained prefix*/).ToString(), Name = ov.Name, StringValue = FormatNamedVariable(val) }); } AssignNamedVariable(val, ov.StringValue); FsmEditSet orCreateActiveEditSet = GetOrCreateActiveEditSet(fsmKey); orCreateActiveEditSet.VariableOverrides.RemoveAll((VariableOverride v) => v.Name == ov.Name && v.ArrayIndex == -1); orCreateActiveEditSet.VariableOverrides.Add(ov); BumpEditGeneration(); } private void ApplyVariableArrayElementOverride(string fsmKey, Fsm fsm, NamedVariable variable, VariableOverride ov) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) FsmArray val = (FsmArray)(object)((variable is FsmArray) ? variable : null); if (val == null) { _logger.LogWarning((object)("[FsmMaster] Variable '" + ov.Name + "' on fsm '" + fsm.Name + "' is not an array; skipping element edit.")); return; } if (!SupportedArrayElementTypes.Contains(val.ElementType)) { _logger.LogWarning((object)$"[FsmMaster] Variable '{ov.Name}' on fsm '{fsm.Name}' has unsupported array element type '{val.ElementType}'; skipping."); return; } if (ov.ArrayIndex >= val.Length) { _logger.LogWarning((object)$"[FsmMaster] Variable '{ov.Name}' on fsm '{fsm.Name}' array index {ov.ArrayIndex} is out of range (length {val.Length}); skipping."); return; } FsmPristineSnapshot orCreateSnapshot = GetOrCreateSnapshot(fsmKey); if (!orCreateSnapshot.OriginalValues.VariableOverrides.Exists((VariableOverride v) => v.Name == ov.Name && v.ArrayIndex == ov.ArrayIndex)) { orCreateSnapshot.OriginalValues.VariableOverrides.Add(new VariableOverride { VariableType = ov.VariableType, Name = ov.Name, ArrayIndex = ov.ArrayIndex, StringValue = FormatArrayElement(val.ElementType, val.Get(ov.ArrayIndex)) }); } AssignArrayElement(val, ov.ArrayIndex, ov.StringValue); FsmEditSet orCreateActiveEditSet = GetOrCreateActiveEditSet(fsmKey); orCreateActiveEditSet.VariableOverrides.RemoveAll((VariableOverride v) => v.Name == ov.Name && v.ArrayIndex == ov.ArrayIndex); orCreateActiveEditSet.VariableOverrides.Add(ov); BumpEditGeneration(); } private static void AssignArrayElement(FsmArray array, int index, string stringValue) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) array.Set(index, ParseArrayElement(array.ElementType, stringValue)); array.SaveChanges(); } internal static bool IsSupportedArrayElementType(VariableType elementType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return SupportedArrayElementTypes.Contains(elementType); } internal static string FormatArrayElement(VariableType elementType, object? rawValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) return (int)elementType switch { 0 => Convert.ToSingle(rawValue, CultureInfo.InvariantCulture).ToString("R", CultureInfo.InvariantCulture), 1 => Convert.ToInt32(rawValue, CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture), 2 => Convert.ToBoolean(rawValue).ToString(CultureInfo.InvariantCulture), 4 => (rawValue as string) ?? "", _ => throw new NotSupportedException($"Array element type '{elementType}' is not supported for editing."), }; } private static object ParseArrayElement(VariableType elementType, string stringValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) return (int)elementType switch { 0 => float.Parse(stringValue, CultureInfo.InvariantCulture), 1 => int.Parse(stringValue, CultureInfo.InvariantCulture), 2 => bool.Parse(stringValue), 4 => stringValue, _ => throw new NotSupportedException($"Array element type '{elementType}' is not supported for editing."), }; } public void ApplyActionFieldOverride(string fsmKey, Fsm fsm, ActionFieldOverride ov) { FsmState state = fsm.GetState(ov.StateName); if (state == null || ov.ActionIndex < 0 || ov.ActionIndex >= state.Actions.Length) { _logger.LogWarning((object)$"[FsmMaster] State '{ov.StateName}' action index {ov.ActionIndex} not found on fsm '{fsm.Name}'; skipping."); return; } FsmStateAction val = state.Actions[ov.ActionIndex]; if (((object)val).GetType().Name != ov.ExpectedActionTypeName) { _logger.LogWarning((object)$"[FsmMaster] Action at '{ov.StateName}'[{ov.ActionIndex}] on fsm '{fsm.Name}' is '{((object)val).GetType().Name}', expected '{ov.ExpectedActionTypeName}'; skipping."); return; } FieldInfo field = ((object)val).GetType().GetField(ov.FieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { _logger.LogWarning((object)("[FsmMaster] Field '" + ov.FieldName + "' not found on action '" + ov.ExpectedActionTypeName + "'; skipping.")); return; } object value = field.GetValue(val); if (ov.ArrayIndex >= 0) { ApplyActionFieldArrayElementOverride(fsmKey, ov, value); return; } if (!TryFormatValue(value, out string formatted)) { _logger.LogWarning((object)("[FsmMaster] Field '" + ov.FieldName + "' on '" + ov.ExpectedActionTypeName + "' has unsupported type '" + (value?.GetType().Name ?? "null") + "'; skipping.")); return; } FsmPristineSnapshot orCreateSnapshot = GetOrCreateSnapshot(fsmKey); if (!orCreateSnapshot.OriginalValues.ActionFieldOverrides.Exists((ActionFieldOverride f) => f.StateName == ov.StateName && f.ActionIndex == ov.ActionIndex && f.FieldName == ov.FieldName && f.ArrayIndex == -1)) { orCreateSnapshot.OriginalValues.ActionFieldOverrides.Add(new ActionFieldOverride { StateName = ov.StateName, ActionIndex = ov.ActionIndex, ExpectedActionTypeName = ov.ExpectedActionTypeName, FieldName = ov.FieldName, StringValue = formatted }); } TryAssignFieldValue(val, field, value, ov.StringValue); FsmEditSet orCreateActiveEditSet = GetOrCreateActiveEditSet(fsmKey); orCreateActiveEditSet.ActionFieldOverrides.RemoveAll((ActionFieldOverride f) => f.StateName == ov.StateName && f.ActionIndex == ov.ActionIndex && f.FieldName == ov.FieldName && f.ArrayIndex == -1); orCreateActiveEditSet.ActionFieldOverrides.Add(ov); BumpEditGeneration(); } private void ApplyActionFieldArrayElementOverride(string fsmKey, ActionFieldOverride ov, object? fieldValue) { //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown if (!(fieldValue is Array array) || ov.ArrayIndex >= array.Length) { _logger.LogWarning((object)$"[FsmMaster] Field '{ov.FieldName}' on '{ov.ExpectedActionTypeName}' has no array element at index {ov.ArrayIndex}; skipping."); return; } object value = array.GetValue(ov.ArrayIndex); if (!TryFormatValue(value, out string formatted)) { _logger.LogWarning((object)string.Format("[FsmMaster] Field '{0}[{1}]' on '{2}' has unsupported type '{3}'; skipping.", ov.FieldName, ov.ArrayIndex, ov.ExpectedActionTypeName, value?.GetType().Name ?? "null")); return; } FsmPristineSnapshot orCreateSnapshot = GetOrCreateSnapshot(fsmKey); if (!orCreateSnapshot.OriginalValues.ActionFieldOverrides.Exists((ActionFieldOverride f) => f.StateName == ov.StateName && f.ActionIndex == ov.ActionIndex && f.FieldName == ov.FieldName && f.ArrayIndex == ov.ArrayIndex)) { orCreateSnapshot.OriginalValues.ActionFieldOverrides.Add(new ActionFieldOverride { StateName = ov.StateName, ActionIndex = ov.ActionIndex, ExpectedActionTypeName = ov.ExpectedActionTypeName, FieldName = ov.FieldName, ArrayIndex = ov.ArrayIndex, StringValue = formatted }); } AssignNamedVariable((NamedVariable)value, ov.StringValue); FsmEditSet orCreateActiveEditSet = GetOrCreateActiveEditSet(fsmKey); orCreateActiveEditSet.ActionFieldOverrides.RemoveAll((ActionFieldOverride f) => f.StateName == ov.StateName && f.ActionIndex == ov.ActionIndex && f.FieldName == ov.FieldName && f.ArrayIndex == ov.ArrayIndex); orCreateActiveEditSet.ActionFieldOverrides.Add(ov); BumpEditGeneration(); } private static void RestoreActionField(Fsm fsm, ActionFieldOverride ov) { FsmState state = fsm.GetState(ov.StateName); if (state == null || ov.ActionIndex < 0 || ov.ActionIndex >= state.Actions.Length) { return; } FsmStateAction val = state.Actions[ov.ActionIndex]; FieldInfo field = ((object)val).GetType().GetField(ov.FieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return; } object value = field.GetValue(val); if (ov.ArrayIndex >= 0) { if (value is Array array && ov.ArrayIndex < array.Length) { object? value2 = array.GetValue(ov.ArrayIndex); NamedVariable val2 = (NamedVariable)((value2 is NamedVariable) ? value2 : null); if (val2 != null) { AssignNamedVariable(val2, ov.StringValue); } } } else { TryAssignFieldValue(val, field, value, ov.StringValue); } } public void DisableState(string fsmKey, string stateName) { FsmPristineSnapshot value; bool flag = _pristine.TryGetValue(fsmKey, out value) && value.NeuteredActionIndices.ContainsKey(stateName); foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { DisableState(fsmKey, liveInstance, stateName); } if (!flag) { PushUndo(fsmKey, delegate { EnableState(fsmKey, stateName); }); } } public void EnableState(string fsmKey, string stateName) { if (!_pristine.TryGetValue(fsmKey, out FsmPristineSnapshot value) || !value.NeuteredActionIndices.TryGetValue(stateName, out List value2)) { return; } foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { FsmState state = liveInstance.GetState(stateName); if (state == null) { continue; } foreach (int item in value2) { if (item >= 0 && item < state.Actions.Length) { state.Actions[item].Enabled = true; } } FsmStateAction val = ((IEnumerable)state.Actions).FirstOrDefault((Func)((FsmStateAction a) => a is SendExitEventAction)); if (val != null) { int num = Array.IndexOf(state.Actions, val); if (num >= 0) { FsmUtil.RemoveAction(state, num); } value.InjectedExitActions.Remove(val); } } value.NeuteredActionIndices.Remove(stateName); if (_activeEdits.TryGetValue(fsmKey, out FsmEditSet value3)) { value3.DisabledStates.Remove(stateName); } PushUndo(fsmKey, delegate { DisableState(fsmKey, stateName); }); BumpEditGeneration(); } public void DisableState(string fsmKey, Fsm fsm, string stateName) { FsmState state = fsm.GetState(stateName); if (state == null) { _logger.LogWarning((object)("[FsmMaster] State '" + stateName + "' not found on fsm '" + fsm.Name + "'; skipping disable.")); } else { if (state.Actions.Any((FsmStateAction a) => a is SendExitEventAction)) { return; } FsmPristineSnapshot orCreateSnapshot = GetOrCreateSnapshot(fsmKey); if (!orCreateSnapshot.NeuteredActionIndices.ContainsKey(stateName)) { List list = new List(); for (int num = 0; num < state.Actions.Length; num++) { if (state.Actions[num].Enabled) { state.Actions[num].Enabled = false; list.Add(num); } } orCreateSnapshot.NeuteredActionIndices[stateName] = list; } FsmEvent val = FindExitEvent(state); if (val != null) { SendExitEventAction sendExitEventAction = new SendExitEventAction(val); FsmUtil.AddAction(state, (FsmStateAction)(object)sendExitEventAction); orCreateSnapshot.InjectedExitActions.Add((FsmStateAction)(object)sendExitEventAction); } else if (!state.IsInitialized) { _logger.LogWarning((object)("[FsmMaster] Fsm '" + fsm.Name + "' hasn't activated yet (owning object inactive); state '" + stateName + "' has its actions disabled but its exit event can't be resolved until this instance activates.")); _pendingActivationFsmKeys.Add(fsmKey); } else { _logger.LogWarning((object)("[FsmMaster] State '" + stateName + "' on fsm '" + fsm.Name + "' has no CANCEL/FINISHED/NEXT transition and no FsmEvent-valued action field to fall back on; leaving it inert with no exit.")); } FsmEditSet orCreateActiveEditSet = GetOrCreateActiveEditSet(fsmKey); if (!orCreateActiveEditSet.DisabledStates.Contains(stateName)) { orCreateActiveEditSet.DisabledStates.Add(stateName); } BumpEditGeneration(); } } internal static FsmEvent? FindExitEvent(FsmState state) { string[] exitEventPriority = ExitEventPriority; foreach (string text in exitEventPriority) { FsmTransition val = FsmUtil.GetTransition(state, text) ?? (state.IsInitialized ? FsmUtil.GetGlobalTransition(state.Fsm, text) : null); if (val != null) { return val.FsmEvent; } } FsmEvent result = null; FsmStateAction[] actions = state.Actions; foreach (FsmStateAction val2 in actions) { FieldInfo[] fields = ((object)val2).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public); for (int j = 0; j < fields.Length; j++) { object value = fields[j].GetValue(val2); FsmEvent val3 = (FsmEvent)((value is FsmEvent) ? value : null); if (val3 == null) { if (value is FsmEvent[] array && array.Length > 0) { result = array[^1]; } } else { result = val3; } } } return result; } public void ApplyTransitionRetarget(string fsmKey, Fsm fsm, TransitionRetarget retarget) { bool flag = string.IsNullOrEmpty(retarget.StateName); FsmTransition val = (flag ? FsmUtil.GetGlobalTransition(fsm, retarget.EventName) : FsmUtil.GetTransition(fsm, retarget.StateName, retarget.EventName)); if (val == null) { string text = (flag ? "global transitions" : ("state '" + retarget.StateName + "'")); _logger.LogWarning((object)("[FsmMaster] Transition for event '" + retarget.EventName + "' not found on " + text + " on fsm '" + fsm.Name + "'; skipping.")); return; } string text2 = EffectiveNewEventName(retarget); FsmPristineSnapshot orCreateSnapshot = GetOrCreateSnapshot(fsmKey); if (!orCreateSnapshot.OriginalValues.TransitionRetargets.Exists((TransitionRetarget t) => t.StateName == retarget.StateName && t.EventName == retarget.EventName)) { bool flag2 = retarget.NewToState == "\0DISABLED"; orCreateSnapshot.OriginalValues.TransitionRetargets.Add(new TransitionRetarget { StateName = (flag2 ? retarget.StateName : retarget.NewStateName), EventName = (flag2 ? retarget.EventName : text2), NewStateName = retarget.StateName, NewEventName = retarget.EventName, NewToState = val.ToState }); } FsmEditSet orCreateActiveEditSet = GetOrCreateActiveEditSet(fsmKey); orCreateActiveEditSet.TransitionRetargets.RemoveAll((TransitionRetarget t) => t.StateName == retarget.StateName && t.EventName == retarget.EventName); orCreateActiveEditSet.TransitionRetargets.Add(retarget); BumpEditGeneration(); if (retarget.NewToState == "\0DISABLED") { RemoveTransitionAt(fsm, retarget.StateName, retarget.EventName); } else { RelocateTransition(fsm, retarget.StateName, retarget.NewStateName, retarget.EventName, text2, retarget.NewToState); } } private static void RestoreTransition(Fsm fsm, TransitionRetarget original) { RelocateTransition(fsm, original.StateName, original.NewStateName, original.EventName, EffectiveNewEventName(original), original.NewToState); } private static void RelocateTransition(Fsm fsm, string fromStateName, string toStateName, string fromEventName, string toEventName, string newToState) { if (fromStateName != toStateName || fromEventName != toEventName) { RemoveTransitionAt(fsm, fromStateName, fromEventName); } AddOrChangeTransitionAt(fsm, toStateName, toEventName, newToState); } internal static string EffectiveNewEventName(TransitionRetarget retarget) { if (!string.IsNullOrEmpty(retarget.NewEventName)) { return retarget.NewEventName; } return retarget.EventName; } public void RetargetTransitionToState(string fsmKey, string stateName, string eventName, string newToState) { string previousToState = GetCurrentTransitionToState(fsmKey, stateName, eventName); TransitionRetarget retarget = new TransitionRetarget { StateName = stateName, EventName = eventName, NewStateName = stateName, NewToState = newToState }; foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { ApplyTransitionRetarget(fsmKey, liveInstance, retarget); } if (previousToState != null) { PushUndo(fsmKey, delegate { RetargetTransitionToState(fsmKey, stateName, eventName, previousToState); }); } } private string? GetCurrentTransitionToState(string fsmKey, string stateName, string eventName) { foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { FsmTransition val = (string.IsNullOrEmpty(stateName) ? FsmUtil.GetGlobalTransition(liveInstance, eventName) : FsmUtil.GetTransition(liveInstance, stateName, eventName)); if (val != null) { return val.ToState; } } return null; } public void DisableTransition(string fsmKey, string stateName, string eventName) { FsmPristineSnapshot value; bool flag = _pristine.TryGetValue(fsmKey, out value) && value.OriginalValues.TransitionRetargets.Exists((TransitionRetarget t) => t.NewStateName == stateName && EffectiveNewEventName(t) == eventName); TransitionRetarget retarget = new TransitionRetarget { StateName = stateName, EventName = eventName, NewStateName = stateName, NewToState = "\0DISABLED" }; foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { ApplyTransitionRetarget(fsmKey, liveInstance, retarget); } if (!flag) { PushUndo(fsmKey, delegate { EnableTransition(fsmKey, stateName, eventName); }); } } public void EnableTransition(string fsmKey, string stateName, string eventName) { if (!_pristine.TryGetValue(fsmKey, out FsmPristineSnapshot value)) { return; } TransitionRetarget transitionRetarget = value.OriginalValues.TransitionRetargets.Find((TransitionRetarget t) => t.NewStateName == stateName && EffectiveNewEventName(t) == eventName); if (transitionRetarget == null) { return; } foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { RestoreTransition(liveInstance, transitionRetarget); } value.OriginalValues.TransitionRetargets.Remove(transitionRetarget); if (_activeEdits.TryGetValue(fsmKey, out FsmEditSet value2)) { value2.TransitionRetargets.RemoveAll((TransitionRetarget t) => t.StateName == stateName && t.EventName == eventName); } PushUndo(fsmKey, delegate { DisableTransition(fsmKey, stateName, eventName); }); BumpEditGeneration(); } public void RetargetTransitionEvent(string fsmKey, string stateName, string eventName, string newOwnerStateName, string newEventName, string toState) { bool flag = newOwnerStateName == stateName && newEventName == eventName; TransitionRetarget retarget = new TransitionRetarget { StateName = stateName, EventName = eventName, NewStateName = newOwnerStateName, NewEventName = newEventName, NewToState = toState }; foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { if (!flag && (string.IsNullOrEmpty(newOwnerStateName) ? FsmUtil.GetGlobalTransition(liveInstance, newEventName) : FsmUtil.GetTransition(liveInstance, newOwnerStateName, newEventName)) != null) { RemoveTransitionAt(liveInstance, newOwnerStateName, newEventName); } ApplyTransitionRetarget(fsmKey, liveInstance, retarget); } if (!flag) { PushUndo(fsmKey, delegate { RetargetTransitionEvent(fsmKey, newOwnerStateName, newEventName, stateName, eventName, toState); }); } } private static void RemoveTransitionAt(Fsm fsm, string stateName, string eventName) { if (string.IsNullOrEmpty(stateName)) { FsmUtil.RemoveGlobalTransition(fsm, eventName); } else { FsmUtil.RemoveTransition(fsm, stateName, eventName); } } private static void AddOrChangeTransitionAt(Fsm fsm, string stateName, string eventName, string toState) { bool flag = string.IsNullOrEmpty(stateName); if (!(flag ? FsmUtil.ChangeGlobalTransition(fsm, eventName, toState) : FsmUtil.ChangeTransition(fsm, stateName, eventName, toState))) { if (flag) { FsmUtil.AddGlobalTransition(fsm, eventName, toState); } else { FsmUtil.AddTransition(fsm, stateName, eventName, toState); } } } public void InstallSequencer(string fsmKey, SequencerOverride seq) { foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { InstallSequencer(fsmKey, liveInstance, seq); } } public void InstallSequencer(string fsmKey, Fsm fsm, SequencerOverride seq) { FsmState state = fsm.GetState(seq.StateName); if (state == null) { _logger.LogWarning((object)("[FsmMaster] State '" + seq.StateName + "' not found on fsm '" + fsm.Name + "'; skipping sequencer install.")); return; } if (seq.Pattern.Count == 0) { _logger.LogWarning((object)("[FsmMaster] Sequencer pattern for state '" + seq.StateName + "' on fsm '" + fsm.Name + "' is empty; skipping.")); return; } int num = FsmActionSequencer.IndexRandomEventAction(state, seq.ActionIndex); if (num < 0) { _logger.LogWarning((object)$"[FsmMaster] No random-event action at rank {seq.ActionIndex} on state '{seq.StateName}' on fsm '{fsm.Name}'; skipping sequencer install."); return; } FsmEditSet orCreateActiveEditSet = GetOrCreateActiveEditSet(fsmKey); orCreateActiveEditSet.SequencerOverrides.RemoveAll((SequencerOverride s) => s.StateName == seq.StateName && s.ActionIndex == seq.ActionIndex); orCreateActiveEditSet.SequencerOverrides.Add(seq); FsmStateAction val = state.Actions[num]; if (val.State == null) { _logger.LogWarning((object)("[FsmMaster] Fsm '" + fsm.Name + "' hasn't activated yet (owning object inactive); sequencer override for state '" + seq.StateName + "' recorded but not installed on this instance.")); _pendingActivationFsmKeys.Add(fsmKey); BumpEditGeneration(); } else { RemoveInstalledSequencerFor(fsmKey, val, restoreOriginalEnabled: false); val.Enabled = false; SequenceSendEventAction sequenceSendEventAction = new SequenceSendEventAction(((IEnumerable)seq.Pattern).Select((Func)FsmEvent.GetFsmEvent).ToArray(), seq.RepeatCount, val, state); FsmUtil.InsertActionAfter(val, (FsmStateAction)(object)sequenceSendEventAction); GetOrCreateSnapshot(fsmKey).InstalledSequencers.Add((val, (FsmStateAction)(object)sequenceSendEventAction)); BumpEditGeneration(); } } public void RemoveSequencer(string fsmKey, string stateName, int actionRank) { foreach (Fsm liveInstance in GetLiveInstances(fsmKey)) { FsmState state = liveInstance.GetState(stateName); if (state != null) { int num = FsmActionSequencer.IndexRandomEventAction(state, actionRank); if (num >= 0) { RemoveInstalledSequencerFor(fsmKey, state.Actions[num], restoreOriginalEnabled: true); } } } if (_activeEdits.TryGetValue(fsmKey, out FsmEditSet value)) { value.SequencerOverrides.RemoveAll((SequencerOverride s) => s.StateName == stateName && s.ActionIndex == actionRank); } BumpEditGeneration(); } private void RemoveInstalledSequencerFor(string fsmKey, FsmStateAction original, bool restoreOriginalEnabled) { if (!_pristine.TryGetValue(fsmKey, out FsmPristineSnapshot value)) { return; } int num = value.InstalledSequencers.FindIndex(((FsmStateAction Original, FsmStateAction Sequencer) p) => p.Original == original); if (num >= 0) { var (val, val2) = value.InstalledSequencers[num]; value.InstalledSequencers.RemoveAt(num); if (restoreOriginalEnabled) { val.Enabled = true; } FsmState state = val2.State; int num2 = Array.IndexOf(state.Actions, val2); if (num2 >= 0) { FsmUtil.RemoveAction(state, num2); } } } private FsmPristineSnapshot GetOrCreateSnapshot(string fsmKey) { if (!_pristine.TryGetValue(fsmKey, out FsmPristineSnapshot value)) { value = new FsmPristineSnapshot(); _pristine[fsmKey] = value; } return value; } private FsmEditSet GetOrCreateActiveEditSet(string fsmKey) { if (!_activeEdits.TryGetValue(fsmKey, out FsmEditSet value)) { value = new FsmEditSet { FsmKey = fsmKey }; _activeEdits[fsmKey] = value; } return value; } private static void RestoreSnapshot(FsmPristineSnapshot snapshot, List instances) { foreach (Fsm instance in instances) { foreach (VariableOverride variableOverride in snapshot.OriginalValues.VariableOverrides) { NamedVariable val = instance.Variables.FindVariable(variableOverride.Name); if (val == null) { continue; } if (variableOverride.ArrayIndex >= 0) { FsmArray val2 = (FsmArray)(object)((val is FsmArray) ? val : null); if (val2 != null && variableOverride.ArrayIndex < val2.Length) { AssignArrayElement(val2, variableOverride.ArrayIndex, variableOverride.StringValue); } } else { AssignNamedVariable(val, variableOverride.StringValue); } } foreach (ActionFieldOverride actionFieldOverride in snapshot.OriginalValues.ActionFieldOverrides) { RestoreActionField(instance, actionFieldOverride); } foreach (TransitionRetarget transitionRetarget in snapshot.OriginalValues.TransitionRetargets) { RestoreTransition(instance, transitionRetarget); } } foreach (KeyValuePair> neuteredActionIndex in snapshot.NeuteredActionIndices) { foreach (Fsm instance2 in instances) { FsmState state = instance2.GetState(neuteredActionIndex.Key); if (state == null) { continue; } foreach (int item in neuteredActionIndex.Value) { if (item >= 0 && item < state.Actions.Length) { state.Actions[item].Enabled = true; } } } } foreach (FsmStateAction injectedExitAction in snapshot.InjectedExitActions) { FsmState state2 = injectedExitAction.State; int num = Array.IndexOf(state2.Actions, injectedExitAction); if (num >= 0) { FsmUtil.RemoveAction(state2, num); } } foreach (var (val3, val4) in snapshot.InstalledSequencers) { val3.Enabled = true; FsmState state3 = val4.State; int num2 = Array.IndexOf(state3.Actions, val4); if (num2 >= 0) { FsmUtil.RemoveAction(state3, num2); } } } internal static bool TryFormatValue(object? value, out string formatted) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) NamedVariable val = (NamedVariable)((value is NamedVariable) ? value : null); if (val == null) { if (value is bool flag) { formatted = flag.ToString(CultureInfo.InvariantCulture); return true; } if (value is int num) { formatted = num.ToString(CultureInfo.InvariantCulture); return true; } if (value is float num2) { formatted = num2.ToString("R", CultureInfo.InvariantCulture); return true; } if (value is string text) { formatted = text; return true; } if (value is Enum value2) { formatted = Convert.ToInt32(value2).ToString(CultureInfo.InvariantCulture); return true; } } else if (SupportedVariableTypes.Contains(val.VariableType)) { formatted = FormatNamedVariable(val); return true; } formatted = ""; return false; } private static bool TryAssignFieldValue(FsmStateAction action, FieldInfo field, object? currentValue, string stringValue) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) NamedVariable val = (NamedVariable)((currentValue is NamedVariable) ? currentValue : null); if (val == null) { if (currentValue is bool) { field.SetValue(action, bool.Parse(stringValue)); return true; } if (currentValue is int) { field.SetValue(action, int.Parse(stringValue, CultureInfo.InvariantCulture)); return true; } if (currentValue is float) { field.SetValue(action, float.Parse(stringValue, CultureInfo.InvariantCulture)); return true; } if (currentValue is string) { field.SetValue(action, stringValue); return true; } if (currentValue is Enum) { field.SetValue(action, Enum.ToObject(field.FieldType, int.Parse(stringValue, CultureInfo.InvariantCulture))); return true; } } else if (SupportedVariableTypes.Contains(val.VariableType)) { AssignNamedVariable(val, stringValue); return true; } return false; } private static string FormatNamedVariable(NamedVariable variable) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected I4, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) //IL_00af: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) VariableType variableType = variable.VariableType; switch ((int)variableType) { case 0: return ((FsmFloat)variable).Value.ToString("R", CultureInfo.InvariantCulture); case 1: return ((FsmInt)variable).Value.ToString(CultureInfo.InvariantCulture); case 2: return ((FsmBool)variable).Value.ToString(CultureInfo.InvariantCulture); case 4: return ((FsmString)variable).Value ?? ""; case 5: return FormatFloats(((FsmVector2)variable).Value.x, ((FsmVector2)variable).Value.y); case 6: return FormatFloats(((FsmVector3)variable).Value.x, ((FsmVector3)variable).Value.y, ((FsmVector3)variable).Value.z); case 8: { float[] array = new float[4]; Rect value = ((FsmRect)variable).Value; array[0] = ((Rect)(ref value)).x; value = ((FsmRect)variable).Value; array[1] = ((Rect)(ref value)).y; value = ((FsmRect)variable).Value; array[2] = ((Rect)(ref value)).width; value = ((FsmRect)variable).Value; array[3] = ((Rect)(ref value)).height; return FormatFloats(array); } case 11: return FormatFloats(((FsmQuaternion)variable).Value.x, ((FsmQuaternion)variable).Value.y, ((FsmQuaternion)variable).Value.z, ((FsmQuaternion)variable).Value.w); case 7: return FormatFloats(((FsmColor)variable).Value.r, ((FsmColor)variable).Value.g, ((FsmColor)variable).Value.b, ((FsmColor)variable).Value.a); case 14: return ((NamedVariable)(FsmEnum)variable).ToInt().ToString(CultureInfo.InvariantCulture); default: return ""; } } private static void AssignNamedVariable(NamedVariable variable, string stringValue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected I4, but got Unknown //IL_004d: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) VariableType variableType = variable.VariableType; switch ((int)variableType) { case 0: ((FsmFloat)variable).Value = float.Parse(stringValue, CultureInfo.InvariantCulture); break; case 1: ((FsmInt)variable).Value = int.Parse(stringValue, CultureInfo.InvariantCulture); break; case 2: ((FsmBool)variable).Value = bool.Parse(stringValue); break; case 4: ((FsmString)variable).Value = stringValue; break; case 5: { float[] array5 = ParseFloats(stringValue, 2); ((FsmVector2)variable).Value = new Vector2(array5[0], array5[1]); break; } case 6: { float[] array4 = ParseFloats(stringValue, 3); ((FsmVector3)variable).Value = new Vector3(array4[0], array4[1], array4[2]); break; } case 8: { float[] array3 = ParseFloats(stringValue, 4); ((FsmRect)variable).Value = new Rect(array3[0], array3[1], array3[2], array3[3]); break; } case 11: { float[] array2 = ParseFloats(stringValue, 4); ((FsmQuaternion)variable).Value = new Quaternion(array2[0], array2[1], array2[2], array2[3]); break; } case 7: { float[] array = ParseFloats(stringValue, 4); ((FsmColor)variable).Value = new Color(array[0], array[1], array[2], array[3]); break; } case 14: { FsmEnum val = (FsmEnum)variable; val.Value = (Enum)Enum.ToObject(val.EnumType, int.Parse(stringValue, CultureInfo.InvariantCulture)); break; } case 3: case 9: case 10: case 12: case 13: break; } } private static string FormatFloats(params float[] values) { return string.Join(",", values.Select((float v) => v.ToString("R", CultureInfo.InvariantCulture))); } private static float[] ParseFloats(string s, int count) { string[] array = s.Split(','); float[] array2 = new float[count]; for (int i = 0; i < count && i < array.Length; i++) { array2[i] = float.Parse(array[i].Trim(), CultureInfo.InvariantCulture); } return array2; } } [Serializable] internal sealed class SceneEdits { public string SceneName = ""; public List FsmEdits = new List(); } [Serializable] internal sealed class FsmEditSet { public string FsmKey = ""; public List VariableOverrides = new List(); public List ActionFieldOverrides = new List(); public List DisabledStates = new List(); public List TransitionRetargets = new List(); public List SequencerOverrides = new List(); } [Serializable] internal sealed class VariableOverride { public string VariableType = ""; public string Name = ""; public int ArrayIndex = -1; public string StringValue = ""; } [Serializable] internal sealed class ActionFieldOverride { public string StateName = ""; public int ActionIndex; public string ExpectedActionTypeName = ""; public string FieldName = ""; public int ArrayIndex = -1; public string StringValue = ""; } [Serializable] internal sealed class TransitionRetarget { public const string DisabledMarker = "\0DISABLED"; public string StateName = ""; public string EventName = ""; public string NewStateName = ""; public string NewToState = ""; public string NewEventName = ""; } [Serializable] internal sealed class SequencerOverride { public string StateName = ""; public int ActionIndex; public List Pattern = new List(); public int RepeatCount; } internal sealed class CanvasBorder : CanvasPanel { private const float Thickness = 1f; private readonly CanvasImage _top; private readonly CanvasImage _bottom; private readonly CanvasImage _left; private readonly CanvasImage _right; public CanvasBorder(string name, UICommon ui, Color color) : base(name) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) _top = Add(new CanvasImage("Top", ui) { Tint = color }); _bottom = Add(new CanvasImage("Bottom", ui) { Tint = color }); _left = Add(new CanvasImage("Left", ui) { Tint = color }); _right = Add(new CanvasImage("Right", ui) { Tint = color }); } protected override void OnUpdateSize() { base.OnUpdateSize(); Layout(); } public override void Build(Transform? rootParent = null) { base.Build(rootParent); Layout(); } private void Layout() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) _top.LocalPosition = Vector2.zero; _top.Size = new Vector2(base.Size.x, 1f); _bottom.LocalPosition = new Vector2(0f, Mathf.Max(0f, base.Size.y - 1f)); _bottom.Size = new Vector2(base.Size.x, 1f); _left.LocalPosition = Vector2.zero; _left.Size = new Vector2(1f, base.Size.y); _right.LocalPosition = new Vector2(Mathf.Max(0f, base.Size.x - 1f), 0f); _right.Size = new Vector2(1f, base.Size.y); } } internal class CanvasButton : CanvasImage { private readonly UICommon _ui; private readonly CanvasText _text; private readonly CanvasBorder _hoverBorder; private bool _toggled; private CanvasNode[] _ownChildList = Array.Empty(); public CanvasText Text => _text; public bool Toggled { get { return _toggled; } set { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (_toggled != value) { _toggled = value; base.Tint = (_toggled ? _ui.ButtonActive : _ui.ButtonNormal); } } } protected override bool Interactable => true; public event Action? OnClicked; public CanvasButton(string name, UICommon ui) : base(name, ui) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) _ui = ui; base.Tint = ui.ButtonNormal; AddBorder(ui.PanelBorder); _text = new CanvasText("Label", ui) { Alignment = (TextAnchor)4 }; _text.Parent = this; _hoverBorder = new CanvasBorder("HoverBorder", ui, ui.AccentColor) { ActiveSelf = false }; _hoverBorder.Parent = this; RebuildOwnChildList(); } public override CanvasBorder AddBorder(Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CanvasBorder result = base.AddBorder(color); RebuildOwnChildList(); return result; } public override void RemoveBorder() { base.RemoveBorder(); RebuildOwnChildList(); } private void RebuildOwnChildList() { if (_text != null && _hoverBorder != null) { _ownChildList = ((base.Border == null) ? new CanvasNode[2] { _hoverBorder, _text } : new CanvasNode[3] { base.Border, _hoverBorder, _text }); } } protected override IEnumerable ChildList() { return _ownChildList; } protected override void OnUpdateSize() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) base.OnUpdateSize(); _text.Size = base.Size; _hoverBorder.Size = base.Size; } public override void Build(Transform? rootParent = null) { base.Build(rootParent); AddEventTrigger((EventTriggerType)4, delegate { this.OnClicked?.Invoke(); }); AddEventTrigger((EventTriggerType)0, delegate { _hoverBorder.ActiveSelf = true; }); AddEventTrigger((EventTriggerType)1, delegate { _hoverBorder.ActiveSelf = false; }); } } internal interface IHorizontalScrollSource { CanvasNode? Content { get; } float GetScrollableWidth(); void SetScrollPercentage(float percentage); } internal sealed class CanvasHorizontalScrollbar : CanvasNode { private const float MinGripWidth = 24f; private readonly CanvasButton _dragSurface; private readonly CanvasImage _grip; private readonly CanvasNode[] _childList; public IHorizontalScrollSource? Source { get; set; } protected override bool Interactable => true; public bool ShouldBeVisible { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (Source?.Content != null) { return Source.Content.Size.x > base.Size.x; } return false; } } public CanvasHorizontalScrollbar(string name, UICommon ui) : base(name) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) _dragSurface = new CanvasButton("DragSurface", ui) { Tint = ui.ScrollTrackColor }; _dragSurface.RemoveBorder(); _dragSurface.Parent = this; _grip = new CanvasImage("Grip", ui) { Tint = ui.PanelBorder }; _grip.AddBorder(ui.AccentColor); _grip.Parent = this; _childList = new CanvasNode[2] { _dragSurface, _grip }; base.OnUpdate += Refresh; } protected override IEnumerable ChildList() { return _childList; } protected override void OnUpdateSize() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) base.OnUpdateSize(); _dragSurface.Size = base.Size; } public override void Build(Transform? rootParent = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _dragSurface.Size = base.Size; base.Build(rootParent); _dragSurface.OnClicked += OnTrackClicked; _dragSurface.AddEventTrigger((EventTriggerType)5, OnDragged); } private void OnTrackClicked() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (Source != null) { float x = Input.mousePosition.x; if (!(x >= _grip.Position.x) || !(x <= _grip.Position.x + _grip.Size.x)) { float num = Mathf.Max(1f, base.Size.x - _grip.Size.x); float num2 = Mathf.Clamp(x - base.Position.x - _grip.Size.x / 2f, 0f, num); Source.SetScrollPercentage(num2 / num); } } } private void OnDragged(PointerEventData eventData) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0041: Unknown result type (might be due to invalid IL or missing references) if (Source != null) { float num = Mathf.Max(1f, base.Size.x - _grip.Size.x); float num2 = Mathf.Clamp(_grip.LocalPosition.x + eventData.delta.x, 0f, num); Source.SetScrollPercentage(num2 / num); } } private void Refresh() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (Source?.Content != null) { float x = Source.Content.Size.x; float num = Mathf.Clamp(base.Size.x * base.Size.x / Mathf.Max(1f, x), 24f, base.Size.x); _grip.Size = new Vector2(num, base.Size.y); float scrollableWidth = Source.GetScrollableWidth(); float num2 = ((scrollableWidth > 0f) ? Mathf.Clamp01((0f - Source.Content.LocalPosition.x) / scrollableWidth) : 0f); _grip.LocalPosition = new Vector2(num2 * (base.Size.x - num), 0f); } } } internal sealed class CanvasHorizontalScrollStrip : CanvasNode, IHorizontalScrollSource { private const float ScrollSpeed = 30f; private CanvasNode? _content; private float _contentWidthAtLastCheck; private CanvasNode[] _childList = Array.Empty(); public CanvasNode? Content => _content; public CanvasHorizontalScrollStrip(string name) : base(name) { base.OnUpdate += Poll; } public T SetContent(T content) where T : CanvasNode { _content = content; content.Parent = this; _childList = new CanvasNode[1] { content }; return content; } protected override IEnumerable ChildList() { return _childList; } public override void Build(Transform? rootParent = null) { base.Build(rootParent); base.GameObject.AddComponent(); } private void Poll() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if (_content != null) { if (!Mathf.Approximately(_content.Size.x, _contentWidthAtLastCheck)) { float num = Mathf.Clamp(_content.LocalPosition.x, Mathf.Min(0f - GetScrollableWidth(), 0f), 0f); _content.LocalPosition = new Vector2(num, _content.LocalPosition.y); _contentWidthAtLastCheck = _content.Size.x; } if (!Mathf.Approximately(Input.mouseScrollDelta.y, 0f) && IsMouseOver()) { float num2 = _content.LocalPosition.x + Input.mouseScrollDelta.y * 30f; num2 = Mathf.Clamp(num2, Mathf.Min(0f - GetScrollableWidth(), 0f), 0f); _content.LocalPosition = new Vector2(num2, _content.LocalPosition.y); } } } public void SetScrollPercentage(float percentage) { //IL_0026: 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) if (_content != null) { percentage = Mathf.Clamp01(percentage); _content.LocalPosition = new Vector2((0f - percentage) * GetScrollableWidth(), _content.LocalPosition.y); } } public float GetScrollableWidth() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(0f, (_content?.Size.x ?? 0f) - base.Size.x); } } internal class CanvasImage : CanvasNode { private readonly UICommon _ui; private Color _tint = Color.white; private CanvasBorder? _border; private CanvasNode[] _childList = Array.Empty(); public CanvasBorder? Border => _border; public bool IsBackground { get; set; } protected override bool Interactable => false; public Color Tint { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _tint; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _tint = value; if ((Object)(object)base.GameObject != (Object)null) { ApplyTint(); } } } public CanvasImage(string name, UICommon ui) : base(name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) _ui = ui; } public virtual CanvasBorder AddBorder(Color color) { //IL_0032: 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) if (_border == null) { _border = new CanvasBorder("Border", _ui, color); } _border.Parent = this; _border.Size = base.Size; RebuildChildList(); return _border; } public virtual void RemoveBorder() { _border = null; RebuildChildList(); } private void RebuildChildList() { _childList = ((_border == null) ? Array.Empty() : new CanvasNode[1] { _border }); } protected override IEnumerable ChildList() { return _childList; } protected override void OnUpdateSize() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) base.OnUpdateSize(); if (_border != null) { _border.Size = base.Size; } } public override void Build(Transform? rootParent = null) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (IsBackground && base.Parent != null) { base.Size = base.Parent.Size; } base.Build(rootParent); Image obj = base.GameObject.AddComponent(); obj.sprite = _ui.SolidSprite; ((Graphic)obj).color = _tint; if (IsBackground) { CanvasGroup component = base.GameObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.blocksRaycasts = true; } } } private void ApplyTint() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) Image component = base.GameObject.GetComponent(); if ((Object)(object)component != (Object)null) { ((Graphic)component).color = _tint; } } } internal abstract class CanvasNode { private CanvasNode? _parent; private Vector2 _localPosition; private Vector2 _size; private bool _activeSelf = true; protected GameObject? gameObject; protected RectTransform? transform; private EventTrigger? _eventTrigger; public string Name { get; } public CanvasNode? Parent { get { return _parent; } set { if (_parent != value) { _parent = value; OnUpdateParent(); } } } public Vector2 LocalPosition { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _localPosition; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (_localPosition != value) { _localPosition = value; OnUpdateLocalPosition(); } } } public Vector2 Position => LocalPosition + (Parent?.Position ?? Vector2.zero); public Vector2 Size { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _size; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (_size != value) { _size = value; OnUpdateSize(); } } } public bool ActiveSelf { get { return _activeSelf; } set { if (_activeSelf != value) { _activeSelf = value; OnUpdateActive(); } } } public bool ActiveInHierarchy { get { if (ActiveSelf) { return Parent?.ActiveInHierarchy ?? true; } return false; } } public GameObject? GameObject => gameObject; protected virtual bool Interactable => true; public event Action? OnUpdate; protected CanvasNode(string name) { Name = name; } protected virtual IEnumerable ChildList() { return Array.Empty(); } public void CollectSubtree(List results) { results.Add(this); foreach (CanvasNode item in ChildList()) { item.CollectSubtree(results); } } protected virtual void OnUpdateLocalPosition() { if ((Object)(object)gameObject != (Object)null) { UpdateAnchoredPosition(); } } protected virtual void OnUpdateSize() { if ((Object)(object)gameObject != (Object)null) { UpdateSizeDelta(); UpdateClipRect(); } } protected virtual void OnUpdateActive() { if ((Object)(object)gameObject != (Object)null) { gameObject.SetActive(ActiveSelf); } } protected virtual void OnUpdateParent() { if ((Object)(object)gameObject != (Object)null) { gameObject.transform.SetParent(GetParentTransform(null), false); UpdateClipRect(); } OnUpdateActive(); } public virtual void Build(Transform? rootParent = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) gameObject = new GameObject(Name); gameObject.transform.SetParent(GetParentTransform(rootParent), false); gameObject.AddComponent(); transform = gameObject.AddComponent(); RectTransform? obj = transform; RectTransform? obj2 = transform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); obj2.anchorMax = val; obj.anchorMin = val; transform.pivot = new Vector2(0f, 1f); if (!Interactable) { CanvasGroup obj3 = gameObject.AddComponent(); obj3.interactable = false; obj3.blocksRaycasts = false; } gameObject.SetActive(ActiveSelf); UpdateAnchoredPosition(); UpdateSizeDelta(); UpdateClipRect(); foreach (CanvasNode item in ChildList()) { item.Build(); } } private Transform GetParentTransform(Transform? rootParent) { if (Parent != null) { return Parent.GameObject.transform; } if ((Object)(object)rootParent != (Object)null) { return rootParent; } throw new InvalidOperationException("Root node '" + Name + "' has no Parent and no root transform was supplied to Build()."); } private void UpdateAnchoredPosition() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) transform.anchoredPosition = new Vector2(LocalPosition.x, 0f - LocalPosition.y); } private void UpdateSizeDelta() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) transform.sizeDelta = Size; } protected virtual bool GetClipRect(out Rect clipRect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) clipRect = default(Rect); return false; } private bool ShouldClip(out Rect clipRect) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) bool clipRect2 = GetClipRect(out clipRect); if (Parent != null && Parent.ShouldClip(out var clipRect3)) { clipRect = (clipRect2 ? Intersect(clipRect, clipRect3) : clipRect3); return true; } return clipRect2; } private void UpdateClipRect() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gameObject == (Object)null)) { CanvasRenderer component = gameObject.GetComponent(); component.DisableRectClipping(); if (ShouldClip(out var clipRect)) { component.EnableRectClipping(clipRect); } } } private static Rect Intersect(Rect a, Rect b) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(((Rect)(ref a)).xMin, ((Rect)(ref b)).xMin); float num2 = Mathf.Max(((Rect)(ref a)).yMin, ((Rect)(ref b)).yMin); float num3 = Mathf.Min(((Rect)(ref a)).xMax, ((Rect)(ref b)).xMax); float num4 = Mathf.Min(((Rect)(ref a)).yMax, ((Rect)(ref b)).yMax); return new Rect(num, num2, Mathf.Max(0f, num3 - num), Mathf.Max(0f, num4 - num2)); } public void Update() { this.OnUpdate?.Invoke(); } public virtual void Destroy() { ActiveSelf = false; this.OnUpdate = null; foreach (CanvasNode item in ChildList()) { item.Destroy(); } if ((Object)(object)gameObject != (Object)null) { Object.Destroy((Object)(object)gameObject); gameObject = null; } } public bool IsMouseOver() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return IsPointOver(Vector2.op_Implicit(Input.mousePosition)); } public bool IsPointOver(Vector2 screenPoint) { //IL_0003: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) Rect a = default(Rect); ((Rect)(ref a))..ctor(Position.x, (float)Screen.height - Position.y - Size.y, Size.x, Size.y); if (ShouldClip(out var clipRect)) { ((Rect)(ref clipRect))..ctor(((Rect)(ref clipRect)).position + new Vector2((float)Screen.width / 2f, (float)Screen.height / 2f), ((Rect)(ref clipRect)).size); a = Intersect(a, clipRect); } ((Rect)(ref a)).x = ((Rect)(ref a)).x - 1f; ((Rect)(ref a)).y = ((Rect)(ref a)).y - 1f; ((Rect)(ref a)).width = ((Rect)(ref a)).width + 2f; ((Rect)(ref a)).height = ((Rect)(ref a)).height + 2f; return ((Rect)(ref a)).Contains(screenPoint); } public void AddEventTrigger(EventTriggerType type, Action callback) where T : BaseEventData { //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_0055: 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_005c: Expected O, but got Unknown if ((Object)(object)gameObject == (Object)null) { throw new InvalidOperationException("Cannot add an event trigger to '" + Name + "' before Build() has run."); } if (_eventTrigger == null) { _eventTrigger = gameObject.AddComponent(); } Entry val = new Entry { eventID = type }; ((UnityEvent)(object)val.callback).AddListener((UnityAction)delegate(BaseEventData data) { callback((T)(object)data); }); _eventTrigger.triggers.Add(val); } public void AddEventTrigger(EventTriggerType type, Action callback) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) this.AddEventTrigger(type, callback); } } internal class CanvasPanel : CanvasNode { private readonly List _elements = new List(); private readonly Dictionary _byName = new Dictionary(); internal static int StructureVersion { get; private set; } public CanvasPanel(string name) : base(name) { } protected override IEnumerable ChildList() { return _elements; } public T Add(T element) where T : CanvasNode { element.Parent = this; _elements.Add(element); _byName[element.Name] = element; StructureVersion++; return element; } public T? Get(string name) where T : CanvasNode { if (!_byName.TryGetValue(name, out CanvasNode value)) { return null; } return value as T; } public void Remove(CanvasNode element) { _elements.Remove(element); _byName.Remove(element.Name); StructureVersion++; } public void ClearChildren() { foreach (CanvasNode element in _elements) { element.Destroy(); } _elements.Clear(); _byName.Clear(); StructureVersion++; } public override void Destroy() { base.Destroy(); _elements.Clear(); _byName.Clear(); } } internal sealed class CanvasResizeHandle : CanvasButton { public event Action? OnDragDelta; public event Action? OnDragEnd; public CanvasResizeHandle(string name, UICommon ui) : base(name, ui) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) base.Tint = ui.AccentColor; } public override void Build(Transform? rootParent = null) { base.Build(rootParent); AddEventTrigger((EventTriggerType)5, delegate(PointerEventData e) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) this.OnDragDelta?.Invoke(e.delta); }); AddEventTrigger((EventTriggerType)14, delegate { this.OnDragEnd?.Invoke(); }); } } internal sealed class CanvasScrollbar : CanvasNode { private const float MinGripHeight = 24f; private readonly CanvasButton _dragSurface; private readonly CanvasImage _grip; private readonly CanvasNode[] _childList; public CanvasScrollView? ScrollView { get; set; } protected override bool Interactable => true; public bool ShouldBeVisible { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (ScrollView?.Content != null) { return ScrollView.Content.Size.y > base.Size.y; } return false; } } public CanvasScrollbar(string name, UICommon ui) : base(name) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) _dragSurface = new CanvasButton("DragSurface", ui) { Tint = ui.ScrollTrackColor }; _dragSurface.RemoveBorder(); _dragSurface.Parent = this; _grip = new CanvasImage("Grip", ui) { Tint = ui.PanelBorder }; _grip.AddBorder(ui.AccentColor); _grip.Parent = this; _childList = new CanvasNode[2] { _dragSurface, _grip }; base.OnUpdate += Refresh; } protected override IEnumerable ChildList() { return _childList; } protected override void OnUpdateSize() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) base.OnUpdateSize(); _dragSurface.Size = base.Size; } public override void Build(Transform? rootParent = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _dragSurface.Size = base.Size; base.Build(rootParent); _dragSurface.OnClicked += OnTrackClicked; _dragSurface.AddEventTrigger((EventTriggerType)5, OnDragged); } private void OnTrackClicked() { //IL_000f: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0045: Unknown result type (might be due to invalid IL or missing references) if (ScrollView != null) { float num = (float)Screen.height - Input.mousePosition.y; if (!(num >= _grip.Position.y) || !(num <= _grip.Position.y + _grip.Size.y)) { float num2 = Mathf.Max(1f, base.Size.y - _grip.Size.y); float num3 = Mathf.Clamp(num - base.Position.y - _grip.Size.y / 2f, 0f, num2); ScrollView.SetScrollPercentage(num3 / num2); } } } private void OnDragged(PointerEventData eventData) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0041: Unknown result type (might be due to invalid IL or missing references) if (ScrollView != null) { float num = Mathf.Max(1f, base.Size.y - _grip.Size.y); float num2 = Mathf.Clamp(_grip.LocalPosition.y - eventData.delta.y, 0f, num); ScrollView.SetScrollPercentage(num2 / num); } } private void Refresh() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (ScrollView?.Content != null) { float y = ScrollView.Content.Size.y; float num = Mathf.Clamp(base.Size.y * base.Size.y / Mathf.Max(1f, y), 24f, base.Size.y); _grip.Size = new Vector2(base.Size.x, num); float scrollableHeight = ScrollView.GetScrollableHeight(); float num2 = ((scrollableHeight > 0f) ? Mathf.Clamp01((0f - ScrollView.Content.LocalPosition.y) / scrollableHeight) : 0f); _grip.LocalPosition = new Vector2(0f, num2 * (base.Size.y - num)); } } } internal sealed class CanvasScrollView : CanvasNode, IHorizontalScrollSource { private const float ScrollSpeed = 30f; private CanvasNode? _content; private float _contentHeightAtLastCheck; private float _contentWidthAtLastCheck; private CanvasNode[] _childList = Array.Empty(); public CanvasNode? Content => _content; public CanvasScrollView(string name) : base(name) { base.OnUpdate += Poll; } public T SetContent(T content) where T : CanvasNode { _content = content; content.Parent = this; _childList = new CanvasNode[1] { content }; return content; } protected override IEnumerable ChildList() { return _childList; } public override void Build(Transform? rootParent = null) { base.Build(rootParent); base.GameObject.AddComponent(); } private void Poll() { //IL_000f: 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_002c: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) if (_content != null) { if (!Mathf.Approximately(_content.Size.y, _contentHeightAtLastCheck)) { float num = Mathf.Clamp(_content.LocalPosition.y, Mathf.Min(0f - GetScrollableHeight(), 0f), 0f); _content.LocalPosition = new Vector2(_content.LocalPosition.x, num); _contentHeightAtLastCheck = _content.Size.y; } if (!Mathf.Approximately(_content.Size.x, _contentWidthAtLastCheck)) { float num2 = Mathf.Clamp(_content.LocalPosition.x, Mathf.Min(0f - GetScrollableWidth(), 0f), 0f); _content.LocalPosition = new Vector2(num2, _content.LocalPosition.y); _contentWidthAtLastCheck = _content.Size.x; } if (!Mathf.Approximately(Input.mouseScrollDelta.y, 0f) && IsMouseOver()) { float num3 = _content.LocalPosition.y + Input.mouseScrollDelta.y * 30f; num3 = Mathf.Clamp(num3, Mathf.Min(0f - GetScrollableHeight(), 0f), 0f); _content.LocalPosition = new Vector2(_content.LocalPosition.x, num3); } } } public void SetScrollPercentage(float percentage) { //IL_001d: 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) if (_content != null) { percentage = Mathf.Clamp01(percentage); _content.LocalPosition = new Vector2(_content.LocalPosition.x, (0f - percentage) * GetScrollableHeight()); } } public void ScrollToShow(float y, float height) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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 (_content != null) { float scrollableHeight = GetScrollableHeight(); float num = 0f - _content.LocalPosition.y; float y2 = base.Size.y; float num2 = num; if (y < num) { num2 = y; } else if (y + height > num + y2) { num2 = y + height - y2; } num2 = Mathf.Clamp(num2, 0f, scrollableHeight); _content.LocalPosition = new Vector2(_content.LocalPosition.x, 0f - num2); } } public float GetScrollableHeight() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(0f, (_content?.Size.y ?? 0f) - base.Size.y); } public float GetScrollableWidth() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(0f, (_content?.Size.x ?? 0f) - base.Size.x); } void IHorizontalScrollSource.SetScrollPercentage(float percentage) { //IL_0026: 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) if (_content != null) { percentage = Mathf.Clamp01(percentage); _content.LocalPosition = new Vector2((0f - percentage) * GetScrollableWidth(), _content.LocalPosition.y); } } } internal sealed class CanvasSectionBlock : CanvasImage { private readonly UICommon _ui; private bool _selected; protected override bool Interactable => true; public bool Selected { get { return _selected; } set { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) _selected = value; base.Tint = (_selected ? _ui.SectionBlockSelectedColor : _ui.SectionBlockColor); } } public event Action? OnClicked; public CanvasSectionBlock(string name, UICommon ui) : base(name, ui) { //IL_0011: 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) _ui = ui; base.Tint = ui.SectionBlockColor; AddBorder(ui.PanelBorder); } public override void Build(Transform? rootParent = null) { base.Build(rootParent); AddEventTrigger((EventTriggerType)4, delegate { this.OnClicked?.Invoke(); }); } } internal class CanvasText : CanvasNode { protected Text? _uiText; private readonly UICommon _ui; private string _text = ""; private Font? _font; private int _fontSize; private TextAnchor _alignment = (TextAnchor)3; private Color _color; private HorizontalWrapMode _overflow; private FontStyle _fontStyle; public Text? TextComponent => _uiText; protected override bool Interactable => false; public string Text { get { return _text; } set { _text = value; if ((Object)(object)_uiText != (Object)null) { _uiText.text = value; } } } public TextAnchor Alignment { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _alignment; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _alignment = value; if ((Object)(object)_uiText != (Object)null) { _uiText.alignment = value; } } } public Color Color { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _color; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _color = value; if ((Object)(object)_uiText != (Object)null) { ((Graphic)_uiText).color = value; } } } public int FontSize { get { return _fontSize; } set { _fontSize = value; if ((Object)(object)_uiText != (Object)null) { _uiText.fontSize = value; } } } public HorizontalWrapMode Overflow { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _overflow; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _overflow = value; if ((Object)(object)_uiText != (Object)null) { _uiText.horizontalOverflow = value; } } } public Font? Font { get { return _font; } set { _font = value; if ((Object)(object)_uiText != (Object)null) { _uiText.font = value; } } } public FontStyle FontStyle { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _fontStyle; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _fontStyle = value; if ((Object)(object)_uiText != (Object)null) { _uiText.fontStyle = value; } } } public CanvasText(string name, UICommon ui) : base(name) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) _ui = ui; _font = ui.BodyFont; _fontSize = ui.FontSize; _color = ui.TextColor; base.OnUpdate += SyncFontSizeToScale; } private void SyncFontSizeToScale() { if (_fontSize != _ui.FontSize) { FontSize = _ui.FontSize; } } public override void Build(Transform? rootParent = null) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) base.Build(rootParent); _uiText = base.GameObject.AddComponent(); _uiText.text = _text; _uiText.font = _font; _uiText.fontSize = _fontSize; _uiText.fontStyle = _fontStyle; _uiText.alignment = _alignment; ((Graphic)_uiText).color = _color; _uiText.horizontalOverflow = _overflow; _uiText.verticalOverflow = (VerticalWrapMode)1; } } internal sealed class CanvasTextField : CanvasNode { private readonly UICommon _ui; private readonly InteractiveLabel _label; private readonly CanvasNode[] _childList; private InputField? _inputField; private Color _baseColor; private bool _submittedThisEdit; private static bool s_resolutionAttempted; private static PropertyInfo? s_inputManagerEnabled; public static bool AnyFieldFocused { get; private set; } protected override bool Interactable => true; public string Text { get { return _label.Text; } set { _label.Text = value; } } public Color Color { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _baseColor; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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) _baseColor = value; _label.Color = value; } } public HorizontalWrapMode Overflow { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _label.Overflow; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _label.Overflow = value; } } public Text? TextComponent => _label.TextComponent; public event Action? OnSubmit; public CanvasTextField(string name, UICommon ui) : base(name) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) _ui = ui; _label = new InteractiveLabel("Label", ui); _label.Parent = this; _baseColor = _label.Color; _childList = new CanvasNode[1] { _label }; base.OnUpdate += UpdateSelectionTextColor; } private void UpdateSelectionTextColor() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_inputField == (Object)null)) { bool flag = IsFocused() && _inputField.selectionAnchorPosition != _inputField.selectionFocusPosition; _label.Color = (flag ? Color.black : _baseColor); } } protected override IEnumerable ChildList() { return _childList; } protected override void OnUpdateSize() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) base.OnUpdateSize(); _label.Size = base.Size; } public override void Build(Transform? rootParent = null) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) base.Build(rootParent); _inputField = base.GameObject.AddComponent(); _inputField.textComponent = _label.TextComponent; ((Selectable)_inputField).transition = (Transition)0; ((Behaviour)_inputField).enabled = false; _inputField.selectionColor = _ui.SelectionColor; _inputField.customCaretColor = true; _inputField.caretColor = _ui.CaretColor; _inputField.caretWidth = (byte)Mathf.Max(1, UICommon.ScaleWidth(2)); ((UnityEvent)(object)_inputField.onSubmit).AddListener((UnityAction)delegate(string text) { _submittedThisEdit = true; Text = text; this.OnSubmit?.Invoke(text); }); ((UnityEvent)(object)_inputField.onEndEdit).AddListener((UnityAction)delegate { ((Behaviour)_inputField).enabled = false; if (!_submittedThisEdit) { string obj = (Text = _inputField.text); this.OnSubmit?.Invoke(obj); } _submittedThisEdit = false; AnyFieldFocused = false; TrySetInputLocked(locked: false); }); AddEventTrigger((EventTriggerType)2, delegate { if (!IsFocused()) { Activate(); } }); } public void Activate() { if (!((Object)(object)_inputField == (Object)null)) { _inputField.text = Text; ((Behaviour)_inputField).enabled = true; ((Selectable)_inputField).Select(); AnyFieldFocused = true; TrySetInputLocked(locked: true); _inputField.caretPosition = _inputField.text.Length; } } public void UpdateDefaultText(string text) { if (!IsFocused()) { Text = text; if ((Object)(object)_inputField != (Object)null) { _inputField.text = text; } } } public bool IsFocused() { if ((Object)(object)_inputField != (Object)null) { return ((Behaviour)_inputField).enabled; } return false; } public override void Destroy() { if (IsFocused()) { AnyFieldFocused = false; TrySetInputLocked(locked: false); } base.Destroy(); } public static void ForceReleaseFocus() { if (AnyFieldFocused) { AnyFieldFocused = false; TrySetInputLocked(locked: false); } } private static void TrySetInputLocked(bool locked) { if (!s_resolutionAttempted) { s_resolutionAttempted = true; try { s_inputManagerEnabled = Type.GetType("InControl.InputManager, InControl")?.GetProperty("enabled", BindingFlags.Static | BindingFlags.Public); } catch { s_inputManagerEnabled = null; } } if (s_inputManagerEnabled == null) { return; } try { s_inputManagerEnabled.SetValue(null, !locked); } catch { s_inputManagerEnabled = null; } } } internal sealed class InteractiveLabel : CanvasText { protected override bool Interactable => true; public InteractiveLabel(string name, UICommon ui) : base(name, ui) { } } [HarmonyPatch(typeof(HollowKnightInputModule), "ProcessMove")] internal static class FocusOnHoverSuppressionPatch { [HarmonyPrefix] private static void Prefix(HollowKnightInputModule __instance, out bool __state) { __state = __instance.focusOnMouseHover; if (CanvasTextField.AnyFieldFocused) { __instance.focusOnMouseHover = false; } } [HarmonyPostfix] private static void Postfix(HollowKnightInputModule __instance, bool __state) { __instance.focusOnMouseHover = __state; } } internal sealed class CanvasToggleDot : CanvasNode { private readonly UICommon _ui; private Image? _image; private bool _on; protected override bool Interactable => true; public bool On { get { return _on; } set { _on = value; if ((Object)(object)_image != (Object)null) { _image.sprite = (_on ? _ui.DotFilledSprite : _ui.DotRingSprite); } } } public event Action? OnClicked; public CanvasToggleDot(string name, UICommon ui) : base(name) { _ui = ui; } public override void Build(Transform? rootParent = null) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) base.Build(rootParent); _image = base.GameObject.AddComponent(); _image.sprite = (_on ? _ui.DotFilledSprite : _ui.DotRingSprite); ((Graphic)_image).color = _ui.AccentColor; AddEventTrigger((EventTriggerType)4, delegate { this.OnClicked?.Invoke(); }); } } internal sealed class PanelBuilder { private sealed class Entry { public readonly CanvasNode? Element; public readonly LengthType Type; public readonly float Length; public Entry(CanvasNode? element, LengthType type, float length) { Element = element; Type = type; Length = length; } } private enum LengthType { Fixed, Square, Flex } private readonly CanvasPanel _panel; private readonly ManualLogSource? _logger; private readonly List _entries = new List(); public bool Horizontal { get; set; } public bool DynamicLength { get; set; } public float OuterPadding { get; set; } public float InnerPadding { get; set; } public PanelBuilder(CanvasPanel panel, ManualLogSource? logger = null) { _panel = panel; _logger = logger; } public T AppendFixed(T element, float length) where T : CanvasNode { return Append(element, LengthType.Fixed, length); } public T AppendSquare(T element) where T : CanvasNode { return Append(element, LengthType.Square); } public T AppendFlex(T element) where T : CanvasNode { return Append(element, LengthType.Flex); } public void AppendPadding(float length) { Append(null, LengthType.Fixed, length); } private T Append(T? element, LengthType type, float length = 0f) where T : CanvasNode { //IL_0054: 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) _entries.Add(new Entry(element, type, length)); if (element != null) { _panel.Add(element); float num = ChildBreadth(); if (type == LengthType.Square) { length = num; } element.Size = (Horizontal ? new Vector2(length, num) : new Vector2(num, length)); } return element; } public void Build() { //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) float num = OuterPadding * 2f + InnerPadding * (float)Mathf.Max(0, _entries.Count - 1); int num2 = 0; foreach (Entry entry in _entries) { switch (entry.Type) { case LengthType.Fixed: num += entry.Length; break; case LengthType.Square: num += ChildBreadth(); break; case LengthType.Flex: num2++; break; } } float num3 = 0f; if (num2 > 0) { num3 = (Length() - num) / (float)num2; if (Length() < num) { ManualLogSource? logger = _logger; if (logger != null) { logger.LogWarning((object)("[FsmMaster] PanelBuilder: '" + _panel.Name + "' has no room for flex elements; using 0 length.")); } num3 = 0f; } } float num4 = OuterPadding; foreach (Entry entry2 in _entries) { float num5 = entry2.Type switch { LengthType.Square => ChildBreadth(), LengthType.Flex => num3, _ => entry2.Length, }; if (entry2.Element != null) { float num6 = OuterPadding; float num7 = num4; float num8 = ChildBreadth(); float num9 = num5; if (Horizontal) { float num10 = num7; float num11 = num6; float num12 = num9; num9 = num8; num8 = num12; num7 = num11; num6 = num10; } entry2.Element.LocalPosition = new Vector2(num6, num7); entry2.Element.Size = new Vector2(num8, num9); } num4 += num5 + InnerPadding; } num4 -= InnerPadding; num4 += OuterPadding; if (DynamicLength) { _panel.Size = (Horizontal ? new Vector2(num4, _panel.Size.y) : new Vector2(_panel.Size.x, num4)); } } private float Length() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Horizontal) { return _panel.Size.y; } return _panel.Size.x; } private float Breadth() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Horizontal) { return _panel.Size.x; } return _panel.Size.y; } private float ChildBreadth() { return Breadth() - OuterPadding * 2f; } } internal sealed class UICommon { public Texture2D SolidTexture { get; } public Sprite SolidSprite { get; } public Texture2D DotFilledTexture { get; } public Sprite DotFilledSprite { get; } public Texture2D DotRingTexture { get; } public Sprite DotRingSprite { get; } public Font? BodyFont { get; } public Font? HeaderFont { get; } public Color PanelBackground { get; } = new Color(0.10980392f, 0.11764706f, 12f / 85f, 0.92f); public Color PanelBorder { get; } = new Color(14f / 51f, 0.2901961f, 28f / 85f, 1f); public Color ButtonNormal { get; } = new Color(14f / 85f, 0.1764706f, 0.20784314f, 0.95f); public Color ButtonActive { get; } = new Color(0.22745098f, 0.38431373f, 0.5882353f, 0.95f); public Color AccentColor { get; } = new Color(0.47058824f, 2f / 3f, 47f / 51f, 1f); public Color TextColor { get; } = new Color(46f / 51f, 46f / 51f, 47f / 51f, 1f); public Color ScrollTrackColor { get; } = new Color(10f / 51f, 0.20784314f, 0.23921569f, 0.6f); public Color SelectionColor { get; } = new Color(0.47058824f, 2f / 3f, 47f / 51f, 1f); public Color CaretColor { get; } = new Color(0.47058824f, 2f / 3f, 47f / 51f, 1f); public Color TypeBadgeColor { get; } = new Color(22f / 51f, 0.76862746f, 0.7137255f, 1f); public Color NumericValueColor { get; } = new Color(28f / 51f, 38f / 51f, 0.88235295f, 1f); public Color StringValueColor { get; } = new Color(0.8235294f, 32f / 51f, 0.47058824f, 1f); public Color ReadOnlyColor { get; } = new Color(28f / 51f, 28f / 51f, 29f / 51f, 0.75f); public Color SectionBlockColor { get; } = new Color(12f / 85f, 13f / 85f, 0.18039216f, 0.5f); public Color SectionBlockSelectedColor { get; } = new Color(0.22745098f, 0.24313726f, 24f / 85f, 0.75f); public Color HiddenFieldLabelColor { get; } = new Color(2f / 3f, 29f / 51f, 0.8235294f, 0.9f); public Color SuccessColor { get; } = new Color(26f / 51f, 41f / 51f, 28f / 51f, 1f); public Color ErrorColor { get; } = new Color(0.88235295f, 0.47058824f, 0.47058824f, 1f); public int FontSize => ScaleHeight(13); public int HeaderFontSize => ScaleHeight(15); public float DotSize => FontSize; public UICommon() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0053: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01cc: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) SolidTexture = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; SolidTexture.SetPixel(0, 0, Color.white); SolidTexture.Apply(); SolidSprite = Sprite.Create(SolidTexture, new Rect(0f, 0f, 1f, 1f), Vector2.zero); ((Object)SolidSprite).hideFlags = (HideFlags)61; (Texture2D, Sprite, Texture2D, Sprite) tuple = CreateDotSprites(); DotFilledTexture = tuple.Item1; DotFilledSprite = tuple.Item2; DotRingTexture = tuple.Item3; DotRingSprite = tuple.Item4; BodyFont = Resources.GetBuiltinResource("Arial.ttf"); HeaderFont = FindLoadedFont("TrajanPro-Bold") ?? BodyFont; } private static (Texture2D FilledTexture, Sprite FilledSprite, Texture2D RingTexture, Sprite RingSprite) CreateDotSprites() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(24, 24) { hideFlags = (HideFlags)61 }; Texture2D val2 = new Texture2D(24, 24) { hideFlags = (HideFlags)61 }; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(12f, 12f); float num = 11f; for (int i = 0; i < 24; i++) { for (int j = 0; j < 24; j++) { float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), val3); float num3 = Mathf.Clamp01(num - num2 + 1f); float num4 = ((num2 <= num && num2 >= num - 2.5f) ? 1f : 0f); val.SetPixel(j, i, new Color(1f, 1f, 1f, num3)); val2.SetPixel(j, i, new Color(1f, 1f, 1f, num4)); } } val.Apply(); val2.Apply(); Sprite val4 = Sprite.Create(val, new Rect(0f, 0f, 24f, 24f), new Vector2(0.5f, 0.5f)); ((Object)val4).hideFlags = (HideFlags)61; Sprite val5 = Sprite.Create(val2, new Rect(0f, 0f, 24f, 24f), new Vector2(0.5f, 0.5f)); ((Object)val5).hideFlags = (HideFlags)61; return (FilledTexture: val, FilledSprite: val4, RingTexture: val2, RingSprite: val5); } private static Font? FindLoadedFont(string name) { Font[] array = Resources.FindObjectsOfTypeAll(); foreach (Font val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name == name) { return val; } } return null; } public static int ScaleWidth(int unscaled) { return Mathf.RoundToInt((float)(unscaled * Screen.width) / 1920f); } public static int ScaleHeight(int unscaled) { return Mathf.RoundToInt((float)(unscaled * Screen.height) / 1080f); } public static float ScaleWidth(float unscaled) { return unscaled * (float)Screen.width / 1920f; } public static float ScaleHeight(float unscaled) { return unscaled * (float)Screen.height / 1080f; } public void Destroy() { if ((Object)(object)SolidSprite != (Object)null) { Object.Destroy((Object)(object)SolidSprite); } if ((Object)(object)SolidTexture != (Object)null) { Object.Destroy((Object)(object)SolidTexture); } if ((Object)(object)DotFilledSprite != (Object)null) { Object.Destroy((Object)(object)DotFilledSprite); } if ((Object)(object)DotFilledTexture != (Object)null) { Object.Destroy((Object)(object)DotFilledTexture); } if ((Object)(object)DotRingSprite != (Object)null) { Object.Destroy((Object)(object)DotRingSprite); } if ((Object)(object)DotRingTexture != (Object)null) { Object.Destroy((Object)(object)DotRingTexture); } } } internal sealed class FsmPanelLayoutConfig { private const string Section = "UI Layout"; private static readonly Vector2 Unset = new Vector2(-1f, -1f); public ConfigEntry Position { get; } public ConfigEntry Size { get; } public bool HasSavedPosition { get { //IL_0006: 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) if (Position.Value.x >= 0f) { return Position.Value.y >= 0f; } return false; } } public bool HasSavedSize { get { //IL_0006: 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) if (Size.Value.x >= 0f) { return Size.Value.y >= 0f; } return false; } } private FsmPanelLayoutConfig(ConfigEntry position, ConfigEntry size) { Position = position; Size = size; } public static FsmPanelLayoutConfig Bind(ConfigFile config, string panelName) { //IL_0023: 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) //IL_004d: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Browsable = false }; ConfigEntry position = config.Bind("UI Layout", panelName + " Position", Unset, new ConfigDescription("Saved screen position of the " + panelName + ", in pixels from the top-left. (-1, -1) means no saved position yet.", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); ConfigEntry size = config.Bind("UI Layout", panelName + " Size", Unset, new ConfigDescription("Saved size of the " + panelName + ", in pixels. (-1, -1) means no saved size yet.", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); return new FsmPanelLayoutConfig(position, size); } } internal sealed class FsmGraphColorConfig { private const string StateSection = "Graph Colors - State Palette"; private const string TransitionSection = "Graph Colors - Transition Palette"; private const string OverlaySection = "Graph Colors - Overlay"; public ConfigEntry[] StateColors { get; } public ConfigEntry[] TransitionColors { get; } public ConfigEntry GlobalTransitionColor { get; } public ConfigEntry VignetteColor { get; } public ConfigEntry GlobalPseudoNodeColor { get; } public ConfigEntry GlobalPseudoNodeOutlineColor { get; } public ConfigEntry GlobalPseudoNodeTextColor { get; } public ConfigEntry NodeOutlineColor { get; } public ConfigEntry TransitionRowBackgroundColor { get; } public ConfigEntry ActiveStateColor { get; } public ConfigEntry ActiveTitleBackgroundColor { get; } public ConfigEntry ActiveTitleTextColor { get; } public ConfigEntry SelectedStateColor { get; } public ConfigEntry DisabledOutlineColor { get; } public ConfigEntry DisabledTitleTextColor { get; } public ConfigEntry DisabledEventTextColor { get; } public ConfigEntry DisabledTransitionLineColor { get; } public ConfigEntry DragTransitionColor { get; } private FsmGraphColorConfig(ConfigEntry[] stateColors, ConfigEntry[] transitionColors, ConfigEntry globalTransitionColor, ConfigEntry vignetteColor, ConfigEntry globalPseudoNodeColor, ConfigEntry globalPseudoNodeOutlineColor, ConfigEntry globalPseudoNodeTextColor, ConfigEntry nodeOutlineColor, ConfigEntry transitionRowBackgroundColor, ConfigEntry activeStateColor, ConfigEntry activeTitleBackgroundColor, ConfigEntry activeTitleTextColor, ConfigEntry selectedStateColor, ConfigEntry disabledOutlineColor, ConfigEntry disabledTitleTextColor, ConfigEntry disabledEventTextColor, ConfigEntry disabledTransitionLineColor, ConfigEntry dragTransitionColor) { StateColors = stateColors; TransitionColors = transitionColors; GlobalTransitionColor = globalTransitionColor; VignetteColor = vignetteColor; GlobalPseudoNodeColor = globalPseudoNodeColor; GlobalPseudoNodeOutlineColor = globalPseudoNodeOutlineColor; GlobalPseudoNodeTextColor = globalPseudoNodeTextColor; NodeOutlineColor = nodeOutlineColor; TransitionRowBackgroundColor = transitionRowBackgroundColor; ActiveStateColor = activeStateColor; ActiveTitleBackgroundColor = activeTitleBackgroundColor; ActiveTitleTextColor = activeTitleTextColor; SelectedStateColor = selectedStateColor; DisabledOutlineColor = disabledOutlineColor; DisabledTitleTextColor = disabledTitleTextColor; DisabledEventTextColor = disabledEventTextColor; DisabledTransitionLineColor = disabledTransitionLineColor; DragTransitionColor = dragTransitionColor; } public static FsmGraphColorConfig Bind(ConfigFile config) { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[8] { new Color(0.5019608f, 0.5019608f, 0.5019608f), new Color(67f / 85f, 0.45490196f, 0.6784314f), new Color(0.22745098f, 0.7137255f, 0.6509804f), new Color(31f / 85f, 0.6431373f, 0.20784314f), new Color(0.88235295f, 0.99607843f, 10f / 51f), new Color(47f / 51f, 0.5137255f, 0.18039216f), new Color(11f / 15f, 0.29411766f, 0.29411766f), new Color(39f / 85f, 0.20784314f, 0.6431373f) }; Color[] array2 = (Color[])(object)new Color[8] { Color.white, new Color(0.972549f, 0.77254903f, 77f / 85f), new Color(53f / 85f, 0.88235295f, 72f / 85f), new Color(61f / 85f, 0.88235295f, 53f / 85f), new Color(0.88235295f, 0.99607843f, 0.4f), new Color(1f, 66f / 85f, 0.59607846f), new Color(0.88235295f, 53f / 85f, 32f / 51f), new Color(0.77254903f, 53f / 85f, 0.88235295f) }; ConfigEntry[] array3 = new ConfigEntry[array.Length]; for (int i = 0; i < array.Length; i++) { array3[i] = BindColor(config, "Graph Colors - State Palette", $"State Color {i}", array[i], $"Fill color for a state whose FsmState.ColorIndex is {i} (colorIndex 0 is PlayMaker's \"no color set\" default)."); } ConfigEntry[] array4 = new ConfigEntry[array2.Length]; for (int j = 0; j < array2.Length; j++) { array4[j] = BindColor(config, "Graph Colors - Transition Palette", $"Transition Color {j}", array2[j], $"Transition name/line color for a state whose FsmState.ColorIndex is {j}."); } Color val = default(Color); ((Color)(ref val))..ctor(0f, 1f, 1f); return new FsmGraphColorConfig(array3, array4, BindColor(config, "Graph Colors - Overlay", "Global Transition Color", new Color(0.6f, 0.6f, 0.6f), "Line color for a global transition's connecting arrow."), BindColor(config, "Graph Colors - Overlay", "Vignette Color", new Color(0f, 0f, 0f, 0.6f), "Dimming fill drawn over the graph wherever the selection panel isn't."), BindColor(config, "Graph Colors - Overlay", "Global Pseudo Node Color", new Color(0.82f, 0.82f, 0.82f), "Fill color of a global transition's pseudo-node box."), BindColor(config, "Graph Colors - Overlay", "Global Pseudo Node Outline Color", Color.black, "Outline color of a global transition's pseudo-node box."), BindColor(config, "Graph Colors - Overlay", "Global Pseudo Node Text Color", Color.black, "Event label color on a global transition's pseudo-node box."), BindColor(config, "Graph Colors - Overlay", "Node Outline Color", Color.white, "Default (non-active, non-disabled) inner ring and title/row divider color on a state node."), BindColor(config, "Graph Colors - Overlay", "Transition Row Background Color", new Color(0.2f, 0.2f, 0.2f), "Background color of a state's transition rows."), BindColor(config, "Graph Colors - Overlay", "Active State Color", val, "Outer halo, inner-ring fallback, and outgoing-line color for the FSM's currently active state."), BindColor(config, "Graph Colors - Overlay", "Active Title Background Color", Color.Lerp(val, Color.white, 0.5f), "Title band background for the currently active state."), BindColor(config, "Graph Colors - Overlay", "Active Title Text Color", Color.black, "Title text color for the currently active state."), BindColor(config, "Graph Colors - Overlay", "Selected State Color", Color.yellow, "Outline and outgoing-line color for whichever state is currently selected."), BindColor(config, "Graph Colors - Overlay", "Disabled Outline Color", new Color(0.5f, 0.5f, 0.5f), "Inner ring and title/row divider color for a disabled state."), BindColor(config, "Graph Colors - Overlay", "Disabled Title Text Color", new Color(0.75f, 0.75f, 0.75f), "Title text color for a disabled state."), BindColor(config, "Graph Colors - Overlay", "Disabled Event Text Color", Color.black, "Transition row text color for a disabled state."), BindColor(config, "Graph Colors - Overlay", "Disabled Transition Line Color", new Color(0.55f, 0.55f, 0.55f), "Line color for a disabled transition."), BindColor(config, "Graph Colors - Overlay", "Drag Transition Color", new Color(0f, 1f, 0f), "Rubber-band preview line color while dragging a transition endpoint.")); } private static ConfigEntry BindColor(ConfigFile config, string section, string key, Color defaultValue, string description) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return config.Bind(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { IsAdvanced = true } })); } } internal sealed class FsmGraphOverlay { private sealed class GraphLayoutCache { public Dictionary? NodeLayoutCache; public List? GlobalPseudoNodeCache; public int NodeLayoutVersion; public PlayMakerFSM? LayoutCacheComponent; public Vector2 LayoutCachePanCenter; public float LayoutCacheZoom; public Rect LayoutCacheCanvasRect; public int LayoutCacheEditGeneration = -1; public readonly List<(Vector2[] Points, Color Color, float Thickness, float ArrowLength, float OutlineMargin)> LineDrawBuffer = new List<(Vector2[], Color, float, float, float)>(); public readonly List<(Vector2 Position, Color Color)> ChromeVertexBuffer = new List<(Vector2, Color)>(); public int ChromeCacheLayoutVersion = -1; public Rect ChromeCacheVisibleRect; public string? ChromeCacheActiveStateName; public string? ChromeCacheSelectedStateName; public GraphBoxStyle ChromeCacheBoxStyle; public int ChromeCacheConfigGeneration = -1; } private sealed class NodeLayout { public string Name = ""; public Rect ScreenRect; public Rect TitleRect; public Color FillColor; public int ColorIndex; public bool IsDisabled; public List Rows = new List(); } private readonly struct TransitionRow { public readonly string ToState; public readonly string EventName; public readonly Rect Rect; public readonly Vector2[] CurvePoints; public readonly Rect CurveBounds; public readonly bool IsDisabled; public TransitionRow(string toState, string eventName, Rect rect, Vector2[] curvePoints, Rect curveBounds, bool isDisabled) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) ToState = toState; EventName = eventName; Rect = rect; CurvePoints = curvePoints; CurveBounds = curveBounds; IsDisabled = isDisabled; } public TransitionRow Translated(Vector2 delta) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //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_003d: 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_0043: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < CurvePoints.Length; i++) { ref Vector2 reference = ref CurvePoints[i]; reference += delta; } return new TransitionRow(ToState, EventName, Translate(Rect, delta), CurvePoints, Translate(CurveBounds, delta), IsDisabled); } } private readonly struct GlobalPseudoNodeLayout { public readonly string EventName; public readonly Rect Rect; public readonly Vector2[] ArrowPoints; public readonly bool IsDisabled; public GlobalPseudoNodeLayout(string eventName, Rect rect, Vector2 arrowFrom, Vector2 arrowTo, bool isDisabled) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) EventName = eventName; Rect = rect; ArrowPoints = (Vector2[])(object)new Vector2[2] { arrowFrom, arrowTo }; IsDisabled = isDisabled; } private GlobalPseudoNodeLayout(string eventName, Rect rect, Vector2[] arrowPoints, bool isDisabled) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) EventName = eventName; Rect = rect; ArrowPoints = arrowPoints; IsDisabled = isDisabled; } public GlobalPseudoNodeLayout Translated(Vector2 delta) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) for (int i = 0; i < ArrowPoints.Length; i++) { ref Vector2 reference = ref ArrowPoints[i]; reference += delta; } return new GlobalPseudoNodeLayout(EventName, Translate(Rect, delta), ArrowPoints, IsDisabled); } } private sealed class DraggingTransition { public string OwningStateName = ""; public string EventName = ""; public bool DraggingSourceEnd; public Vector2 MouseDownScreenPos; public bool HasCrossedThreshold; } private const float MinZoom = 0.1f; private const float MaxZoom = 3f; private const float ZoomSpeed = 0.05f; private const float MinNodeWidth = 60f; private const float TitleBarHeight = 16f; private const float TransitionRowHeight = 16f; private const float GlobalPseudoNodeHeight = 22f; private const float GlobalPseudoNodeGap = 10f; private const float GlobalPseudoNodeOffset = 40f; private const float FitMargin = 60f; private const float NodeCornerRadius = 10f; private const float NodeBorderThickness = 2f; private const float NodeActiveOutlineThickness = 3f; private const float NodeSelectedOutlineThickness = 3f; private const float BezierControlOffset = 40f; private const float BezierTargetSegmentLength = 14f; private const int MinBezierSegments = 6; private const int MaxBezierSegments = 40; private const float DynamicFontPointSize = 12f; private const float TransitionLineThickness = 3f; private const float ActiveTransitionLineThickness = 6f; private const float SelectedTransitionOutlineMargin = 3f; private static readonly string[] DynamicFontNames = new string[4] { "Segoe UI", "DejaVu Sans", "Liberation Sans", "Arial" }; private const float TransitionLineHitTolerance = 6f; private const float DragStartThreshold = 4f; private const double DoubleClickWindowSeconds = 0.35; private readonly ManualLogSource _logger; private readonly FsmEditManager _editManager; private readonly FsmTabManager _tabManager; private readonly ConfigEntry _toggleOverlayHotkey; private readonly ConfigEntry _toggleMinimalViewHotkey; private readonly FsmGraphColorConfig _colors; private readonly FsmGraphPerformanceConfig _performance; private Material? _glMaterial; private bool _glMaterialFailed; private Font? _dynamicFont; private GUIStyle? _titleStyle; private GUIStyle? _eventStyle; private GUIStyle? _globalEventStyle; private float _textStyleBuiltForZoom = -1f; private bool _isVisible; private bool _selectionUiVisible = true; private bool _graphVisible = true; private FsmSnapshot? _snapshot; private readonly Dictionary _fullInfoCache = new Dictionary(); private readonly HashSet _notFoundThisScene = new HashSet(); private string? _selectedStateName; private Vector2 _panWorldCenter; private float _zoom = 1f; private readonly FsmActiveStateTracker _activeStateTracker = new FsmActiveStateTracker(); private bool _isPanning; private readonly Dictionary _layoutCachesByFsmKey = new Dictionary(); private GraphLayoutCache _currentCache = new GraphLayoutCache(); private double _lastNodeClickTime = double.NegativeInfinity; private string? _lastNodeClickName; private int? _pendingScrollActionIndex; private DraggingTransition? _draggingTransition; private readonly List _vignetteHolesBuffer = new List(3); private readonly List _vignetteXCutsBuffer = new List(); private readonly List _vignetteYCutsBuffer = new List(); private const int CornerFanSegments = 8; private const float DimGreyBlend = 0.6f; private const float DimAlphaMultiplier = 0.55f; private const float ArrowheadLength = 14f; private const float ArrowheadAngleLookbackFactor = 0.6f; private const float ArrowheadWingAngleDegrees = 25f; private static readonly float ArrowheadBackTrimFactor = Mathf.Cos(0.43633232f); private const float LineAntiAliasWidth = 1.5f; internal FsmSnapshot? CurrentSnapshot => _snapshot; internal bool IsVisible => _isVisible; internal bool SelectionUiVisible => _selectionUiVisible; internal bool GraphVisible { get { return _graphVisible; } set { _graphVisible = value; } } internal FsmInfo? ResolveFsmInfo(string fsmKey) { if (_snapshot == null) { return null; } if (_fullInfoCache.TryGetValue(fsmKey, out FsmInfo value)) { if (!((Object)(object)value.Component == (Object)null)) { return value; } return null; } if (_notFoundThisScene.Contains(fsmKey)) { return null; } foreach (FsmIdentityInfo fsm in _snapshot.Fsms) { if (!((Object)(object)fsm.Component == (Object)null) && FsmIdentity.GetFsmKey(fsm.Component) == fsmKey) { FsmInfo fsmInfo = FsmDataCollector.CollectFsmInfo(fsm.Component); _fullInfoCache[fsmKey] = fsmInfo; return fsmInfo; } } _notFoundThisScene.Add(fsmKey); return null; } private GraphLayoutCache GetOrCreateLayoutCache(string fsmKey) { if (!_layoutCachesByFsmKey.TryGetValue(fsmKey, out GraphLayoutCache value)) { value = new GraphLayoutCache(); _layoutCachesByFsmKey[fsmKey] = value; } return value; } public FsmGraphOverlay(ManualLogSource logger, FsmEditManager editManager, FsmTabManager tabManager, ConfigEntry toggleOverlayHotkey, ConfigEntry toggleMinimalViewHotkey, FsmGraphColorConfig colors, FsmGraphPerformanceConfig performance, bool startVisible = false) { _logger = logger; _editManager = editManager; _tabManager = tabManager; _toggleOverlayHotkey = toggleOverlayHotkey; _toggleMinimalViewHotkey = toggleMinimalViewHotkey; _colors = colors; _performance = performance; _isVisible = startVisible; } public void Shutdown() { _activeStateTracker.UnsubscribeAll(); if ((Object)(object)_glMaterial != (Object)null) { Object.Destroy((Object)(object)_glMaterial); _glMaterial = null; } _glMaterialFailed = false; if ((Object)(object)_dynamicFont != (Object)null) { Object.Destroy((Object)(object)_dynamicFont); _dynamicFont = null; } _titleStyle = null; _eventStyle = null; _globalEventStyle = null; _textStyleBuiltForZoom = -1f; } public void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value; if (!CanvasTextField.AnyFieldFocused) { value = _toggleOverlayHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { _isVisible = !_isVisible; } } if (_isVisible && !CanvasTextField.AnyFieldFocused) { value = _toggleMinimalViewHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { _selectionUiVisible = !_selectionUiVisible; _logger.LogInfo((object)("[FsmMaster] Graph overlay: minimal view " + ((!_selectionUiVisible) ? "on" : "off") + ".")); } } } internal void RefreshSnapshot(string sceneName, PlayMakerFSM[] components) { _snapshot = FsmDataCollector.CollectSnapshot(sceneName, components); _fullInfoCache.Clear(); _notFoundThisScene.Clear(); if (_snapshot.Fsms.Count == 0) { _logger.LogInfo((object)"[FsmMaster] Graph overlay: no live PlayMakerFSM instances found in this scene."); } InvalidateGraphCaches(); } public void OnGUI(FsmTabState? activeTab, Rect? rightPanelScreenRect, Rect? monitorPanelScreenRect, Rect? openDropdownScreenRect) { //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Invalid comparison between Unknown and I4 //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (!_isVisible || _snapshot == null) { return; } Rect canvasRect = default(Rect); ((Rect)(ref canvasRect))..ctor(0f, 0f, (float)Screen.width, (float)Screen.height); Rect interactiveRect = ComputeInteractiveRect(rightPanelScreenRect); if (_selectionUiVisible) { DrawVignette(rightPanelScreenRect, monitorPanelScreenRect, openDropdownScreenRect); } if (!_graphVisible) { return; } foreach (FsmTabState tab in _tabManager.Tabs) { if (tab.IsPinned && tab.IsLive && tab != activeTab) { FsmInfo fsmInfo = ResolveFsmInfo(tab.FsmKey); if (fsmInfo != null) { DrawGraph(fsmInfo, tab, canvasRect, interactiveRect, interactive: false, _selectionUiVisible); } } } FsmInfo fsmInfo2 = ((activeTab != null && activeTab.IsLive) ? ResolveFsmInfo(activeTab.FsmKey) : null); if (fsmInfo2 != null) { DrawGraph(fsmInfo2, activeTab, canvasRect, interactiveRect, interactive: true, dim: false); } if ((int)Event.current.type == 7) { _activeStateTracker.CommitFrame(); } } private static Rect ComputeInteractiveRect(Rect? rightPanelScreenRect) { //IL_0013: 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_003c: Unknown result type (might be due to invalid IL or missing references) float num; if (!rightPanelScreenRect.HasValue) { num = Screen.width; } else { Rect valueOrDefault = rightPanelScreenRect.GetValueOrDefault(); num = ((Rect)(ref valueOrDefault)).x; } float num2 = num; return new Rect(0f, 0f, Mathf.Max(0f, num2), (float)Screen.height); } private void DrawVignette(Rect? rightPanelScreenRect, Rect? monitorPanelScreenRect, Rect? openDropdownScreenRect) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_025b: 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_003d: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_0223: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type != 7) { return; } List vignetteHolesBuffer = _vignetteHolesBuffer; vignetteHolesBuffer.Clear(); if (rightPanelScreenRect.HasValue) { vignetteHolesBuffer.Add(rightPanelScreenRect.Value); } if (monitorPanelScreenRect.HasValue) { vignetteHolesBuffer.Add(monitorPanelScreenRect.Value); } if (openDropdownScreenRect.HasValue) { vignetteHolesBuffer.Add(openDropdownScreenRect.Value); } Color color = GUI.color; GUI.color = _colors.VignetteColor.Value; try { if (vignetteHolesBuffer.Count == 0) { GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture); return; } List vignetteXCutsBuffer = _vignetteXCutsBuffer; List vignetteYCutsBuffer = _vignetteYCutsBuffer; vignetteXCutsBuffer.Clear(); vignetteXCutsBuffer.Add(0f); vignetteXCutsBuffer.Add(Screen.width); vignetteYCutsBuffer.Clear(); vignetteYCutsBuffer.Add(0f); vignetteYCutsBuffer.Add(Screen.height); foreach (Rect item in vignetteHolesBuffer) { Rect current = item; vignetteXCutsBuffer.Add(Mathf.Clamp(((Rect)(ref current)).xMin, 0f, (float)Screen.width)); vignetteXCutsBuffer.Add(Mathf.Clamp(((Rect)(ref current)).xMax, 0f, (float)Screen.width)); vignetteYCutsBuffer.Add(Mathf.Clamp(((Rect)(ref current)).yMin, 0f, (float)Screen.height)); vignetteYCutsBuffer.Add(Mathf.Clamp(((Rect)(ref current)).yMax, 0f, (float)Screen.height)); } vignetteXCutsBuffer.Sort(); vignetteYCutsBuffer.Sort(); for (int i = 0; i < vignetteXCutsBuffer.Count - 1; i++) { float num = vignetteXCutsBuffer[i]; float num2 = vignetteXCutsBuffer[i + 1]; if (num2 - num <= 0f) { continue; } for (int j = 0; j < vignetteYCutsBuffer.Count - 1; j++) { float num3 = vignetteYCutsBuffer[j]; float num4 = vignetteYCutsBuffer[j + 1]; if (!(num4 - num3 <= 0f) && !IsInsideAny(new Vector2((num + num2) / 2f, (num3 + num4) / 2f), vignetteHolesBuffer)) { GUI.DrawTexture(new Rect(num, num3, num2 - num, num4 - num3), (Texture)(object)Texture2D.whiteTexture); } } } } finally { GUI.color = color; } } private static bool IsInsideAny(Vector2 point, List rects) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) foreach (Rect rect in rects) { Rect current = rect; if (((Rect)(ref current)).Contains(point)) { return true; } } return false; } private static bool IsPointerOverUi() { if ((Object)(object)EventSystem.current != (Object)null) { return EventSystem.current.IsPointerOverGameObject(); } return false; } private void EnsureTextStyles() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (_dynamicFont == null) { _dynamicFont = Font.CreateDynamicFontFromOSFont(DynamicFontNames, 12); } if (_titleStyle == null || !Mathf.Approximately(_textStyleBuiltForZoom, _zoom)) { _titleStyle = new GUIStyle { font = _dynamicFont, fontSize = Mathf.Max(1, Mathf.RoundToInt(12f * _zoom)), fontStyle = (FontStyle)1, alignment = (TextAnchor)4, clipping = (TextClipping)1, wordWrap = false }; _titleStyle.normal.textColor = Color.white; _eventStyle = new GUIStyle(_titleStyle) { fontStyle = (FontStyle)0 }; _globalEventStyle = new GUIStyle(_eventStyle); _globalEventStyle.normal.textColor = _colors.GlobalPseudoNodeTextColor.Value; _textStyleBuiltForZoom = _zoom; } } private void InvalidateGraphCaches() { _layoutCachesByFsmKey.Clear(); } internal static (Vector2 PanCenter, float Zoom) FitViewToFsm(FsmInfo fsm) { //IL_000d: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) if (fsm.States.Count == 0) { return (PanCenter: Vector2.zero, Zoom: 1f); } float num = float.MaxValue; float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MinValue; foreach (FsmStateInfo state in fsm.States) { Rect position = state.State.Position; num = Mathf.Min(num, ((Rect)(ref position)).x); num2 = Mathf.Min(num2, ((Rect)(ref position)).y); num3 = Mathf.Max(num3, ((Rect)(ref position)).x + Mathf.Max(((Rect)(ref position)).width, 60f)); num4 = Mathf.Max(num4, ((Rect)(ref position)).y + ComputeNodeWorldHeight(state)); } float num5 = Mathf.Max(num3 - num, 1f) + 120f; float num6 = Mathf.Max(num4 - num2, 1f) + 120f; float num7 = Mathf.Max((float)Screen.width, 100f); float num8 = Mathf.Max((float)Screen.height, 100f); float item = Mathf.Clamp(Mathf.Min(num7 / num5, num8 / num6), 0.1f, 3f); return (PanCenter: new Vector2((num + num3) / 2f, (num2 + num4) / 2f), Zoom: item); } private static float ComputeNodeWorldHeight(FsmStateInfo state) { return 16f + (float)state.Transitions.Count * 16f; } private Vector2 WorldToScreen(Vector2 worldPoint, Rect canvasRect) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_001e: 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_0036: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ((Rect)(ref canvasRect)).position + ((Rect)(ref canvasRect)).size / 2f; return (worldPoint - _panWorldCenter) * _zoom + val; } private Rect WorldToScreen(Rect worldRect, Rect canvasRect) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector2 val = WorldToScreen(((Rect)(ref worldRect)).position, canvasRect); return new Rect(val.x, val.y, ((Rect)(ref worldRect)).width * _zoom, ((Rect)(ref worldRect)).height * _zoom); } private void DrawGraph(FsmInfo fsm, FsmTabState tab, Rect canvasRect, Rect interactiveRect, bool interactive, bool dim) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) _currentCache = GetOrCreateLayoutCache(tab.FsmKey); _panWorldCenter = tab.PanWorldCenter; _zoom = tab.Zoom; _selectedStateName = tab.SelectedStateName; _activeStateTracker.EnsureTracked(tab.FsmKey, fsm.Fsm); GUI.BeginGroup(canvasRect, GUIStyle.none); Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, ((Rect)(ref canvasRect)).width, ((Rect)(ref canvasRect)).height); int num; int num2; if (_currentCache.NodeLayoutCache != null && _currentCache.LayoutCacheComponent == fsm.Component && Mathf.Approximately(_currentCache.LayoutCacheZoom, _zoom) && !(_currentCache.LayoutCacheCanvasRect != val)) { num = ((_currentCache.LayoutCacheEditGeneration != _editManager.EditGeneration) ? 1 : 0); if (num == 0) { num2 = ((_currentCache.LayoutCachePanCenter != _panWorldCenter) ? 1 : 0); goto IL_00fc; } } else { num = 1; } num2 = 0; goto IL_00fc; IL_00fc: bool flag = (byte)num2 != 0; if (num != 0) { RebuildNodeLayoutCache(fsm, val); _currentCache.NodeLayoutVersion++; _currentCache.LayoutCacheComponent = fsm.Component; _currentCache.LayoutCachePanCenter = _panWorldCenter; _currentCache.LayoutCacheZoom = _zoom; _currentCache.LayoutCacheCanvasRect = val; _currentCache.LayoutCacheEditGeneration = _editManager.EditGeneration; } else if (flag) { Vector2 screenDelta = (_currentCache.LayoutCachePanCenter - _panWorldCenter) * _zoom; TranslateNodeLayoutCache(screenDelta); _currentCache.NodeLayoutVersion++; _currentCache.LayoutCachePanCenter = _panWorldCenter; } DrawCachedGraph(fsm, tab.FsmKey, ((Rect)(ref canvasRect)).position, interactiveRect, interactive, dim); if (interactive) { HandlePanAndZoom(interactiveRect); HandleTransitionDrag(fsm, interactiveRect); } GUI.EndGroup(); if (interactive) { tab.PanWorldCenter = _panWorldCenter; tab.Zoom = _zoom; tab.SelectedStateName = _selectedStateName; if (_pendingScrollActionIndex.HasValue) { tab.PendingScrollActionIndex = _pendingScrollActionIndex; _pendingScrollActionIndex = null; } } } private void RebuildNodeLayoutCache(FsmInfo fsm, Rect canvasRect) { //IL_003e: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) string fsmKey = FsmIdentity.GetFsmKey(fsm.Component); FsmEditSet activeEditSet = _editManager.GetActiveEditSet(fsmKey); Dictionary dictionary = new Dictionary(); foreach (FsmStateInfo state2 in fsm.States) { Rect position = state2.State.Position; ((Rect)(ref position)).width = Mathf.Max(((Rect)(ref position)).width, 60f); ((Rect)(ref position)).height = ComputeNodeWorldHeight(state2); dictionary[state2.Name] = WorldToScreen(position, canvasRect); } Dictionary dictionary2 = new Dictionary(); Rect titleRect = default(Rect); Rect rect = default(Rect); Vector2 val3 = default(Vector2); Vector2 val4 = default(Vector2); Rect fromRect = default(Rect); foreach (FsmStateInfo state in fsm.States) { Rect val = dictionary[state.Name]; int num = Mathf.Clamp(state.State.ColorIndex, 0, _colors.StateColors.Length - 1); ((Rect)(ref titleRect))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 16f * _zoom); bool flag = activeEditSet?.DisabledStates.Contains(state.Name) ?? false; FsmEvent val2 = (flag ? FsmEditManager.FindExitEvent(state.State) : null); NodeLayout nodeLayout = new NodeLayout { Name = state.Name, ScreenRect = val, TitleRect = titleRect, FillColor = ((num == 0) ? Color.black : _colors.StateColors[num].Value), ColorIndex = num, IsDisabled = flag }; float num2 = 16f * _zoom; for (int i = 0; i < state.Transitions.Count; i++) { FsmTransitionInfo transition = state.Transitions[i]; ((Rect)(ref rect))..ctor(((Rect)(ref val)).x, ((Rect)(ref titleRect)).yMax + (float)i * num2, ((Rect)(ref val)).width, num2); TransitionRetarget transitionRetarget = activeEditSet?.TransitionRetargets.Find((TransitionRetarget t) => t.StateName == state.Name && t.EventName == transition.EventName); bool flag2 = transitionRetarget != null && transitionRetarget.NewToState == "\0DISABLED"; string text = transition.ToState; string text2 = transition.EventName; if (transitionRetarget != null && !flag2 && transitionRetarget.NewStateName == state.Name) { text = transitionRetarget.NewToState; text2 = FsmEditManager.EffectiveNewEventName(transitionRetarget); } Vector2 center = ((Rect)(ref rect)).center; Vector2 target = ((Rect)(ref rect)).center; ((Vector2)(ref val3))..ctor(1f, 0f); ((Vector2)(ref val4))..ctor(-1f, 0f); if (dictionary.TryGetValue(text, out var value)) { val3 = PickExitDirection(val, value); ((Vector2)(ref center))..ctor((val3.x > 0f) ? ((Rect)(ref rect)).xMax : ((Rect)(ref rect)).x, ((Rect)(ref rect)).center.y); ((Rect)(ref fromRect))..ctor(((Rect)(ref value)).x, ((Rect)(ref value)).y, ((Rect)(ref value)).width, 16f * _zoom); val4 = PickExitDirection(fromRect, val); target = ((val4.x > 0f) ? new Vector2(((Rect)(ref fromRect)).xMax, ((Rect)(ref fromRect)).center.y) : new Vector2(((Rect)(ref fromRect)).x, ((Rect)(ref fromRect)).center.y)); } Vector2[] array = SampleBezierCurve(center, target, val3, val4, _zoom); bool flag3 = flag && (val2 == null || text2 != val2.Name); nodeLayout.Rows.Add(new TransitionRow(text, text2, rect, array, ComputeCurveBounds(array), flag3 || flag2)); } dictionary2[state.Name] = nodeLayout; } Dictionary> dictionary3 = new Dictionary>(); foreach (FsmTransitionInfo globalTransition in fsm.GlobalTransitions) { if (!dictionary3.TryGetValue(globalTransition.ToState, out var value2)) { value2 = new List(); dictionary3[globalTransition.ToState] = value2; } value2.Add(globalTransition); } float num3 = 22f * _zoom; float num4 = 10f * _zoom; float num5 = 40f * _zoom; List list = new List(); Rect rect2 = default(Rect); foreach (KeyValuePair> item in dictionary3) { if (!dictionary.TryGetValue(item.Key, out var value3)) { continue; } for (int num6 = 0; num6 < item.Value.Count; num6++) { string eventName = item.Value[num6].EventName; float num7 = ((Rect)(ref value3)).y - num5 - (float)num6 * (num3 + num4); ((Rect)(ref rect2))..ctor(((Rect)(ref value3)).x, num7, ((Rect)(ref value3)).width, num3); bool isDisabled = activeEditSet?.TransitionRetargets.Exists((TransitionRetarget t) => t.StateName == "" && t.EventName == eventName && t.NewToState == "\0DISABLED") ?? false; list.Add(new GlobalPseudoNodeLayout(eventName, rect2, new Vector2(((Rect)(ref rect2)).center.x, ((Rect)(ref rect2)).yMax), new Vector2(((Rect)(ref value3)).center.x, ((Rect)(ref value3)).y), isDisabled)); } } _currentCache.NodeLayoutCache = dictionary2; _currentCache.GlobalPseudoNodeCache = list; } private void TranslateNodeLayoutCache(Vector2 screenDelta) { //IL_00d9: 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_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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //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_006e: Unknown result type (might be due to invalid IL or missing references) if (_currentCache.NodeLayoutCache != null) { foreach (NodeLayout value in _currentCache.NodeLayoutCache.Values) { value.ScreenRect = Translate(value.ScreenRect, screenDelta); value.TitleRect = Translate(value.TitleRect, screenDelta); for (int i = 0; i < value.Rows.Count; i++) { value.Rows[i] = value.Rows[i].Translated(screenDelta); } } } if (_currentCache.GlobalPseudoNodeCache != null) { for (int j = 0; j < _currentCache.GlobalPseudoNodeCache.Count; j++) { _currentCache.GlobalPseudoNodeCache[j] = _currentCache.GlobalPseudoNodeCache[j].Translated(screenDelta); } } } private static Rect Translate(Rect rect, Vector2 delta) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref rect)).x + delta.x, ((Rect)(ref rect)).y + delta.y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height); } private static Vector2 PickExitDirection(Rect fromRect, Rect toRect) { //IL_0002: 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_001f: 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_0044: Unknown result type (might be due to invalid IL or missing references) if (((Rect)(ref toRect)).center.x > ((Rect)(ref fromRect)).xMax) { return new Vector2(1f, 0f); } if (((Rect)(ref toRect)).center.x < ((Rect)(ref fromRect)).x) { return new Vector2(-1f, 0f); } return new Vector2(1f, 0f); } private static Vector2[] SampleBezierCurve(Vector2 source, Vector2 target, Vector2 exitDirection, Vector2 entryDirection, float zoom) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) Vector2 val = source + exitDirection * (40f * zoom); Vector2 val2 = target + entryDirection * (40f * zoom); int num = Mathf.Clamp(Mathf.RoundToInt((Vector2.Distance(source, val) + Vector2.Distance(val, val2) + Vector2.Distance(val2, target)) / 14f), 6, 40); Vector2[] array = (Vector2[])(object)new Vector2[num + 1]; for (int i = 0; i <= num; i++) { float t = (float)i / (float)num; array[i] = CubicBezierPoint(source, val, val2, target, t); } return array; } private static Vector2 CubicBezierPoint(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) float num = 1f - t; return num * num * num * p0 + 3f * num * num * t * p1 + 3f * num * t * t * p2 + t * t * t * p3; } private static Rect ComputeCurveBounds(Vector2[] points) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) float num = points[0].x; float num2 = points[0].x; float num3 = points[0].y; float num4 = points[0].y; for (int i = 1; i < points.Length; i++) { num = Mathf.Min(num, points[i].x); num2 = Mathf.Max(num2, points[i].x); num3 = Mathf.Min(num3, points[i].y); num4 = Mathf.Max(num4, points[i].y); } return new Rect(num, num3, num2 - num, num4 - num3); } private void DrawCachedGraph(FsmInfo fsm, string fsmKey, Vector2 canvasScreenOffset, Rect interactiveRect, bool interactive, bool dim) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0c33: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0c44: Unknown result type (might be due to invalid IL or missing references) //IL_0c62: Unknown result type (might be due to invalid IL or missing references) //IL_0c67: Unknown result type (might be due to invalid IL or missing references) //IL_0cd1: Unknown result type (might be due to invalid IL or missing references) //IL_0c7e: Unknown result type (might be due to invalid IL or missing references) //IL_0cac: Unknown result type (might be due to invalid IL or missing references) //IL_0cae: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0d1f: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_09f8: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a17: Unknown result type (might be due to invalid IL or missing references) //IL_0a1e: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Unknown result type (might be due to invalid IL or missing references) //IL_09a3: Unknown result type (might be due to invalid IL or missing references) //IL_09a4: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_0a44: Unknown result type (might be due to invalid IL or missing references) //IL_0a29: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0a7a: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) //IL_0a83: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_0c1b: Unknown result type (might be due to invalid IL or missing references) //IL_0a8d: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0b4e: Unknown result type (might be due to invalid IL or missing references) //IL_0b3c: Unknown result type (might be due to invalid IL or missing references) //IL_0b2a: Unknown result type (might be due to invalid IL or missing references) //IL_0b91: Unknown result type (might be due to invalid IL or missing references) //IL_0b7f: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0b9d: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_0bcf: Unknown result type (might be due to invalid IL or missing references) //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_0700: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_081f: Unknown result type (might be due to invalid IL or missing references) //IL_0824: Unknown result type (might be due to invalid IL or missing references) //IL_0829: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Unknown result type (might be due to invalid IL or missing references) //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_0801: Unknown result type (might be due to invalid IL or missing references) //IL_080d: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Unknown result type (might be due to invalid IL or missing references) //IL_088b: Unknown result type (might be due to invalid IL or missing references) //IL_0890: Unknown result type (might be due to invalid IL or missing references) //IL_08ed: Unknown result type (might be due to invalid IL or missing references) //IL_08fd: Unknown result type (might be due to invalid IL or missing references) //IL_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_08dc: Unknown result type (might be due to invalid IL or missing references) //IL_091e: Unknown result type (might be due to invalid IL or missing references) //IL_0923: Unknown result type (might be due to invalid IL or missing references) //IL_0943: Unknown result type (might be due to invalid IL or missing references) //IL_0948: Unknown result type (might be due to invalid IL or missing references) if (_currentCache.NodeLayoutCache == null) { return; } string activeStateName = fsm.Fsm.ActiveStateName; bool flag = _activeStateTracker.HasAnyFading(fsmKey); if ((int)Event.current.type == 7) { EnsureTextStyles(); Rect val = interactiveRect; _currentCache.LineDrawBuffer.Clear(); bool flag2 = _currentCache.ChromeCacheLayoutVersion == _currentCache.NodeLayoutVersion && _currentCache.ChromeCacheVisibleRect == val && _currentCache.ChromeCacheActiveStateName == activeStateName && _currentCache.ChromeCacheSelectedStateName == _selectedStateName && _currentCache.ChromeCacheBoxStyle == _performance.BoxStyle.Value && _currentCache.ChromeCacheConfigGeneration == _performance.Generation && !flag; if (!flag2) { _currentCache.ChromeVertexBuffer.Clear(); } Rect val2; if (_currentCache.GlobalPseudoNodeCache != null) { foreach (GlobalPseudoNodeLayout item5 in _currentCache.GlobalPseudoNodeCache) { val2 = item5.Rect; if (((Rect)(ref val2)).Overlaps(val)) { if (!flag2) { AddRoundedRectOutlineToChromeBuffer(item5.Rect, _colors.GlobalPseudoNodeColor.Value, _colors.GlobalPseudoNodeOutlineColor.Value, 2f * _zoom); } Color item = (item5.IsDisabled ? _colors.DisabledTransitionLineColor.Value : _colors.GlobalTransitionColor.Value); _currentCache.LineDrawBuffer.Add((item5.ArrowPoints, item, 3f, 14f, 0f)); } } } foreach (NodeLayout value2 in _currentCache.NodeLayoutCache.Values) { int num; Color value; if (!value2.IsDisabled && activeStateName != null) { num = ((value2.Name == activeStateName) ? 1 : 0); if (num != 0) { value = _colors.ActiveStateColor.Value; goto IL_025c; } } else { num = 0; } value = _colors.TransitionColors[value2.ColorIndex].Value; goto IL_025c; IL_025c: Color val3 = value; float num2 = ((num != 0) ? 6f : 3f); bool flag3 = _selectedStateName != null && value2.Name == _selectedStateName; foreach (TransitionRow row in value2.Rows) { val2 = row.CurveBounds; if (((Rect)(ref val2)).Overlaps(val)) { Color item2 = (row.IsDisabled ? _colors.DisabledTransitionLineColor.Value : val3); float num3 = (row.IsDisabled ? 3f : num2); float item3 = 14f * (num3 / 3f); if (flag3) { _currentCache.LineDrawBuffer.Add((row.CurvePoints, _colors.SelectedStateColor.Value, num3 + 6f, item3, 3f)); } _currentCache.LineDrawBuffer.Add((row.CurvePoints, item2, num3, item3, 0f)); } } } if (interactive) { DraggingTransition draggingTransition = _draggingTransition; if (draggingTransition != null && draggingTransition.HasCrossedThreshold) { Vector2 mousePosition = Event.current.mousePosition; (Vector2, Vector2)? tuple = ResolveDragAnchor(mousePosition); if (tuple.HasValue) { Vector2[] item4 = SampleBezierCurve(tuple.Value.Item1, mousePosition, tuple.Value.Item2, -tuple.Value.Item2, _zoom); _currentCache.LineDrawBuffer.Add((item4, _colors.DragTransitionColor.Value, 6f, 28f, 0f)); } } } if (!flag2) { Rect rect = default(Rect); Rect rect2 = default(Rect); Rect rect3 = default(Rect); Rect rect4 = default(Rect); foreach (NodeLayout value3 in _currentCache.NodeLayoutCache.Values) { if (!((Rect)(ref value3.ScreenRect)).Overlaps(val)) { continue; } bool flag4 = _performance.BoxStyle.Value == GraphBoxStyle.Standard; float num4 = (flag4 ? 0f : GetNodeCornerRadius(value3.ScreenRect)); bool flag5 = !value3.IsDisabled && activeStateName != null && value3.Name == activeStateName; bool flag6 = _selectedStateName != null && value3.Name == _selectedStateName; float? num5 = (value3.IsDisabled ? ((float?)null) : _activeStateTracker.GetFadeProgress(fsmKey, value3.Name)); if (flag5 && flag6) { float num6 = 8f * _zoom; ((Rect)(ref rect))..ctor(((Rect)(ref value3.ScreenRect)).x - num6, ((Rect)(ref value3.ScreenRect)).y - num6, ((Rect)(ref value3.ScreenRect)).width + num6 * 2f, ((Rect)(ref value3.ScreenRect)).height + num6 * 2f); AddRoundedRectToChromeBuffer(rect, num4 + num6, _colors.SelectedStateColor.Value); } else if (flag6) { float num7 = 5f * _zoom; ((Rect)(ref rect2))..ctor(((Rect)(ref value3.ScreenRect)).x - num7, ((Rect)(ref value3.ScreenRect)).y - num7, ((Rect)(ref value3.ScreenRect)).width + num7 * 2f, ((Rect)(ref value3.ScreenRect)).height + num7 * 2f); AddRoundedRectToChromeBuffer(rect2, num4 + num7, _colors.SelectedStateColor.Value); } if (flag5 || num5.HasValue) { Color color = (flag5 ? _colors.ActiveStateColor.Value : GetFadingActiveColor(num5.Value)); float num8 = 5f * _zoom; ((Rect)(ref rect3))..ctor(((Rect)(ref value3.ScreenRect)).x - num8, ((Rect)(ref value3.ScreenRect)).y - num8, ((Rect)(ref value3.ScreenRect)).width + num8 * 2f, ((Rect)(ref value3.ScreenRect)).height + num8 * 2f); AddRoundedRectToChromeBuffer(rect3, num4 + num8, color); } Color color2 = (value3.IsDisabled ? _colors.DisabledOutlineColor.Value : (flag5 ? GetActiveOutlineColor(value3.ColorIndex) : (num5.HasValue ? Color.Lerp(GetActiveOutlineColor(value3.ColorIndex), _colors.NodeOutlineColor.Value, num5.Value) : _colors.NodeOutlineColor.Value))); if (!flag4 || flag5 || flag6 || num5.HasValue) { float num9 = 2f * _zoom; ((Rect)(ref rect4))..ctor(((Rect)(ref value3.ScreenRect)).x - num9, ((Rect)(ref value3.ScreenRect)).y - num9, ((Rect)(ref value3.ScreenRect)).width + num9 * 2f, ((Rect)(ref value3.ScreenRect)).height + num9 * 2f); AddRoundedRectToChromeBuffer(rect4, num4 + num9, color2); } bool roundBottom = value3.Rows.Count == 0; Color color3 = (flag5 ? _colors.ActiveTitleBackgroundColor.Value : (num5.HasValue ? Color.Lerp(_colors.ActiveTitleBackgroundColor.Value, value3.FillColor, num5.Value) : value3.FillColor)); AddRoundedRectToChromeBuffer(value3.TitleRect, num4, color3, roundTop: true, roundBottom); float num10 = 2f * _zoom; if (!flag4 && value3.Rows.Count > 0) { AddFilledRectToChromeBuffer(new Rect(((Rect)(ref value3.ScreenRect)).x, ((Rect)(ref value3.TitleRect)).yMax - num10 / 2f, ((Rect)(ref value3.ScreenRect)).width, num10), color2); } for (int i = 0; i < value3.Rows.Count; i++) { TransitionRow transitionRow = value3.Rows[i]; bool flag7 = i == value3.Rows.Count - 1; if (flag7) { AddRoundedRectToChromeBuffer(transitionRow.Rect, num4, _colors.TransitionRowBackgroundColor.Value, roundTop: false); } else { AddFilledRectToChromeBuffer(transitionRow.Rect, _colors.TransitionRowBackgroundColor.Value); } if (!flag4 && !flag7) { float x = ((Rect)(ref value3.ScreenRect)).x; val2 = transitionRow.Rect; AddFilledRectToChromeBuffer(new Rect(x, ((Rect)(ref val2)).yMax - num10 / 2f, ((Rect)(ref value3.ScreenRect)).width, num10), color2); } } } } if (!flag2) { _currentCache.ChromeCacheLayoutVersion = _currentCache.NodeLayoutVersion; _currentCache.ChromeCacheVisibleRect = val; _currentCache.ChromeCacheActiveStateName = activeStateName; _currentCache.ChromeCacheSelectedStateName = _selectedStateName; _currentCache.ChromeCacheBoxStyle = _performance.BoxStyle.Value; _currentCache.ChromeCacheConfigGeneration = _performance.Generation; } DrawLineBufferGL(canvasScreenOffset, ((Rect)(ref interactiveRect)).width, dim); FlushChromeBufferGL(canvasScreenOffset, ((Rect)(ref interactiveRect)).width, dim); GUI.BeginGroup(interactiveRect); Color color4 = GUI.color; GUI.color = (Color)(dim ? new Color(1f, 1f, 1f, 0.55f) : Color.white); if (_currentCache.GlobalPseudoNodeCache != null) { foreach (GlobalPseudoNodeLayout item6 in _currentCache.GlobalPseudoNodeCache) { val2 = item6.Rect; if (((Rect)(ref val2)).Overlaps(val)) { GUI.Label(item6.Rect, item6.EventName, _globalEventStyle); } } } foreach (NodeLayout value4 in _currentCache.NodeLayoutCache.Values) { if (!((Rect)(ref value4.ScreenRect)).Overlaps(val)) { continue; } bool flag8 = !value4.IsDisabled && activeStateName != null && value4.Name == activeStateName; _titleStyle.normal.textColor = (value4.IsDisabled ? _colors.DisabledTitleTextColor.Value : (flag8 ? _colors.ActiveTitleTextColor.Value : Color.white)); _eventStyle.normal.textColor = (value4.IsDisabled ? _colors.DisabledEventTextColor.Value : _colors.TransitionColors[value4.ColorIndex].Value); GUI.Label(value4.TitleRect, value4.Name, _titleStyle); foreach (TransitionRow row2 in value4.Rows) { GUI.Label(row2.Rect, row2.EventName, _eventStyle); } } GUI.color = color4; GUI.EndGroup(); } if (!interactive || (int)Event.current.type != 0 || !((Rect)(ref interactiveRect)).Contains(Event.current.mousePosition) || IsPointerOverUi()) { return; } Vector2 mousePosition2 = Event.current.mousePosition; if (Event.current.button == 0 && _draggingTransition == null && TryHitTestActionZone(mousePosition2, out string owningStateName, out string eventName, out bool isSourceEnd)) { _draggingTransition = new DraggingTransition { OwningStateName = owningStateName, EventName = eventName, DraggingSourceEnd = isSourceEnd, MouseDownScreenPos = mousePosition2 }; Event.current.Use(); return; } if (Event.current.button == 1 && TryHitTestActionZone(mousePosition2, out string owningStateName2, out string eventName2, out bool _)) { HandleTransitionRightClick(fsm, owningStateName2, eventName2); Event.current.Use(); return; } foreach (NodeLayout value5 in _currentCache.NodeLayoutCache.Values) { if (((Rect)(ref value5.ScreenRect)).Contains(mousePosition2)) { if (Event.current.button == 0) { HandleNodeLeftClick(fsm, value5.Name); } else if (Event.current.button == 1) { HandleNodeRightClick(fsm, value5.Name); } Event.current.Use(); break; } } } private void HandleNodeLeftClick(FsmInfo fsm, string stateName) { double num = Time.realtimeSinceStartup; if (_lastNodeClickName == stateName && num - _lastNodeClickTime <= 0.35) { fsm.Fsm.SetState(stateName); _logger.LogInfo((object)("[FsmMaster] Forced fsm '" + fsm.FsmName + "' on '" + fsm.GameObjectName + "' into state '" + stateName + "'.")); _lastNodeClickTime = double.NegativeInfinity; _lastNodeClickName = null; } else { _lastNodeClickTime = num; _lastNodeClickName = stateName; } _selectedStateName = stateName; } private void HandleNodeRightClick(FsmInfo fsm, string stateName) { string fsmKey = FsmIdentity.GetFsmKey(fsm.Component); FsmEditSet activeEditSet = _editManager.GetActiveEditSet(fsmKey); if (activeEditSet != null && activeEditSet.DisabledStates.Contains(stateName)) { _editManager.EnableState(fsmKey, stateName); } else { _editManager.DisableState(fsmKey, stateName); } InvalidateGraphCaches(); } private void HandleTransitionLeftClick(FsmInfo fsm, string owningStateName, string eventName) { if (owningStateName != "") { _selectedStateName = owningStateName; FsmStateInfo fsmStateInfo = FindStateInfo(fsm, owningStateName); int? pendingScrollActionIndex = ((fsmStateInfo != null) ? FindActionIndexForEvent(fsmStateInfo, eventName) : ((int?)null)); if (pendingScrollActionIndex.HasValue) { _pendingScrollActionIndex = pendingScrollActionIndex; } return; } foreach (FsmTabState tab in _tabManager.Tabs) { FsmInfo fsmInfo = ResolveFsmInfo(tab.FsmKey); if (fsmInfo == null) { continue; } foreach (FsmStateInfo state in fsmInfo.States) { int? pendingScrollActionIndex2 = FindActionIndexForEvent(state, eventName); if (pendingScrollActionIndex2.HasValue) { tab.SelectedStateName = state.Name; tab.PendingScrollActionIndex = pendingScrollActionIndex2; _tabManager.Focus(tab); return; } } } } private void HandleTransitionRightClick(FsmInfo fsm, string owningStateName, string eventName) { string fsmKey = FsmIdentity.GetFsmKey(fsm.Component); FsmEditSet activeEditSet = _editManager.GetActiveEditSet(fsmKey); if (activeEditSet != null && activeEditSet.TransitionRetargets.Exists((TransitionRetarget t) => t.StateName == owningStateName && t.EventName == eventName && t.NewToState == "\0DISABLED")) { _editManager.EnableTransition(fsmKey, owningStateName, eventName); } else { _editManager.DisableTransition(fsmKey, owningStateName, eventName); } InvalidateGraphCaches(); } private static FsmStateInfo? FindStateInfo(FsmInfo fsm, string stateName) { foreach (FsmStateInfo state in fsm.States) { if (state.Name == stateName) { return state; } } return null; } private static int? FindActionIndexForEvent(FsmStateInfo state, string eventName) { for (int i = 0; i < state.Actions.Count; i++) { foreach (FsmActionFieldInfo field in state.Actions[i].Fields) { object? fieldValue = field.FieldValue; FsmEvent val = (FsmEvent)((fieldValue is FsmEvent) ? fieldValue : null); if (val != null && val.Name == eventName) { return i; } if (!(field.FieldValue is FsmEvent[] array)) { continue; } FsmEvent[] array2 = array; foreach (FsmEvent val2 in array2) { if (val2 != null && val2.Name == eventName) { return i; } } } } return null; } private bool TryHitTestActionZone(Vector2 mousePos, out string owningStateName, out string eventName, out bool isSourceEnd) { //IL_0001: 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) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!TryHitTestEventNodeBox(mousePos, out owningStateName, out eventName) && !TryHitTestTransitionLine(mousePos, out owningStateName, out eventName)) { isSourceEnd = false; return false; } isSourceEnd = false; if (owningStateName != "" && _currentCache.NodeLayoutCache != null && _currentCache.NodeLayoutCache.TryGetValue(owningStateName, out NodeLayout value)) { foreach (TransitionRow row in value.Rows) { if (row.EventName == eventName) { isSourceEnd = Vector2.Distance(mousePos, row.CurvePoints[0]) <= Vector2.Distance(mousePos, row.CurvePoints[^1]); break; } } } return true; } private bool TryHitTestEventNodeBox(Vector2 dropScreenPos, out string owningStateName, out string eventName) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Rect rect; if (_currentCache.NodeLayoutCache != null) { foreach (NodeLayout value in _currentCache.NodeLayoutCache.Values) { foreach (TransitionRow row in value.Rows) { rect = row.Rect; if (((Rect)(ref rect)).Contains(dropScreenPos)) { owningStateName = value.Name; eventName = row.EventName; return true; } } } } if (_currentCache.GlobalPseudoNodeCache != null) { foreach (GlobalPseudoNodeLayout item in _currentCache.GlobalPseudoNodeCache) { rect = item.Rect; if (((Rect)(ref rect)).Contains(dropScreenPos)) { owningStateName = ""; eventName = item.EventName; return true; } } } owningStateName = ""; eventName = ""; return false; } private bool TryHitTestTransitionLine(Vector2 mousePos, out string owningStateName, out string eventName) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) float num = 6f; Rect val = default(Rect); ((Rect)(ref val))..ctor(mousePos.x - num, mousePos.y - num, num * 2f, num * 2f); if (_currentCache.NodeLayoutCache != null) { foreach (NodeLayout value in _currentCache.NodeLayoutCache.Values) { foreach (TransitionRow row in value.Rows) { Rect curveBounds = row.CurveBounds; if (((Rect)(ref curveBounds)).Overlaps(val) && IsPointNearPolyline(mousePos, row.CurvePoints, num)) { owningStateName = value.Name; eventName = row.EventName; return true; } } } } if (_currentCache.GlobalPseudoNodeCache != null) { foreach (GlobalPseudoNodeLayout item in _currentCache.GlobalPseudoNodeCache) { if (IsPointNearPolyline(mousePos, item.ArrowPoints, num)) { owningStateName = ""; eventName = item.EventName; return true; } } } owningStateName = ""; eventName = ""; return false; } private static bool IsPointNearPolyline(Vector2 point, Vector2[] polyline, float tolerance) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < polyline.Length - 1; i++) { if (DistancePointToSegment(point, polyline[i], polyline[i + 1]) <= tolerance) { return true; } } return false; } private static float DistancePointToSegment(Vector2 point, Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0021: 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_0027: 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_0036: 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) //IL_0042: 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) //IL_0044: 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_0019: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude; if (sqrMagnitude < 0.0001f) { return Vector2.Distance(point, a); } float num = Mathf.Clamp01(Vector2.Dot(point - a, val) / sqrMagnitude); Vector2 val2 = a + val * num; return Vector2.Distance(point, val2); } private void HandleTransitionDrag(FsmInfo fsm, Rect interactiveRect) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (_draggingTransition == null) { return; } Event current = Event.current; if ((int)current.type == 3) { if (!_draggingTransition.HasCrossedThreshold && Vector2.Distance(current.mousePosition, _draggingTransition.MouseDownScreenPos) >= 4f) { _draggingTransition.HasCrossedThreshold = true; } current.Use(); } else if ((int)current.type == 1) { DraggingTransition draggingTransition = _draggingTransition; _draggingTransition = null; current.Use(); if (!draggingTransition.HasCrossedThreshold) { HandleTransitionLeftClick(fsm, draggingTransition.OwningStateName, draggingTransition.EventName); } else { CommitTransitionDrag(fsm, draggingTransition, current.mousePosition); } } } private (Vector2 Anchor, Vector2 ExitDirection)? ResolveDragAnchor(Vector2 mousePos) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) if (_draggingTransition == null) { return null; } if (_draggingTransition.OwningStateName == "") { if (_currentCache.GlobalPseudoNodeCache != null) { foreach (GlobalPseudoNodeLayout item in _currentCache.GlobalPseudoNodeCache) { if (item.EventName == _draggingTransition.EventName) { return (item.ArrowPoints[1], new Vector2(0f, -1f)); } } } return null; } if (_currentCache.NodeLayoutCache != null && _currentCache.NodeLayoutCache.TryGetValue(_draggingTransition.OwningStateName, out NodeLayout value)) { foreach (TransitionRow row in value.Rows) { if (!(row.EventName != _draggingTransition.EventName)) { Rect val = row.Rect; if (!_draggingTransition.DraggingSourceEnd && _currentCache.NodeLayoutCache.TryGetValue(row.ToState, out NodeLayout value2)) { val = value2.TitleRect; } Vector2 val2 = ((mousePos.x >= ((Rect)(ref val)).center.x) ? new Vector2(1f, 0f) : new Vector2(-1f, 0f)); return (new Vector2((val2.x > 0f) ? ((Rect)(ref val)).xMax : ((Rect)(ref val)).x, ((Rect)(ref val)).center.y), val2); } } } return null; } private void CommitTransitionDrag(FsmInfo fsm, DraggingTransition dragging, Vector2 dropScreenPos) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) string fsmKey = FsmIdentity.GetFsmKey(fsm.Component); if (TryHitTestEventNodeBox(dropScreenPos, out string owningStateName, out string eventName)) { if (!(owningStateName == dragging.OwningStateName) || !(eventName == dragging.EventName)) { string text = ReadCurrentToState(fsm, dragging.OwningStateName, dragging.EventName); if (text != null) { _editManager.RetargetTransitionEvent(fsmKey, dragging.OwningStateName, dragging.EventName, owningStateName, eventName, text); InvalidateGraphCaches(); } } } else { if (_currentCache.NodeLayoutCache == null) { return; } foreach (NodeLayout value in _currentCache.NodeLayoutCache.Values) { if (((Rect)(ref value.ScreenRect)).Contains(dropScreenPos)) { if (!(value.Name == dragging.OwningStateName)) { _editManager.RetargetTransitionToState(fsmKey, dragging.OwningStateName, dragging.EventName, value.Name); InvalidateGraphCaches(); } break; } } } } private static string? ReadCurrentToState(FsmInfo fsm, string owningStateName, string eventName) { FsmTransition obj = ((owningStateName == "") ? FsmUtil.GetGlobalTransition(fsm.Fsm, eventName) : FsmUtil.GetTransition(fsm.Fsm, owningStateName, eventName)); if (obj == null) { return null; } return obj.ToState; } private void HandlePanAndZoom(Rect canvasRect) { //IL_0007: 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_003b: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 //IL_008b: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_00a6: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref canvasRect)).Contains(current.mousePosition) && !IsPointerOverUi()) { _isPanning = true; } else if ((int)current.type == 1) { _isPanning = false; } else if ((int)current.type == 3 && _isPanning) { _panWorldCenter -= current.delta / _zoom; current.Use(); } else if ((int)current.type == 6 && ((Rect)(ref canvasRect)).Contains(current.mousePosition) && !IsPointerOverUi()) { _zoom = Mathf.Clamp(_zoom - current.delta.y * 0.05f, 0.1f, 3f); current.Use(); } } private float GetNodeCornerRadius(Rect nodeScreenRect) { float num = Mathf.Min(16f, 16f) * _zoom; return Mathf.Min(10f * _zoom, Mathf.Min(((Rect)(ref nodeScreenRect)).width, num) / 2f); } private float GetScreenCornerRadius(Rect rect) { return Mathf.Min(10f * _zoom, Mathf.Min(((Rect)(ref rect)).width, ((Rect)(ref rect)).height) / 2f); } private Color GetActiveOutlineColor(int colorIndex) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (colorIndex != 0) { return _colors.StateColors[colorIndex].Value; } return _colors.ActiveStateColor.Value; } private Color GetFadingActiveColor(float fadeT) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Color value = _colors.ActiveStateColor.Value; return new Color(value.r, value.g, value.b, value.a * (1f - fadeT)); } private void AddTriangleToChromeBuffer(Vector2 a, Vector2 b, Vector2 c, Color color) { //IL_000b: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) _currentCache.ChromeVertexBuffer.Add((a, color)); _currentCache.ChromeVertexBuffer.Add((b, color)); _currentCache.ChromeVertexBuffer.Add((c, color)); } private void AddFilledRectToChromeBuffer(Rect rect, Color color) { //IL_0055: 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_0057: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Vector2 a = default(Vector2); ((Vector2)(ref a))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y); Vector2 b = default(Vector2); ((Vector2)(ref b))..ctor(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).y); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax); Vector2 c = default(Vector2); ((Vector2)(ref c))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax); AddTriangleToChromeBuffer(a, b, val, color); AddTriangleToChromeBuffer(a, val, c, color); } private void AddRoundedRectToChromeBuffer(Rect rect, float radius, Color color, bool roundTop = true, bool roundBottom = true) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) radius = Mathf.Min(radius, Mathf.Min(((Rect)(ref rect)).width, ((Rect)(ref rect)).height) / 2f); radius = ((roundTop || roundBottom) ? radius : 0f); float num = (roundTop ? radius : 0f); float num2 = (roundBottom ? radius : 0f); AddFilledRectToChromeBuffer(new Rect(((Rect)(ref rect)).x + radius, ((Rect)(ref rect)).y, Mathf.Max(0f, ((Rect)(ref rect)).width - radius * 2f), ((Rect)(ref rect)).height), color); AddFilledRectToChromeBuffer(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + num, radius, Mathf.Max(0f, ((Rect)(ref rect)).height - num - num2)), color); AddFilledRectToChromeBuffer(new Rect(((Rect)(ref rect)).xMax - radius, ((Rect)(ref rect)).y + num, radius, Mathf.Max(0f, ((Rect)(ref rect)).height - num - num2)), color); if (roundTop) { AddCornerFanToChromeBuffer(new Vector2(((Rect)(ref rect)).x + radius, ((Rect)(ref rect)).y + radius), radius, 180f, color); AddCornerFanToChromeBuffer(new Vector2(((Rect)(ref rect)).xMax - radius, ((Rect)(ref rect)).y + radius), radius, 270f, color); } if (roundBottom) { AddCornerFanToChromeBuffer(new Vector2(((Rect)(ref rect)).x + radius, ((Rect)(ref rect)).yMax - radius), radius, 90f, color); AddCornerFanToChromeBuffer(new Vector2(((Rect)(ref rect)).xMax - radius, ((Rect)(ref rect)).yMax - radius), radius, 0f, color); } } private void AddCornerFanToChromeBuffer(Vector2 center, float radius, float fromDegrees, Color color) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006e: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!(radius < 0.5f)) { for (int i = 0; i < 8; i++) { float num = (fromDegrees + 90f * (float)i / 8f) * (MathF.PI / 180f); float num2 = (fromDegrees + 90f * (float)(i + 1) / 8f) * (MathF.PI / 180f); Vector2 b = center + new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * radius; Vector2 c = center + new Vector2(Mathf.Cos(num2), Mathf.Sin(num2)) * radius; AddTriangleToChromeBuffer(center, b, c, color); } } } private void AddRoundedRectOutlineToChromeBuffer(Rect rect, Color fillColor, Color outlineColor, float borderThickness) { //IL_004f: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Rect rect2 = default(Rect); ((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x - borderThickness, ((Rect)(ref rect)).y - borderThickness, ((Rect)(ref rect)).width + borderThickness * 2f, ((Rect)(ref rect)).height + borderThickness * 2f); float num = ((_performance.BoxStyle.Value == GraphBoxStyle.Standard) ? 0f : GetScreenCornerRadius(rect)); AddRoundedRectToChromeBuffer(rect2, num + borderThickness, outlineColor); AddRoundedRectToChromeBuffer(rect, num, fillColor); } private static Color ApplyDim(Color color, bool dim) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (!dim) { return color; } Color val = default(Color); ((Color)(ref val))..ctor(0.5f, 0.5f, 0.5f, color.a); Color result = Color.Lerp(color, val, 0.6f); result.a = color.a * 0.55f; return result; } private void FlushChromeBufferGL(Vector2 canvasScreenOffset, float clipRightAbsolute, bool dim) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (_currentCache.ChromeVertexBuffer.Count == 0) { return; } EnsureGlMaterial(); if ((Object)(object)_glMaterial == (Object)null) { return; } GL.PushMatrix(); ApplyClippedPixelMatrix(canvasScreenOffset, clipRightAbsolute); _glMaterial.SetPass(0); GL.Begin(4); foreach (var item in _currentCache.ChromeVertexBuffer) { var (val, _) = item; GL.Color(ApplyDim(item.Color, dim)); GL.Vertex3(val.x, val.y, 0f); } GL.End(); GL.PopMatrix(); ResetGlViewport(); } private static void ApplyClippedPixelMatrix(Vector2 canvasScreenOffset, float clipRightAbsolute) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0037: Unknown result type (might be due to invalid IL or missing references) GL.Viewport(new Rect(0f, 0f, clipRightAbsolute, (float)Screen.height)); GL.LoadPixelMatrix(0f - canvasScreenOffset.x, clipRightAbsolute - canvasScreenOffset.x, (float)Screen.height - canvasScreenOffset.y, 0f - canvasScreenOffset.y); } private static void ResetGlViewport() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) GL.Viewport(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height)); } private void EnsureGlMaterial() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (!((Object)(object)_glMaterial != (Object)null) && !_glMaterialFailed) { Shader val = Shader.Find("Hidden/Internal-Colored"); if ((Object)(object)val == (Object)null) { _glMaterialFailed = true; _logger.LogError((object)"[FsmMaster] Graph overlay: built-in shader \"Hidden/Internal-Colored\" was not found - transition lines will not render."); return; } _glMaterial = new Material(val) { hideFlags = (HideFlags)61 }; _glMaterial.SetInt("_SrcBlend", 5); _glMaterial.SetInt("_DstBlend", 10); _glMaterial.SetInt("_Cull", 0); _glMaterial.SetInt("_ZWrite", 0); } } private void DrawLineBufferGL(Vector2 canvasScreenOffset, float clipRightAbsolute, bool dim) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (_currentCache.LineDrawBuffer.Count == 0) { return; } EnsureGlMaterial(); if ((Object)(object)_glMaterial == (Object)null) { return; } GL.PushMatrix(); ApplyClippedPixelMatrix(canvasScreenOffset, clipRightAbsolute); _glMaterial.SetPass(0); switch (_performance.LineStyle.Value) { case GraphLineStyle.Straight: GL.Begin(1); foreach (var (array, color2, _, _, _) in _currentCache.LineDrawBuffer) { if (array.Length >= 2) { EmitThinSegment(array[0], array[^1], ApplyDim(color2, dim)); } } GL.End(); break; case GraphLineStyle.Thin: GL.Begin(1); foreach (var (points2, color3, _, num4, num5) in _currentCache.LineDrawBuffer) { EmitThinPolyline(points2, ApplyDim(color3, dim), num4 * _zoom, num5 * _zoom); } GL.End(); break; default: GL.Begin(4); foreach (var (points, color, num, num2, num3) in _currentCache.LineDrawBuffer) { EmitThickPolyline(points, ApplyDim(color, dim), num * _zoom, num2 * _zoom, num3 * _zoom); } GL.End(); break; } GL.PopMatrix(); ResetGlViewport(); } private static Vector2 WalkBackAlongPolyline(Vector2[] points, float distance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0028: 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_0037: Unknown result type (might be due to invalid IL or missing references) float num = distance; for (int num2 = points.Length - 2; num2 >= 0; num2--) { float num3 = Vector2.Distance(points[num2], points[num2 + 1]); if (num3 >= num) { return Vector2.Lerp(points[num2 + 1], points[num2], num / num3); } num -= num3; } return points[0]; } private static Vector2[] TrimPolylineEnd(Vector2[] points, float distance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_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) float num = distance; for (int num2 = points.Length - 1; num2 > 0; num2--) { float num3 = Vector2.Distance(points[num2 - 1], points[num2]); if (num3 >= num) { Vector2[] array = (Vector2[])(object)new Vector2[num2 + 1]; Array.Copy(points, array, num2); array[num2] = Vector2.Lerp(points[num2], points[num2 - 1], num / num3); return array; } num -= num3; } return (Vector2[])(object)new Vector2[1] { points[0] }; } private static void EmitThinPolyline(Vector2[] points, Color color, float arrowLength, float outlineMargin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_002d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < points.Length - 1; i++) { EmitThinSegment(points[i], points[i + 1], color); } if (points.Length >= 2) { EmitThinArrowhead(points, color, arrowLength, outlineMargin); } } private static void EmitThinSegment(Vector2 from, Vector2 to, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_001c: 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) GL.Color(color); GL.Vertex3(from.x, from.y, 0f); GL.Vertex3(to.x, to.y, 0f); } private static void EmitThinArrowhead(Vector2[] points, Color color, float arrowLength, float outlineMargin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) //IL_0043: 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_0049: 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_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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) //IL_0095: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) Vector2 a = points[^1]; Vector2 val = WalkBackAlongPolyline(points, arrowLength * 0.6f); Vector2 val2 = a - val; if (!(((Vector2)(ref val2)).sqrMagnitude < 0.0001f)) { Vector3 val3 = Vector2.op_Implicit(-((Vector2)(ref val2)).normalized) * arrowLength; Vector2 b = a + Vector2.op_Implicit(Quaternion.Euler(0f, 0f, 25f) * val3); Vector2 c = a + Vector2.op_Implicit(Quaternion.Euler(0f, 0f, -25f) * val3); if (outlineMargin > 0f) { PushTriangleOutward(ref a, ref b, ref c, outlineMargin); } EmitThinSegment(a, b, color); EmitThinSegment(a, c, color); EmitThinSegment(b, c, color); } } private static void PushTriangleOutward(ref Vector2 a, ref Vector2 b, ref Vector2 c, float margin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_002e: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (a + b + c) / 3f; a += DirectionFrom(val, a) * margin; b += DirectionFrom(val, b) * margin; c += DirectionFrom(val, c) * margin; static Vector2 DirectionFrom(Vector2 from, Vector2 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) Vector2 val2 = to - from; if (!(((Vector2)(ref val2)).sqrMagnitude < 0.0001f)) { return ((Vector2)(ref val2)).normalized; } return Vector2.zero; } } private static void EmitThickPolyline(Vector2[] points, Color color, float thickness, float arrowLength, float outlineMargin) { //IL_001e: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (points.Length >= 2) { Vector2[] array = TrimPolylineEnd(points, arrowLength * ArrowheadBackTrimFactor + outlineMargin); for (int i = 0; i < array.Length - 1; i++) { EmitThickSegment(array[i], array[i + 1], color, thickness); } EmitThickArrowhead(points, color, arrowLength, outlineMargin); } } private static void EmitThickArrowhead(Vector2[] points, Color color, float arrowLength, float outlineMargin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) //IL_0043: 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_0049: 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_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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) //IL_0095: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) Vector2 a = points[^1]; Vector2 val = WalkBackAlongPolyline(points, arrowLength * 0.6f); Vector2 val2 = a - val; if (!(((Vector2)(ref val2)).sqrMagnitude < 0.0001f)) { Vector3 val3 = Vector2.op_Implicit(-((Vector2)(ref val2)).normalized) * arrowLength; Vector2 b = a + Vector2.op_Implicit(Quaternion.Euler(0f, 0f, 25f) * val3); Vector2 c = a + Vector2.op_Implicit(Quaternion.Euler(0f, 0f, -25f) * val3); if (outlineMargin > 0f) { PushTriangleOutward(ref a, ref b, ref c, outlineMargin); } GL.Color(color); GL.Vertex3(a.x, a.y, 0f); GL.Vertex3(b.x, b.y, 0f); GL.Vertex3(c.x, c.y, 0f); } } private static void EmitThickSegment(Vector2 from, Vector2 to, Color color, float thickness) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Vector2 val = to - from; float magnitude = ((Vector2)(ref val)).magnitude; if (!(magnitude < 0.01f)) { Vector2 val2 = new Vector2(0f - val.y, val.x) / magnitude; Vector2 val3 = val2 * (thickness / 2f); Vector2 val4 = val2 * (thickness / 2f + 1.5f); Color val5 = default(Color); ((Color)(ref val5))..ctor(color.r, color.g, color.b, 0f); EmitQuad(from - val3, from + val3, to + val3, to - val3, color, color, color, color); EmitQuad(from + val3, from + val4, to + val4, to + val3, color, val5, val5, color); EmitQuad(from - val4, from - val3, to - val3, to - val4, val5, color, color, val5); } } private static void EmitQuad(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Color colorA, Color colorB, Color colorC, Color colorD) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) GL.Color(colorA); GL.Vertex3(a.x, a.y, 0f); GL.Color(colorB); GL.Vertex3(b.x, b.y, 0f); GL.Color(colorC); GL.Vertex3(c.x, c.y, 0f); GL.Color(colorA); GL.Vertex3(a.x, a.y, 0f); GL.Color(colorC); GL.Vertex3(c.x, c.y, 0f); GL.Color(colorD); GL.Vertex3(d.x, d.y, 0f); } } internal enum GraphLineStyle { Thick, Thin, Straight } internal enum GraphBoxStyle { Detailed, Standard } internal sealed class FsmGraphPerformanceConfig { public ConfigEntry LineStyle { get; } public ConfigEntry BoxStyle { get; } public int Generation { get; private set; } private FsmGraphPerformanceConfig(ConfigEntry lineStyle, ConfigEntry boxStyle) { LineStyle = lineStyle; BoxStyle = boxStyle; } public static FsmGraphPerformanceConfig Bind(ConfigFile config) { ConfigEntry lineStyle = config.Bind("Performance", "Line Style", GraphLineStyle.Thin, "How transition lines are drawn. Thick: antialiased curved lines with arrowheads (most detailed, most expensive). Thin: the same curves drawn as hard-edged 1px lines with arrowheads. Straight: a plain straight segment between each transition's endpoints, no arrowhead (cheapest)."); ConfigEntry boxStyle = config.Bind("Performance", "Box Style", GraphBoxStyle.Detailed, "How state/event boxes are drawn. Detailed: rounded corners, a border ring on every box, and divider lines between the title and its transition rows. Standard: square corners, no border ring unless the state is active or selected, and no divider lines (cheapest)."); FsmGraphPerformanceConfig instance = new FsmGraphPerformanceConfig(lineStyle, boxStyle); config.SettingChanged += delegate { instance.Generation++; }; return instance; } } internal sealed class FsmMonitorPanel : CanvasPanel { private const int PanelWidth = 355; private const int PanelHeight = 231; private const int ScreenMargin = 0; private const float TitleBarHeightDesign = 20f; private const float RowHeightDesign = 18f; private const float ScrollbarWidthDesign = 10f; private const float ResizeHandleSizeDesign = 14f; private const int MinPanelWidth = 150; private const int MinPanelHeight = 100; private readonly UICommon _ui; private readonly CanvasImage _background; private readonly CanvasButton _dragSurface; private readonly CanvasText _titleText; private readonly CanvasScrollView _scrollView; private readonly CanvasScrollbar _scrollbar; private readonly CanvasResizeHandle _resizeHandle; private readonly FsmPanelLayoutConfig _layout; private readonly List _valueTexts = new List(); private readonly List _lastValues = new List(); private int _lastTrackerVersion = -1; private bool _locked; private int _lastScreenWidth = -1; private int _lastScreenHeight = -1; private static float TitleBarHeight => UICommon.ScaleHeight(20f); private static float RowHeight => UICommon.ScaleHeight(18f); private static float ScrollbarWidth => UICommon.ScaleWidth(10f); private static float ResizeHandleSize => UICommon.ScaleWidth(14f); private static float MinWidth => UICommon.ScaleWidth(150); private static float MinHeight => UICommon.ScaleHeight(100); public bool Locked { set { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (_locked != value) { _locked = value; _dragSurface.ActiveSelf = !value; _resizeHandle.ActiveSelf = !value; _background.Tint = (value ? Color.clear : _ui.PanelBackground); } } } public FsmMonitorPanel(UICommon ui, FsmVariableTracker tracker, FsmPanelLayoutConfig layout) : base("FsmMonitorPanel") { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) _ui = ui; _layout = layout; _background = Add(new CanvasImage("Background", ui) { IsBackground = true, Tint = ui.PanelBackground }); _background.AddBorder(ui.PanelBorder); _dragSurface = Add(new CanvasButton("DragSurface", ui) { Tint = Color.clear }); _dragSurface.RemoveBorder(); _titleText = Add(new CanvasText("Title", ui) { Text = "Monitor" }); _titleText.Font = ui.HeaderFont; _titleText.FontStyle = (FontStyle)1; _titleText.Alignment = (TextAnchor)3; _scrollView = Add(new CanvasScrollView("ScrollView")); _scrollView.SetContent(new CanvasPanel("Content")); _scrollbar = Add(new CanvasScrollbar("Scrollbar", ui) { ScrollView = _scrollView }); _resizeHandle = Add(new CanvasResizeHandle("ResizeHandle", ui)); _resizeHandle.OnDragDelta += OnResizeDragged; _resizeHandle.OnDragEnd += OnResizeDragEnded; Reposition(); Layout(); base.OnUpdate += delegate { _scrollbar.ActiveSelf = _scrollbar.ShouldBeVisible; ReflowOnResolutionChange(); }; } public override void Build(Transform? rootParent = null) { base.Build(rootParent); _dragSurface.AddEventTrigger((EventTriggerType)5, OnDragged); _dragSurface.AddEventTrigger((EventTriggerType)14, OnDragEnded); } public void RefreshRows(FsmVariableTracker tracker) { IReadOnlyList tracked = tracker.GetTracked(); if (tracker.Version != _lastTrackerVersion) { _lastTrackerVersion = tracker.Version; RebuildRows(tracked); return; } for (int i = 0; i < tracked.Count && i < _valueTexts.Count; i++) { string currentValue = tracked[i].CurrentValue; if (!(_lastValues[i] == currentValue)) { _lastValues[i] = currentValue; _valueTexts[i].Text = tracked[i].DisplayLabel + ": " + currentValue; } } } private void RebuildRows(IReadOnlyList values) { //IL_0080: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) CanvasPanel canvasPanel = (CanvasPanel)_scrollView.Content; canvasPanel.ClearChildren(); _valueTexts.Clear(); _lastValues.Clear(); float num = 0f; int num2 = 0; foreach (TrackedVariableValue value in values) { CanvasText canvasText = canvasPanel.Add(new CanvasText($"Row{num2++}", _ui)); canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(4f, num); canvasText.Size = new Vector2(Mathf.Max(0f, _scrollView.Size.x - 8f), RowHeight); canvasText.Text = value.DisplayLabel + ": " + value.CurrentValue; canvasText.Build(); _valueTexts.Add(canvasText); _lastValues.Add(value.CurrentValue); num += RowHeight; } canvasPanel.Size = new Vector2(_scrollView.Size.x, num); } private void OnDragged(PointerEventData eventData) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!_locked) { Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(base.LocalPosition.x + eventData.delta.x, base.LocalPosition.y - eventData.delta.y); val.x = Mathf.Clamp(val.x, 0f, Mathf.Max(0f, (float)Screen.width - base.Size.x)); val.y = Mathf.Clamp(val.y, 0f, Mathf.Max(0f, (float)Screen.height - base.Size.y)); base.LocalPosition = val; } } private void OnDragEnded(PointerEventData _) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!_locked) { _layout.Position.Value = base.LocalPosition; } } private void OnResizeDragged(Vector2 delta) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (!_locked) { float num = base.LocalPosition.x + base.Size.x; float num2 = base.LocalPosition.y + base.Size.y; float num3 = Mathf.Clamp(base.Size.x - delta.x, MinWidth, Mathf.Max(MinWidth, num)); float num4 = Mathf.Clamp(base.Size.y + delta.y, MinHeight, Mathf.Max(MinHeight, num2)); base.LocalPosition = new Vector2(num - num3, num2 - num4); base.Size = new Vector2(num3, num4); Layout(); } } private void OnResizeDragEnded() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!_locked) { _layout.Position.Value = base.LocalPosition; _layout.Size.Value = base.Size; } } private void Layout() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) _background.Size = base.Size; _dragSurface.LocalPosition = Vector2.zero; _dragSurface.Size = new Vector2(base.Size.x, TitleBarHeight); _titleText.LocalPosition = new Vector2(6f, 0f); _titleText.Size = new Vector2(Mathf.Max(0f, base.Size.x - 12f), TitleBarHeight); float num = TitleBarHeight + 2f; float num2 = Mathf.Max(0f, base.Size.y - num - 4f - ResizeHandleSize); _scrollView.LocalPosition = new Vector2(4f, num); _scrollView.Size = new Vector2(Mathf.Max(0f, base.Size.x - ScrollbarWidth - 8f), num2); _scrollbar.LocalPosition = new Vector2(base.Size.x - ScrollbarWidth - 2f, num); _scrollbar.Size = new Vector2(ScrollbarWidth, num2); _resizeHandle.LocalPosition = new Vector2(0f, base.Size.y - ResizeHandleSize); _resizeHandle.Size = new Vector2(ResizeHandleSize, ResizeHandleSize); } private void ReflowOnResolutionChange() { if (Screen.width != _lastScreenWidth || Screen.height != _lastScreenHeight) { Reposition(); Layout(); } } private void Reposition() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) _lastScreenWidth = Screen.width; _lastScreenHeight = Screen.height; base.Size = (_layout.HasSavedSize ? new Vector2(Mathf.Max(MinWidth, _layout.Size.Value.x), Mathf.Max(MinHeight, _layout.Size.Value.y)) : new Vector2((float)UICommon.ScaleWidth(355), (float)UICommon.ScaleHeight(231))); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)(Screen.width - UICommon.ScaleWidth(0)) - base.Size.x, (float)(Screen.height - UICommon.ScaleHeight(0)) - base.Size.y); Vector2 val2 = (_layout.HasSavedPosition ? _layout.Position.Value : val); base.LocalPosition = new Vector2(Mathf.Clamp(val2.x, 0f, Mathf.Max(0f, (float)Screen.width - base.Size.x)), Mathf.Clamp(val2.y, 0f, Mathf.Max(0f, (float)Screen.height - base.Size.y))); } } internal sealed class FsmActiveStatePanel : CanvasPanel { private enum SubTabKind { Actions, Events, Variables, Sequencer } private sealed class RowCursor { public float Y; public int Count; } private const float HeaderHeightDesign = 18f; private const float SubTabButtonHeightDesign = 24f; private const float RowHeightDesign = 18f; private const float HeaderRowHeightDesign = 22f; private const float ScrollbarWidthDesign = 10f; private const float RowIndentDesign = 4f; private const float FieldIndentDesign = 14f; private const float BlockPaddingDesign = 4f; private const float BlockGapDesign = 6f; private const float BlockRightGapDesign = 4f; private const float SequencerButtonWidthDesign = 80f; private const float ColumnGapDesign = 10f; private const float CloseButtonSizeDesign = 16f; private const float SeqDeleteButtonSizeDesign = 18f; private const float SeqRowGapDesign = 2f; private const float LoopToggleWidthDesign = 70f; private const float DragGhostWidthDesign = 140f; private readonly UICommon _ui; private readonly FsmEditManager _editManager; private readonly FsmVariableTracker _tracker; private readonly ManualLogSource _logger; private readonly Action _showStatus; private readonly CanvasText _header; private readonly CanvasToggleDot _stateHeaderDot; private readonly CanvasButton _actionsTab; private readonly CanvasButton _eventsTab; private readonly CanvasButton _variablesTab; private readonly CanvasButton _sequencerTab; private readonly CanvasScrollView _scrollView; private readonly CanvasScrollbar _scrollbar; private SubTabKind _activeSubTab; private FsmInfo? _cachedFsm; private string? _cachedStateName; private SubTabKind? _cachedSubTab; private string? _cachedTabFsmKey; private readonly List _headerRefreshers = new List(); private readonly List _valueRefreshers = new List(); private readonly Dictionary _actionBlocks = new Dictionary(); private CanvasSectionBlock? _selectedBlock; private readonly Dictionary> _openSequencerBlocks = new Dictionary>(); private readonly Dictionary<(string StateName, int ActionRank), CanvasSectionBlock> _sequencerBlockWidgets = new Dictionary<(string, int), CanvasSectionBlock>(); private readonly Dictionary<(string StateName, int ActionRank), CanvasNode> _sequenceColumnHitAreas = new Dictionary<(string, int), CanvasNode>(); private readonly Dictionary<(string StateName, int ActionRank), List> _sequenceRowWidgets = new Dictionary<(string, int), List>(); private (string StateName, int ActionRank)? _dragBlockKey; private string? _dragEventName; private int? _dragSourceIndex; private readonly CanvasPanel _dragGhost; private readonly CanvasText _dragGhostText; private static float HeaderHeight => UICommon.ScaleHeight(18f); private static float SubTabButtonHeight => UICommon.ScaleHeight(24f); private static float RowHeight => UICommon.ScaleHeight(18f); private static float HeaderRowHeight => UICommon.ScaleHeight(22f); private static float ScrollbarWidth => UICommon.ScaleWidth(10f); private static float RowIndent => UICommon.ScaleWidth(4f); private static float FieldIndent => UICommon.ScaleWidth(14f); private static float ArrayElementIndent => FieldIndent + UICommon.ScaleWidth(12f); private static float BlockPadding => UICommon.ScaleHeight(4f); private static float BlockGap => UICommon.ScaleHeight(6f); private static float BlockRightGap => UICommon.ScaleWidth(4f); private static float SequencerButtonWidth => UICommon.ScaleWidth(80f); private static float ColumnGap => UICommon.ScaleWidth(10f); private static float CloseButtonSize => UICommon.ScaleWidth(16f); private static float SeqDeleteButtonSize => UICommon.ScaleWidth(18f); private static float SeqRowGap => UICommon.ScaleHeight(2f); private static float LoopToggleWidth => UICommon.ScaleWidth(70f); private static float DragGhostWidth => UICommon.ScaleWidth(140f); private float DotWidth => _ui.DotSize; private static float DotGap => UICommon.ScaleWidth(4f); public FsmActiveStatePanel(UICommon ui, FsmEditManager editManager, FsmVariableTracker tracker, ManualLogSource logger, Action showStatus) : base("ActiveStatePanel") { //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) _ui = ui; _editManager = editManager; _tracker = tracker; _logger = logger; _showStatus = showStatus; _header = Add(new CanvasText("Header", ui) { Text = "No state selected" }); _header.Font = ui.HeaderFont; _header.FontStyle = (FontStyle)1; _stateHeaderDot = Add(new CanvasToggleDot("StateHeaderDot", ui)); _stateHeaderDot.ActiveSelf = false; _stateHeaderDot.OnClicked += delegate { if (!((Object)(object)_cachedFsm?.Component == (Object)null)) { string fsmKey = FsmIdentity.GetFsmKey(_cachedFsm.Component); string activeStateName = _cachedFsm.Fsm.ActiveStateName; if (_tracker.IsStateTracked(fsmKey, activeStateName)) { _tracker.UntrackState(fsmKey, activeStateName); } else { _tracker.TrackState(fsmKey, activeStateName); } } }; _headerRefreshers.Add(delegate { if (!((Object)(object)_cachedFsm?.Component == (Object)null)) { string fsmKey = FsmIdentity.GetFsmKey(_cachedFsm.Component); _stateHeaderDot.On = _tracker.IsStateTracked(fsmKey, _cachedFsm.Fsm.ActiveStateName); } }); _actionsTab = Add(new CanvasButton("ActionsTab", ui)); _actionsTab.Text.Text = "Actions"; _actionsTab.OnClicked += delegate { SetActiveSubTab(SubTabKind.Actions); }; _eventsTab = Add(new CanvasButton("EventsTab", ui)); _eventsTab.Text.Text = "Events"; _eventsTab.OnClicked += delegate { SetActiveSubTab(SubTabKind.Events); }; _variablesTab = Add(new CanvasButton("VariablesTab", ui)); _variablesTab.Text.Text = "Variables"; _variablesTab.OnClicked += delegate { SetActiveSubTab(SubTabKind.Variables); }; _sequencerTab = Add(new CanvasButton("SequencerTab", ui)); _sequencerTab.Text.Text = "Sequencer"; _sequencerTab.OnClicked += delegate { SetActiveSubTab(SubTabKind.Sequencer); }; _scrollView = Add(new CanvasScrollView("ScrollView")); _scrollView.SetContent(new CanvasPanel("Content")); _scrollbar = Add(new CanvasScrollbar("Scrollbar", ui) { ScrollView = _scrollView }); _dragGhost = Add(new CanvasPanel("DragGhost")); _dragGhost.ActiveSelf = false; _dragGhost.Add(new CanvasImage("Background", ui) { IsBackground = true, Tint = ui.ButtonActive }).AddBorder(ui.AccentColor); _dragGhostText = _dragGhost.Add(new CanvasText("Label", ui)); _dragGhostText.Alignment = (TextAnchor)3; _dragGhostText.Overflow = (HorizontalWrapMode)1; UpdateSubTabToggles(); base.OnUpdate += delegate { _scrollbar.ActiveSelf = _scrollbar.ShouldBeVisible; }; base.OnUpdate += RecheckScrollWidth; } public override void Build(Transform? rootParent = null) { Layout(); base.Build(rootParent); } protected override void OnUpdateSize() { base.OnUpdateSize(); Layout(); } private void Layout() { //IL_001d: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) _stateHeaderDot.LocalPosition = new Vector2(0f, (HeaderHeight - DotWidth) / 2f); _stateHeaderDot.Size = new Vector2(DotWidth, DotWidth); _header.LocalPosition = new Vector2(DotWidth + DotGap, 0f); _header.Size = new Vector2(Mathf.Max(0f, base.Size.x - DotWidth - DotGap), HeaderHeight); float num = HeaderHeight + 2f; float num2 = base.Size.x / 4f; _actionsTab.LocalPosition = new Vector2(0f, num); _actionsTab.Size = new Vector2(num2, SubTabButtonHeight); _eventsTab.LocalPosition = new Vector2(num2, num); _eventsTab.Size = new Vector2(num2, SubTabButtonHeight); _variablesTab.LocalPosition = new Vector2(num2 * 2f, num); _variablesTab.Size = new Vector2(num2, SubTabButtonHeight); _sequencerTab.LocalPosition = new Vector2(num2 * 3f, num); _sequencerTab.Size = new Vector2(base.Size.x - num2 * 3f, SubTabButtonHeight); float num3 = num + SubTabButtonHeight + 4f; float num4 = Mathf.Max(0f, base.Size.y - num3); float num5 = ComputeScrollWidth(num4); _scrollView.LocalPosition = new Vector2(0f, num3); _scrollView.Size = new Vector2(num5, num4); _scrollbar.LocalPosition = new Vector2(base.Size.x - ScrollbarWidth, num3); _scrollbar.Size = new Vector2(ScrollbarWidth, num4); _dragGhost.Size = new Vector2(DragGhostWidth, RowHeight); _dragGhostText.Size = _dragGhost.Size; } private float ComputeScrollWidth(float scrollHeight) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) CanvasNode content = _scrollView.Content; if (content == null || !(content.Size.y > scrollHeight)) { return Mathf.Max(0f, base.Size.x); } return Mathf.Max(0f, base.Size.x - ScrollbarWidth - 2f); } private void RecheckScrollWidth() { //IL_0007: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) float num = ComputeScrollWidth(_scrollView.Size.y); if (!Mathf.Approximately(_scrollView.Size.x, num)) { _scrollView.Size = new Vector2(num, _scrollView.Size.y); RebuildContent(_cachedFsm, _cachedStateName); } } private void SetActiveSubTab(SubTabKind kind) { if (_activeSubTab != kind) { _activeSubTab = kind; UpdateSubTabToggles(); } } private void UpdateSubTabToggles() { _actionsTab.Toggled = _activeSubTab == SubTabKind.Actions; _eventsTab.Toggled = _activeSubTab == SubTabKind.Events; _variablesTab.Toggled = _activeSubTab == SubTabKind.Variables; _sequencerTab.Toggled = _activeSubTab == SubTabKind.Sequencer; } public void Refresh(FsmInfo? fsm, string? stateName, string? tabFsmKey) { if (fsm == null) { if (!(tabFsmKey == _cachedTabFsmKey)) { _cachedFsm = null; _cachedStateName = stateName; _cachedSubTab = _activeSubTab; _cachedTabFsmKey = tabFsmKey; RebuildContent(null, stateName); } } else if (_cachedFsm != fsm || !(_cachedStateName == stateName) || _cachedSubTab != _activeSubTab) { _cachedFsm = fsm; _cachedStateName = stateName; _cachedSubTab = _activeSubTab; _cachedTabFsmKey = tabFsmKey; RebuildContent(fsm, stateName); } } public void ScrollToAction(int actionIndex) { //IL_0049: 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) if (_activeSubTab != SubTabKind.Actions) { SetActiveSubTab(SubTabKind.Actions); RebuildContent(_cachedFsm, _cachedStateName); _cachedSubTab = _activeSubTab; } if (_actionBlocks.TryGetValue(actionIndex, out CanvasSectionBlock value)) { _scrollView.ScrollToShow(value.LocalPosition.y, value.Size.y); SelectBlock(value); } } public void RefreshLiveValues() { foreach (Action valueRefresher in _valueRefreshers) { valueRefresher(); } foreach (Action headerRefresher in _headerRefreshers) { headerRefresher(); } } private void RebuildContent(FsmInfo? fsm, string? stateName) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) CanvasPanel canvasPanel = (CanvasPanel)_scrollView.Content; canvasPanel.ClearChildren(); _valueRefreshers.Clear(); _actionBlocks.Clear(); _selectedBlock = null; _sequencerBlockWidgets.Clear(); _sequenceColumnHitAreas.Clear(); _sequenceRowWidgets.Clear(); FsmStateInfo fsmStateInfo = null; if (fsm != null && stateName != null) { foreach (FsmStateInfo state in fsm.States) { if (state.Name == stateName) { fsmStateInfo = state; break; } } } _header.Text = ((fsmStateInfo != null) ? ("State: " + fsmStateInfo.Name) : "No state selected"); _stateHeaderDot.ActiveSelf = fsm != null && fsmStateInfo != null; if (fsm == null || (fsmStateInfo == null && _activeSubTab != SubTabKind.Sequencer)) { canvasPanel.Size = new Vector2(_scrollView.Size.x, 0f); return; } string fsmKey = FsmIdentity.GetFsmKey(fsm.Component); RowCursor rowCursor = new RowCursor(); switch (_activeSubTab) { case SubTabKind.Actions: BuildActionsRows(canvasPanel, rowCursor, fsmKey, fsmStateInfo); break; case SubTabKind.Events: BuildEventsRows(canvasPanel, rowCursor, fsm); break; case SubTabKind.Variables: BuildVariableRows(canvasPanel, rowCursor, fsmKey, fsm); break; case SubTabKind.Sequencer: BuildSequencerRows(canvasPanel, rowCursor, fsmKey, fsm); break; } canvasPanel.Size = new Vector2(_scrollView.Size.x, rowCursor.Y); } private void BuildActionsRows(CanvasPanel content, RowCursor cursor, string fsmKey, FsmStateInfo state) { int num = -1; for (int i = 0; i < state.Actions.Count; i++) { FsmActionInfo fsmActionInfo = state.Actions[i]; if (fsmActionInfo.ActionType.Name.Contains("Random")) { num++; } CanvasSectionBlock canvasSectionBlock = BeginBlock(content, cursor); AddActionHeaderRow(content, cursor, fsmKey, state, i, num, fsmActionInfo); foreach (FsmActionFieldInfo field in fsmActionInfo.Fields) { AddActionFieldRow(content, cursor, fsmKey, state.Name, i, fsmActionInfo, field); } EndBlock(canvasSectionBlock, cursor); _actionBlocks[i] = canvasSectionBlock; } } private void AddActionFieldRow(CanvasPanel content, RowCursor cursor, string fsmKey, string stateName, int actionIndex, FsmActionInfo action, FsmActionFieldInfo field) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) string expectedActionTypeName = action.ActionType.Name; string fieldName = field.FieldName; string label = (field.IsHidden ? (fieldName + " (hidden)") : fieldName); Color? labelColor = (field.IsHidden ? new Color?(_ui.HiddenFieldLabelColor) : ((Color?)null)); if (field.FieldValue is Array array) { AddActionFieldArrayRows(content, cursor, fsmKey, stateName, actionIndex, action, field, array); return; } float indent = AddToggleDot(content, cursor, FieldIndent, () => _tracker.IsActionFieldTracked(fsmKey, stateName, actionIndex, fieldName), delegate { if (_tracker.IsActionFieldTracked(fsmKey, stateName, actionIndex, fieldName)) { _tracker.UntrackActionField(fsmKey, stateName, actionIndex, fieldName); } else { _tracker.TrackActionField(fsmKey, stateName, actionIndex, fieldName); } }); if (!FsmEditManager.TryFormatValue(field.FieldValue, out string formatted)) { AddReadOnlyRow(content, cursor, label, () => FormatActionField(action.Action, field.Field.GetValue(action.Action)), _ui.ReadOnlyColor, indent, labelColor); return; } if (IsBoolLike(field.FieldValue)) { AddBoolRow(content, cursor, label, () => ToBool(field.Field.GetValue(action.Action)), indent, delegate(bool newValue) { try { _editManager.SetActionField(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName, newValue.ToString(CultureInfo.InvariantCulture)); } catch (Exception ex) { _logger.LogWarning((object)$"[FsmMaster] Failed to set action field '{stateName}'[{actionIndex}].{fieldName}: {ex.Message}"); } }, labelColor); return; } Color valueColor = ValueColorFor(field.FieldValue); AddTextFieldRow(content, cursor, label, ReadCurrentFieldText, valueColor, indent, delegate(string text) { try { _editManager.SetActionField(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName, text); } catch (Exception ex) { _logger.LogWarning((object)$"[FsmMaster] Failed to set action field '{stateName}'[{actionIndex}].{fieldName}: {ex.Message}"); } return ReadCurrentFieldText(); }, labelColor); string ReadCurrentFieldText() { if (!FsmEditManager.TryFormatValue(field.Field.GetValue(action.Action), out string formatted2)) { return formatted; } return formatted2; } } private void AddActionFieldArrayRows(CanvasPanel content, RowCursor cursor, string fsmKey, string stateName, int actionIndex, FsmActionInfo action, FsmActionFieldInfo field, Array array) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) string expectedActionTypeName = action.ActionType.Name; string fieldName = field.FieldName; string text = (field.IsHidden ? (fieldName + " (hidden)") : fieldName); Color? val = (field.IsHidden ? new Color?(_ui.HiddenFieldLabelColor) : ((Color?)null)); AddLabelOnlyRow(content, cursor, (array.Length > 0) ? $"{text} [{array.Length}]" : (text + " (empty)"), (Color)(((??)val) ?? _ui.TextColor), FieldIndent); for (int i = 0; i < array.Length; i++) { object value = array.GetValue(i); NamedVariable val2 = (NamedVariable)((value is NamedVariable) ? value : null); string label = ((val2 != null && !string.IsNullOrEmpty(val2.Name)) ? $"[{i}] \"{val2.Name}\"" : $"[{i}]"); int capturedIndex = i; float indent = AddToggleDot(content, cursor, ArrayElementIndent, () => _tracker.IsActionFieldArrayElementTracked(fsmKey, stateName, actionIndex, fieldName, capturedIndex), delegate { if (_tracker.IsActionFieldArrayElementTracked(fsmKey, stateName, actionIndex, fieldName, capturedIndex)) { _tracker.UntrackActionFieldArrayElement(fsmKey, stateName, actionIndex, fieldName, capturedIndex); } else { _tracker.TrackActionFieldArrayElement(fsmKey, stateName, actionIndex, fieldName, capturedIndex); } }); if (!FsmEditManager.TryFormatValue(value, out string formatted)) { AddReadOnlyRow(content, cursor, label, () => FormatActionField(action.Action, ReadCurrentElement(capturedIndex)), _ui.ReadOnlyColor, indent, val); continue; } if (IsBoolLike(value)) { AddBoolRow(content, cursor, label, () => ToBool(ReadCurrentElement(capturedIndex)), indent, delegate(bool newValue) { try { _editManager.SetActionFieldArrayElement(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName, capturedIndex, newValue.ToString(CultureInfo.InvariantCulture)); } catch (Exception ex) { _logger.LogWarning((object)$"[FsmMaster] Failed to set action field '{stateName}'[{actionIndex}].{fieldName}[{capturedIndex}]: {ex.Message}"); } }, val); continue; } Color valueColor = ValueColorFor(value); AddTextFieldRow(content, cursor, label, ReadCurrentElementText, valueColor, indent, delegate(string elementStringValue) { try { _editManager.SetActionFieldArrayElement(fsmKey, stateName, actionIndex, expectedActionTypeName, fieldName, capturedIndex, elementStringValue); } catch (Exception ex) { _logger.LogWarning((object)$"[FsmMaster] Failed to set action field '{stateName}'[{actionIndex}].{fieldName}[{capturedIndex}]: {ex.Message}"); } return ReadCurrentElementText(); }, val); string ReadCurrentElementText() { if (!FsmEditManager.TryFormatValue(ReadCurrentElement(capturedIndex), out string formatted2)) { return formatted; } return formatted2; } } object? ReadCurrentElement(int num) { if (!(field.Field.GetValue(action.Action) is Array array2) || num >= array2.Length) { return null; } return array2.GetValue(num); } } private void BuildEventsRows(CanvasPanel content, RowCursor cursor, FsmInfo fsm) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (fsm.Fsm.Events.Length != 0) { CanvasSectionBlock block = BeginBlock(content, cursor); AddSectionHeaderRow(content, cursor, "Events", RowIndent); FsmEvent[] events = fsm.Fsm.Events; foreach (FsmEvent val in events) { AddLabelOnlyRow(content, cursor, val.Name, _ui.TextColor, FieldIndent); } EndBlock(block, cursor); } } private void BuildVariableRows(CanvasPanel content, RowCursor cursor, string fsmKey, FsmInfo fsm) { FsmVariables variables = fsm.Fsm.Variables; AddNamedVariableGroup(content, cursor, fsmKey, "Float", variables.FloatVariables); AddNamedVariableGroup(content, cursor, fsmKey, "Int", variables.IntVariables); AddNamedVariableGroup(content, cursor, fsmKey, "Bool", variables.BoolVariables); AddNamedVariableGroup(content, cursor, fsmKey, "String", variables.StringVariables); AddNamedVariableGroup(content, cursor, fsmKey, "Vector2", variables.Vector2Variables); AddNamedVariableGroup(content, cursor, fsmKey, "Vector3", variables.Vector3Variables); AddNamedVariableGroup(content, cursor, fsmKey, "Rect", variables.RectVariables); AddNamedVariableGroup(content, cursor, fsmKey, "Quaternion", variables.QuaternionVariables); AddNamedVariableGroup(content, cursor, fsmKey, "Color", variables.ColorVariables); AddNamedVariableGroup(content, cursor, fsmKey, "Enum", variables.EnumVariables); AddReadOnlyGroup(content, cursor, fsmKey, "GameObject", variables.GameObjectVariables, (Func)((FsmGameObject v) => (!((Object)(object)v.Value != (Object)null)) ? "null" : ((Object)v.Value).name)); AddReadOnlyGroup(content, cursor, fsmKey, "Object", variables.ObjectVariables, (Func)((FsmObject v) => (!(v.Value != (Object)null)) ? "null" : ((object)v.Value).ToString())); AddReadOnlyGroup(content, cursor, fsmKey, "Material", variables.MaterialVariables, (Func)((FsmMaterial v) => (!((Object)(object)v.Value != (Object)null)) ? "null" : ((object)v.Value).ToString())); AddReadOnlyGroup(content, cursor, fsmKey, "Texture", variables.TextureVariables, (Func)((FsmTexture v) => (!((Object)(object)v.Value != (Object)null)) ? "null" : ((object)v.Value).ToString())); AddArrayVariableGroup(content, cursor, fsmKey, variables.ArrayVariables); } private void AddArrayVariableGroup(CanvasPanel content, RowCursor cursor, string fsmKey, FsmArray[] items) { if (items.Length != 0) { CanvasSectionBlock block = BeginBlock(content, cursor); AddSectionHeaderRow(content, cursor, "Array", RowIndent); foreach (FsmArray array in items) { AddArrayVariableRow(content, cursor, fsmKey, array); } EndBlock(block, cursor); } } private void AddArrayVariableRow(CanvasPanel content, RowCursor cursor, string fsmKey, FsmArray array) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Invalid comparison between Unknown and I4 //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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) string variableName = ((NamedVariable)array).Name; if (!FsmEditManager.IsSupportedArrayElementType(array.ElementType)) { AddReadOnlyRow(content, cursor, $"{variableName} ({array.ElementType})", () => string.Join(", ", array.Values), _ui.ReadOnlyColor, FieldIndent); return; } AddLabelOnlyRow(content, cursor, (array.Length > 0) ? $"{variableName} ({array.ElementType}[{array.Length}])" : (variableName + " (empty)"), _ui.TextColor, FieldIndent); for (int num = 0; num < array.Length; num++) { object obj = array.Get(num); string label = $"[{num}]"; int capturedIndex = num; float indent = AddToggleDot(content, cursor, ArrayElementIndent, () => _tracker.IsVariableArrayElementTracked(fsmKey, variableName, capturedIndex), delegate { if (_tracker.IsVariableArrayElementTracked(fsmKey, variableName, capturedIndex)) { _tracker.UntrackVariableArrayElement(fsmKey, variableName, capturedIndex); } else { _tracker.TrackVariableArrayElement(fsmKey, variableName, capturedIndex); } }); if ((int)array.ElementType == 2) { AddBoolRow(content, cursor, label, () => Convert.ToBoolean(array.Get(capturedIndex)), indent, delegate(bool newValue) { try { _editManager.SetVariableArrayElement(fsmKey, variableName, capturedIndex, newValue.ToString(CultureInfo.InvariantCulture)); } catch (Exception ex) { _logger.LogWarning((object)$"[FsmMaster] Failed to set '{variableName}[{capturedIndex}]': {ex.Message}"); } }); continue; } string formatted = FsmEditManager.FormatArrayElement(array.ElementType, obj); Color valueColor = ValueColorFor(obj); AddTextFieldRow(content, cursor, label, ReadCurrentElementText, valueColor, indent, delegate(string text) { try { _editManager.SetVariableArrayElement(fsmKey, variableName, capturedIndex, text); } catch (Exception ex) { _logger.LogWarning((object)$"[FsmMaster] Failed to set '{variableName}[{capturedIndex}]': {ex.Message}"); } return ReadCurrentElementText(); }); string ReadCurrentElementText() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (capturedIndex >= array.Length) { return formatted; } return FsmEditManager.FormatArrayElement(array.ElementType, array.Get(capturedIndex)); } } } private void AddNamedVariableGroup(CanvasPanel content, RowCursor cursor, string fsmKey, string typeName, T[] items) where T : NamedVariable { if (items.Length != 0) { CanvasSectionBlock block = BeginBlock(content, cursor); AddSectionHeaderRow(content, cursor, typeName, RowIndent); foreach (T val in items) { AddNamedVariableRow(content, cursor, fsmKey, (NamedVariable)(object)val); } EndBlock(block, cursor); } } private void AddNamedVariableRow(CanvasPanel content, RowCursor cursor, string fsmKey, NamedVariable variable) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) string variableName = variable.Name; float indent = AddToggleDot(content, cursor, FieldIndent, () => _tracker.IsVariableTracked(fsmKey, variableName), delegate { if (_tracker.IsVariableTracked(fsmKey, variableName)) { _tracker.UntrackVariable(fsmKey, variableName); } else { _tracker.TrackVariable(fsmKey, variableName); } }); if (!FsmEditManager.TryFormatValue(variable, out string formatted)) { AddReadOnlyRow(content, cursor, variable.Name, () => (!FsmEditManager.TryFormatValue(variable, out string formatted2)) ? formatted : formatted2, _ui.ReadOnlyColor, indent); return; } string variableType = ((object)variable.VariableType/*cast due to .constrained prefix*/).ToString(); if (IsBoolLike(variable)) { AddBoolRow(content, cursor, variableName, () => ToBool(variable), indent, delegate(bool newValue) { try { _editManager.SetVariable(fsmKey, variableName, variableType, newValue.ToString(CultureInfo.InvariantCulture)); } catch (Exception ex) { _logger.LogWarning((object)("[FsmMaster] Failed to set variable '" + variableName + "': " + ex.Message)); } }); return; } Color valueColor = ValueColorFor(variable); AddTextFieldRow(content, cursor, variableName, ReadCurrentVariableText, valueColor, indent, delegate(string text) { try { _editManager.SetVariable(fsmKey, variableName, variableType, text); } catch (Exception ex) { _logger.LogWarning((object)("[FsmMaster] Failed to set variable '" + variableName + "': " + ex.Message)); } return ReadCurrentVariableText(); }); string ReadCurrentVariableText() { if (!FsmEditManager.TryFormatValue(variable, out string formatted2)) { return formatted; } return formatted2; } } private void AddReadOnlyGroup(CanvasPanel content, RowCursor cursor, string fsmKey, string typeName, T[] items, Func formatValue) where T : NamedVariable { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (items.Length == 0) { return; } CanvasSectionBlock block = BeginBlock(content, cursor); AddSectionHeaderRow(content, cursor, typeName, RowIndent); foreach (T item in items) { string variableName = ((NamedVariable)item).Name; float indent = AddToggleDot(content, cursor, FieldIndent, () => _tracker.IsVariableTracked(fsmKey, variableName), delegate { if (_tracker.IsVariableTracked(fsmKey, variableName)) { _tracker.UntrackVariable(fsmKey, variableName); } else { _tracker.TrackVariable(fsmKey, variableName); } }); AddReadOnlyRow(content, cursor, ((NamedVariable)item).Name, () => formatValue(item), _ui.ReadOnlyColor, indent); } EndBlock(block, cursor); } private void BuildSequencerRows(CanvasPanel content, RowCursor cursor, string fsmKey, FsmInfo fsm) { HashSet<(string, int)> hashSet = CollectOpenSequencerKeys(fsmKey); if (hashSet.Count == 0) { return; } foreach (FsmStateInfo state in fsm.States) { List list = (from k in hashSet where k.StateName == state.Name select k.ActionRank into r orderby r select r).ToList(); if (list.Count == 0) { continue; } int num = -1; for (int num2 = 0; num2 < state.Actions.Count; num2++) { FsmActionInfo fsmActionInfo = state.Actions[num2]; if (fsmActionInfo.ActionType.Name.Contains("Random")) { num++; if (list.Contains(num)) { string label = ((list.Count > 1) ? $"{state.Name} ({list.IndexOf(num) + 1})" : state.Name); BuildSequencerBlock(content, cursor, fsmKey, state, num, fsmActionInfo, label); } } } } } private HashSet<(string StateName, int ActionRank)> CollectOpenSequencerKeys(string fsmKey) { HashSet<(string, int)> hashSet = new HashSet<(string, int)>(); FsmEditSet activeEditSet = _editManager.GetActiveEditSet(fsmKey); if (activeEditSet != null) { foreach (SequencerOverride sequencerOverride in activeEditSet.SequencerOverrides) { hashSet.Add((sequencerOverride.StateName, sequencerOverride.ActionIndex)); } } if (_openSequencerBlocks.TryGetValue(fsmKey, out HashSet<(string, int)> value)) { hashSet.UnionWith(value); } return hashSet; } private void BuildSequencerBlock(CanvasPanel content, RowCursor cursor, string fsmKey, FsmStateInfo state, int actionRank, FsmActionInfo action, string label) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) CanvasSectionBlock canvasSectionBlock = BeginBlock(content, cursor); float num = UICommon.ScaleWidth(4f); float num2 = Mathf.Max(0f, _scrollView.Size.x - RowIndent - BlockRightGap); float num3 = Mathf.Max(0f, num2 - CloseButtonSize - num); CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); canvasText.Text = label; canvasText.Font = _ui.HeaderFont; canvasText.FontStyle = (FontStyle)1; canvasText.Color = _ui.TypeBadgeColor; canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(RowIndent, cursor.Y); canvasText.Size = new Vector2(num3, HeaderRowHeight); canvasText.Build(); CanvasButton canvasButton = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); canvasButton.Text.Text = "x"; canvasButton.Text.Color = _ui.ErrorColor; canvasButton.LocalPosition = new Vector2(RowIndent + num3 + num, cursor.Y); canvasButton.Size = new Vector2(CloseButtonSize, HeaderRowHeight); canvasButton.Build(); string stateName = state.Name; canvasButton.OnClicked += delegate { CloseSequencerBlock(fsmKey, stateName, actionRank); }; cursor.Y += HeaderRowHeight; float num4 = Mathf.Max(0f, (num2 - ColumnGap) / 2f); float rowIndent = RowIndent; float x = rowIndent + num4 + ColumnGap; float y = cursor.Y; List sequencerPattern = GetSequencerPattern(fsmKey, stateName, actionRank); bool sequencerIndefinite = GetSequencerIndefinite(fsmKey, stateName, actionRank); int sequencerFixedExtraLoops = GetSequencerFixedExtraLoops(fsmKey, stateName, actionRank); List candidateEvents = (from e in FsmActionSequencer.ExtractEventCandidates(action.Action, state.State) select e.Name).ToList(); float num5 = BuildSequenceColumn(content, cursor, fsmKey, stateName, actionRank, sequencerPattern, rowIndent, y, num4); float num6 = BuildLoopAndEventsColumn(content, cursor, fsmKey, stateName, actionRank, candidateEvents, sequencerIndefinite, sequencerFixedExtraLoops, x, y, num4); cursor.Y = Mathf.Max(num5, num6); CanvasPanel canvasPanel = content.Add(new CanvasPanel($"Row{cursor.Count++}")); canvasPanel.LocalPosition = new Vector2(rowIndent, y); canvasPanel.Size = new Vector2(num4, cursor.Y - y); canvasPanel.Build(); _sequenceColumnHitAreas[(stateName, actionRank)] = canvasPanel; EndBlock(canvasSectionBlock, cursor); _sequencerBlockWidgets[(stateName, actionRank)] = canvasSectionBlock; } private float BuildSequenceColumn(CanvasPanel content, RowCursor cursor, string fsmKey, string stateName, int actionRank, List pattern, float x, float y, float width) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) (string, int) blockKey = (stateName, actionRank); CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui) { Text = "Sequence" }); canvasText.Color = _ui.ReadOnlyColor; canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(x, y); canvasText.Size = new Vector2(width, RowHeight); canvasText.Build(); y += RowHeight; List list = new List(); float num = Mathf.Max(0f, width - SeqDeleteButtonSize - SeqRowGap); for (int i = 0; i < pattern.Count; i++) { int capturedIndex = i; string eventName = pattern[i]; CanvasButton canvasButton = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); canvasButton.Text.Text = $"{i + 1}. {eventName}"; canvasButton.Text.Alignment = (TextAnchor)3; canvasButton.Text.Overflow = (HorizontalWrapMode)1; canvasButton.LocalPosition = new Vector2(x, y); canvasButton.Size = new Vector2(num, RowHeight); canvasButton.Build(); canvasButton.AddEventTrigger((EventTriggerType)13, delegate(PointerEventData e) { BeginDragReorder(blockKey, capturedIndex, eventName, e); }); canvasButton.AddEventTrigger((EventTriggerType)5, MoveDragGhost); canvasButton.AddEventTrigger((EventTriggerType)14, delegate(PointerEventData e) { EndDrag(fsmKey, e); }); CanvasButton canvasButton2 = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); canvasButton2.Text.Text = "x"; canvasButton2.Text.Color = _ui.ErrorColor; canvasButton2.LocalPosition = new Vector2(x + num + SeqRowGap, y); canvasButton2.Size = new Vector2(SeqDeleteButtonSize, RowHeight); canvasButton2.Build(); canvasButton2.OnClicked += delegate { RemovePatternEntry(fsmKey, stateName, actionRank, capturedIndex); }; list.Add(canvasButton); y += RowHeight + SeqRowGap; } CanvasImage canvasImage = content.Add(new CanvasImage($"Row{cursor.Count++}", _ui) { Tint = Color.clear }); canvasImage.LocalPosition = new Vector2(x, y); canvasImage.Size = new Vector2(width, RowHeight); canvasImage.AddBorder(_ui.PanelBorder); canvasImage.Build(); CanvasText canvasText2 = content.Add(new CanvasText($"Row{cursor.Count++}", _ui) { Text = "(drag events here)" }); canvasText2.Color = _ui.ReadOnlyColor; canvasText2.Alignment = (TextAnchor)4; canvasText2.Overflow = (HorizontalWrapMode)1; canvasText2.LocalPosition = new Vector2(x, y); canvasText2.Size = new Vector2(width, RowHeight); canvasText2.Build(); y += RowHeight; _sequenceRowWidgets[blockKey] = list; return y; } private float BuildLoopAndEventsColumn(CanvasPanel content, RowCursor cursor, string fsmKey, string stateName, int actionRank, List candidateEvents, bool indefinite, int fixedExtraLoops, float x, float y, float width) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui) { Text = "Loop" }); canvasText.Color = _ui.ReadOnlyColor; canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(x, y); canvasText.Size = new Vector2(width, RowHeight); canvasText.Build(); y += RowHeight; float num = Mathf.Max(0f, (width - SeqRowGap) / 2f); CanvasButton canvasButton = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); canvasButton.Text.Text = "Fixed"; canvasButton.Toggled = !indefinite; canvasButton.LocalPosition = new Vector2(x, y); canvasButton.Size = new Vector2(num, RowHeight); canvasButton.Build(); canvasButton.OnClicked += delegate { SetLoopMode(fsmKey, stateName, actionRank, indefinite: false); }; CanvasButton canvasButton2 = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); canvasButton2.Text.Text = "Indefinite"; canvasButton2.Toggled = indefinite; canvasButton2.LocalPosition = new Vector2(x + num + SeqRowGap, y); canvasButton2.Size = new Vector2(Mathf.Max(0f, width - num - SeqRowGap), RowHeight); canvasButton2.Build(); canvasButton2.OnClicked += delegate { SetLoopMode(fsmKey, stateName, actionRank, indefinite: true); }; y += RowHeight + SeqRowGap; if (!indefinite) { CanvasImage canvasImage = content.Add(new CanvasImage($"Row{cursor.Count++}", _ui) { Tint = _ui.ButtonNormal }); canvasImage.LocalPosition = new Vector2(x, y); canvasImage.Size = new Vector2(width, RowHeight); canvasImage.AddBorder(_ui.PanelBorder); canvasImage.Build(); CanvasTextField canvasTextField = content.Add(new CanvasTextField($"Row{cursor.Count++}", _ui)); canvasTextField.Text = fixedExtraLoops.ToString(CultureInfo.InvariantCulture); canvasTextField.LocalPosition = new Vector2(x + 3f, y); canvasTextField.Size = new Vector2(Mathf.Max(0f, width - 6f), RowHeight); canvasTextField.Build(); canvasTextField.OnSubmit += delegate(string text) { SubmitLoopCount(fsmKey, stateName, actionRank, text); }; y += RowHeight; } y += SeqRowGap; CanvasText canvasText2 = content.Add(new CanvasText($"Row{cursor.Count++}", _ui) { Text = "Events" }); canvasText2.Color = _ui.ReadOnlyColor; canvasText2.Overflow = (HorizontalWrapMode)1; canvasText2.LocalPosition = new Vector2(x, y); canvasText2.Size = new Vector2(width, RowHeight); canvasText2.Build(); y += RowHeight; (string, int) blockKey = (stateName, actionRank); foreach (string eventName in candidateEvents) { CanvasButton canvasButton3 = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); canvasButton3.Text.Text = eventName; canvasButton3.Text.Alignment = (TextAnchor)3; canvasButton3.Text.Overflow = (HorizontalWrapMode)1; canvasButton3.LocalPosition = new Vector2(x, y); canvasButton3.Size = new Vector2(width, RowHeight); canvasButton3.Build(); canvasButton3.AddEventTrigger((EventTriggerType)13, delegate(PointerEventData e) { BeginDragFromEvents(blockKey, eventName, e); }); canvasButton3.AddEventTrigger((EventTriggerType)5, MoveDragGhost); canvasButton3.AddEventTrigger((EventTriggerType)14, delegate(PointerEventData e) { EndDrag(fsmKey, e); }); y += RowHeight + SeqRowGap; } return y; } private SequencerOverride? FindSequencerOverride(string fsmKey, string stateName, int actionRank) { return _editManager.GetActiveEditSet(fsmKey)?.SequencerOverrides.FirstOrDefault((SequencerOverride s) => s.StateName == stateName && s.ActionIndex == actionRank); } private List GetSequencerPattern(string fsmKey, string stateName, int actionRank) { SequencerOverride sequencerOverride = FindSequencerOverride(fsmKey, stateName, actionRank); if (sequencerOverride == null) { return new List(); } return new List(sequencerOverride.Pattern); } private bool GetSequencerIndefinite(string fsmKey, string stateName, int actionRank) { SequencerOverride sequencerOverride = FindSequencerOverride(fsmKey, stateName, actionRank); if (sequencerOverride != null) { return sequencerOverride.RepeatCount == 0; } return true; } private int GetSequencerFixedExtraLoops(string fsmKey, string stateName, int actionRank) { SequencerOverride sequencerOverride = FindSequencerOverride(fsmKey, stateName, actionRank); if (sequencerOverride == null) { return 0; } return Mathf.Max(0, sequencerOverride.RepeatCount - 1); } private void ApplySequencer(string fsmKey, string stateName, int actionRank, List pattern, bool indefinite, int fixedExtraLoops) { if (pattern.Count == 0) { _editManager.RemoveSequencer(fsmKey, stateName, actionRank); } else { _editManager.InstallSequencer(fsmKey, new SequencerOverride { StateName = stateName, ActionIndex = actionRank, Pattern = new List(pattern), RepeatCount = ((!indefinite) ? (fixedExtraLoops + 1) : 0) }); } RebuildContent(_cachedFsm, _cachedStateName); } private void RemovePatternEntry(string fsmKey, string stateName, int actionRank, int index) { List sequencerPattern = GetSequencerPattern(fsmKey, stateName, actionRank); if (index >= 0 && index < sequencerPattern.Count) { sequencerPattern.RemoveAt(index); ApplySequencer(fsmKey, stateName, actionRank, sequencerPattern, GetSequencerIndefinite(fsmKey, stateName, actionRank), GetSequencerFixedExtraLoops(fsmKey, stateName, actionRank)); } } private void SetLoopMode(string fsmKey, string stateName, int actionRank, bool indefinite) { List sequencerPattern = GetSequencerPattern(fsmKey, stateName, actionRank); int sequencerFixedExtraLoops = GetSequencerFixedExtraLoops(fsmKey, stateName, actionRank); ApplySequencer(fsmKey, stateName, actionRank, sequencerPattern, indefinite, sequencerFixedExtraLoops); } private void SubmitLoopCount(string fsmKey, string stateName, int actionRank, string text) { if (!int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || result < 0) { result = 0; } List sequencerPattern = GetSequencerPattern(fsmKey, stateName, actionRank); ApplySequencer(fsmKey, stateName, actionRank, sequencerPattern, indefinite: false, result); } private void CloseSequencerBlock(string fsmKey, string stateName, int actionRank) { _editManager.RemoveSequencer(fsmKey, stateName, actionRank); if (_openSequencerBlocks.TryGetValue(fsmKey, out HashSet<(string, int)> value)) { value.Remove((stateName, actionRank)); } _showStatus("Sequencer Removed"); RebuildContent(_cachedFsm, _cachedStateName); } private void BeginDragFromEvents((string StateName, int ActionRank) blockKey, string eventName, PointerEventData e) { _dragBlockKey = blockKey; _dragEventName = eventName; _dragSourceIndex = null; ShowDragGhost(eventName, e); } private void BeginDragReorder((string StateName, int ActionRank) blockKey, int sourceIndex, string eventName, PointerEventData e) { _dragBlockKey = blockKey; _dragEventName = eventName; _dragSourceIndex = sourceIndex; ShowDragGhost(eventName, e); } private void ShowDragGhost(string eventName, PointerEventData e) { _dragGhostText.Text = eventName; _dragGhost.ActiveSelf = true; MoveDragGhost(e); } private void MoveDragGhost(PointerEventData e) { //IL_0003: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(e.position.x, (float)Screen.height - e.position.y); _dragGhost.LocalPosition = val - base.Position + new Vector2(10f, 10f); } private void EndDrag(string fsmKey, PointerEventData e) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) _dragGhost.ActiveSelf = false; (string, int)? dragBlockKey = _dragBlockKey; string dragEventName = _dragEventName; int? dragSourceIndex = _dragSourceIndex; _dragBlockKey = null; _dragEventName = null; _dragSourceIndex = null; if (!dragBlockKey.HasValue || dragEventName == null || !_sequenceColumnHitAreas.TryGetValue(dragBlockKey.Value, out CanvasNode value) || !value.IsPointOver(e.position)) { return; } List sequencerPattern = GetSequencerPattern(fsmKey, dragBlockKey.Value.Item1, dragBlockKey.Value.Item2); int num = ComputeDropIndex(dragBlockKey.Value, e.position); if (dragSourceIndex.HasValue) { int value2 = dragSourceIndex.Value; if (value2 < 0 || value2 >= sequencerPattern.Count) { return; } sequencerPattern.RemoveAt(value2); if (num > value2) { num--; } } num = Mathf.Clamp(num, 0, sequencerPattern.Count); sequencerPattern.Insert(num, dragEventName); ApplySequencer(fsmKey, dragBlockKey.Value.Item1, dragBlockKey.Value.Item2, sequencerPattern, GetSequencerIndefinite(fsmKey, dragBlockKey.Value.Item1, dragBlockKey.Value.Item2), GetSequencerFixedExtraLoops(fsmKey, dragBlockKey.Value.Item1, dragBlockKey.Value.Item2)); } private int ComputeDropIndex((string StateName, int ActionRank) blockKey, Vector2 screenPoint) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) if (!_sequenceRowWidgets.TryGetValue(blockKey, out List value)) { return 0; } float num = (float)Screen.height - screenPoint.y; for (int i = 0; i < value.Count; i++) { CanvasNode canvasNode = value[i]; if (num < canvasNode.Position.y + canvasNode.Size.y / 2f) { return i; } } return value.Count; } private static bool IsBoolLike(object? value) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (!(value is bool)) { NamedVariable val = (NamedVariable)((value is NamedVariable) ? value : null); if (val != null) { return (int)val.VariableType == 2; } return false; } return true; } private static bool ToBool(object? value) { if (!(value is bool result)) { FsmBool val = (FsmBool)((value is FsmBool) ? value : null); if (val != null) { return val.Value; } return false; } return result; } private Color ValueColorFor(object? value) { //IL_002c: 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) NamedVariable val = (NamedVariable)((value is NamedVariable) ? value : null); if (!(((val != null) ? val.RawValue : value) is string)) { return _ui.NumericValueColor; } return _ui.StringValueColor; } private static string FormatActionField(FsmStateAction action, object? fieldValue) { FsmArray val = (FsmArray)((fieldValue is FsmArray) ? fieldValue : null); if (val == null) { if (fieldValue is Array array) { string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = FsmConsoleLogger.FormatActionFieldValue(action, array.GetValue(i)); } return string.Join(", ", array2); } return FsmConsoleLogger.FormatActionFieldValue(action, fieldValue); } string[] array3 = new string[val.Length]; for (int j = 0; j < val.Length; j++) { array3[j] = FsmConsoleLogger.FormatActionFieldValue(action, val.Values[j]); } return string.Join(", ", array3); } private (float LabelWidth, float ValueX, float ValueWidth) ComputeColumns(float indent) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, _scrollView.Size.x - indent - BlockRightGap) * 0.52f; float num2 = indent + num + (float)UICommon.ScaleWidth(6); float item = Mathf.Max(0f, _scrollView.Size.x - BlockRightGap - num2); return (LabelWidth: num, ValueX: num2, ValueWidth: item); } private float AddToggleDot(CanvasPanel content, RowCursor cursor, float indent, Func isOn, Action onClicked) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) CanvasToggleDot dot = content.Add(new CanvasToggleDot($"Row{cursor.Count++}", _ui)); dot.LocalPosition = new Vector2(indent, cursor.Y + (RowHeight - DotWidth) / 2f); dot.Size = new Vector2(DotWidth, DotWidth); dot.On = isOn(); dot.Build(); dot.OnClicked += onClicked; _valueRefreshers.Add(delegate { dot.On = isOn(); }); return indent + DotWidth + DotGap; } private void AddSectionHeaderRow(CanvasPanel content, RowCursor cursor, string title, float indent) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); canvasText.Text = title; canvasText.Font = _ui.HeaderFont; canvasText.FontStyle = (FontStyle)1; canvasText.Color = _ui.TypeBadgeColor; canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(indent, cursor.Y); canvasText.Size = new Vector2(Mathf.Max(0f, _scrollView.Size.x - indent - BlockRightGap), HeaderRowHeight); canvasText.Build(); cursor.Y += HeaderRowHeight; } private void AddActionHeaderRow(CanvasPanel content, RowCursor cursor, string fsmKey, FsmStateInfo state, int actionIndex, int randomActionRank, FsmActionInfo action) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) if (!action.ActionType.Name.Contains("Random")) { AddSectionHeaderRow(content, cursor, action.ActionType.Name, RowIndent); return; } float num = UICommon.ScaleWidth(4f); float num2 = Mathf.Max(0f, _scrollView.Size.x - RowIndent - BlockRightGap); float num3 = Mathf.Max(0f, num2 - SequencerButtonWidth - num); CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); canvasText.Text = action.ActionType.Name; canvasText.Font = _ui.HeaderFont; canvasText.FontStyle = (FontStyle)1; canvasText.Color = _ui.TypeBadgeColor; canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(RowIndent, cursor.Y); canvasText.Size = new Vector2(num3, HeaderRowHeight); canvasText.Build(); CanvasButton sequencerButton = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); sequencerButton.Text.Text = "Sequencer"; sequencerButton.LocalPosition = new Vector2(RowIndent + num3 + num, cursor.Y); sequencerButton.Size = new Vector2(SequencerButtonWidth, HeaderRowHeight); sequencerButton.Toggled = IsSequencerOpen(fsmKey, state.Name, randomActionRank); sequencerButton.Build(); string stateName = state.Name; sequencerButton.OnClicked += delegate { OpenSequencerBlock(fsmKey, stateName, randomActionRank); }; _valueRefreshers.Add(delegate { sequencerButton.Toggled = IsSequencerOpen(fsmKey, stateName, randomActionRank); }); cursor.Y += HeaderRowHeight; } private void OpenSequencerBlock(string fsmKey, string stateName, int actionRank) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (!_openSequencerBlocks.TryGetValue(fsmKey, out HashSet<(string, int)> value)) { value = new HashSet<(string, int)>(); _openSequencerBlocks[fsmKey] = value; } if (value.Add((stateName, actionRank))) { _showStatus("Sequencer Added"); } SetActiveSubTab(SubTabKind.Sequencer); RebuildContent(_cachedFsm, _cachedStateName); _cachedSubTab = _activeSubTab; if (_sequencerBlockWidgets.TryGetValue((stateName, actionRank), out CanvasSectionBlock value2)) { _scrollView.ScrollToShow(value2.LocalPosition.y, value2.Size.y); SelectBlock(value2); } } private bool IsSequencerOpen(string fsmKey, string stateName, int actionRank) { if (_openSequencerBlocks.TryGetValue(fsmKey, out HashSet<(string, int)> value) && value.Contains((stateName, actionRank))) { return true; } return _editManager.GetActiveEditSet(fsmKey)?.SequencerOverrides.Any((SequencerOverride s) => s.StateName == stateName && s.ActionIndex == actionRank) ?? false; } private CanvasSectionBlock BeginBlock(CanvasPanel content, RowCursor cursor) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if (cursor.Y > 0f) { cursor.Y += BlockGap; } CanvasSectionBlock block = content.Add(new CanvasSectionBlock($"Block{cursor.Count++}", _ui)); block.LocalPosition = new Vector2(0f, cursor.Y); block.Size = new Vector2(_scrollView.Size.x, 0f); block.Build(); block.OnClicked += delegate { SelectBlock(block); }; cursor.Y += BlockPadding; return block; } private void EndBlock(CanvasSectionBlock block, RowCursor cursor) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) cursor.Y += BlockPadding; block.Size = new Vector2(_scrollView.Size.x, cursor.Y - block.LocalPosition.y); } private void SelectBlock(CanvasSectionBlock block) { if (_selectedBlock != block) { if (_selectedBlock != null) { _selectedBlock.Selected = false; } block.Selected = true; _selectedBlock = block; } } private void AddLabelOnlyRow(CanvasPanel content, RowCursor cursor, string label, Color color, float indent) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); canvasText.Text = label; canvasText.Color = color; canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(indent, cursor.Y); canvasText.Size = new Vector2(Mathf.Max(0f, _scrollView.Size.x - indent - BlockRightGap), RowHeight); canvasText.Build(); cursor.Y += RowHeight; } private void AddReadOnlyRow(CanvasPanel content, RowCursor cursor, string label, Func readValue, Color valueColor, float indent, Color? labelColor = null) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) (float LabelWidth, float ValueX, float ValueWidth) tuple = ComputeColumns(indent); float item = tuple.LabelWidth; float item2 = tuple.ValueX; float item3 = tuple.ValueWidth; CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); canvasText.Text = label; canvasText.Color = (Color)(((??)labelColor) ?? _ui.TextColor); canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(indent, cursor.Y); canvasText.Size = new Vector2(item, RowHeight); canvasText.Build(); CanvasText valueText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); valueText.Text = readValue(); valueText.Color = valueColor; valueText.Overflow = (HorizontalWrapMode)1; valueText.LocalPosition = new Vector2(item2, cursor.Y); valueText.Size = new Vector2(item3, RowHeight); valueText.Build(); _valueRefreshers.Add(delegate { valueText.Text = readValue(); }); cursor.Y += RowHeight; } private void AddBoolRow(CanvasPanel content, RowCursor cursor, string label, Func readCurrent, float indent, Action onToggle, Color? labelColor = null) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) (float LabelWidth, float ValueX, float ValueWidth) tuple = ComputeColumns(indent); float item = tuple.LabelWidth; float item2 = tuple.ValueX; float item3 = tuple.ValueWidth; CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); canvasText.Text = label; canvasText.Color = (Color)(((??)labelColor) ?? _ui.TextColor); canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(indent, cursor.Y); canvasText.Size = new Vector2(item, RowHeight); canvasText.Build(); CanvasButton toggle = content.Add(new CanvasButton($"Row{cursor.Count++}", _ui)); toggle.Toggled = readCurrent(); toggle.Text.Text = toggle.Toggled.ToString(); toggle.LocalPosition = new Vector2(item2, cursor.Y); toggle.Size = new Vector2(item3, RowHeight); toggle.Build(); toggle.OnClicked += delegate { bool flag = !toggle.Toggled; toggle.Toggled = flag; toggle.Text.Text = flag.ToString(); onToggle(flag); }; _valueRefreshers.Add(delegate { bool toggled = readCurrent(); toggle.Toggled = toggled; toggle.Text.Text = toggled.ToString(); }); cursor.Y += RowHeight; } private void AddTextFieldRow(CanvasPanel content, RowCursor cursor, string label, Func readCurrent, Color valueColor, float indent, Func onSubmit, Color? labelColor = null) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) (float LabelWidth, float ValueX, float ValueWidth) tuple = ComputeColumns(indent); float item = tuple.LabelWidth; float item2 = tuple.ValueX; float item3 = tuple.ValueWidth; CanvasText canvasText = content.Add(new CanvasText($"Row{cursor.Count++}", _ui)); canvasText.Text = label; canvasText.Color = (Color)(((??)labelColor) ?? _ui.TextColor); canvasText.Overflow = (HorizontalWrapMode)1; canvasText.LocalPosition = new Vector2(indent, cursor.Y); canvasText.Size = new Vector2(item, RowHeight); canvasText.Build(); CanvasImage canvasImage = content.Add(new CanvasImage($"Row{cursor.Count++}", _ui) { Tint = _ui.ButtonNormal }); canvasImage.LocalPosition = new Vector2(item2, cursor.Y); canvasImage.Size = new Vector2(item3, RowHeight); canvasImage.AddBorder(_ui.PanelBorder); canvasImage.Build(); CanvasTextField valueField = content.Add(new CanvasTextField($"Row{cursor.Count++}", _ui)); valueField.Text = readCurrent(); valueField.Color = valueColor; valueField.Overflow = (HorizontalWrapMode)1; valueField.LocalPosition = new Vector2(item2 + 3f, cursor.Y); valueField.Size = new Vector2(Mathf.Max(0f, item3 - 6f), RowHeight); valueField.Build(); valueField.OnSubmit += delegate(string text) { valueField.Text = onSubmit(text); }; _valueRefreshers.Add(delegate { valueField.UpdateDefaultText(readCurrent()); }); cursor.Y += RowHeight; } } internal static class FsmDrilldownHierarchy { public static List Build(FsmSnapshot snapshot) { //IL_0043: 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) Dictionary dictionary = new Dictionary(); Dictionary> dictionary2 = new Dictionary>(); for (int i = 0; i < snapshot.Fsms.Count; i++) { FsmIdentityInfo fsmIdentityInfo = snapshot.Fsms[i]; if (!((Object)(object)fsmIdentityInfo.Component == (Object)null)) { GameObject gameObject = ((Component)fsmIdentityInfo.Component).gameObject; Scene scene = gameObject.scene; string name = ((Scene)(ref scene)).name; if (!dictionary.TryGetValue(name, out var value)) { value = (dictionary[name] = new SceneGroup { SceneName = name }); dictionary2[name] = new Dictionary(); } Dictionary dictionary3 = dictionary2[name]; int instanceID = ((Object)gameObject).GetInstanceID(); if (!dictionary3.TryGetValue(instanceID, out var value2)) { value2 = (dictionary3[instanceID] = new ObjectGroup { InstanceId = instanceID, Label = fsmIdentityInfo.GameObjectName }); value.Objects.Add(value2); } value2.FsmIndices.Add(i); value2.FsmLabels.Add(fsmIdentityInfo.FsmName); } } List list = new List(dictionary.Values); list.Sort((SceneGroup a, SceneGroup b) => string.CompareOrdinal(a.SceneName, b.SceneName)); foreach (SceneGroup item in list) { item.Objects.Sort((ObjectGroup a, ObjectGroup b) => string.CompareOrdinal(a.Label, b.Label)); foreach (ObjectGroup objectGroup2 in item.Objects) { List list2 = new List(objectGroup2.FsmLabels.Count); for (int num = 0; num < objectGroup2.FsmLabels.Count; num++) { list2.Add(num); } list2.Sort((int a, int b) => string.CompareOrdinal(objectGroup2.FsmLabels[a], objectGroup2.FsmLabels[b])); List list3 = new List(list2.Count); List list4 = new List(list2.Count); foreach (int item2 in list2) { list3.Add(objectGroup2.FsmIndices[item2]); list4.Add(objectGroup2.FsmLabels[item2]); } objectGroup2.FsmIndices = list3; objectGroup2.FsmLabels = list4; } } return list; } } internal sealed class SceneGroup { public string SceneName = ""; public List Objects = new List(); } internal sealed class ObjectGroup { public int InstanceId; public string Label = ""; public List FsmIndices = new List(); public List FsmLabels = new List(); } internal sealed class FsmLoadDialog : CanvasPanel { private const float Width = 240f; private const float RowHeight = 24f; private const float HeaderHeight = 22f; private readonly UICommon _ui; private readonly CanvasButton _anchorButton; private readonly CanvasText _headerText; private readonly CanvasPanel _rowsContainer; private readonly List _rowNodes = new List(); private string _sceneName = ""; private string _fsmKey = ""; public event Action? OnSelected; public FsmLoadDialog(UICommon ui, CanvasButton anchorButton) : base("LoadDialog") { //IL_004c: 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) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) _ui = ui; _anchorButton = anchorButton; base.ActiveSelf = false; base.Size = new Vector2(240f, 46f); Add(new CanvasImage("Background", ui) { IsBackground = true, Tint = ui.PanelBackground }).AddBorder(ui.PanelBorder); _headerText = Add(new CanvasText("Header", ui) { Text = "Load configuration:" }); _headerText.LocalPosition = new Vector2(6f, 0f); _headerText.Size = new Vector2(228f, 22f); _headerText.Alignment = (TextAnchor)3; _rowsContainer = Add(new CanvasPanel("Rows")); _rowsContainer.LocalPosition = new Vector2(0f, 22f); base.OnUpdate += CloseOnOutsideClick; } public void Show(string sceneName, string fsmKey) { //IL_0022: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) _sceneName = sceneName; _fsmKey = fsmKey; RebuildRows(FsmSaveDataStore.ListSaveNames(sceneName, fsmKey)); base.LocalPosition = new Vector2(_anchorButton.LocalPosition.x, _anchorButton.LocalPosition.y + _anchorButton.Size.y + 4f); base.ActiveSelf = true; ((Transform)transform).SetAsLastSibling(); } private void Hide() { base.ActiveSelf = false; } private void RebuildRows(List saveNames) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) foreach (CanvasNode rowNode in _rowNodes) { rowNode.Destroy(); _rowsContainer.Remove(rowNode); } _rowNodes.Clear(); if (saveNames.Count == 0) { CanvasText canvasText = _rowsContainer.Add(new CanvasText("Empty", _ui) { Text = "(no saved configurations)" }); canvasText.LocalPosition = new Vector2(6f, 0f); canvasText.Size = new Vector2(228f, 24f); canvasText.Alignment = (TextAnchor)3; canvasText.Color = _ui.ReadOnlyColor; canvasText.Build(); _rowNodes.Add(canvasText); } else { float num = 0f; foreach (string saveName in saveNames) { CanvasButton canvasButton = _rowsContainer.Add(new CanvasButton($"Row{_rowNodes.Count}", _ui)); canvasButton.LocalPosition = new Vector2(0f, num); canvasButton.Size = new Vector2(240f, 24f); canvasButton.Text.Text = saveName; canvasButton.Text.Alignment = (TextAnchor)3; canvasButton.Text.Overflow = (HorizontalWrapMode)1; canvasButton.OnClicked += delegate { Select(saveName); }; canvasButton.Build(); num += 24f; _rowNodes.Add(canvasButton); } } base.Size = new Vector2(240f, 22f + Mathf.Max(24f, (float)_rowNodes.Count * 24f)); } private void Select(string saveName) { this.OnSelected?.Invoke(_sceneName, _fsmKey, saveName); Hide(); } private void CloseOnOutsideClick() { if (base.ActiveSelf && Input.GetMouseButtonDown(0) && !IsMouseOver() && !_anchorButton.IsMouseOver()) { Hide(); } } } internal sealed class FsmOpenDropdown : CanvasPanel { private enum Level { Scenes, Objects, Fsms } private const float Width = 260f; private const float RowHeight = 22f; private const float HeaderHeight = 22f; private const float BackButtonWidth = 70f; private const float ScrollbarWidth = 10f; private readonly UICommon _ui; private readonly FsmTabManager _tabManager; private readonly Func _getSnapshot; private readonly CanvasButton _anchorButton; private readonly Action _showStatus; private readonly CanvasButton _backButton; private readonly CanvasText _headerText; private readonly CanvasScrollView _rowsScrollView; private readonly CanvasScrollbar _rowsScrollbar; private readonly CanvasPanel _rowsContainer; private readonly List _rowButtons = new List(); private Level _level; private List? _sceneGroups; private int _selectedSceneIndex = -1; private int _selectedObjectIndex = -1; public FsmOpenDropdown(UICommon ui, FsmTabManager tabManager, Func getSnapshot, CanvasButton anchorButton, Action showStatus) : base("OpenDropdown") { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) _ui = ui; _tabManager = tabManager; _getSnapshot = getSnapshot; _anchorButton = anchorButton; _showStatus = showStatus; base.ActiveSelf = false; base.Size = new Vector2(260f, 44f); Add(new CanvasImage("Background", ui) { IsBackground = true, Tint = ui.PanelBackground }).AddBorder(ui.PanelBorder); _backButton = Add(new CanvasButton("Back", ui)); _backButton.LocalPosition = Vector2.zero; _backButton.Size = new Vector2(70f, 22f); _backButton.Text.Text = "< Back"; _backButton.OnClicked += GoBack; _headerText = Add(new CanvasText("Header", ui)); _headerText.LocalPosition = new Vector2(74f, 0f); _headerText.Size = new Vector2(182f, 22f); _headerText.Alignment = (TextAnchor)3; _headerText.Overflow = (HorizontalWrapMode)1; _rowsScrollView = Add(new CanvasScrollView("RowsScroll")); _rowsScrollView.LocalPosition = new Vector2(0f, 22f); _rowsContainer = _rowsScrollView.SetContent(new CanvasPanel("Rows")); _rowsScrollbar = Add(new CanvasScrollbar("RowsScrollbar", ui) { ScrollView = _rowsScrollView }); base.OnUpdate += CloseOnOutsideClick; base.OnUpdate += delegate { _rowsScrollbar.ActiveSelf = _rowsScrollbar.ShouldBeVisible; }; } public void Toggle() { if (base.ActiveSelf) { Hide(); } else { Show(); } } private void Show() { _level = Level.Scenes; _selectedSceneIndex = -1; _selectedObjectIndex = -1; FsmSnapshot fsmSnapshot = _getSnapshot(); _sceneGroups = ((fsmSnapshot != null) ? FsmDrilldownHierarchy.Build(fsmSnapshot) : new List()); RebuildRows(); base.ActiveSelf = true; ((Transform)transform).SetAsLastSibling(); } private void Hide() { base.ActiveSelf = false; } private void CloseOnOutsideClick() { if (base.ActiveSelf && Input.GetMouseButtonDown(0) && !IsMouseOver() && !_anchorButton.IsMouseOver()) { Hide(); } } private void GoBack() { switch (_level) { case Level.Objects: _level = Level.Scenes; _selectedSceneIndex = -1; break; case Level.Fsms: _level = Level.Objects; _selectedObjectIndex = -1; break; } RebuildRows(); } private void RebuildRows() { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) foreach (CanvasButton rowButton in _rowButtons) { rowButton.Destroy(); _rowsContainer.Remove(rowButton); } _rowButtons.Clear(); _backButton.ActiveSelf = _level != Level.Scenes; _headerText.Text = BuildHeaderText(); float num = 250f; float num2 = 0f; foreach (var item2 in BuildRowList()) { string item = item2.Label; Action onClick = item2.OnClick; CanvasButton canvasButton = _rowsContainer.Add(new CanvasButton($"Row{_rowButtons.Count}", _ui)); canvasButton.LocalPosition = new Vector2(0f, num2); canvasButton.Size = new Vector2(num, 22f); canvasButton.Text.Text = item; canvasButton.Text.Alignment = (TextAnchor)3; canvasButton.Text.Overflow = (HorizontalWrapMode)1; canvasButton.OnClicked += delegate { onClick(); }; canvasButton.Build(); num2 += 22f; _rowButtons.Add(canvasButton); } _rowsContainer.Size = new Vector2(num, Mathf.Max(22f, num2)); float num3 = 22f + _rowsContainer.Size.y; float num4 = ((base.Parent != null) ? Mathf.Max(44f, base.Parent.Size.y - base.LocalPosition.y) : num3); float num5 = Mathf.Min(num3, num4); base.Size = new Vector2(260f, num5); float num6 = Mathf.Max(0f, num5 - 22f); _rowsScrollView.Size = new Vector2(num, num6); _rowsScrollbar.LocalPosition = new Vector2(num, 22f); _rowsScrollbar.Size = new Vector2(10f, num6); } private List<(string Label, Action OnClick)> BuildRowList() { List<(string, Action)> list = new List<(string, Action)>(); if (_sceneGroups == null) { return list; } switch (_level) { case Level.Scenes: { for (int num = 0; num < _sceneGroups.Count; num++) { int index = num; list.Add((_sceneGroups[num].SceneName, delegate { _selectedSceneIndex = index; _level = Level.Objects; RebuildRows(); })); } break; } case Level.Objects: { SceneGroup sceneGroup = _sceneGroups[_selectedSceneIndex]; for (int num2 = 0; num2 < sceneGroup.Objects.Count; num2++) { int index2 = num2; list.Add((sceneGroup.Objects[num2].Label, delegate { _selectedObjectIndex = index2; _level = Level.Fsms; RebuildRows(); })); } break; } case Level.Fsms: { ObjectGroup objectGroup = _sceneGroups[_selectedSceneIndex].Objects[_selectedObjectIndex]; for (int i = 0; i < objectGroup.FsmLabels.Count; i++) { int snapshotIndex = objectGroup.FsmIndices[i]; list.Add((objectGroup.FsmLabels[i], delegate { OpenFsm(snapshotIndex); })); } break; } } return list; } private void OpenFsm(int snapshotIndex) { FsmSnapshot fsmSnapshot = _getSnapshot(); if (fsmSnapshot != null && snapshotIndex >= 0 && snapshotIndex < fsmSnapshot.Fsms.Count) { _tabManager.OpenOrFocus(fsmSnapshot.Fsms[snapshotIndex]); _showStatus("FSM Opened"); Hide(); } } private string BuildHeaderText() { return _level switch { Level.Scenes => "Select a scene", Level.Objects => "Scene: " + _sceneGroups[_selectedSceneIndex].SceneName, Level.Fsms => "Object: " + _sceneGroups[_selectedSceneIndex].Objects[_selectedObjectIndex].Label, _ => "", }; } } internal sealed class FsmRightPanel : CanvasPanel { private const int PanelWidth = 355; private const int PanelHeight = 850; private const int ScreenMargin = 0; private const float TitleBarHeightDesign = 22f; private const float ButtonRowHeight = 28f; private const float ButtonGap = 4f; private const float SectionGap = 8f; private const float ResizeHandleSizeDesign = 14f; private const int MinPanelWidth = 260; private const int MinPanelHeight = 320; private const float AutoButtonWidthDesign = 50f; private const float TitleTextWidthDesign = 90f; private const float StatusDurationSeconds = 5f; private readonly UICommon _ui; private readonly CanvasImage _background; private readonly CanvasButton _dragSurface; private readonly CanvasText _titleText; private readonly CanvasText _statusText; private readonly CanvasButton _autoButton; private readonly CanvasButton _openButton; private readonly CanvasButton _saveButton; private readonly CanvasButton _loadButton; private readonly CanvasButton _undoButton; private readonly CanvasButton _resetButton; private readonly CanvasButton _graphButton; private readonly FsmOpenDropdown _openDropdown; private readonly FsmSaveDialog _saveDialog; private readonly FsmLoadDialog _loadDialog; private readonly CanvasResizeHandle _resizeHandle; private readonly FsmPanelLayoutConfig _layout; private int _lastScreenWidth = -1; private int _lastScreenHeight = -1; private float _statusHideAtUnscaledTime; private static float TitleBarHeight => UICommon.ScaleHeight(22f); private static float ResizeHandleSize => UICommon.ScaleWidth(14f); private static float MinWidth => UICommon.ScaleWidth(260); private static float MinHeight => UICommon.ScaleHeight(320); private static float AutoButtonWidth => UICommon.ScaleWidth(50f); private static float TitleTextWidth => UICommon.ScaleWidth(90f); private static float ContentTop => TitleBarHeight + 6f; public FsmTabStripPanel TabStrip { get; } public FsmActiveStatePanel ActiveStatePanel { get; } public Rect? OpenDropdownScreenRect { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_004d: 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) if (!_openDropdown.ActiveInHierarchy) { return null; } return new Rect(_openDropdown.Position.x, _openDropdown.Position.y, _openDropdown.Size.x, _openDropdown.Size.y); } } public FsmRightPanel(UICommon ui, FsmTabManager tabManager, FsmEditManager editManager, FsmVariableTracker tracker, Func getSnapshot, Func getGraphVisible, Action setGraphVisible, ManualLogSource logger, FsmPanelLayoutConfig layout, ConfigEntry autoLoadConfig) : base("FsmRightPanel") { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) FsmRightPanel fsmRightPanel = this; _ui = ui; _layout = layout; Reposition(); _background = Add(new CanvasImage("Background", ui) { IsBackground = true, Tint = ui.PanelBackground }); _background.AddBorder(ui.PanelBorder); _dragSurface = Add(new CanvasButton("DragSurface", ui) { Tint = Color.clear }); _dragSurface.RemoveBorder(); _titleText = Add(new CanvasText("Title", ui) { Text = "FsmMaster" }); _titleText.Font = ui.HeaderFont; _titleText.FontStyle = (FontStyle)1; _titleText.Alignment = (TextAnchor)3; _statusText = Add(new CanvasText("StatusText", ui) { Text = "" }); _statusText.FontStyle = (FontStyle)1; _statusText.Alignment = (TextAnchor)4; _statusText.ActiveSelf = false; _autoButton = Add(new CanvasButton("AutoButton", ui)); _autoButton.Text.Text = "Auto"; _autoButton.Toggled = autoLoadConfig.Value; _autoButton.OnClicked += delegate { autoLoadConfig.Value = !autoLoadConfig.Value; fsmRightPanel._autoButton.Toggled = autoLoadConfig.Value; }; _openButton = Add(new CanvasButton("OpenButton", ui)); _openButton.Text.Text = "Open"; _saveButton = Add(new CanvasButton("SaveButton", ui)); _saveButton.Text.Text = "Save"; _saveButton.OnClicked += delegate { fsmRightPanel.OpenSaveDialog(tabManager, logger); }; _loadButton = Add(new CanvasButton("LoadButton", ui)); _loadButton.Text.Text = "Load"; _loadButton.OnClicked += delegate { fsmRightPanel.OpenLoadDialog(tabManager, logger); }; _undoButton = Add(new CanvasButton("UndoButton", ui)); _undoButton.Text.Text = "Undo"; _undoButton.OnClicked += delegate { fsmRightPanel.UndoActiveTab(tabManager, editManager, logger); }; _resetButton = Add(new CanvasButton("ResetButton", ui)); _resetButton.Text.Text = "Reset"; _resetButton.OnClicked += delegate { fsmRightPanel.ResetActiveTab(tabManager, editManager, logger); }; _graphButton = Add(new CanvasButton("GraphButton", ui)); _graphButton.Toggled = getGraphVisible(); _graphButton.Text.Text = (_graphButton.Toggled ? "Hide" : "Show"); _graphButton.OnClicked += delegate { //IL_0070: Unknown result type (might be due to invalid IL or missing references) bool flag = !getGraphVisible(); setGraphVisible(flag); fsmRightPanel._graphButton.Toggled = flag; fsmRightPanel._graphButton.Text.Text = (flag ? "Hide" : "Show"); fsmRightPanel.ShowStatus(flag ? "Graph Shown" : "Graph Hidden", fsmRightPanel._ui.SuccessColor); }; LayoutButtonRow(); TabStrip = Add(new FsmTabStripPanel(ui, tabManager)); LayoutTabStrip(); ActiveStatePanel = Add(new FsmActiveStatePanel(ui, editManager, tracker, logger, delegate(string msg) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) fsmRightPanel.ShowStatus(msg, fsmRightPanel._ui.SuccessColor); })); LayoutActiveStatePanel(); _openDropdown = Add(new FsmOpenDropdown(ui, tabManager, getSnapshot, _openButton, delegate(string msg) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) fsmRightPanel.ShowStatus(msg, fsmRightPanel._ui.SuccessColor); })); _openDropdown.LocalPosition = new Vector2(10f, ContentTop + 28f + 4f); _openButton.OnClicked += _openDropdown.Toggle; _saveDialog = Add(new FsmSaveDialog(ui, _saveButton)); _saveDialog.OnConfirm += delegate(string sceneName, string fsmKey, string saveName) { fsmRightPanel.ConfirmSave(editManager, logger, sceneName, fsmKey, saveName); }; _loadDialog = Add(new FsmLoadDialog(ui, _loadButton)); _loadDialog.OnSelected += delegate(string sceneName, string fsmKey, string saveName) { fsmRightPanel.ConfirmLoad(editManager, logger, sceneName, fsmKey, saveName); }; _resizeHandle = Add(new CanvasResizeHandle("ResizeHandle", ui)); _resizeHandle.OnDragDelta += OnResizeDragged; _resizeHandle.OnDragEnd += OnResizeDragEnded; LayoutResizeHandle(); base.OnUpdate += ReflowOnResolutionChange; base.OnUpdate += UpdateStatusTimeout; } public override void Build(Transform? rootParent = null) { base.Build(rootParent); _dragSurface.AddEventTrigger((EventTriggerType)5, OnDragged); _dragSurface.AddEventTrigger((EventTriggerType)14, OnDragEnded); } private void OnDragged(PointerEventData eventData) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(base.LocalPosition.x + eventData.delta.x, base.LocalPosition.y - eventData.delta.y); val.x = Mathf.Clamp(val.x, 0f, Mathf.Max(0f, (float)Screen.width - base.Size.x)); val.y = Mathf.Clamp(val.y, 0f, Mathf.Max(0f, (float)Screen.height - base.Size.y)); base.LocalPosition = val; } private void OnDragEnded(PointerEventData _) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) _layout.Position.Value = base.LocalPosition; } private void OnResizeDragged(Vector2 delta) { //IL_0001: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) float num = base.LocalPosition.x + base.Size.x; float num2 = Mathf.Clamp(base.Size.x - delta.x, MinWidth, Mathf.Max(MinWidth, num)); float num3 = Mathf.Clamp(base.Size.y - delta.y, MinHeight, Mathf.Max(MinHeight, (float)Screen.height - base.LocalPosition.y)); base.LocalPosition = new Vector2(num - num2, base.LocalPosition.y); base.Size = new Vector2(num2, num3); LayoutButtonRow(); LayoutTabStrip(); LayoutActiveStatePanel(); LayoutResizeHandle(); } private void OnResizeDragEnded() { //IL_000c: 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) _layout.Position.Value = base.LocalPosition; _layout.Size.Value = base.Size; } private void LayoutResizeHandle() { //IL_000c: 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_0036: Unknown result type (might be due to invalid IL or missing references) _resizeHandle.LocalPosition = new Vector2(0f, base.Size.y - ResizeHandleSize); _resizeHandle.Size = new Vector2(ResizeHandleSize, ResizeHandleSize); } protected override void OnUpdateActive() { if (!base.ActiveSelf) { CanvasTextField.ForceReleaseFocus(); } base.OnUpdateActive(); } private void OpenSaveDialog(FsmTabManager tabManager, ManualLogSource logger) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) FsmTabState active = tabManager.GetActive(); if ((Object)(object)active?.Component == (Object)null) { logger.LogInfo((object)"[FsmMaster] Save: no active tab."); return; } Scene scene = ((Component)active.Component).gameObject.scene; string name = ((Scene)(ref scene)).name; string defaultName = FsmSaveDataStore.GetLastChosenSaveName(name, active.FsmKey) ?? ""; _saveDialog.Show(name, active.FsmKey, defaultName); } private void OpenLoadDialog(FsmTabManager tabManager, ManualLogSource logger) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) FsmTabState active = tabManager.GetActive(); if ((Object)(object)active?.Component == (Object)null) { logger.LogInfo((object)"[FsmMaster] Load: no active tab."); return; } Scene scene = ((Component)active.Component).gameObject.scene; string name = ((Scene)(ref scene)).name; _loadDialog.Show(name, active.FsmKey); } private void ConfirmSave(FsmEditManager editManager, ManualLogSource logger, string sceneName, string fsmKey, string saveName) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) string filePath = FsmSaveDataStore.GetFilePath(sceneName, fsmKey, saveName); FsmEditSet edits = editManager.GetActiveEditSet(fsmKey) ?? new FsmEditSet { FsmKey = fsmKey }; try { string text = FsmSaveDataStore.Save(sceneName, saveName, edits); FsmSaveDataStore.SetLastChosenSaveName(sceneName, fsmKey, saveName); logger.LogInfo((object)("[FsmMaster] Saved '" + saveName + "' for '" + fsmKey + "' in scene '" + sceneName + "' to '" + filePath + "':\n" + text)); ShowStatus("Config Saved", _ui.SuccessColor); } catch (Exception ex) { logger.LogError((object)$"[FsmMaster] Save failed for '{saveName}' ('{fsmKey}' in scene '{sceneName}') at '{filePath}': {ex}"); ShowStatus("Save Failed", _ui.ErrorColor); } } private void ConfirmLoad(FsmEditManager editManager, ManualLogSource logger, string sceneName, string fsmKey, string saveName) { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) string filePath = FsmSaveDataStore.GetFilePath(sceneName, fsmKey, saveName); try { FsmEditSet fsmEditSet = FsmSaveDataStore.Load(sceneName, fsmKey, saveName); if (fsmEditSet == null) { logger.LogInfo((object)("[FsmMaster] Load: '" + saveName + "' not found for '" + fsmKey + "' in scene '" + sceneName + "' (looked at '" + filePath + "').")); ShowStatus("Load Failed", _ui.ErrorColor); } else { editManager.ApplyEditSet(fsmEditSet); FsmSaveDataStore.SetLastChosenSaveName(sceneName, fsmKey, saveName); logger.LogInfo((object)("[FsmMaster] Loaded '" + saveName + "' for '" + fsmKey + "' in scene '" + sceneName + "' from '" + filePath + "'.")); ShowStatus("Config Loaded", _ui.SuccessColor); } } catch (Exception ex) { logger.LogError((object)$"[FsmMaster] Load failed for '{saveName}' ('{fsmKey}' in scene '{sceneName}') at '{filePath}': {ex}"); ShowStatus("Load Failed", _ui.ErrorColor); } } internal void ShowStatus(string text, Color color, float durationSeconds = 5f) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) _statusText.Text = text; _statusText.Color = color; _statusText.ActiveSelf = true; _statusHideAtUnscaledTime = Time.unscaledTime + durationSeconds; } private void UpdateStatusTimeout() { if (_statusText.ActiveSelf && Time.unscaledTime >= _statusHideAtUnscaledTime) { _statusText.ActiveSelf = false; } } private void UndoActiveTab(FsmTabManager tabManager, FsmEditManager editManager, ManualLogSource logger) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) FsmTabState active = tabManager.GetActive(); if ((Object)(object)active?.Component == (Object)null) { logger.LogInfo((object)"[FsmMaster] Undo: no active tab."); return; } if (!editManager.HasUndo(active.FsmKey)) { logger.LogInfo((object)("[FsmMaster] Undo: nothing to undo for '" + active.FsmKey + "'.")); return; } editManager.Undo(active.FsmKey); logger.LogInfo((object)("[FsmMaster] Undid last edit for '" + active.FsmKey + "'.")); ShowStatus("Edit Undone", _ui.SuccessColor); } private void ResetActiveTab(FsmTabManager tabManager, FsmEditManager editManager, ManualLogSource logger) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) FsmTabState active = tabManager.GetActive(); if ((Object)(object)active?.Component == (Object)null) { logger.LogInfo((object)"[FsmMaster] Reset: no active tab."); return; } editManager.ResetFsm(active.FsmKey); logger.LogInfo((object)("[FsmMaster] Reset all edits for '" + active.FsmKey + "'.")); ShowStatus("Edits Reset", _ui.SuccessColor); } private void LayoutButtonRow() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) //IL_007c: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) _background.Size = base.Size; _dragSurface.LocalPosition = Vector2.zero; _dragSurface.Size = new Vector2(base.Size.x, TitleBarHeight); _titleText.LocalPosition = new Vector2(6f, 0f); _titleText.Size = new Vector2(TitleTextWidth, TitleBarHeight); _autoButton.LocalPosition = new Vector2(base.Size.x - AutoButtonWidth - 6f, 2f); _autoButton.Size = new Vector2(AutoButtonWidth, Mathf.Max(0f, TitleBarHeight - 4f)); float num = 6f + TitleTextWidth + 4f; float num2 = Mathf.Max(0f, base.Size.x - num - AutoButtonWidth - 10f); _statusText.LocalPosition = new Vector2(num, 0f); _statusText.Size = new Vector2(num2, TitleBarHeight); float contentTop = ContentTop; float num3 = base.Size.x - 20f; float num4 = (num3 - 20f) / 6f; _openButton.LocalPosition = new Vector2(10f, contentTop); _openButton.Size = new Vector2(num4, 28f); _saveButton.LocalPosition = new Vector2(10f + num4 + 4f, contentTop); _saveButton.Size = new Vector2(num4, 28f); _loadButton.LocalPosition = new Vector2(10f + (num4 + 4f) * 2f, contentTop); _loadButton.Size = new Vector2(num4, 28f); _undoButton.LocalPosition = new Vector2(10f + (num4 + 4f) * 3f, contentTop); _undoButton.Size = new Vector2(num4, 28f); _resetButton.LocalPosition = new Vector2(10f + (num4 + 4f) * 4f, contentTop); _resetButton.Size = new Vector2(num4, 28f); _graphButton.LocalPosition = new Vector2(10f + (num4 + 4f) * 5f, contentTop); _graphButton.Size = new Vector2(num3 - (num4 + 4f) * 5f, 28f); } private void LayoutTabStrip() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) TabStrip.LocalPosition = new Vector2(10f, ContentTop + 28f + 8f); TabStrip.Size = new Vector2(base.Size.x - 20f, 52f); } private void LayoutActiveStatePanel() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) float num = ContentTop + 28f + 8f + 52f + 8f; ActiveStatePanel.LocalPosition = new Vector2(10f, num); ActiveStatePanel.Size = new Vector2(base.Size.x - 20f, Mathf.Max(0f, base.Size.y - num - 10f)); } private void ReflowOnResolutionChange() { if (Screen.width != _lastScreenWidth || Screen.height != _lastScreenHeight) { Reposition(); LayoutButtonRow(); LayoutTabStrip(); LayoutActiveStatePanel(); LayoutResizeHandle(); } } private void Reposition() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) _lastScreenWidth = Screen.width; _lastScreenHeight = Screen.height; base.Size = (_layout.HasSavedSize ? new Vector2(Mathf.Max(MinWidth, _layout.Size.Value.x), Mathf.Max(MinHeight, _layout.Size.Value.y)) : new Vector2((float)UICommon.ScaleWidth(355), (float)UICommon.ScaleHeight(850))); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)(Screen.width - UICommon.ScaleWidth(0)) - base.Size.x, (float)UICommon.ScaleHeight(0)); Vector2 val2 = (_layout.HasSavedPosition ? _layout.Position.Value : val); base.LocalPosition = new Vector2(Mathf.Clamp(val2.x, 0f, Mathf.Max(0f, (float)Screen.width - base.Size.x)), Mathf.Clamp(val2.y, 0f, Mathf.Max(0f, (float)Screen.height - base.Size.y))); } } internal sealed class FsmSaveDialog : CanvasPanel { private const float Width = 240f; private const float HeaderHeight = 22f; private const float FieldHeight = 26f; private const float ButtonHeight = 26f; private const float Padding = 8f; private readonly CanvasButton _anchorButton; private readonly CanvasText _headerText; private readonly CanvasTextField _nameField; private readonly CanvasButton _confirmButton; private string _sceneName = ""; private string _fsmKey = ""; public event Action? OnConfirm; public FsmSaveDialog(UICommon ui, CanvasButton anchorButton) : base("SaveDialog") { //IL_003a: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) _anchorButton = anchorButton; base.ActiveSelf = false; base.Size = new Vector2(240f, 106f); Add(new CanvasImage("Background", ui) { IsBackground = true, Tint = ui.PanelBackground }).AddBorder(ui.PanelBorder); _headerText = Add(new CanvasText("Header", ui) { Text = "Save configuration as:" }); _headerText.LocalPosition = new Vector2(8f, 8f); _headerText.Size = new Vector2(224f, 22f); _headerText.Alignment = (TextAnchor)3; _nameField = Add(new CanvasTextField("NameField", ui)); _nameField.LocalPosition = new Vector2(8f, 38f); _nameField.Size = new Vector2(224f, 26f); _nameField.OnSubmit += delegate { Confirm(); }; _confirmButton = Add(new CanvasButton("ConfirmButton", ui)); _confirmButton.Text.Text = "Save"; _confirmButton.LocalPosition = new Vector2(8f, 72f); _confirmButton.Size = new Vector2(224f, 26f); _confirmButton.OnClicked += Confirm; base.OnUpdate += CloseOnOutsideClick; } public void Show(string sceneName, string fsmKey, string defaultName) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) _sceneName = sceneName; _fsmKey = fsmKey; _nameField.Text = defaultName; base.LocalPosition = new Vector2(_anchorButton.LocalPosition.x, _anchorButton.LocalPosition.y + _anchorButton.Size.y + 4f); base.ActiveSelf = true; ((Transform)transform).SetAsLastSibling(); _nameField.Activate(); } private void Hide() { CanvasTextField.ForceReleaseFocus(); base.ActiveSelf = false; } private void Confirm() { string text = _nameField.Text.Trim(); if (text.Length != 0) { this.OnConfirm?.Invoke(_sceneName, _fsmKey, text); Hide(); } } private void CloseOnOutsideClick() { if (base.ActiveSelf && Input.GetMouseButtonDown(0) && !IsMouseOver() && !_anchorButton.IsMouseOver()) { Hide(); } } } internal sealed class FsmTabManager { private readonly List _tabs = new List(); public IReadOnlyList Tabs => _tabs; public int ActiveTabIndex { get; private set; } = -1; public FsmTabState? GetActive() { if (ActiveTabIndex < 0 || ActiveTabIndex >= _tabs.Count) { return null; } return _tabs[ActiveTabIndex]; } public FsmTabState OpenOrFocus(FsmIdentityInfo fsm) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) string fsmKey = FsmIdentity.GetFsmKey(fsm.Component); for (int i = 0; i < _tabs.Count; i++) { if (_tabs[i].FsmKey == fsmKey) { ActiveTabIndex = i; return _tabs[i]; } } FsmTabState fsmTabState = new FsmTabState { FsmKey = fsmKey, Component = fsm.Component, GameObjectNameForLabel = fsm.GameObjectName, FsmNameForLabel = fsm.FsmName }; (fsmTabState.PanWorldCenter, fsmTabState.Zoom) = FsmGraphOverlay.FitViewToFsm(FsmDataCollector.CollectFsmInfo(fsm.Component)); _tabs.Add(fsmTabState); ActiveTabIndex = _tabs.Count - 1; return fsmTabState; } public void Focus(FsmTabState tab) { int num = _tabs.IndexOf(tab); if (num >= 0) { ActiveTabIndex = num; } } public void Close(FsmTabState tab) { int num = _tabs.IndexOf(tab); if (num >= 0) { _tabs.RemoveAt(num); if (ActiveTabIndex == num) { ActiveTabIndex = ((_tabs.Count > 0) ? Math.Min(num, _tabs.Count - 1) : (-1)); } else if (ActiveTabIndex > num) { ActiveTabIndex--; } } } public void RebindAfterRefresh(IReadOnlyDictionary> groupsByFsmKey) { foreach (FsmTabState tab in _tabs) { if (groupsByFsmKey.TryGetValue(tab.FsmKey, out List value) && value.Count > 0) { tab.Component = value[0]; tab.IsLive = true; } else { tab.Component = null; tab.IsLive = false; } } } } internal sealed class FsmTabState { public string FsmKey = ""; public PlayMakerFSM? Component; public bool IsLive = true; public bool IsPinned; public string GameObjectNameForLabel = ""; public string FsmNameForLabel = ""; public Vector2 PanWorldCenter; public float Zoom = 1f; public string? SelectedStateName; public int? PendingScrollActionIndex; } internal sealed class FsmTabStripPanel : CanvasPanel { private sealed class TabWidget { public FsmTabState Tab { get; } public CanvasPanel Root { get; } public CanvasButton SelectButton { get; } public CanvasButton CloseButton { get; } public CanvasToggleDot PinDot { get; } public float PreferredTextWidth { get; set; } public TabWidget(FsmTabState tab, CanvasPanel root, CanvasButton selectButton, CanvasButton closeButton, CanvasToggleDot pinDot) { Tab = tab; Root = root; SelectButton = selectButton; CloseButton = closeButton; PinDot = pinDot; } } private const float TabWidth = 170f; private const float TabGap = 4f; private const float CloseButtonSize = 14f; private const float ScrollbarHeight = 10f; private const float ScrollbarGap = 2f; private const float SelectedTabTextPadding = 16f; public const float TabRowHeight = 40f; public const float TotalHeight = 52f; private readonly UICommon _ui; private readonly FsmTabManager _tabManager; private readonly CanvasHorizontalScrollbar _scrollbar; private readonly CanvasHorizontalScrollStrip _scrollStrip; private readonly CanvasPanel _content; private readonly List _tabWidgets = new List(); private readonly List _lastTabsSnapshot = new List(); public FsmTabStripPanel(UICommon ui, FsmTabManager tabManager) : base("TabStrip") { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) _ui = ui; _tabManager = tabManager; _scrollbar = Add(new CanvasHorizontalScrollbar("Scrollbar", ui)); _scrollbar.LocalPosition = Vector2.zero; _scrollStrip = Add(new CanvasHorizontalScrollStrip("ScrollStrip")); _scrollStrip.LocalPosition = new Vector2(0f, 12f); _content = _scrollStrip.SetContent(new CanvasPanel("Content")); _scrollbar.Source = _scrollStrip; base.OnUpdate += Refresh; } protected override void OnUpdateSize() { base.OnUpdateSize(); Layout(); } public override void Build(Transform? rootParent = null) { Layout(); base.Build(rootParent); } private void Layout() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0036: Unknown result type (might be due to invalid IL or missing references) _scrollbar.Size = new Vector2(base.Size.x, 10f); _scrollStrip.Size = new Vector2(base.Size.x, 40f); } private void Refresh() { IReadOnlyList tabs = _tabManager.Tabs; bool flag = tabs.Count != _lastTabsSnapshot.Count; if (!flag) { for (int i = 0; i < tabs.Count; i++) { if (tabs[i] != _lastTabsSnapshot[i]) { flag = true; break; } } } if (flag) { RebuildWidgets(tabs); _lastTabsSnapshot.Clear(); _lastTabsSnapshot.AddRange(tabs); } FsmTabState active = _tabManager.GetActive(); foreach (TabWidget tabWidget in _tabWidgets) { tabWidget.SelectButton.Toggled = tabWidget.Tab == active; tabWidget.PinDot.On = tabWidget.Tab.IsPinned; } LayoutWidgets(active); _scrollbar.ActiveSelf = _scrollbar.ShouldBeVisible; } private void RebuildWidgets(IReadOnlyList tabs) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) foreach (TabWidget tabWidget2 in _tabWidgets) { tabWidget2.Root.Destroy(); _content.Remove(tabWidget2.Root); } _tabWidgets.Clear(); int num = 0; foreach (FsmTabState tab in tabs) { TabWidget tabWidget = CreateTabWidget(tab, num); tabWidget.Root.Size = new Vector2(170f, 40f); tabWidget.Root.Build(); Text? textComponent = tabWidget.SelectButton.Text.TextComponent; tabWidget.PreferredTextWidth = ((textComponent != null) ? textComponent.preferredWidth : 170f); num++; _tabWidgets.Add(tabWidget); } } private void LayoutWidgets(FsmTabState? active) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) float num = 0f; foreach (TabWidget tabWidget in _tabWidgets) { float num2 = ((tabWidget.Tab == active) ? Mathf.Max(170f, tabWidget.PreferredTextWidth + 16f) : 170f); tabWidget.Root.LocalPosition = new Vector2(num, 0f); tabWidget.Root.Size = new Vector2(num2, 40f); tabWidget.SelectButton.Size = new Vector2(num2, 40f); tabWidget.CloseButton.LocalPosition = new Vector2(num2 - 14f - 2f, 2f); num += num2 + 4f; } _content.Size = new Vector2(Mathf.Max(_scrollStrip.Size.x, Mathf.Max(0f, num - 4f)), 40f); } private TabWidget CreateTabWidget(FsmTabState tab, int index) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) CanvasPanel canvasPanel = _content.Add(new CanvasPanel($"Tab{index}")); CanvasButton canvasButton = canvasPanel.Add(new CanvasButton("Select", _ui)); canvasButton.LocalPosition = Vector2.zero; canvasButton.Size = new Vector2(170f, 40f); canvasButton.Text.Text = tab.GameObjectNameForLabel + "\n" + tab.FsmNameForLabel; canvasButton.Text.Alignment = (TextAnchor)4; canvasButton.OnClicked += delegate { _tabManager.Focus(tab); }; CanvasButton canvasButton2 = canvasPanel.Add(new CanvasButton("Close", _ui)); canvasButton2.LocalPosition = new Vector2(154f, 2f); canvasButton2.Size = new Vector2(14f, 14f); canvasButton2.Text.Text = "x"; canvasButton2.OnClicked += delegate { _tabManager.Close(tab); }; CanvasToggleDot canvasToggleDot = canvasPanel.Add(new CanvasToggleDot("Pin", _ui)); canvasToggleDot.LocalPosition = new Vector2(2f, 2f); canvasToggleDot.Size = new Vector2(_ui.DotSize, _ui.DotSize); canvasToggleDot.On = tab.IsPinned; canvasToggleDot.OnClicked += delegate { tab.IsPinned = !tab.IsPinned; }; return new TabWidget(tab, canvasPanel, canvasButton, canvasButton2, canvasToggleDot); } } }