Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
common.h
1#pragma once
2#include "gaia/config/config.h"
3
4#include <cstdint>
5
6namespace gaia {
7 namespace ecs {
12 GAIA_NODISCARD inline bool version_changed(uint32_t changeVersion, uint32_t requiredVersion) {
13 // When a system runs for the first time, everything is considered changed.
14 if GAIA_UNLIKELY (requiredVersion == 0U)
15 return true;
16
17 // Supporting wrap-around for version numbers. ChangeVersion must be
18 // bigger than requiredVersion (never detect change of something the
19 // system itself changed).
20 return (int)(changeVersion - requiredVersion) > 0;
21 }
22
25 inline void update_version(uint32_t& version) {
26 ++version;
27 // Handle wrap-around, 0 is reserved for systems that have never run.
28 if GAIA_UNLIKELY (version == 0U)
29 ++version;
30 }
31 } // namespace ecs
32} // namespace gaia