-
-
Save barcharcraz/d6cd3fc46d44c141b529 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| iterator matchEntsComponents(scene: SceneId; typ1: typedesc; typ2: typedesc): tuple[a: ptr TComponent[typ1], b: ptr TComponent[typ2]] {.inline.} = | |
| var comps1 = components(scene, TComponent[typ1]) | |
| var comps2 = components(scene, TComponent[typ2]) | |
| for i1 in 0..comps1.high: | |
| for i2 in 0..comps2.high: | |
| if comps1[i1].id == comps2[i2].id: | |
| yield (addr comps1[i1], addr comps2[i2]) | |
| break | |
| iterator matchEntsComponents(scene: SceneId; typ1: typedesc; typ2: typedesc; typ3: typedesc): | |
| tuple[a: ptr TComponent[typ1]; b: ptr TComponent[typ2], c: ptr TComponent[typ3]] {.inline.} = | |
| var comps = components(scene, TComponent[typ3]) | |
| for a,b in matchEntsComponents(scene, typ1, typ2): | |
| for i in 0..comps.high: | |
| if comps[i].id == a.id: | |
| yield (a, b, addr comps[i]) | |
| iterator matchEnts*(scene: SceneId; typ1: typedesc; typ2: typedesc): tuple[a: ptr typ1, b: ptr typ2] {.inline.} = | |
| var comps1 = components(scene, TComponent[typ1]) | |
| var comps2 = components(scene, TComponnet[typ2]) | |
| for a,b in matchEntsComponents(scene, typ1, typ2): | |
| yield (addr a[].data, addr b[].data) | |
| iterator matchEnts*(scene: SceneId; typ1: typedesc; typ2: typedesc; typ3: typedesc): tuple[a: ptr typ1, b: ptr typ2, c: ptr typ3] {.inline.} = | |
| for a,b,c in matchEntsComponents(scene, typ1, typ2, typ3): | |
| yield( addr a[].data, addr b[].data, addr c[].data) | |
| proc matchEnt*(scene: SceneId; typ1: typedesc): EntityId = | |
| result = components(scene, TComponent[typ1])[0].id | |
| proc matchEnt*(scene: SceneId; typ1: typedesc; typ2: typedesc): EntityId = | |
| result = (-1).EntityId | |
| for elm in components(scene, TComponent[typ1]): | |
| for typ in components(scene, TComponent[typ2]): | |
| if typ.id == elm.id: | |
| return elm.id | |
| proc matchEnt*(scene: SceneId; typ1: typedesc; typ2: typedesc; typ3: typedesc): EntityId = | |
| result = (-1).EntityId | |
| for elm1 in components(scene, TComponent[typ1]): | |
| for elm2 in components(scene, TComponent[typ2]): | |
| if elm2.id == elm1.id: | |
| for elm3 in components(scene, TComponent[typ3]): | |
| if elm3.id == elm2.id: | |
| return elm1.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment