-
My implementation seems like I'm really close, but not quite there and may be something I just don't know how to do. Essentially, I have components that all inherit from an interface and I'd like to generate query descriptions based on a list of types.
When I try to do this, I get the following error:
My guess is that it has to do with the way I'm passing Something like this would make it very easy for me to automatically have new spell components processed correctly, for example if I added Spell4, Spell5, and Spell6 in addition to the existing Spell1, Spell2, and Spell3. Same thing would apply with components I use for effects like Burn, Shock, and Slow. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Is this commited already? If so i would check it out real quick ^^ I assume that theres a conversion error somewhere. What type is the array ComponentTypes? My assumption, it is : "Type[]" which is then being passed into the get? If so thats not valid and would produce such an error ^^ |
Beta Was this translation helpful? Give feedback.
-
Can you take a look at the "entity.Get()" method? Ts signature? Sometimes it happens that e.g. the generic methods are favored which is not what we want in this case ^^ The highlighting also occurs once an error inside that method is called, since most code gets inlined :) Would be great if you could check it in on an other branch, that way i could debug it... If its an bug :) |
Beta Was this translation helpful? Give feedback.
-
Sooo i found the issue. Its not a bug, it was an logic mistake ^^ First of all, your Second, the Use this instead for your spellQueries : var spellQuery = new QueryDescription
{
All = new[] { Component.GetComponentType(spellType), typeof(Position) }
}; So make sure the spellQueries are filling correctly and its fine ^^ |
Beta Was this translation helpful? Give feedback.
Sooo i found the issue. Its not a bug, it was an logic mistake ^^
First of all, your
spellQueries
are... empty. No all, any or none set. I assume that your code to fill the doesn't work properly.Thus each SpellQuery targets ALL entities.
Second, the
world.Query
trys to accessref Position position
. Since the query targets ALL entities, it tries to receive the position from ALL of them (also entities without it) which throws that exception.Use this instead for your spellQueries :
So make sure the spellQuerie…