small 'bugfix'
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 27 Feb 2022 04:42:45 +0000 (22:42 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 27 Feb 2022 04:42:45 +0000 (22:42 -0600)
src/entity/manager.onyx

index e6e7d1ce7f7eab328b17db949da1d07f37fe732f..f648ce63fefdf468889e47bd75ffc01dc682a3bb 100644 (file)
@@ -16,8 +16,8 @@ Entity_ID :: #distinct u32
 }
 
 #local Component_Vtable :: struct {
-    init  : (^Component) -> void               = null_proc;
-    update: (^Component, ^Entity, f32) -> void = null_proc;
+    init  : (rawptr) -> void               = null_proc;
+    update: (rawptr, ^Entity, f32) -> void = null_proc;
 }
 
 Component :: struct {
@@ -204,8 +204,8 @@ entity_manager_create_component :: (use this: ^Entity_Manager, component_type: t
     }
 
     comp.vtable = component_vtables->get(comp.type);
-    if comp.vtable.init != null_proc {
-        comp.vtable.init(comp);
+    if comp.init != null_proc {
+        comp->init();
     }
 
     return comp;
@@ -230,10 +230,8 @@ entity_manager_update :: (use this: ^Entity_Manager, dt: f32) {
     for entities {
         for^ entry: it.components.entries {
             comp := entry.value;
-
-            @CompilerBug // comp->update(it, dt); should be legal here, but it says 'update' is not a member of '^Component'.
-            if comp.vtable.update != null_proc {
-                comp.vtable.update(comp, it, dt);
+            if comp.update != null_proc {
+                comp->update(it, dt);
             }
         }
     }