[metadata]
name=bar-game
description=Bar simulation for MadLads Brewing
-url=
author=Brendan Hansen
version=0.0.1
[config]
lib_source_directory=./lib
lib_bin_directory=./run_tree/lib
-run_cmd=
-debug_cmd=
-test_cmd=
[native_library]
-build_cmd=
-library=
[dependencies]
git://onyxlang.io/repo/openal=0.0.3
-git://onyxlang.io/repo/ogre=0.0.19
+git://onyxlang.io/repo/ogre=0.0.20
[dependency_folders]
git://onyxlang.io/repo/openal=openal
check) shift; onyx check -V -I ../src build $@ ;;
run) onyx run $dest ;;
debug) shift; onyx run -V -I ../src build --debug $@ ;;
- *) onyx run -V -I ../src build $@ ;;
+ watch) shift; onyx watch -I ../src build -o $dest $@ ;;
+ *) onyx run -V ../src/build $@ ;;
esac
}
if !mask[ty * width + tx] || target_pos == .{tx, ty} {
- if array.contains(stack, #(it.pos == .{tx, ty})) do continue;
+ if slice.contains(stack, [s](s.pos == .{tx, ty})) do continue;
g := cast(f32) (math.abs(dx) + math.abs(dy)) + top.g;
h := cast(f32) (math.abs(tx - target_pos.x) + math.abs(ty - target_pos.y)) / 2;
}
}
- array.sort(stack, (n1, n2) => {
+ slice.sort(stack, (n1, n2) => {
if n1.f < n2.f do return 1;
if n2.f < n1.f do return -1;
return 0;
~~(path_pos.x * grid_size),
~~(path_pos.y * grid_size),
};
- path_pos = visited[path_pos].prev;
+ path_pos = visited[path_pos]->unwrap().prev;
}
- array.reverse(*buf);
+ slice.reverse(*buf);
}
return found;
w := sidebar_width / 2;
h := 200.0f;
x := ~~ window.width - sidebar_width;
- render := render_field_editor;
-
- if custom_editors[it.type] != null_proc {
- render = custom_editors[it.type];
- }
+ render := custom_editors[it.type] ?? render_field_editor;
for it.tags {
if it.type == Editor_Custom_Field {
}
item_store_get_item :: (use this: ^Item_Store, id: str) -> ^Item {
- return items[id];
+ return items[id]?;
}
@Entity_Schematic.{"Item_Entity"}
has :: (use this: ^Entity, component_type: type_expr) => components->has(component_type);
- get :: (use this: ^Entity, $component_type: type_expr) => cast(^component_type) components[component_type];
+ get :: (use this: ^Entity, $component_type: type_expr) => cast(^component_type) components[component_type]->unwrap();
add :: (use this: ^Entity, component: ^Component) => {
if components->has(component.type) do return;
}
scene_create_from_schematic :: (use this: ^Scene, schematic_name: str) -> ^Entity {
- schematic := schematics[schematic_name];
+ schematic := schematics[schematic_name] ?? null;
if schematic == null do return null;
entity := schematic.create(this);
component_vtables[comp.type] = vtable;
}
- comp.vtable = component_vtables[comp.type];
+ comp.vtable = component_vtables[comp.type] ?? null;
if comp.init != null_proc {
comp->init();
}
//
// This is a rather expensive check.
// It could probably be done solely when entities are added/removed.
- array.sort(entities, (e1, e2) => {
+ slice.sort(entities, (e1, e2) => {
e1_comp := e1->get(RenderComponent);
e2_comp := e2->get(RenderComponent);
}
}
-scene_get :: (use this: ^Scene, id: Entity_ID) => entity_map[id];
+scene_get :: (use this: ^Scene, id: Entity_ID) => entity_map[id] ?? null;
scene_delete :: (use this: ^Scene, ent: ^Entity, delete_from_array := true) {
map.delete(^entity_map, ent.id);
component_kind := string.advance(line);
component_type := get_struct_by_name(component_kind);
- if current_entity->has(component_type) {
- current_component = current_entity.components[component_type];
-
- } else {
- current_component = scene->create_component(component_type);
+ current_component = current_entity.components[component_type] ?? [] {
+ new_component := scene->create_component(component_type);
logf(.Debug, "Adding {} to entity.", component_type);
- current_entity->add(current_component);
- }
+ current_entity->add(new_component);
+
+ return new_component;
+ };
continue;
}
// #inject runtime.vars.Onyx_Enable_Operator_Methods :: true
+use runtime
use core {*}
use ogre {*}
}
get_sound :: (path: str) -> Sound {
- if loaded_sounds->has(path) {
- return loaded_sounds[path];
- }
+ loaded_sounds->get(path)->with([sound] {
+ return sound;
+ });
wav_file := load_wav_file(path);