resonance 1.0.1
Loading...
Searching...
No Matches
idable.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "game/idablebase.h"
6
28template <typename T>
29class IDable : public IDableBase {
30public:
40 explicit IDable(int nId) {
41 mId = nId;
42 if (nId != kIDableUnregistered) {
43 sObjects[nId] = static_cast<T *>(this);
44 }
45 }
46
55 virtual ~IDable();
56
64 static std::vector<T *> sObjects;
65};
66
72constexpr int kIDableInitialSlots = 4;
73
74template <typename T>
76
77// NTSC-U/C: 0x00121db0, PAL: 0x001223b8
78template <typename T>
80 if (mId != kIDableUnregistered) {
81 sObjects[mId] = nullptr;
82 }
83}
Base of an object that occupies a slot of a global identifier table.
Definition idablebase.h:17
int mId
Definition idablebase.h:31
IDable(int nId)
Register the object in sObjects under an identifier.
Definition idable.h:40
static std::vector< T * > sObjects
Every registered object, indexed by mId.
Definition idable.h:64
virtual ~IDable()
Release the table slot this object occupies.
Definition idable.h:79
constexpr int kIDableInitialSlots
Slots each identifier table starts with, one per player.
Definition idable.h:72
constexpr int kIDableUnregistered
Identifier a never-registered object stores, distinct from any real index.
Definition idablebase.h:4