Implemented Entity tagged union for highlighted entity (similar to abstract class in some ways)

This commit is contained in:
2026-04-29 21:45:56 +02:00
parent 7348861145
commit e75fc6dbe9
8 changed files with 77 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const rl = @import("raylib");
const c = @import("../constants.zig");
const c = @import("../common/constants.zig");
const e = @import("../errors.zig");
const Road = @import("road.zig").Road;
@@ -39,11 +39,16 @@ pub const Node = struct {
rl.drawCircleV(self.pos, c.NODE_RADIUS, colour);
}
/// Identifies whether the pos (location) is within the snapping radius of the node
pub fn posWithinRadius(self: *const Node, pos: rl.Vector2) bool {
/// Determines whether the pos (location) is within the snapping radius of the node
pub fn withinSnapRadius(self: *const Node, pos: rl.Vector2) bool {
return rl.checkCollisionPointCircle(pos, self.pos, c.NODE_SNAP_RADIUS);
}
/// Determines whether the pos (location) is within the strict (visual representation) radius of the node
pub fn withinRadius(self: *const Node, pos: rl.Vector2) bool {
return rl.checkCollisionPointCircle(pos, self.pos, c.NODE_RADIUS);
}
/// Tries to reference the passed road to self
///
/// Returns an error if the passed road cannot be appended to the list or if said road is already in the list