keep.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package gg
  2. /*func (e *engine) Resolve() {
  3. eng := (*Engine)(e)
  4. type resHold struct{
  5. Resolver Resolver
  6. input chan *Context
  7. }
  8. colliders := map[CollisionType] []Collider{}
  9. resolvers := []resHold{}
  10. for _, object := range e.Objects.store {
  11. if object.IsResolvable() {
  12. interests := object.GetCollisionInterest()
  13. for _, interest := range interests {
  14. _, ok := colliders[interest]
  15. if !ok {
  16. colliders[interest] = []Collider{}
  17. }
  18. }
  19. resolvers = append(resolvers, resHold{
  20. object,
  21. object.Input(),
  22. })
  23. }
  24. }
  25. for _, object := range e.Objects.store {
  26. if object.IsCollidable() {
  27. typ := object.CollisionType()
  28. _, ok := colliders[typ]
  29. if !ok {
  30. continue
  31. }
  32. colliders[typ] = append(colliders[typ], object)
  33. }
  34. }
  35. for _, resolver := range resolvers {
  36. interests := resolver.Resolver.GetCollisionInterest()
  37. cols := []Collision{}
  38. for _, interest := range interests {
  39. cols = append(cols, GetCollisions(resolver.Resolver, colliders[interest])...)
  40. }
  41. if len(cols) > 0 {
  42. c := &Context{
  43. typ: resolveContext,
  44. Collisions: cols,
  45. Engine: eng,
  46. }
  47. e.wg.Add(1)
  48. resolver.input <- c
  49. }
  50. }
  51. e.wg.Wait()
  52. }*/