Further implementation plans

This commit is contained in:
2026-04-08 23:08:15 +02:00
parent 288cfd6b50
commit dc0d91997a
3 changed files with 22 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ const NodeManager = @import("infrastructure/node_manager.zig").NodeManager;
const RoadManager = @import("infrastructure/road_manager.zig").RoadManager;
const Node = @import("infrastructure/node.zig").Node;
const Road = @import("infrastructure/road.zig").Road;
pub const Simulator = struct {
allocator: std.mem.Allocator,
@@ -95,11 +96,17 @@ pub const Simulator = struct {
const temp = self.node_man.temp_node.?;
if (temp.id == node.id) return;
// todo remove
self.road_man.add(self.allocator, temp, node) catch |err| {
std.debug.panic("Error while attempting to add a road: {}\n", .{err});
};
// get intersections made
// todo plan out the implementation
// add both nodes to the intersection array
// first in front, second in last
// all of the road connections will not be added here but rather in the split_roads function as it will
// create road connection for each nodes that are to be connected via connection
const data = self.getIntersectingRoads(self.allocator, temp, node) catch |err| {
std.debug.panic("Failed to save intersection data: {}\n", .{err});
};
@@ -205,6 +212,18 @@ pub const Simulator = struct {
return sorted_intersections;
}
fn splitRoadsByPoints(self: *Simulator, intersections: []const st.IntersectionData) void {
_ = self; // autofix
// todo plan it out
if (intersections.len == 0) return;
for (0..intersections.len) |i| {
const intersection = intersections[i];
_ = intersection; // autofix
}
}
pub fn update(self: *Simulator) void {
const pos = rl.getMousePosition();