X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fecs%2Flib.qh;h=192136b6253225e014490f4d4e100f2ddfca30e9;hp=a617c73b09312ca5c1de45d2b8cac9ef47c2929e;hb=HEAD;hpb=79eebf87e68861e205a8754d6551bd0aa2229c44 diff --git a/qcsrc/ecs/lib.qh b/qcsrc/ecs/lib.qh index a617c73b09..192136b625 100644 --- a/qcsrc/ecs/lib.qh +++ b/qcsrc/ecs/lib.qh @@ -1,24 +1,29 @@ #pragma once +IntrusiveList g_events; +IntrusiveList g_components; +STATIC_INIT(components) { g_events = IL_NEW(); g_components = IL_NEW(); } + /** Components always interpolate from the previous state */ #define COMPONENT(com) \ void com_##com##_interpolate(entity it, float a); \ .bool com_##com -#define FOREACH_COMPONENT(com, body) FOREACH_ENTITY_FLOAT(com_##com, true, body) +#define FOREACH_COMPONENT(com, body) IL_EACH(g_components, it.com_##com, body) #define EVENT(T, args) .bool evt_##T##_listener; .void args evt_##T #define emit(T, ...) \ MACRO_BEGIN \ - FOREACH_ENTITY_FLOAT_ORDERED(evt_##T##_listener, true, it.evt_##T(__VA_ARGS__)); \ + IL_EACH(g_events, it.evt_##T##_listener, it.evt_##T(__VA_ARGS__)); \ MACRO_END #define subscribe(listener, T, fn) \ MACRO_BEGIN \ listener.evt_##T = (fn); \ listener.evt_##T##_listener = true; \ + IL_PUSH(g_events, listener); \ MACRO_END @@ -28,8 +33,8 @@ */ #define SYSTEM(sys, frameLimit, minfps) \ void sys_##sys##_update(entity this, float dt); \ - float autocvar_xon_sys_##sys##_dt = ((frameLimit) ? (1 / (frameLimit)) : 0); \ - float autocvar_xon_sys_##sys##_minfps = (1 / (1 / (minfps))) + noref float autocvar_xon_sys_##sys##_dt = ((frameLimit) ? (1 / (frameLimit)) : 0); \ + noref float autocvar_xon_sys_##sys##_minfps = (1 / (1 / (minfps))) #define SYSTEM_UPDATE(sys) \ MACRO_BEGIN \