using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text.Json; using System.Threading.Tasks; using Godot; using Age.Engine.Diagnostics; using Age.Engine.Hosting; using Age.Engine.Model; using Age.Engine.Persistence; using Age.Engine.Sys4; using Age.Engine.Vm; using Script = Age.Engine.Model.Script; // disambiguate from Godot.Script public partial class Main : Godot.Control { private const int ScreenWidth = 800; private const int ScreenHeight = 600; private TextureRect _screenView = null!; // shows the composited screen backbuffer private Image _screen = null!; // 800x600 immediate-mode canvas private ImageTexture _screenTex = null!; private GpuRetainedRenderer _gpuRenderer = null!; private bool _useGpuBackend = true; private ImageTexture? _ageCursorTexture; private TextureRect _waitIndicator = null!; private ImageTexture? _waitIndicatorSheet; private AtlasTexture? _waitIndicatorAtlas; private int _waitIndicatorAssetId = -1; // One managed composition target for the entire frame. Layer helpers mutate it in place; only the // completed frame crosses the Godot Image boundary, avoiding a full GetData/SetData round-trip per layer. private readonly byte[] _screenPixels = new byte[ScreenWidth * ScreenHeight * 4]; private Label _text = null!; private Label _speaker = null!; private readonly System.Collections.Generic.List