i don't know how to spell
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 1 Mar 2022 02:34:53 +0000 (20:34 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 1 Mar 2022 02:34:53 +0000 (20:34 -0600)
run_tree/scenes/quick_save_new.scene
src/entity/components/patreon.onyx [deleted file]
src/entity/components/patron.onyx [new file with mode: 0644]
src/entity/schematics/patreon.onyx [deleted file]
src/entity/schematics/patron.onyx [new file with mode: 0644]

index 188450325de7a6e76f9ff30baf32c37d24f4ce06..829da2f60f6c4776335f9e0c91b2646affe4867c 100644 (file)
@@ -119,7 +119,7 @@ color.a = 1.0000
 item = "beer"
 max_timeout = 2.0000
 
-[Patreon]
+[Patron]
 id = 22
 flags = 3
 pos.x = 388.6049
@@ -132,7 +132,7 @@ color.r = 1.0000
 color.g = 0.0000
 color.b = 0.0000
 color.a = 1.0000
-:PatreonComponent
+:PatronComponent
 state = 0
 seat_location.x = 400.0000
 seat_location.y = 400.0000
diff --git a/src/entity/components/patreon.onyx b/src/entity/components/patreon.onyx
deleted file mode 100644 (file)
index 4f35f82..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-
-use package core
-
-#local Patreon_State :: enum {
-    Walking_To_Seat;
-    Waiting_To_Place_Order;
-    Waiting_For_Order;
-    Consuming_Order;
-    Leaving;
-}
-
-PatreonComponent :: struct {
-    use component: Component;
-
-    state := Patreon_State.Waiting_To_Place_Order;
-    seat_location: Vector2;
-    order_item: str;
-    order_show_animation: f32;
-    holding: Entity_ID;
-    consume_timeout: f32;
-
-    init :: (use this: ^PatreonComponent) {
-        order_item = "beer";
-        seat_location = .{ 400, 400 };
-    }
-
-    added :: (use this: ^PatreonComponent, entity: ^Entity) {
-        entity.flags |= .Interactable;
-
-        scene->create_and_add(entity, InteractableComponent) {
-            comp.interact = interact;
-        }
-    }
-
-    update :: (use this: ^PatreonComponent, entity: ^Entity, dt: f32) {
-        if state == .Walking_To_Seat {
-            delta := Vector2.norm(seat_location - entity.pos) * 100;
-            entity.pos += delta * dt;
-
-            if Vector2.square_mag(seat_location - entity.pos) < 16 {
-                entity.pos = seat_location;
-                state = .Waiting_To_Place_Order;
-            }
-        }
-
-        if consume_timeout > 0 && state == .Consuming_Order {
-            consume_timeout -= dt;
-            if consume_timeout < 0 {
-                state = .Leaving;
-                holding_object := scene->get(holding);
-                holding_object.flags |= .Dead;
-                holding = Entity_Nothing;
-            }
-        }
-
-        if state == .Waiting_For_Order {
-            if order_show_animation > 0 {
-                order_show_animation *= 0.75;
-            }
-        }
-
-        if holding != Entity_Nothing {
-            holding_object := scene->get(holding);
-            r := Entity.get_rect(holding_object);
-            target_pos := entity.pos + .{-10, 0};
-            holding_object.pos += (target_pos - holding_object.pos) * 0.25;
-        }
-    }
-
-    interact :: (entity: ^Entity, interactor: ^Entity) {
-        patreon := entity->get(PatreonComponent);
-
-        switch patreon.state {
-            case .Waiting_To_Place_Order {
-                if interactor->has(PlayerComponent) {
-                    patreon.state = .Waiting_For_Order;
-                    patreon.order_show_animation = 1.0f;
-                }
-            }
-
-            case .Waiting_For_Order {
-                player_comp := interactor->get(PlayerComponent);
-                if player_comp == null do return;
-                if player_comp.holding == Entity_Nothing do return;
-                if item := scene->get(player_comp.holding); item->has(ItemComponent) {
-                    item_comp := item->get(ItemComponent);
-                    if item_comp.item == patreon.order_item {
-                        patreon.state = .Consuming_Order;
-                        patreon.consume_timeout = 10;
-                        patreon.holding = player_comp.holding;
-                        player_comp.holding = Entity_Nothing;
-                    }
-                }
-            }
-        }
-    }
-
-    post_render :: (use this: ^PatreonComponent, entity: ^Entity) {
-        r := entity->get_rect();
-
-        r = Rect.{ r.x + (r.w - 24) / 2, r.y - r.h / 2 - 16, 24, 24 };
-        r.y += 24 * order_show_animation;
-
-        if state == .Waiting_To_Place_Order {
-            immediate_set_color(.{1, 1, 1});
-            immediate_subimage(^Spritesheet, r.x + 4, r.y + 4, 16, 16, 1*16, 4*16, 16, 16);
-        }
-
-        if state == .Waiting_For_Order {
-            immediate_set_color(.{0, 0, 0});
-            immediate_rectangle(r.x, r.y, r.w, r.h);
-
-            r.x += 2;
-            r.y += 2;
-            r.w -= 4;
-            r.h -= 4;
-            immediate_set_color(.{1, 1, 1});
-            immediate_rectangle(r.x, r.y, r.w, r.h);
-
-            r.x += 2;
-            r.y += 2;
-            r.w -= 4;
-            r.h -= 4;
-
-            item_data := item_store->get_item(order_item);
-            texture, loaded := texture_lookup(item_data.texture_path);
-
-            immediate_set_color(item_data.color);
-            if !loaded {
-                immediate_rectangle(r.x, r.y, 16, 16);
-            } else {
-                tp := item_data.texture_pos;
-                ts := item_data.texture_size;
-                immediate_subimage(^texture, r.x, r.y, r.w, r.h,
-                                             tp.x, tp.y, ts.x, ts.y);
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/entity/components/patron.onyx b/src/entity/components/patron.onyx
new file mode 100644 (file)
index 0000000..184f2a4
--- /dev/null
@@ -0,0 +1,139 @@
+
+use package core
+
+#local Patron_State :: enum {
+    Walking_To_Seat;
+    Waiting_To_Place_Order;
+    Waiting_For_Order;
+    Consuming_Order;
+    Leaving;
+}
+
+PatronComponent :: struct {
+    use component: Component;
+
+    state := Patron_State.Waiting_To_Place_Order;
+    seat_location: Vector2;
+    order_item: str;
+    order_show_animation: f32;
+    holding: Entity_ID;
+    consume_timeout: f32;
+
+    init :: (use this: ^PatronComponent) {
+        order_item = "beer";
+        seat_location = .{ 400, 400 };
+    }
+
+    added :: (use this: ^PatronComponent, entity: ^Entity) {
+        entity.flags |= .Interactable;
+
+        scene->create_and_add(entity, InteractableComponent) {
+            comp.interact = interact;
+        }
+    }
+
+    update :: (use this: ^PatronComponent, entity: ^Entity, dt: f32) {
+        if state == .Walking_To_Seat {
+            delta := Vector2.norm(seat_location - entity.pos) * 100;
+            entity.pos += delta * dt;
+
+            if Vector2.square_mag(seat_location - entity.pos) < 16 {
+                entity.pos = seat_location;
+                state = .Waiting_To_Place_Order;
+            }
+        }
+
+        if consume_timeout > 0 && state == .Consuming_Order {
+            consume_timeout -= dt;
+            if consume_timeout < 0 {
+                state = .Leaving;
+                holding_object := scene->get(holding);
+                holding_object.flags |= .Dead;
+                holding = Entity_Nothing;
+            }
+        }
+
+        if state == .Waiting_For_Order {
+            if order_show_animation > 0 {
+                order_show_animation *= 0.75;
+            }
+        }
+
+        if holding != Entity_Nothing {
+            holding_object := scene->get(holding);
+            r := Entity.get_rect(holding_object);
+            target_pos := entity.pos + .{-10, 0};
+            holding_object.pos += (target_pos - holding_object.pos) * 0.25;
+        }
+    }
+
+    interact :: (entity: ^Entity, interactor: ^Entity) {
+        patron := entity->get(PatronComponent);
+
+        switch patron.state {
+            case .Waiting_To_Place_Order {
+                if interactor->has(PlayerComponent) {
+                    patron.state = .Waiting_For_Order;
+                    patron.order_show_animation = 1.0f;
+                }
+            }
+
+            case .Waiting_For_Order {
+                player_comp := interactor->get(PlayerComponent);
+                if player_comp == null do return;
+                if player_comp.holding == Entity_Nothing do return;
+                if item := scene->get(player_comp.holding); item->has(ItemComponent) {
+                    item_comp := item->get(ItemComponent);
+                    if item_comp.item == patron.order_item {
+                        patron.state = .Consuming_Order;
+                        patron.consume_timeout = 10;
+                        patron.holding = player_comp.holding;
+                        player_comp.holding = Entity_Nothing;
+                    }
+                }
+            }
+        }
+    }
+
+    post_render :: (use this: ^PatronComponent, entity: ^Entity) {
+        r := entity->get_rect();
+
+        r = Rect.{ r.x + (r.w - 24) / 2, r.y - r.h / 2 - 16, 24, 24 };
+        r.y += 24 * order_show_animation;
+
+        if state == .Waiting_To_Place_Order {
+            immediate_set_color(.{1, 1, 1});
+            immediate_subimage(^Spritesheet, r.x + 4, r.y + 4, 16, 16, 1*16, 4*16, 16, 16);
+        }
+
+        if state == .Waiting_For_Order {
+            immediate_set_color(.{0, 0, 0});
+            immediate_rectangle(r.x, r.y, r.w, r.h);
+
+            r.x += 2;
+            r.y += 2;
+            r.w -= 4;
+            r.h -= 4;
+            immediate_set_color(.{1, 1, 1});
+            immediate_rectangle(r.x, r.y, r.w, r.h);
+
+            r.x += 2;
+            r.y += 2;
+            r.w -= 4;
+            r.h -= 4;
+
+            item_data := item_store->get_item(order_item);
+            texture, loaded := texture_lookup(item_data.texture_path);
+
+            immediate_set_color(item_data.color);
+            if !loaded {
+                immediate_rectangle(r.x, r.y, 16, 16);
+            } else {
+                tp := item_data.texture_pos;
+                ts := item_data.texture_size;
+                immediate_subimage(^texture, r.x, r.y, r.w, r.h,
+                                             tp.x, tp.y, ts.x, ts.y);
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/entity/schematics/patreon.onyx b/src/entity/schematics/patreon.onyx
deleted file mode 100644 (file)
index b83056f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-
-use package core
-
-Patreon :: struct {
-    #struct_tag Entity_Schematic.{
-        (scene) => Patreon.create(scene, .{0,0})
-    }
-
-    create :: (scene: ^Entity_Manager, pos: Vector2) -> ^Entity {
-        this := scene->make();
-        this.pos = pos;
-        this.size = .{32, 32};
-        this.flags |= .Solid;
-
-        scene->create_and_add(this, RenderComponent) {
-            comp.func = render;
-            comp.color = .{1, 0, 0};
-        }
-
-        scene->create_and_add(this, PatreonComponent) {}
-
-        return this;
-    }
-
-    render :: (use this: ^Entity) {
-        r := this->get_rect();
-        immediate_subimage(^Spritesheet, r.x, r.y, r.w, r.h, 0*16, 4*16, 16, 16);
-    }
-}
-
diff --git a/src/entity/schematics/patron.onyx b/src/entity/schematics/patron.onyx
new file mode 100644 (file)
index 0000000..f2aa238
--- /dev/null
@@ -0,0 +1,30 @@
+
+use package core
+
+Patron :: struct {
+    #struct_tag Entity_Schematic.{
+        (scene) => Patron.create(scene, .{0,0})
+    }
+
+    create :: (scene: ^Entity_Manager, pos: Vector2) -> ^Entity {
+        this := scene->make();
+        this.pos = pos;
+        this.size = .{32, 32};
+        this.flags |= .Solid;
+
+        scene->create_and_add(this, RenderComponent) {
+            comp.func = render;
+            comp.color = .{1, 0, 0};
+        }
+
+        scene->create_and_add(this, PatronComponent) {}
+
+        return this;
+    }
+
+    render :: (use this: ^Entity) {
+        r := this->get_rect();
+        immediate_subimage(^Spritesheet, r.x, r.y, r.w, r.h, 0*16, 4*16, 16, 16);
+    }
+}
+