Hello, I’ve been running into a problem using Entities.ForEach(). I can pass refs all day, but as soon as I start mixing that with the ‘in’ keyword, I get errors. After reading the documentation, it looks like I should be able to mix them as long as I respect the order that they recommend (value, ref, in). I’m able to mix value and ref, just not ‘in’. I’m also not exceeding the 8 parameter limit. I honestly don’t understand what I’m doing wrong.
I don’t know if I’m being clear enough, so let me know if more info is needed. Thanks in advance.
Do you have a code example that is giving you an error?
Here is a code sample of one of my routines.
Entities.WithAll<Channel, Electricity>().WithNone<Connected>().ForEach((Entity entity, ref OmniDirectional connections,in GridCoordinates discoCoords) =>
{
bool adjacentConnection = false;
var adjTiles = GetAdjacentCoordinates(discoCoords.value);
Entities.WithAll<Channel, Electricity>().ForEach((Entity unconnected, ref GridCoordinates otherCoords) =>
{
adjacentConnection = CheckIfAdjacent(adjTiles, otherCoords.value);
if (adjacentConnection)
{
EntityManager.AddComponent<Connected>(unconnected);
return;
}
});
});
Doesn’t look like you’re using SystemBase, instead ComponentSystem or JobComponentSystem
Woah! I didn’t know there was a difference. But I am using ComponentSystem.
Yes, [Job]ComponentSystem are pretty much legacy/deprecated. Should be using SystemBase now.
Wow, that was totally it. I was working from memory a bit and thought that ComponentSystem was the way to go. ComponentBase sounds like something too low level. But awesome, thanks a bunch, was ready to slam my head into the wall. You saved my forehead.