using System.Reflection; using FOU.Scripts; using FOU.Scripts.Elements; using Godot; public partial class Main : Node2D { [Export] public bool DebugVisualization = false; [Export] public int BrushSize = 5; [Export] public float TextureResolution = 0.5f; [Export] public int ChunksPerAxis = 2; [Export] public float RainAmount = 0.01f; public static Main Instance; private TextureRect mLevelDrawer; private Level mLevel; public override void _Ready() { mLevel = new Level(this, (int)(GetViewportRect().Size.X * TextureResolution), (int)(GetViewportRect().Size.Y * TextureResolution)); mLevelDrawer = GetNode("CanvasLayer/LevelDrawer"); Instance = this; } public override void _Process(double delta) { mLevel.Update(); mLevelDrawer.Texture = ImageTexture.CreateFromImage(mLevel.DrawLevel()); } public override void _UnhandledInput(InputEvent @event) { if (@event is InputEventMouseButton eventMouseButton) { if (eventMouseButton.IsPressed()) { Vector2 mouse = GetViewport().GetMousePosition(); float mappedX = mouse.X / (GetViewportRect().Size.X / mLevel.Resolution.X); float mappedY = mouse.Y / (GetViewportRect().Size.Y / mLevel.Resolution.Y); mLevel.WritePixel((int)mappedX, (int)mappedY, BrushSize); } } else base._UnhandledInput(@event); } }