我有 N 个数组结构:
PlayerTable: ids, velocities, positions, animations, healths ...
EnemyTable: ids, velocities, positions, animations, AIs ...
BulletTables: ids, velocities, positions, animations, ranges ...
... other N-3 soas
我有 M 程序来更新这些数组结构:
applyVelocities: [read] velocities, [write] positions
updateAnimations: [write] animations
drawEntities: [read] animations, [read] positions
... other M-3 procedures
是否有一种设计模式可以迭代 SoA 集合中所有相同类型的数组?
我可以考虑编写一个模板函数并为具有这些属性的每个数组结构调用它。是这样吗?这通常可以很好地扩展吗?