Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bucket: Map<Bits, IntArray> = ...
- fun getEntities(aspect: Aspect): IntArray {
- var result = HashMap<Bits, IntArray>()
- // 1st pass, "allOf"
- if (aspect.required == Bits.ZERO) {
- result.addAll(bucket)
- } else {
- bucket.forEach { (bits, entities) ->
- if (bits AND aspect.required == aspect.required) {
- result.add(bits, entities)
- }
- }
- }
- // 2nd pass, "anyOf"
- if (aspect.optional != Bits.ZERO) {
- result = result.filter { (bits, entities) ->
- bits AND aspect.optional != Bits.ZERO
- }.toMap()
- }
- // 3rd pass, "excluding"
- if (aspect.excluded != Bits.ZERO) {
- result = result.filter { (bits, entities) ->
- bits AND aspect.excluded == Bits.ZERO
- }
- }
- return result.values().reduce {base, next -> ...}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement