Skip to content

Commit d5c7c1a

Browse files
committed
It's alive!!!
1 parent 3f653bb commit d5c7c1a

File tree

234 files changed

+78982
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+78982
-0
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(foss)
3+
4+
include(cmake/auxiliary.cmake)
5+
6+
set(CMAKE_CXX_STANDARD 11)
7+
8+
add_subdirectory(external/anax)
9+
add_subdirectory(external/imgui)
10+
11+
add_subdirectory(sources/core)
12+
add_subdirectory(sources/app)

Doxyfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
DOXYFILE_ENCODING = UTF-8
3+
4+
OUTPUT_LANGUAGE = English
5+
6+
PROJECT_NAME = "F.O.S.S."
7+
8+
OUTPUT_DIRECTORY = docs
9+
10+
EXTRACT_PRIVATE = YES
11+
12+
GENERATE_LATEX = NO
13+
14+
RECURSIVE = YES
15+
16+
INPUT = sources
17+
18+
EXCLUDE_PATTERNS = */external/*

cmake/auxiliary.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function(cmake_auxiliary_add_library TARGET HEADERS_EXT SOURCES_EXT)
2+
file(GLOB TARGET_SRC
3+
"${CMAKE_CURRENT_SOURCE_DIR}/*.${HEADERS_EXT}"
4+
"${CMAKE_CURRENT_SOURCE_DIR}/*.${SOURCES_EXT}"
5+
)
6+
add_library(${TARGET} ${TARGET_SRC})
7+
endfunction()
8+
9+
function(cmake_auxiliary_add_execultable TARGET HEADERS_EXT SOURCES_EXT)
10+
file(GLOB TARGET_SRC
11+
"${CMAKE_CURRENT_SOURCE_DIR}/*.${HEADERS_EXT}"
12+
"${CMAKE_CURRENT_SOURCE_DIR}/*.${SOURCES_EXT}"
13+
)
14+
add_executable(${TARGET} ${TARGET_SRC})
15+
endfunction()

external/anax/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
file(GLOB TARGET_SRC
3+
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp"
4+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
5+
"${CMAKE_CURRENT_SOURCE_DIR}/util/*.cpp"
6+
"${CMAKE_CURRENT_SOURCE_DIR}/detail/*.hpp"
7+
"${CMAKE_CURRENT_SOURCE_DIR}/detail/*.cpp"
8+
)
9+
add_library(anax ${TARGET_SRC})
10+
11+
target_include_directories(anax PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
12+
target_include_directories(anax PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/detail/)

external/anax/Component.hpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
///
2+
/// anax
3+
/// An open source C++ entity system.
4+
///
5+
/// Copyright (C) 2013-2014 Miguel Martin ([email protected])
6+
///
7+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
/// of this software and associated documentation files (the "Software"), to deal
9+
/// in the Software without restriction, including without limitation the rights
10+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
/// copies of the Software, and to permit persons to whom the Software is
12+
/// furnished to do so, subject to the following conditions:
13+
///
14+
/// The above copyright notice and this permission notice shall be included in
15+
/// all copies or substantial portions of the Software.
16+
///
17+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
/// THE SOFTWARE.
24+
///
25+
26+
#ifndef ANAX_COMPONENT_HPP
27+
#define ANAX_COMPONENT_HPP
28+
29+
#include <type_traits>
30+
#include <vector>
31+
32+
#include <anax/detail/ClassTypeId.hpp>
33+
#include <anax/Config.hpp>
34+
35+
namespace anax
36+
{
37+
class Component
38+
{
39+
public:
40+
41+
# ifdef ANAX_VIRTUAL_DTORS_IN_COMPONENT
42+
virtual
43+
# endif // ANAX_VIRTUAL_DTORS_IN_COMPONENT
44+
~Component() {}
45+
};
46+
47+
template <class T, class = typename std::enable_if<std::is_base_of<Component, T>::value>::type>
48+
using ComponentPtr = T*;
49+
50+
using ComponentArray = std::vector<Component*>;
51+
52+
template <class T>
53+
detail::TypeId ComponentTypeId()
54+
{
55+
return detail::ClassTypeId<Component>::GetTypeId<T>();
56+
}
57+
}
58+
59+
#endif // ANAX_COMPONENT_HPP

external/anax/Config.hpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
///
2+
/// anax
3+
/// An open source C++ entity system.
4+
///
5+
/// Copyright (C) 2013-2014 Miguel Martin ([email protected])
6+
///
7+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
/// of this software and associated documentation files (the "Software"), to deal
9+
/// in the Software without restriction, including without limitation the rights
10+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
/// copies of the Software, and to permit persons to whom the Software is
12+
/// furnished to do so, subject to the following conditions:
13+
///
14+
/// The above copyright notice and this permission notice shall be included in
15+
/// all copies or substantial portions of the Software.
16+
///
17+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
/// THE SOFTWARE.
24+
///
25+
26+
#ifndef ANAX_DETAIL_CONFIG_HPP
27+
#define ANAX_DETAIL_CONFIG_HPP
28+
29+
#include <cstddef>
30+
31+
#define ANAX_32_BIT_ENTITY_IDS true
32+
#define ANAX_VIRTUAL_DTORS_IN_COMPONENT true
33+
//#cmakedefine ANAX_COMPONENTS_ALIGNED @ANAX_COMPONENTS_ALIGNED@
34+
35+
#ifdef ANAX_32_BIT_ENTITY_IDS
36+
# define ANAX_ENTITY_ID_INDEX_BIT_COUNT 20
37+
# define ANAX_ENTITY_ID_COUNTER_BIT_COUNT 12
38+
#else
39+
# define ANAX_ENTITY_ID_INDEX_BIT_COUNT 48
40+
# define ANAX_ENTITY_ID_COUNTER_BIT_COUNT 16
41+
#endif
42+
43+
namespace anax
44+
{
45+
/// The default size of a pool within a world
46+
constexpr const std::size_t DEFAULT_ENTITY_POOL_SIZE = 1000;
47+
48+
/// The maximum amount of components an entity can
49+
/// contain. Try to make this number even, or preferably
50+
/// a power of 2.
51+
constexpr const std::size_t MAX_AMOUNT_OF_COMPONENTS = 64;
52+
}
53+
54+
#endif // ANAX_DETAIL_CONFIG_HPP

external/anax/Entity.cpp

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
///
2+
/// anax
3+
/// An open source C++ entity system.
4+
///
5+
/// Copyright (C) 2013-2014 Miguel Martin ([email protected])
6+
///
7+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
/// of this software and associated documentation files (the "Software"), to deal
9+
/// in the Software without restriction, including without limitation the rights
10+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
/// copies of the Software, and to permit persons to whom the Software is
12+
/// furnished to do so, subject to the following conditions:
13+
///
14+
/// The above copyright notice and this permission notice shall be included in
15+
/// all copies or substantial portions of the Software.
16+
///
17+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
/// THE SOFTWARE.
24+
///
25+
26+
#include <anax/Entity.hpp>
27+
28+
#include <anax/World.hpp>
29+
#include <anax/detail/AnaxAssert.hpp>
30+
31+
namespace anax
32+
{
33+
Entity::Entity() :
34+
m_world(nullptr)
35+
{
36+
}
37+
38+
Entity::Entity(World& world, Entity::Id id) :
39+
m_id(id),
40+
m_world(&world)
41+
{
42+
}
43+
44+
World& Entity::getWorld() const
45+
{
46+
ANAX_ASSERT(m_world, "world reference in entity is null");
47+
48+
return *m_world;
49+
}
50+
51+
const Entity::Id& Entity::getId() const
52+
{
53+
return m_id;
54+
}
55+
56+
bool Entity::isValid() const
57+
{
58+
//Allows an empty Entity handle to be checked.
59+
if(m_world == nullptr)
60+
return false;
61+
62+
return getWorld().isValid(*this);
63+
}
64+
65+
bool Entity::isActivated() const
66+
{
67+
return getWorld().isActivated(*this);
68+
}
69+
70+
void Entity::activate()
71+
{
72+
getWorld().activateEntity(*this);
73+
}
74+
75+
void Entity::deactivate()
76+
{
77+
getWorld().deactivateEntity(*this);
78+
}
79+
80+
void Entity::kill()
81+
{
82+
getWorld().killEntity(*this);
83+
}
84+
85+
void Entity::removeAllComponents()
86+
{
87+
getWorld().m_entityAttributes.componentStorage.removeAllComponents(*this);
88+
}
89+
90+
ComponentArray Entity::getComponents() const
91+
{
92+
return getWorld().m_entityAttributes.componentStorage.getComponents(*this);
93+
}
94+
95+
detail::ComponentTypeList Entity::getComponentTypeList() const
96+
{
97+
return getWorld().m_entityAttributes.componentStorage.getComponentTypeList(*this);
98+
}
99+
100+
bool Entity::operator==(const anax::Entity &entity) const
101+
{
102+
return m_id == entity.m_id && entity.m_world == m_world;
103+
}
104+
105+
void Entity::addComponent(Component* component, detail::TypeId componentTypeId)
106+
{
107+
getWorld().m_entityAttributes.componentStorage.addComponent(*this, component, componentTypeId);
108+
}
109+
110+
void Entity::removeComponent(detail::TypeId componentTypeId)
111+
{
112+
getWorld().m_entityAttributes.componentStorage.removeComponent(*this, componentTypeId);
113+
}
114+
115+
Component& Entity::getComponent(detail::TypeId componentTypeId) const
116+
{
117+
return getWorld().m_entityAttributes.componentStorage.getComponent(*this, componentTypeId);
118+
}
119+
120+
bool Entity::hasComponent(detail::TypeId componentTypeId) const
121+
{
122+
return getWorld().m_entityAttributes.componentStorage.hasComponent(*this, componentTypeId);
123+
}
124+
}
125+

0 commit comments

Comments
 (0)