(NDK) First commit
-Still missing a build file -This is an Entity Component System, without any component nor system, so this is an Entity. Yay. Former-commit-id: f04d2fdfe8819826f940469c2618140a26afa637
This commit is contained in:
72
SDK/include/NDK/Entity.hpp
Normal file
72
SDK/include/NDK/Entity.hpp
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_ENTITY_HPP
|
||||
#define NDK_ENTITY_HPP
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class World;
|
||||
|
||||
class NDK_API Entity
|
||||
{
|
||||
friend World;
|
||||
|
||||
public:
|
||||
class Id;
|
||||
|
||||
Entity();
|
||||
Entity(const Entity&) = default;
|
||||
~Entity() = default;
|
||||
|
||||
void Kill();
|
||||
|
||||
Id GetId() const;
|
||||
World* GetWorld() const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
Entity& operator=(const Entity&) = default;
|
||||
|
||||
bool operator==(const Entity& other) const;
|
||||
bool operator!=(const Entity& other) const;
|
||||
|
||||
// Identifiant
|
||||
struct Id
|
||||
{
|
||||
struct Part
|
||||
{
|
||||
nzUInt32 counter, index;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
Part part;
|
||||
nzUInt64 value;
|
||||
};
|
||||
|
||||
bool operator==(const Id& other) const
|
||||
{
|
||||
return value == other.value;
|
||||
}
|
||||
|
||||
bool operator!=(const Id& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
Entity(Id id, World* world);
|
||||
|
||||
Id m_id;
|
||||
World* m_world;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_ENTITY_HPP
|
||||
58
SDK/include/NDK/Prerequesites.hpp
Normal file
58
SDK/include/NDK/Prerequesites.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Nazara Development Kit ("NDK"), also called Nazara Engine - SDK ("Software Development Kit")
|
||||
|
||||
Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef NDK_PREREQUESITES_HPP
|
||||
#define NDK_PREREQUESITES_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
// Version du SDK
|
||||
#define NDK_VERSION_MAJOR 0
|
||||
#define NDK_VERSION_MINOR 1
|
||||
|
||||
// Importation/Exportation de l'API
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#if !defined(NDK_STATIC)
|
||||
#ifdef NDK_BUILD
|
||||
#define NDK_API NAZARA_EXPORT
|
||||
#else
|
||||
#define NDK_API NAZARA_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define NDK_API
|
||||
#endif
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#if !defined(NDK_STATIC) && defined(NAZARA_COMPILER_GCC)
|
||||
#define NDK_API NAZARA_EXPORT
|
||||
#else
|
||||
#define NDK_API
|
||||
#endif
|
||||
#else
|
||||
// À commenter pour tenter quand même une compilation
|
||||
#error This operating system is not fully supported by the Nazara Development Kit
|
||||
|
||||
#define NDK_API
|
||||
#endif
|
||||
|
||||
#endif // NDK_PREREQUESITES_HPP
|
||||
47
SDK/include/NDK/World.hpp
Normal file
47
SDK/include/NDK/World.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_WORLD_HPP
|
||||
#define NDK_WORLD_HPP
|
||||
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API World : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
using EntityList = std::vector<Entity>;
|
||||
|
||||
World();
|
||||
~World();
|
||||
|
||||
Entity CreateEntity();
|
||||
EntityList CreateEntities(unsigned int count);
|
||||
|
||||
void KillEntity(Entity& entity);
|
||||
void KillEntities(EntityList& list);
|
||||
|
||||
Entity GetEntity(Entity::Id id);
|
||||
|
||||
bool IsEntityValid(const Entity& entity) const;
|
||||
bool IsEntityIdValid(Entity::Id id) const;
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
std::vector<nzUInt32> m_entitiesCounter;
|
||||
std::vector<Entity::Id> m_freeIdList;
|
||||
EntityList m_aliveEntities;
|
||||
EntityList m_killedEntities;
|
||||
nzUInt32 m_nextIndex;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_WORLD_HPP
|
||||
Reference in New Issue
Block a user