-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Identifier interface, targeted at BasicEntity #23
Comments
yarbelk
added a commit
to yarbelk/ecs
that referenced
this issue
Jun 26, 2016
Merged
I also think it would be good to implement some of the standard library interfaces on top of this (like sort.Interface). Which I added. Sometimes you want to deal with the O=n log n lookups of a sorted slice rather than the muxer needed for a map, or a plain loop over all elements |
paked
pushed a commit
that referenced
this issue
Jun 26, 2016
* Add Identifier interface [Fixes #23] * Implement sort.Interface on IdentifierSlice - so you can use it for collections if you need too.
otraore
pushed a commit
that referenced
this issue
Jul 7, 2016
* ecs: Update documentation and fix golint issues. u@x1 ~/g/s/e/ecs> golint . entity.go:11:2: don't use underscores in Go names; var id_incr should be idIncr entity_test.go:53:1: receiver name sys should be consistent with previous receiver name m for MySystemOneTwo * ecs: Update Add example for Systems. * Use atomic operations in NewBasic, remove overflow check and add benchmarks. (#22) Fixes #21. u@x1 ~/g/s/e/ecs> benchcmp old.txt new.txt benchmark old ns/op new ns/op delta BenchmarkNewBasic-4 27.3 10.4 -61.90% Also add benchmarks to find the breakpoint where it starts to make sense to allocate several basic entities. On this machine, using NewEntities is faster even for 10 entities as it only uses a single lock as compared to 10 atomic operations. BenchmarkNewBasic-4 100000000 10.5 ns/op BenchmarkNewBasics1-4 30000000 42.8 ns/op BenchmarkNewBasic10-4 20000000 105 ns/op BenchmarkNewBasics10-4 20000000 70.3 ns/op BenchmarkNewBasic100-4 1000000 1046 ns/op BenchmarkNewBasics100-4 3000000 433 ns/op BenchmarkNewBasic1000-4 200000 10418 ns/op BenchmarkNewBasics1000-4 300000 3907 ns/op * Add Identifier interface (#24) * Add Identifier interface [Fixes #23] * Implement sort.Interface on IdentifierSlice - so you can use it for collections if you need too. * Documentation (#18)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I want to be able to easily look up an entity by its ID, I would need to easily store purely based on ID; one solution to this is:
The benefit of this is I can register something in one system, and the dynamically
check to see if whatever that entity was implements a specific interface at run time.
this means I don't need to store as many 'half implemented' subsets of the entities, and
i will have less duplicated code. The only thing I need to store in the system itself
would be the ID, and the information specific to the system.
The text was updated successfully, but these errors were encountered: