-
Documentation contains the following examples: world.Query(in query, (Entity entity) => {});
world.Query(in query, (Entity en, ref T1 t1.) => {}); But using entity like this gives me different errors: world.Query(
in query,
(Entity entity) => {} // Cannot convert lambda expression to type 'ForEach' because the parameter types do not match the delegate parameter types
); world.Query(
in query,
(Entity en, ref T1 t1) => {} // Delegate 'ForEach' does not take 2 arguments
); What's the deal here? Any ideas why it seems to act differently for me? Using world.Query(in query, (ref Entity entity) => {
button.Clicked += () => {
Ui.Open(entity); // Cannot use ref, out, or in parameter 'entity' inside an anonymous method, lambda expression, query expression, or local function
};
}); |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It might help to see your query for |
Beta Was this translation helpful? Give feedback.
-
Not sure, I've encountered the error before while tinkereing, but I think it had to do with some implementation error elsewhere in my files. Try comparing your code to this version from the readme that I modified to query on Entity. using Arch.Core;
// Components ( ignore the formatting, this saves space )
public struct Position { public float X, Y; };
public struct Velocity { public float Dx, Dy; };
public sealed class Game
{
public static void Main(string[] args)
{
// Create a world and entities with position and velocity.
var world = World.Create();
for (var index = 0; index < 1000; index++)
world.Create(new Position { X = 0, Y = 0 }, new Velocity { Dx = 1, Dy = 1 });
// Query and modify entities ( There are also alternatives without lambdas ;) )
var query = new QueryDescription().WithAll<Position, Velocity>(); // Targets entities with Position AND Velocity.
world.Query(in query, (Entity en) =>
{
//pos.X += vel.Dx;
//pos.Y += vel.Dy;
});
}
} |
Beta Was this translation helpful? Give feedback.
-
@metaphist Thank you for stopping and trying to help - the cause was actually in the version. |
Beta Was this translation helpful? Give feedback.
@metaphist Thank you for stopping and trying to help - the cause was actually in the version.
So a tip to all future readers - if something is wrong, first try to update to latest version!