TinyEcs
TinyEcs copied to clipboard
How to update raylib on tag add/remove
This is how I was updating my rectangle...
private static void UpdateRectangle(Local<Rectangle> previous, Query<Data<Rectangle>, Filter<With<Window>>> query)
{
foreach (var item in query)
{
if (Raylib.IsWindowReady())
{
item.Deconstruct(out var rectangle);
if (previous.Value != rectangle.Ref)
{
previous.Value = rectangle.Ref;
Raylib.SetWindowPosition(rectangle.Ref.X, rectangle.Ref.Y);
Raylib.SetWindowSize((int)rectangle.Ref.Width, (int)rectangle.Ref.Height);
}
var raylibRectangle = new Rectangle((int)Raylib.GetWindowPosition().X, (int)Raylib.GetWindowPosition().Y, (uint)Raylib.GetScreenWidth(), (uint)Raylib.GetScreenHeight());
if (previous.Value != raylibRectangle)
{
previous.Value = raylibRectangle;
rectangle.Ref = raylibRectangle;
}
}
}
}
But I have a empty Minimized, Maximized, and Fullscreen empty readonly record struct which I want to use for syncing state...
public readonly record struct Fullscreen();
public readonly record struct Maximized();
public readonly record struct Minimized();
I want to do something when these are added and removed from a entity if it has a window tag. How do I do this?
Your State example in your readme is outdated.