]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/items/item.qh
Add an item dumping command
[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     METHOD(GameItem, show, void(entity this))
7     void GameItem_show(entity this) { print("A game item\n"); }
8     void ITEM_HANDLE(Show, entity this) { this.show(this); }
9 ENDCLASS(GameItem)
10
11
12 int ITEM_COUNT;
13 #define REGISTER_ITEM(id, class, body)          \
14     entity ITEM_##id;                           \
15     void RegisterItems_##id() {                 \
16         const entity this = NEW(class);         \
17         ITEM_##id = this;                       \
18         ITEMS[ITEM_COUNT++] = this;             \
19         body                                    \
20     }                                           \
21     ACCUMULATE_FUNCTION(RegisterItems, RegisterItems_##id)
22
23 #endif