Filter System and then Add Component to Entity? #95
Unanswered
Shadowblitz16
asked this question in
Q&A
Replies: 1 comment 3 replies
-
The above error can be fixed by changing .Add to .Set. // The type 'SpaceTest.Engine.Systems.WindowModule.WindowHandle' must be convertible to 'System.Enum' in order to use it as parameter 'T' in the generic method 'ref Entity Flecs.NET.Core.Entity.Add<T>(T)'
entity.Add(new WindowHandle(silkWindow, silkWindow.CreateOpenGL(), silkWindow.CreateInput())); The position and size references provided by the observer are not valid after the observer callback finishes. Your .Move and .Resize callbacks will be attempting to reference invalid objects when the events are signaled. silkWindow.Move += (v) => {
// Cannot use ref parameter inside lambda expression.
position = new Position(v.X, v.Y);
};
silkWindow.Resize += (v) => {
// Cannot use ref parameter inside lambda expression.
size = new Size((uint)v.X, (uint)v.Y);
}; In my opinion, I think a better idea would be to update the window position and size every frame using a system. System<WindowHandle, Size, Position> system = world.System<WindowHandle, Size, Position>()
.Each((ref WindowHandle handle, ref Size size, ref Position position) =>
{
size = new Size(handle.SilkWindow.Size.X, handle.SilkWindow.Size.Y);
position = new Size(handle.SilkWindow.Position.X, handle.SilkWindow.Position.Y);
}); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How would I do something like this?
Beta Was this translation helpful? Give feedback.
All reactions