/* * SPDX-FileCopyrightText: Dora "cat" * SPDX-License-Identifier: MPL-2.0 * * This Source Code Form is subject to the terms of the Mozilla Public License, * v. 2.0. If a copy of the MPL was not distributed with this file, You can * obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include using namespace Tourmaline::Systems; using namespace ECS; void World::Step() { preSystems(); // Actual systems will happen here postSystems(); } void World::preSystems() { // Defined for future use } void World::postSystems() { // Defined for future use } // Entities Entity World::CreateEntity() { auto newEntity = Random::GenerateUUID(); // Default components entityComponentMap.insert(newEntity, typeid(Components::Base), Components::Base()); return newEntity; } bool World::EntityExists(const Entity &entity) noexcept { bool exists = false; entityComponentMap.scan( [&exists, entity](const Tourmaline::Type::UUID ¤tEntity, const std::type_index &, std::any &) -> bool { if (currentEntity == entity) { exists = true; return true; } return false; }); return exists; } bool World::DestroyEntity(Entity entity) { return entityComponentMap.remove(entity, std::nullopt); }