{module,ecs}: Mach ECS becomes the Mach' module system
This moves the bulk of the ECS code into `src/module`. It also makes types like `mach.ecs.EntityID` accessible at the top-level `mach.EntityID` instead. The motivation of this change is to make the Mach module system a first-class property of Mach. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
679a05faf4
commit
f578e1f5e2
15 changed files with 23 additions and 52 deletions
|
|
@ -1,6 +1,5 @@
|
|||
const std = @import("std");
|
||||
const mach = @import("mach");
|
||||
const ecs = mach.ecs;
|
||||
const core = mach.core;
|
||||
const math = mach.math;
|
||||
const Renderer = @import("Renderer.zig");
|
||||
|
|
@ -12,7 +11,7 @@ const Vec3 = math.Vec3;
|
|||
|
||||
// Global state for our game module.
|
||||
timer: mach.Timer,
|
||||
player: ecs.EntityID,
|
||||
player: mach.EntityID,
|
||||
direction: Vec2 = vec2(0, 0),
|
||||
spawning: bool = false,
|
||||
spawn_timer: mach.Timer,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ const std = @import("std");
|
|||
const mach = @import("mach");
|
||||
const core = mach.core;
|
||||
const gpu = mach.gpu;
|
||||
const ecs = mach.ecs;
|
||||
const Sprite = mach.gfx.Sprite;
|
||||
const math = mach.math;
|
||||
const vec2 = math.vec2;
|
||||
|
|
@ -16,7 +15,7 @@ const Mat4x4 = math.Mat4x4;
|
|||
const Text = @import("Text.zig");
|
||||
|
||||
timer: mach.Timer,
|
||||
player: mach.ecs.EntityID,
|
||||
player: mach.EntityID,
|
||||
direction: Vec2 = vec2(0, 0),
|
||||
spawning: bool = false,
|
||||
spawn_timer: mach.Timer,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// TODO(important): review all code in this file in-depth
|
||||
const mach = @import("mach");
|
||||
const gpu = mach.gpu;
|
||||
const ecs = mach.ecs;
|
||||
const ft = @import("freetype");
|
||||
const std = @import("std");
|
||||
const assets = @import("assets");
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ const assets = @import("assets");
|
|||
const mach = @import("mach");
|
||||
const core = mach.core;
|
||||
const gpu = mach.gpu;
|
||||
const ecs = mach.ecs;
|
||||
const Sprite = mach.gfx.Sprite;
|
||||
const math = mach.math;
|
||||
|
||||
|
|
@ -19,7 +18,7 @@ const Mat4x4 = math.Mat4x4;
|
|||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
|
||||
timer: mach.Timer,
|
||||
player: mach.ecs.EntityID,
|
||||
player: mach.EntityID,
|
||||
direction: Vec2 = vec2(0, 0),
|
||||
spawning: bool = false,
|
||||
spawn_timer: mach.Timer,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ const mach = @import("mach");
|
|||
const core = mach.core;
|
||||
const gfx = mach.gfx;
|
||||
const gpu = mach.gpu;
|
||||
const ecs = mach.ecs;
|
||||
const Text = mach.gfx.Text;
|
||||
const math = mach.math;
|
||||
|
||||
|
|
@ -21,7 +20,7 @@ const Mat4x4 = math.Mat4x4;
|
|||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
|
||||
timer: mach.Timer,
|
||||
player: mach.ecs.EntityID,
|
||||
player: mach.EntityID,
|
||||
direction: Vec2 = vec2(0, 0),
|
||||
spawning: bool = false,
|
||||
spawn_timer: mach.Timer,
|
||||
|
|
@ -30,7 +29,7 @@ frame_count: usize,
|
|||
texts: usize,
|
||||
rand: std.rand.DefaultPrng,
|
||||
time: f32,
|
||||
style1: mach.ecs.EntityID,
|
||||
style1: mach.EntityID,
|
||||
allocator: std.mem.Allocator,
|
||||
|
||||
const d0 = 0.000001;
|
||||
|
|
@ -106,7 +105,7 @@ fn init(
|
|||
// TODO: better storage mechanism for this
|
||||
// TODO: this is a leak
|
||||
const allocator = gpa.allocator();
|
||||
const styles = try allocator.alloc(mach.ecs.EntityID, 3);
|
||||
const styles = try allocator.alloc(mach.EntityID, 3);
|
||||
styles[0] = style1;
|
||||
styles[1] = style2;
|
||||
styles[2] = style3;
|
||||
|
|
@ -189,7 +188,7 @@ fn tick(
|
|||
|
||||
// TODO: better storage mechanism for this
|
||||
// TODO: this is a leak
|
||||
const styles = try game.state().allocator.alloc(mach.ecs.EntityID, 1);
|
||||
const styles = try game.state().allocator.alloc(mach.EntityID, 1);
|
||||
styles[0] = game.state().style1;
|
||||
try text_mod.set(new_entity, .text, text2);
|
||||
try text_mod.set(new_entity, .style, styles);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue