On Fri, 26 Aug 2016 23:59:05 +0000, Lurker wrote: > On Friday, 26 August 2016 at 19:55:30 UTC, vladdeSV wrote: >> What I can conclude so far is my approach uses a lot of processing >> power. I did a test where I generated 10000 entities and it drained my >> CPU to 50%. >> >> All feedback is appreciated. Thank you for your input :) > > hasComponent()/getComponent() should be O(1) and preferrably CTFEable. > > You could turn Entity into a template, or store a bitmask of applied > Components etc.
Which requires specifying in advance every component the system contains. Part of the reason for using a loose component architecture like this is making it trivial to add features that require additional data. I suppose you could do this with runtime reflection -- iterate through all modules, then all classes in those modules, check each to see if it's convertible to Component, then generate the bitfield. Awkward.
