39 lines
1.3 KiB
Zig
39 lines
1.3 KiB
Zig
const std = @import("std");
|
|
const rl = @import("raylib");
|
|
const spawn_area = @import("spawn-area.zig");
|
|
const structures = @import("structures.zig");
|
|
|
|
const Areas = struct {
|
|
areas: []spawn_area.SpawnArea,
|
|
allocator: std.mem.Allocator,
|
|
|
|
pub fn init(allocator: std.mem.Allocator, size: usize) !Areas {
|
|
const values = std.enums.values(structures.AreaLocation);
|
|
if (size > values.len) size = values.len;
|
|
|
|
var used_areas = std.ArrayList(structures.AreaLocation).init(allocator);
|
|
defer used_areas.deinit();
|
|
|
|
// here we generate size random AreaLocation enums that aren't in used_areas
|
|
// the random generator will only generate AreaLocation enums that are not in
|
|
//
|
|
// todo implement function which will subtract values from used_areas (after RANDOM)
|
|
// based on this we will fill data with 0..size data and return the final value
|
|
|
|
const data = try allocator.alloc(structures.AreaLocation, size);
|
|
// todo data must be set before returned
|
|
return Areas{
|
|
.areas = data,
|
|
};
|
|
}
|
|
|
|
pub fn deinit(self: *Areas) void {
|
|
self.allocator.free(self.areas);
|
|
}
|
|
|
|
pub fn draw(areas: *Areas) void {
|
|
// todo implement draw
|
|
_ = areas;
|
|
}
|
|
};
|