From d678f3210f90a8e6b76158a9d66234d6b688cd65 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 15 Jun 2026 22:00:25 +0100 Subject: [PATCH] Delete renderer-local console authority --- .voidbot/state/aetheria.cc | Bin 137593 -> 138936 bytes Aetheria.State.Verify/Program.cs | 49 ++++++ Assets/Scenes/ARPG.unity | 18 --- Assets/Scripts/Gameplay/ActionGameManager.cs | 105 ------------- Assets/Scripts/UI/ConsoleController.cs | 124 --------------- Assets/Scripts/UI/ConsoleController.cs.meta | 11 -- Assets/Scripts/UI/ConsoleView.cs | 149 ------------------- Assets/Scripts/UI/ConsoleView.cs.meta | 11 -- docs/aetheria-perfect-machine-map.md | 15 +- 9 files changed, 61 insertions(+), 421 deletions(-) delete mode 100644 Assets/Scripts/UI/ConsoleController.cs delete mode 100644 Assets/Scripts/UI/ConsoleController.cs.meta delete mode 100644 Assets/Scripts/UI/ConsoleView.cs delete mode 100644 Assets/Scripts/UI/ConsoleView.cs.meta diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index ef14b14c2a087cb62a12b4013f4db9a25cc9669c..0b03f8b6d8c74a3b5abcf99e13efce366e21e86a 100644 GIT binary patch delta 1320 zcmZWpOK%fb6qYAxn@|xdB#?@PxGOezjInE@n3Y9PLgDfK zzda6iHR`QuqtcjdF5WKfTmLJ#l_SmSu?$fYmkZ>0hD=Q!IyiIX#?OZJAfXpP8=++B z2h&s9E`Uzb>vNNvbCV@^uJO(H2_#Cdo#tCdDA*ooK|`jbQ89$hiI6&rX~M3B%-OJ3 ztu?F7^uY(g=fhL&Jf3if!2&0kPE^c^2FXE#4r9e=Ox*nW(-^btB9d1oMb*k97E_UI z-NX>4l7vcbNaBno-B_()MXg-aBYmv~0&9kp4?tUCfDg&30gQ79SIi|Kttk_!Y>{_z z#N>j2m81E8d|0jG7&Ni4YDu4>JTf9elJgRIR-RapUa+lO9Ve|wfZ%M#ia7S;TPma> z%JxvI5i`RyU`Cl3l_`KhUcHejSceFVmq3=4Ls|GXcY=zJ#zp3Rl+XvOZdSx|!?uZt z^xc1hPlp?GDkG*r`0=@8K;9!%9z&jQnJ7)#oSz)28XCKXLycEc2nVZxV_@eKgmS(u zv|5ok>saC;?uGR52W2zFzZj>xlz~Crj0MUoKT^riDIMsV+tSQHF%EaH*S7A>nMJ&N094zv(oHng% zi<2`_a}&c-i;6Sz^B7kaXXF=^grpYbPHT2y+3v!^SQ@bXM3u8l&(Dt_?Ob0n(VwNUR E04~rxp#T5? diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 5968585d6..cc69148e5 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -10,6 +10,7 @@ var statePath = args.Length > 1 RequireGameplaySourcePurity(root); RequirePackageSerializerBoundary(root); RequireEveRuntimeBootstrap(root); +RequireNoRendererLocalConsole(root); await using var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-state-verify"); @@ -449,6 +450,7 @@ Console.WriteLine($"Name files: {nameFiles.Length}"); Console.WriteLine("Live gameplay source purity: no serializer or legacy database symbols in Assets/Scripts"); Console.WriteLine("Package serializer boundary: MessagePack symbols remain in named CultCache transport files only"); Console.WriteLine("Eve runtime bootstrap: operations surface mounts through UI Toolkit presenter"); +Console.WriteLine("Renderer-local console authority: deleted; UI commands flow through Eve command documents"); static void RequireCount(AetheriaMigrationLedger ledger, string documentType, int actual) { @@ -594,6 +596,53 @@ static void RequireEveRuntimeBootstrap(string root) } } +static void RequireNoRendererLocalConsole(string root) +{ + var consoleFiles = new[] + { + Path.Combine(root, "Assets", "Scripts", "UI", "ConsoleController.cs"), + Path.Combine(root, "Assets", "Scripts", "UI", "ConsoleView.cs") + }; + + var existingConsoleFiles = consoleFiles + .Where(File.Exists) + .Select(path => Path.GetRelativePath(root, path)) + .ToArray(); + + if (existingConsoleFiles.Length > 0) + { + throw new InvalidOperationException( + "Renderer-local console source files still exist: " + + string.Join(", ", existingConsoleFiles)); + } + + var forbiddenSymbols = new[] + { + "ConsoleController", + "ConsoleView", + "AddCommand(" + }; + + var hits = Directory.EnumerateFiles(Path.Combine(root, "Assets"), "*.*", SearchOption.AllDirectories) + .Where(path => + path.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) || + path.EndsWith(".unity", StringComparison.OrdinalIgnoreCase) || + path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase)) + .SelectMany(path => File.ReadLines(path) + .Select((line, index) => new { Path = path, LineNumber = index + 1, Line = line })) + .Where(line => forbiddenSymbols.Any(symbol => line.Line.Contains(symbol, StringComparison.Ordinal))) + .Select(line => $"{Path.GetRelativePath(root, line.Path)}:{line.LineNumber}: {line.Line.Trim()}") + .Take(10) + .ToArray(); + + if (hits.Length > 0) + { + throw new InvalidOperationException( + "Renderer-local console authority is still wired in Assets: " + + string.Join("; ", hits)); + } +} + static bool ContainsBehaviorValueKind(AetheriaBehaviorValue value, string kind) { return string.Equals(value.Kind, kind, StringComparison.OrdinalIgnoreCase) || diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index c4bd71fcf..662da9991 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -27255,7 +27255,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1723136546} - - component: {fileID: 1723136547} m_Layer: 5 m_Name: Console m_TagString: Untagged @@ -27283,23 +27282,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} ---- !u!114 &1723136547 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1723136545} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 60214997723e68547b9c784ebda51d9a, type: 3} - m_Name: - m_EditorClassIdentifier: - GameManager: {fileID: 1009503729} - ViewContainer: {fileID: 460484048} - LogTextArea: {fileID: 825923021} - InputArea: {fileID: 1973552682} - Scroll: {fileID: 1956431015} --- !u!1 &1724695812 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 4019c2fc5..40863b8bc 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -1407,7 +1407,6 @@ public class ActionGameManager : MonoBehaviour private void OnDisable() { Input.Dispose(); - ConsoleController.ClearCommands(); EntityInstance.ClearWeaponManagers(); } @@ -1415,7 +1414,6 @@ public class ActionGameManager : MonoBehaviour { Instance = this; EntityInstance.EffectManagerParent = EffectManagerParent; - ConsoleController.MessageReceiver = this; var stateBoot = AetheriaRuntimeStateBoot.Inspect(GameDataDirectory); _runtimeStateFilePath = stateBoot.StateFilePath; @@ -1673,109 +1671,6 @@ public class ActionGameManager : MonoBehaviour slot.Binding = new ActionBarWeaponGroupBinding(CurrentEntity, slot, i) ); } - - ConsoleController.AddCommand("revealzones", - _ => - { - foreach (var zones in CurrentGalaxy.Zones - .Where(z=>!CurrentGalaxy.DiscoveredZones.Contains(z)) - .GroupBy(z=>z.Distance[CurrentGalaxy.Entrance]) - .OrderBy(g=>g.Key)) - { - SectorMap.QueueZoneReveal(zones); - } - }); - - ConsoleController.AddCommand("trackmissile", - _ => - { - foreach (var missileManager in FindObjectsByType(FindObjectsSortMode.None)) - { - missileManager.OnFireGuided.Where(x => x.source == _currentEntity).Take(1).Subscribe(x => - { - FollowCamera.Follow = x.missile.transform; - FollowCamera.LookAt = x.target; - x.missile.OnKill += () => - { - FollowCamera.LookAt = ZoneRenderer.EntityInstances[CurrentEntity].LookAtPoint; - FollowCamera.Follow = ZoneRenderer.EntityInstances[CurrentEntity].transform; - }; - }); - } - }); - - ConsoleController.AddCommand("spawnturret", - _ => - { - var nearestFaction = CurrentGalaxy.Factions.MinBy(f => CurrentGalaxy.HomeZones[f].Distance[Zone.GalaxyZone]); - - var loadoutGenerator = IsTutorial ? new LoadoutGenerator( - ref ItemManager.Random, - ItemManager, - RuntimeCatalog, - CurrentGalaxy, - Zone.GalaxyZone, - nearestFaction, - .5f) : new LoadoutGenerator( - ref ItemManager.Random, - ItemManager, - RuntimeCatalog, - CurrentGalaxy, - Zone.GalaxyZone, - nearestFaction, - .5f); - - var turret = EntityConstructionBlueprintProjector.InstantiateFromBlueprint(ItemManager, Zone, loadoutGenerator.GenerateTurretLoadout(), true); - turret.Position.xz = _currentEntity.Position.xz + - ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500); - turret.Zone = Zone; - Zone.Entities.Add(turret); - turret.Activate(); - }); - //Temporary, or not - ConsoleController.AddCommand("tow", _ => TowShip()); - - // ConsoleController.AddCommand("pingscene", - // _ => - // { - // var startTime = Time.time; - // Observable.EveryUpdate().TakeWhile(_ => Time.time - startTime < 5).Subscribe( - // _ => Debug.Log($"{(int) (Time.time - startTime)}"), - // () => - // { - // var nearestFaction = CurrentSector.Factions.MinBy(f => CurrentSector.HomeZones[f].Distance[Zone.SectorZone]); - // var nearestFactionHomeZone = CurrentSector.HomeZones[nearestFaction]; - // var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[Zone.SectorZone] + 1; - // - // var loadoutGenerator = new LoadoutGenerator( - // ref ItemManager.Random, - // ItemManager, - // CurrentSector, - // Zone.SectorZone, - // nearestFaction, - // .5f); - // - // for (int i = 0; i < 8; i++) - // { - // var ship = EntityConstructionBlueprintProjector.InstantiateFromBlueprint(ItemManager, Zone, loadoutGenerator.GenerateShipLoadout(), true); - // ship.Position.xz = _currentEntity.Position.xz + - // ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500); - // ship.Zone = Zone; - // Zone.Entities.Add(ship); - // ship.Activate(); - // } - // - // for (int i = 0; i < 8; i++) - // { - // var turret = EntityConstructionBlueprintProjector.InstantiateFromBlueprint(ItemManager, Zone, loadoutGenerator.GenerateTurretLoadout(), true); - // turret.Position.xz = _currentEntity.Position.xz + - // ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500); - // turret.Zone = Zone; - // Zone.Entities.Add(turret); - // turret.Activate(); - // } - // }); - // }); } public void BeginDrag(DragObject dragObject) diff --git a/Assets/Scripts/UI/ConsoleController.cs b/Assets/Scripts/UI/ConsoleController.cs deleted file mode 100644 index 640b3d6f7..000000000 --- a/Assets/Scripts/UI/ConsoleController.cs +++ /dev/null @@ -1,124 +0,0 @@ -/// -/// Handles parsing and execution of console commands, as well as collecting log output. -/// -using UnityEngine; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text; -using System.Text.RegularExpressions; -using UnityEngine.SceneManagement; -using Object = UnityEngine.Object; - -public class ConsoleController -{ - public static Component MessageReceiver; - private static ConsoleController _instance; - private static Regex _permittedCharacters = new Regex("[^a-zA-Z0-9 -]"); - private static Dictionary> _commands = new Dictionary>(); - - private ConsoleController() - { - } - - public static ConsoleController Instance - { - get => _instance ?? (_instance = new ConsoleController()); - } - - public static void ClearCommands() - { - _commands.Clear(); - } - - public static void AddCommand(string command, Action action) - { - var lower = command.ToLowerInvariant(); - if(!_commands.ContainsKey(lower)) - _commands.Add(lower, action); - } - - #region Event declarations - // Used to communicate with ConsoleView - public delegate void LogChangedHandler(string[] log); - public event LogChangedHandler LogChanged; - - public delegate void VisibilityChangedHandler(bool visible); - public event VisibilityChangedHandler VisibilityChanged; - #endregion - - /// - /// How many log lines should be retained? - /// Note that strings submitted to appendLogLine with embedded newlines will be counted as a single line. - /// - private const int ScrollbackSize = 100; - - private readonly Queue _scrollback = new Queue(ScrollbackSize); - private readonly List _commandHistory = new List(); - - public string[] Log { get; private set; } //Copy of scrollback as an array for easier use by ConsoleView - - public void AppendLogLine(string line) { - if (_scrollback.Count >= ScrollbackSize) { - _scrollback.Dequeue(); - } - _scrollback.Enqueue(line); - - Log = _scrollback.ToArray(); - LogChanged?.Invoke(Log); - } - - public void RunCommandString(string commandString) { - AppendLogLine($"$ {commandString}"); - - string[] commandSplit = ParseArguments(commandString); - string[] args = {"",""}; - if (commandSplit.Length < 1) { - AppendLogLine($"Unable to process command '{commandString}'"); - return; - - } - if (commandSplit.Length >= 2) { - int numArgs = commandSplit.Length - 1; - args = new string[numArgs]; - Array.Copy(commandSplit, 1, args, 0, numArgs); - } - - var cmd = commandSplit[0].ToLower(); - if(_commands.ContainsKey(cmd)) - _commands[cmd].Invoke(args); - else AppendLogLine("Invalid command!"); - //MessageReceiver.SendMessage(commandSplit[0].ToLower(), args, SendMessageOptions.DontRequireReceiver); - _commandHistory.Add(commandString); - } - - static string[] ParseArguments(string commandString) - { - var parmChars = new LinkedList(commandString.ToCharArray()); - var inQuote = false; - var node = parmChars.First; - while (node != null) - { - var next = node.Next; - if (node.Value == '"') { - inQuote = !inQuote; - parmChars.Remove(node); - } - if (!inQuote && node.Value == ' ') { - node.Value = '\n'; - } - node = next; - } - var parmCharsArr = new char[parmChars.Count]; - parmChars.CopyTo(parmCharsArr, 0); - var args = new string(parmCharsArr).Split(new[] {'\n'}, StringSplitOptions.RemoveEmptyEntries); - for (var i = 0; i < args.Length; i++) - { - args[i] = _permittedCharacters.Replace(args[i], ""); - } - return args; - } -} diff --git a/Assets/Scripts/UI/ConsoleController.cs.meta b/Assets/Scripts/UI/ConsoleController.cs.meta deleted file mode 100644 index 7d07ee170..000000000 --- a/Assets/Scripts/UI/ConsoleController.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 426b2d2dbea4d4d40b069c1ba2f6efb0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/UI/ConsoleView.cs b/Assets/Scripts/UI/ConsoleView.cs deleted file mode 100644 index fcde87e29..000000000 --- a/Assets/Scripts/UI/ConsoleView.cs +++ /dev/null @@ -1,149 +0,0 @@ -/// -/// Marshals events and data between ConsoleController and uGUI. -/// -using UnityEngine; -using UnityEngine.UI; -using System.Text; -using System.Collections; -using System.Linq; -using TMPro; -using UniRx; -using UnityEngine.InputSystem; - -public class ConsoleView : MonoBehaviour { - bool _didShow = false; - - public ActionGameManager GameManager; - public GameObject ViewContainer; //Container for console view, should be a child of this GameObject - public TextMeshProUGUI LogTextArea; - public TextMeshProUGUI InputArea; - public ScrollRect Scroll; - - private string _inputString = ""; - private CursorLockMode _previousCursorLockMode; - private bool _playerInputPreviouslyEnabled; - - public string InputString - { - get => _inputString; - set - { - _inputString = value; - InputArea.text = $"> {_inputString}"; - } - } - - //public bool AcceptingInput { get; private set; } - - public bool Visible { get; private set; } - - void Start() - { - //AcceptingInput = false; - //_console = new ConsoleController(); - Application.logMessageReceived += OnLogCallback; - - SetVisibility(false); - - ConsoleController.Instance.VisibilityChanged += OnVisibilityChanged; - ConsoleController.Instance.LogChanged += OnLogChanged; - - Keyboard.current.onTextInput += c => - { - if (!Visible || c == '`') return; - InputString += c; - }; - InputString = ""; - - ConsoleController.AddCommand("echo", Echo); - - // var sizeFitter = GetComponentInChildren().on - } - - private void OnLogCallback(string condition, string trace, LogType type) - { - ConsoleController.Instance.AppendLogLine("" + condition + ""); - } - - private void OnDestroy() { - Application.logMessageReceived -= OnLogCallback; - ConsoleController.Instance.VisibilityChanged -= OnVisibilityChanged; - ConsoleController.Instance.LogChanged -= OnLogChanged; - } - - void Update() - { - var keyboard = Keyboard.current; - //Toggle visibility when tilde key pressed - if (keyboard.backquoteKey.wasPressedThisFrame) { - ToggleVisibility(); - } - - if (!Visible) return; - - if(keyboard.deleteKey.wasPressedThisFrame && InputString.Length>0) - { - InputString = InputString.Substring(0, InputString.Length - 1); - } - - if (keyboard.enterKey.wasPressedThisFrame) - { - if (/*AcceptingInput && */InputString.Length > 0) - { - //if(_inputString.StartsWith("!") || _inputString.StartsWith("/")) - ConsoleController.Instance.RunCommandString(InputString);//.Substring(1)); - //else ConsoleController.Instance.RunCommandString($"say \"{_inputString}\""); - InputString = ""; - } - //AcceptingInput = !AcceptingInput; - } - } - - void Echo(string[] args) - { - if(args.Length>0) - Debug.Log(args.Aggregate((a,b) => a + " " + b)); - } - - void ToggleVisibility() { - SetVisibility(!ViewContainer.activeSelf); - } - - void SetVisibility(bool visible) { - ViewContainer.SetActive(visible); - Visible = visible; - if(visible) - { - _playerInputPreviouslyEnabled = GameManager.Input.Player.enabled; - _previousCursorLockMode = Cursor.lockState; - GameManager.Input.Global.Disable(); - GameManager.DisablePlayerInput(); - GameManager.Input.UI.Disable(); - Cursor.lockState = CursorLockMode.None; - } - else - { - if(_playerInputPreviouslyEnabled) - GameManager.EnablePlayerInput(); - else GameManager.Input.UI.Enable(); - GameManager.Input.Global.Enable(); - Cursor.lockState = _previousCursorLockMode; - } - } - - void OnVisibilityChanged(bool visible) { - SetVisibility(visible); - } - - void OnLogChanged(string[] newLog) { - LogTextArea.text = string.Join("\n", newLog); - // if (AcceptingInput) - // LogTextArea.text += "\n\n> " + _inputString; - Observable.NextFrame().Subscribe(_ => - { - if(Scroll) - Scroll.verticalNormalizedPosition = 0; - }); - } - -} diff --git a/Assets/Scripts/UI/ConsoleView.cs.meta b/Assets/Scripts/UI/ConsoleView.cs.meta deleted file mode 100644 index ec8e1118a..000000000 --- a/Assets/Scripts/UI/ConsoleView.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 60214997723e68547b9c784ebda51d9a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index ef2d6b99d..e67a589d5 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -611,8 +611,11 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. - The dead story compiled-JSON cache sketch and its SHA helper are deleted; story compilation currently reads Ink source directly until a typed Verse story/cache document exists. -- Runtime UI is old Unity UI/uGUI prefabs plus `MonoBehaviour` scripts under - `Assets/Scripts/UI/` and `Assets/Prefabs/UI/`. +- Runtime UI still contains old Unity UI/uGUI prefabs plus `MonoBehaviour` + scripts under `Assets/Scripts/UI/` and `Assets/Prefabs/UI/`, but the old + renderer-local debug console authority has been deleted. Runtime UI commands + must be provider-advertised Eve command documents, not text parsed by a Unity + component and invoked directly against gameplay objects. - Aetheria already has Unity UIElements support available through `com.unity.modules.uielements`. It now imports local staged `org.gamecult.eve.surface` and `org.gamecult.eve.unity-uitoolkit` packages: @@ -1348,7 +1351,13 @@ First Aetheria surfaces to publish: surfaces acquire provider-owned handlers. - Done: wire the presenter into runtime through `AetheriaEveRuntimeBootstrap` so the operations surface mounts as a UI Toolkit surface after scene load. - - Replace a concrete uGUI screen with an Eve-owned surface. + - Done: delete the concrete uGUI debug console path: `ConsoleView`, + `ConsoleController`, the `ARPG.unity` script binding, and + `ActionGameManager` debug command registrations. Refresh commands now use + the Eve command bridge; future gameplay/editor commands must add + provider-owned Eve handlers instead of reintroducing renderer-local text + command execution. + - Replace the next concrete uGUI screen with an Eve-owned surface. - Move the staged packages into the Eve repo once its worktree is clean, then import them back into Aetheria from Eve instead of carrying a local copy. - Replace the old IMGUI DB inspector first, because it is closest to state