module: rename query -> queryDeprecated

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-05-06 14:17:20 -07:00 committed by Stephen Gutekanst
parent 26b2351d4b
commit 2e8926d6fa
16 changed files with 33 additions and 33 deletions

View file

@ -155,7 +155,7 @@ fn tick(
// Query all the entities that have the .follower tag indicating they should follow the player. // Query all the entities that have the .follower tag indicating they should follow the player.
// TODO(important): better querying API // TODO(important): better querying API
var archetypes_iter = core.entities.query(.{ .all = &.{ var archetypes_iter = core.entities.queryDeprecated(.{ .all = &.{
.{ .app = &.{.follower} }, .{ .app = &.{.follower} },
} }); } });
while (archetypes_iter.next()) |archetype| { while (archetypes_iter.next()) |archetype| {
@ -169,7 +169,7 @@ fn tick(
const close_dist = 1.0 / 15.0; const close_dist = 1.0 / 15.0;
var avoidance = Vec3.splat(0); var avoidance = Vec3.splat(0);
var avoidance_div: f32 = 1.0; var avoidance_div: f32 = 1.0;
var archetypes_iter_2 = core.entities.query(.{ .all = &.{ var archetypes_iter_2 = core.entities.queryDeprecated(.{ .all = &.{
.{ .app = &.{.follower} }, .{ .app = &.{.follower} },
} }); } });
while (archetypes_iter_2.next()) |archetype_2| { while (archetypes_iter_2.next()) |archetype_2| {

View file

@ -138,7 +138,7 @@ fn renderFrame(
defer encoder.release(); defer encoder.release();
// Update uniform buffer // Update uniform buffer
var archetypes_iter = core.entities.query(.{ .all = &.{ var archetypes_iter = core.entities.queryDeprecated(.{ .all = &.{
.{ .renderer = &.{ .position, .scale } }, .{ .renderer = &.{ .position, .scale } },
} }); } });
var num_entities: usize = 0; var num_entities: usize = 0;

View file

@ -163,7 +163,7 @@ fn tick(
const delta_time = game.state().timer.lap(); const delta_time = game.state().timer.lap();
// Animate entities // Animate entities
var archetypes_iter = core.entities.query(.{ .all = &.{ var archetypes_iter = core.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite = &.{.transform} }, .{ .mach_gfx_sprite = &.{.transform} },
} }); } });
while (archetypes_iter.next()) |archetype| { while (archetypes_iter.next()) |archetype| {

View file

@ -69,7 +69,7 @@ fn audioStateChange(
app: *Mod, app: *Mod,
) !void { ) !void {
// Find audio entities that are no longer playing // Find audio entities that are no longer playing
var archetypes_iter = audio.entities.query(.{ .all = &.{ var archetypes_iter = audio.entities.queryDeprecated(.{ .all = &.{
.{ .mach_audio = &.{.playing} }, .{ .mach_audio = &.{.playing} },
} }); } });
while (archetypes_iter.next()) |archetype| { while (archetypes_iter.next()) |archetype| {

View file

@ -79,7 +79,7 @@ fn audioStateChange(
app: *Mod, app: *Mod,
) !void { ) !void {
// Find audio entities that are no longer playing // Find audio entities that are no longer playing
var archetypes_iter = audio.entities.query(.{ .all = &.{.{ .mach_audio = &.{.playing} }} }); var archetypes_iter = audio.entities.queryDeprecated(.{ .all = &.{.{ .mach_audio = &.{.playing} }} });
while (archetypes_iter.next()) |archetype| { while (archetypes_iter.next()) |archetype| {
for ( for (
archetype.slice(.entity, .id), archetype.slice(.entity, .id),

View file

@ -156,7 +156,7 @@ fn tick(
const delta_time = game.state().timer.lap(); const delta_time = game.state().timer.lap();
// Rotate entities // Rotate entities
var archetypes_iter = core.entities.query(.{ .all = &.{ var archetypes_iter = core.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite = &.{.transform} }, .{ .mach_gfx_sprite = &.{.transform} },
} }); } });
while (archetypes_iter.next()) |archetype| { while (archetypes_iter.next()) |archetype| {

View file

@ -199,7 +199,7 @@ fn tick(
const delta_time = game.state().timer.lap(); const delta_time = game.state().timer.lap();
// Rotate entities // Rotate entities
var archetypes_iter = core.entities.query(.{ .all = &.{ var archetypes_iter = core.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text = &.{.transform} }, .{ .mach_gfx_text = &.{.transform} },
} }); } });
while (archetypes_iter.next()) |archetype| { while (archetypes_iter.next()) |archetype| {
@ -283,7 +283,7 @@ fn endFrame(game: *Mod, text: *gfx.Text.Mod, core: *mach.Core.Mod) !void {
// Gather some text rendering stats // Gather some text rendering stats
var num_texts: u32 = 0; var num_texts: u32 = 0;
var num_glyphs: usize = 0; var num_glyphs: usize = 0;
var archetypes_iter = text.entities.query(.{ .all = &.{ var archetypes_iter = text.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text = &.{ .{ .mach_gfx_text = &.{
.built, .built,
} }, } },

View file

@ -134,7 +134,7 @@ fn audioTick(audio: *Mod) !void {
@memset(mixing_buffer.items, 0); @memset(mixing_buffer.items, 0);
var did_state_change = false; var did_state_change = false;
var archetypes_iter = audio.entities.query(.{ .all = &.{ var archetypes_iter = audio.entities.queryDeprecated(.{ .all = &.{
.{ .mach_audio = &.{ .samples, .channels, .playing, .index } }, .{ .mach_audio = &.{ .samples, .channels, .playing, .index } },
} }); } });
while (archetypes_iter.next()) |archetype| { while (archetypes_iter.next()) |archetype| {

View file

@ -132,7 +132,7 @@ fn init(core: *Mod) !void {
} }
fn update(core: *Mod) !void { fn update(core: *Mod) !void {
var archetypes_iter = core.entities.query(.{ .all = &.{ var archetypes_iter = core.entities.queryDeprecated(.{ .all = &.{
.{ .mach_core = &.{ .{ .mach_core = &.{
.title, .title,
} }, } },
@ -173,7 +173,7 @@ fn deinit(core: *Mod) void {
core.state().queue.release(); core.state().queue.release();
mach.core.deinit(); mach.core.deinit();
var archetypes_iter = core.entities.query(.{ .all = &.{ var archetypes_iter = core.entities.queryDeprecated(.{ .all = &.{
.{ .mach_core = &.{ .{ .mach_core = &.{
.title, .title,
} }, } },

View file

@ -43,7 +43,7 @@ pub const events = .{
}; };
fn update(core: *mach.Core.Mod, sprite: *Mod, sprite_pipeline: *gfx.SpritePipeline.Mod) !void { fn update(core: *mach.Core.Mod, sprite: *Mod, sprite_pipeline: *gfx.SpritePipeline.Mod) !void {
var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = sprite_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite_pipeline = &.{ .{ .mach_gfx_sprite_pipeline = &.{
.built, .built,
} }, } },
@ -69,7 +69,7 @@ fn updatePipeline(
const encoder = device.createCommandEncoder(&.{ .label = label }); const encoder = device.createCommandEncoder(&.{ .label = label });
defer encoder.release(); defer encoder.release();
var archetypes_iter = sprite.entities.query(.{ .all = &.{ var archetypes_iter = sprite.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite = &.{ .{ .mach_gfx_sprite = &.{
.uv_transform, .uv_transform,
.transform, .transform,

View file

@ -124,7 +124,7 @@ fn init(sprite_pipeline: *Mod) void {
} }
fn deinit(sprite_pipeline: *Mod) void { fn deinit(sprite_pipeline: *Mod) void {
var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = sprite_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite_pipeline = &.{ .{ .mach_gfx_sprite_pipeline = &.{
.built, .built,
} }, } },
@ -138,7 +138,7 @@ fn update(core: *mach.Core.Mod, sprite_pipeline: *Mod) !void {
// Destroy all sprite render pipelines. We will rebuild them all. // Destroy all sprite render pipelines. We will rebuild them all.
deinit(sprite_pipeline); deinit(sprite_pipeline);
var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = sprite_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite_pipeline = &.{ .{ .mach_gfx_sprite_pipeline = &.{
.texture, .texture,
} }, } },
@ -324,7 +324,7 @@ fn preRender(sprite_pipeline: *Mod, core: *mach.Core.Mod) void {
const encoder = core.state().device.createCommandEncoder(&.{ .label = label }); const encoder = core.state().device.createCommandEncoder(&.{ .label = label });
defer encoder.release(); defer encoder.release();
var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = sprite_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite_pipeline = &.{ .{ .mach_gfx_sprite_pipeline = &.{
.built, .built,
} }, } },
@ -367,7 +367,7 @@ fn render(sprite_pipeline: *Mod) !void {
sprite_pipeline.state().render_pass = null; sprite_pipeline.state().render_pass = null;
// TODO(sprite): need a way to specify order of rendering with multiple pipelines // TODO(sprite): need a way to specify order of rendering with multiple pipelines
var archetypes_iter = sprite_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = sprite_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_sprite_pipeline = &.{ .{ .mach_gfx_sprite_pipeline = &.{
.built, .built,
} }, } },

View file

@ -59,7 +59,7 @@ const BuiltText = struct {
}; };
fn update(core: *mach.Core.Mod, text: *Mod, text_pipeline: *gfx.TextPipeline.Mod) !void { fn update(core: *mach.Core.Mod, text: *Mod, text_pipeline: *gfx.TextPipeline.Mod) !void {
var archetypes_iter = text_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = text_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text_pipeline = &.{ .{ .mach_gfx_text_pipeline = &.{
.built, .built,
} }, } },
@ -97,7 +97,7 @@ fn updatePipeline(
var texture_update = false; var texture_update = false;
var num_texts: u32 = 0; var num_texts: u32 = 0;
var removes = try std.ArrayListUnmanaged(mach.EntityID).initCapacity(allocator, 8); var removes = try std.ArrayListUnmanaged(mach.EntityID).initCapacity(allocator, 8);
var archetypes_iter = text.entities.query(.{ .all = &.{ var archetypes_iter = text.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text = &.{ .{ .mach_gfx_text = &.{
.transform, .transform,
.text, .text,

View file

@ -145,7 +145,7 @@ pub const BuiltPipeline = struct {
}; };
fn deinit(text_pipeline: *Mod) void { fn deinit(text_pipeline: *Mod) void {
var archetypes_iter = text_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = text_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text_pipeline = &.{ .{ .mach_gfx_text_pipeline = &.{
.built, .built,
} }, } },
@ -163,7 +163,7 @@ fn update(core: *mach.Core.Mod, text_pipeline: *Mod) !void {
// Destroy all text render pipelines. We will rebuild them all. // Destroy all text render pipelines. We will rebuild them all.
deinit(text_pipeline); deinit(text_pipeline);
var archetypes_iter = text_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = text_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text_pipeline = &.{ .{ .mach_gfx_text_pipeline = &.{
.is_pipeline, .is_pipeline,
} }, } },
@ -353,7 +353,7 @@ fn preRender(text_pipeline: *Mod, core: *mach.Core.Mod) void {
const encoder = core.state().device.createCommandEncoder(&.{ .label = label }); const encoder = core.state().device.createCommandEncoder(&.{ .label = label });
defer encoder.release(); defer encoder.release();
var archetypes_iter = text_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = text_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text_pipeline = &.{ .{ .mach_gfx_text_pipeline = &.{
.built, .built,
} }, } },
@ -396,7 +396,7 @@ fn render(text_pipeline: *Mod) !void {
text_pipeline.state().render_pass = null; text_pipeline.state().render_pass = null;
// TODO(text): need a way to specify order of rendering with multiple pipelines // TODO(text): need a way to specify order of rendering with multiple pipelines
var archetypes_iter = text_pipeline.entities.query(.{ .all = &.{ var archetypes_iter = text_pipeline.entities.queryDeprecated(.{ .all = &.{
.{ .mach_gfx_text_pipeline = &.{ .{ .mach_gfx_text_pipeline = &.{
.built, .built,
} }, } },

View file

@ -114,7 +114,7 @@ pub fn Entities(comptime modules: anytype) type {
}; };
/// A complex query for entities matching a given criteria /// A complex query for entities matching a given criteria
pub const Query = query_mod.Query(modules); pub const QueryDeprecated = query_mod.QueryDeprecated(modules);
pub const QueryTag = query_mod.QueryTag; pub const QueryTag = query_mod.QueryTag;
pub fn init(allocator: Allocator) !Self { pub fn init(allocator: Allocator) !Self {
@ -628,9 +628,9 @@ pub fn Entities(comptime modules: anytype) type {
} }
// Queries for archetypes matching the given query. // Queries for archetypes matching the given query.
pub fn query( pub fn queryDeprecated(
entities: *Self, entities: *Self,
q: Query, q: QueryDeprecated,
) ArchetypeIterator(modules) { ) ArchetypeIterator(modules) {
return ArchetypeIterator(modules).init(entities, q); return ArchetypeIterator(modules).init(entities, q);
} }
@ -721,12 +721,12 @@ pub fn ArchetypeIterator(comptime modules: anytype) type {
const EntitiesT = Entities(modules); const EntitiesT = Entities(modules);
return struct { return struct {
entities: *EntitiesT, entities: *EntitiesT,
query: EntitiesT.Query, query: EntitiesT.QueryDeprecated,
index: usize, index: usize,
const Self = @This(); const Self = @This();
pub fn init(entities: *EntitiesT, query: EntitiesT.Query) Self { pub fn init(entities: *EntitiesT, query: EntitiesT.QueryDeprecated) Self {
return Self{ return Self{
.entities = entities, .entities = entities,
.query = query, .query = query,
@ -921,7 +921,7 @@ test "example" {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Query for archetypes that have all of the given components // Query for archetypes that have all of the given components
var iter = world.query(.{ .all = &.{ var iter = world.queryDeprecated(.{ .all = &.{
.{ .game = &.{.rotation} }, .{ .game = &.{.rotation} },
} }); } });
while (iter.next()) |archetype| { while (iter.next()) |archetype| {

View file

@ -96,7 +96,7 @@ test "entities DB" {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Querying // Querying
var iter = world.entities.query(.{ .all = &.{ var iter = world.entities.queryDeprecated(.{ .all = &.{
.{ .physics = &.{.id} }, .{ .physics = &.{.id} },
} }); } });

View file

@ -10,7 +10,7 @@ pub const QueryTag = enum {
}; };
/// A complex query for entities matching a given criteria /// A complex query for entities matching a given criteria
pub fn Query(comptime modules: anytype) type { pub fn QueryDeprecated(comptime modules: anytype) type {
const component_types_by_name = ComponentTypesByName(modules){}; const component_types_by_name = ComponentTypesByName(modules){};
return union(QueryTag) { return union(QueryTag) {
// TODO: cleanup comptime // TODO: cleanup comptime
@ -102,7 +102,7 @@ test "query" {
}, },
}); });
const Q = Query(modules); const Q = QueryDeprecated(modules);
// Namespace type lets us select a single namespace. // Namespace type lets us select a single namespace.
try testing.expectEqual(@as(Q.Namespace, .game), .game); try testing.expectEqual(@as(Q.Namespace, .game), .game);