Files
traffic-simulator/src/common/structures.zig

31 lines
1.4 KiB
Zig

const Vector2 = @import("raylib").Vector2;
const Road = @import("../infrastructure/road.zig").Road;
const Node = @import("../infrastructure/node.zig").Node;
/// This is a simple equivalent to something like abstract class, so the simulator class has only one variable
/// which tracks which object is highlighted and the logic that seeks to find the current highlighted class doesn't need
/// to figure out which highlighted entity has priority in case of overlap;
/// given that car can be on node and road, and node itself is on road(s)
///
/// TLDR: Can point to either entity type (node, road, etc.)
pub const Entity = union(enum) {
node: *Node,
road: *Road,
};
/// Represents intersection data, mainly used in cases where we draw over existing roads
/// and wish to see data about such intersections or collisions
pub const IntersectionData = struct {
/// Tracks the location of the intersection
pos: Vector2,
/// Points to the road where the intersection occured
road: *Road,
/// Tracks whether this intersection is actually an origin point
/// (In simple terms this means whether the point/node that intersects is also the start/end node)
///
/// We do this because the referencing logic is very strict and will return an error
/// if we try to reference something that is already referenced, due to stricter approach helping with
/// earlier bug and error detection
origin: bool,
};