From 53f37adbd79266707faff9aa4815ce9f833f91e1 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Wed, 22 Jun 2022 08:38:46 +0100 Subject: [PATCH] type-safe entity classes --- include/fggl/ecs/types.hpp | 39 ++++++++++++++++++++++++++++++++++++ include/fggl/ecs/utility.hpp | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 include/fggl/ecs/types.hpp diff --git a/include/fggl/ecs/types.hpp b/include/fggl/ecs/types.hpp new file mode 100644 index 0000000..d82bd01 --- /dev/null +++ b/include/fggl/ecs/types.hpp @@ -0,0 +1,39 @@ +/* + * This file is part of FGGL. + * + * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with FGGL. + * If not, see <https://www.gnu.org/licenses/>. + */ + +// +// Created by webpigeon on 22/06/22. +// + +#ifndef FGGL_ECS_TYPES_HPP +#define FGGL_ECS_TYPES_HPP + +#include <cstdint> + +namespace fggl::ecs { + + struct entity { + std::uint32_t id; + }; + constexpr const entity NULL_ENTITY = {0}; + constexpr const entity MAX_ENTITY = {0xFFFFFFFF}; + + struct componentID { + std::uint32_t id; + }; + constexpr const entity NULL_COMPONENT = {0}; + +} + +#endif //FGGL_ECS_TYPES_HPP diff --git a/include/fggl/ecs/utility.hpp b/include/fggl/ecs/utility.hpp index 8900801..ebcc051 100644 --- a/include/fggl/ecs/utility.hpp +++ b/include/fggl/ecs/utility.hpp @@ -37,7 +37,7 @@ namespace fggl::ecs { } }; - template<class T> IDType TypeIdGenerator<T>::m_count = 0; + template<class T> IDType TypeIdGenerator<T>::m_count = 1; } #endif -- GitLab