updated to new Onyx version
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 22 Jun 2023 23:44:20 +0000 (18:44 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 22 Jun 2023 23:44:20 +0000 (18:44 -0500)
onyx-pkg.ini
run_tree/run.sh
src/entity/components/collision_mask.onyx
src/entity/editor.onyx
src/entity/items.onyx
src/entity/scene.onyx
src/entity/store.onyx
src/main.onyx
src/sfx/audio_manager.onyx

index fc9cc131102b781971aabad64b09841e581944d9..43c7e11fefa45efbb06aa8e3d446cadd5c7844b2 100644 (file)
@@ -1,24 +1,18 @@
 [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
index 465d8174e42501445f748bf49055825d8cdaa1b6..c640edcd5c3470c60894b47e1b9f82901f6ed930 100755 (executable)
@@ -5,5 +5,6 @@ case "$1" in
     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
index 190c4e4b59ad3a930b8a80801dd65db30214ebcc..5d2a825eb816682cc1eba4c451ccbeee4686ef0a 100644 (file)
@@ -87,7 +87,7 @@ CollisionMaskComponent :: struct {
                     }
 
                     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;
@@ -107,7 +107,7 @@ CollisionMaskComponent :: struct {
                 }
             }
 
-            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;
@@ -121,10 +121,10 @@ CollisionMaskComponent :: struct {
                     ~~(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;
index e3865b40b295c05bdb0b9de7909a064adc5d31e4..ec94adf76b2d6847cf33e4bb60fe05e92c893daf 100644 (file)
@@ -476,11 +476,7 @@ editor_draw :: () {
             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 {
index 69db529b85b3036087fdee6493a71b50d8f1ca4e..fee289c91469303537b95ba17e4821d388ac4a0c 100644 (file)
@@ -91,7 +91,7 @@ item_store_load_items_from_file :: (use this: ^Item_Store, path: str) {
 }
 
 item_store_get_item :: (use this: ^Item_Store, id: str) -> ^Item {
-    return items[id];
+    return items[id]?;
 }
 
 @Entity_Schematic.{"Item_Entity"}
index 5361788bbbf145468aeefea981fc6964a16437d3..b32ec78476d7934e91169a6065d3d46a922b46ab 100644 (file)
@@ -122,7 +122,7 @@ Entity :: struct {
 
     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;
@@ -263,7 +263,7 @@ scene_make :: (use this: ^Scene) -> ^Entity {
 }
 
 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);
@@ -302,7 +302,7 @@ scene_create_component :: (use this: ^Scene, component_type: type_expr) -> ^Comp
         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();
     }
@@ -355,7 +355,7 @@ scene_draw :: (use this: ^Scene) {
     //
     // 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);
 
@@ -381,7 +381,7 @@ scene_draw :: (use this: ^Scene) {
     }
 }
 
-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);
index 2c3a27f0d1a0fbefbc9cf04e02037c7d6234dc5c..74b8dc9498ae7287e7df4955c3ffa6cdc5441124 100644 (file)
@@ -154,14 +154,13 @@ scene_load_from_file :: (use this: ^Scene, filename: str, reset_scene := true) {
 
             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;
         }
index e235f1934bc16bc5ff963c0ca291f50ccee389c4..92bf33a4e8775237de1b71668d035d8a4769df3d 100644 (file)
@@ -1,5 +1,6 @@
 // #inject runtime.vars.Onyx_Enable_Operator_Methods :: true
 
+use runtime
 use core {*}
 use ogre {*}
 
index 8307870756ab420537973f22853da13ae1f05f42..3a71da0bb12535432e5773409a3b666ff966e4e2 100644 (file)
@@ -31,9 +31,9 @@ Audio_Manager :: struct {
     }
 
     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);