]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/items/item.qh
Tidy up
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item.qh
1 #ifndef GAMEITEM_H
2 #define GAMEITEM_H
3 #include "../oo.qh"
4 #define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
5 CLASS(GameItem, Object)
6     ATTRIB(GameItem, m_id, int, 0)
7     METHOD(GameItem, show, void(entity this))
8     void GameItem_show(entity this) { print("A game item\n"); }
9     void ITEM_HANDLE(Show, entity this) { this.show(this); }
10 ENDCLASS(GameItem)
11
12
13 int ITEM_COUNT;
14 #define REGISTER_ITEM(id, class, body)          \
15     entity ITEM_##id;                           \
16     void RegisterItems_##id() {                 \
17         const entity this = NEW(class);         \
18         ITEM_##id = this;                       \
19         this.m_id = ITEM_COUNT;                 \
20         ITEMS[ITEM_COUNT++] = this;             \
21         body                                    \
22     }                                           \
23     ACCUMULATE_FUNCTION(RegisterItems, RegisterItems_##id)
24
25 #endif