This commit is contained in:
Jeeves 2025-02-11 13:07:08 -07:00
parent 01107aece5
commit 84965904b3

View file

@ -78,7 +78,6 @@ pub const Component = struct {
x: u16 = 0, x: u16 = 0,
y: u16 = 0, y: u16 = 0,
state: *anyopaque,
processFn: *const fn (*Component) void, processFn: *const fn (*Component) void,
}; };
@ -89,13 +88,23 @@ pub const Circuit = struct {
}; };
pub const Battery = struct { pub const Battery = struct {
pub fn process(component: *Component) Signal {} component: Component = .{ .processFn = process },
value: f32,
pub fn process(component: *Component, inputs: []*Signal) []Signal {
_ = inputs;
const self: *Battery = @fieldParentPtr("component", component);
return &[_]Signal{.{
.digital = std.math.sign(self.value),
.analog = self.value,
}};
}
}; };
pub const Signal = struct { pub const Signal = struct {
digital: i2, digital: i2 = 0,
analog: f32, analog: f32 = 0.0,
color: u24, color: u24 = 0,
}; };
// pub const Wire = struct { // pub const Wire = struct {