Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd1f81127a | |||
| 3a3a9e0341 | |||
| 5e123d96b3 |
8 changed files with 143 additions and 26 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,6 +6,7 @@
|
|||
!.gitignore
|
||||
!codecov.yml
|
||||
!skeleton.html
|
||||
!**/xmake.lua
|
||||
!**/meson.build
|
||||
!**/*.wrap
|
||||
!meson_options.txt
|
||||
|
|
|
|||
16
dub.json
16
dub.json
|
|
@ -7,9 +7,9 @@
|
|||
"description": "Dynamic Entity Component System",
|
||||
"copyright": "Copyright © 2018-2023, Michał Masiukiewicz, Dawid Masiukiewicz",
|
||||
"license": "BSD 3-clause",
|
||||
"sourcePaths" : ["source\/"],
|
||||
"sourcePaths" : ["source/"],
|
||||
"excludedSourceFiles":[
|
||||
"source\/ecs\/traits.d"
|
||||
"source/ecs/traits.d"
|
||||
],
|
||||
"configurations" : [
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
"sourceFiles" : ["tests/tests.d"],
|
||||
"targetType" : "executable",
|
||||
"excludedSourceFiles":[
|
||||
"source\/win_dll.d"
|
||||
"source/win_dll.d"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
"sourcePaths": ["source/","tests/"],
|
||||
"mainSourceFile":"tests/runner.d",
|
||||
"excludedSourceFiles":[
|
||||
"source\/win_dll.d",
|
||||
"source/win_dll.d",
|
||||
"tests/tests.d"
|
||||
],
|
||||
"dflags": [
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
"sourcePaths": ["source/","tests/"],
|
||||
"mainSourceFile":"tests/runner.d",
|
||||
"excludedSourceFiles":[
|
||||
"source\/win_dll.d",
|
||||
"source/win_dll.d",
|
||||
"tests/tests.d"
|
||||
],
|
||||
"dflags": [
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
"name" : "library-betterC",
|
||||
"targetType" : "library",
|
||||
"excludedSourceFiles":[
|
||||
"source\/win_dll.d"
|
||||
"source/win_dll.d"
|
||||
],
|
||||
"dflags": [
|
||||
"-betterC",
|
||||
|
|
@ -101,7 +101,7 @@
|
|||
"targetType" : "executable",
|
||||
"sourceFiles" : ["tests/tests.d"],
|
||||
"excludedSourceFiles":[
|
||||
"source\/win_dll.d"
|
||||
"source/win_dll.d"
|
||||
],
|
||||
"dflags": [
|
||||
"-betterC"
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
"sourcePaths": ["source/","tests/"],
|
||||
"mainSourceFile":"tests/runner.d",
|
||||
"excludedSourceFiles":[
|
||||
"source\/win_dll.d",
|
||||
"source/win_dll.d",
|
||||
"tests/tests.d"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ struct Entity
|
|||
return cast(T*)getComponent(becsID!T);
|
||||
}
|
||||
|
||||
void* getComponent(ushort component_id) const
|
||||
void* getComponent(ushort component_id) const nothrow @nogc
|
||||
{
|
||||
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
|
||||
EntityManager.EntityInfo* info = block.type_info;
|
||||
|
|
@ -54,7 +54,7 @@ struct Entity
|
|||
return (cast(void*)block + info.deltas[component_id] + block.entityIndex(&this) * gEntityManager.components[component_id].size);
|
||||
}
|
||||
|
||||
bool hasComponent(ushort component_id) const
|
||||
bool hasComponent(ushort component_id) const nothrow @nogc
|
||||
{
|
||||
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
|
||||
EntityManager.EntityInfo* info = block.type_info;
|
||||
|
|
@ -62,7 +62,7 @@ struct Entity
|
|||
return true;
|
||||
}
|
||||
|
||||
EntityMeta getMeta() const
|
||||
EntityMeta getMeta() const nothrow @nogc
|
||||
{
|
||||
EntityMeta meta;
|
||||
meta.block = gEntityManager.getMetaData(&this);
|
||||
|
|
@ -85,7 +85,7 @@ struct EntityMeta
|
|||
return cast(T*)getComponent(becsID!T);
|
||||
}
|
||||
|
||||
void* getComponent(ushort component_id) const
|
||||
void* getComponent(ushort component_id) const nothrow @nogc
|
||||
{
|
||||
const (EntityManager.EntityInfo)* info = block.type_info;
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ struct EntityMeta
|
|||
return (cast(void*)block + info.deltas[component_id] + index * gEntityManager.components[component_id].size);
|
||||
}
|
||||
|
||||
bool hasComponent(ushort component_id) const
|
||||
bool hasComponent(ushort component_id) const nothrow @nogc
|
||||
{
|
||||
const EntityManager.EntityInfo* info = block.type_info;
|
||||
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)return false;
|
||||
|
|
@ -124,7 +124,7 @@ export struct EntityTemplate
|
|||
/************************************************************************************************************************
|
||||
Get specified component. If component doesn't exist function return null. Returned pointer is valid during EntityTemplate lifetime.
|
||||
*/
|
||||
T* getComponent(T)() nothrow @nogc
|
||||
T* getComponent(T)()
|
||||
{
|
||||
if(becsID!T >= info.tmpl_deltas.length || info.tmpl_deltas[becsID!T] == ushort.max)return null;
|
||||
return cast(T*)(entity_data.ptr + info.tmpl_deltas[becsID!T]);
|
||||
|
|
|
|||
|
|
@ -1305,7 +1305,7 @@ export struct EntityManager
|
|||
// static assert(0, "Add \"mixin ECS.Component;\" in top of component structure;");
|
||||
// }
|
||||
|
||||
static if (hasMember!(Comp, "onDestroy") && isFunction!(Comp.onDestroy)
|
||||
static if (__traits(hasMember, Comp.init, "onDestroy") && isFunction!(Comp.onDestroy)
|
||||
&& is(ReturnType!(Comp.onDestroy) == void)
|
||||
&& Parameters!(Comp.onDestroy).length == 0)
|
||||
{
|
||||
|
|
@ -1317,7 +1317,7 @@ export struct EntityManager
|
|||
info.destroy_callback = &callDestroy;
|
||||
}
|
||||
|
||||
static if (hasMember!(Comp, "onCreate") && isFunction!(Comp.onCreate)
|
||||
static if (__traits(hasMember, Comp.init, "onCreate") && isFunction!(Comp.onCreate)
|
||||
&& is(ReturnType!(Comp.onCreate) == void) && Parameters!(Comp.onCreate).length == 0)
|
||||
{
|
||||
static void callCreate(void* pointer) nothrow @nogc
|
||||
|
|
@ -2502,7 +2502,7 @@ export struct EntityManager
|
|||
*Params:
|
||||
*id = ID of entity to be copyied.
|
||||
*/
|
||||
export Entity* addEntityCopy(EntityID id)
|
||||
export Entity* addEntityCopy(EntityID id) nothrow @nogc
|
||||
{
|
||||
Entity* entity = getEntity(id);
|
||||
EntitiesBlock* block = getMetaData(entity);
|
||||
|
|
@ -2554,7 +2554,7 @@ export struct EntityManager
|
|||
Params:
|
||||
tmpl = pointer entity template allocated by EntityManager.
|
||||
*/
|
||||
export Entity* addEntity(EntityTemplate* tmpl)
|
||||
export Entity* addEntity(EntityTemplate* tmpl) nothrow @nogc
|
||||
{
|
||||
return addEntity(tmpl, null);
|
||||
}
|
||||
|
|
@ -2567,7 +2567,7 @@ export struct EntityManager
|
|||
tmpl = pointer entity template allocated by EntityManager.
|
||||
replacement = list of components references to used. Memory form list replace data from template inside new entity. Should be used only for data which vary between most entities (like 3D position etc.)
|
||||
*/
|
||||
export Entity* addEntity(EntityTemplate* tmpl, ComponentRef[] replacement)
|
||||
export Entity* addEntity(EntityTemplate* tmpl, ComponentRef[] replacement) nothrow @nogc
|
||||
{
|
||||
EntityInfo* info = tmpl.info;
|
||||
|
||||
|
|
@ -2664,7 +2664,7 @@ export struct EntityManager
|
|||
/************************************************************************************************************************
|
||||
Return block with free space for selected EntityInfo. Additional this function is multithread safe.
|
||||
*/
|
||||
private EntitiesBlock* findBlockWithFreeSpaceMT(EntityInfo* info)
|
||||
private EntitiesBlock* findBlockWithFreeSpaceMT(EntityInfo* info) nothrow @nogc
|
||||
{
|
||||
EntitiesBlock* block = info.last_block;
|
||||
|
||||
|
|
@ -2718,7 +2718,7 @@ export struct EntityManager
|
|||
Params:
|
||||
id = id of entity to remove
|
||||
*/
|
||||
export void removeEntity(EntityID id)
|
||||
export void removeEntity(EntityID id) nothrow @nogc
|
||||
{
|
||||
threads[threadID].entitesToRemove.add(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ static struct Mallocator
|
|||
|
||||
static if (__traits(isPOD, T))
|
||||
{
|
||||
__gshared immutable T init = T.init;
|
||||
__gshared T init = T.init;
|
||||
memcpy(ret, &init, T.sizeof);
|
||||
}
|
||||
else static if (is(T == struct))
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ tests_src = files(
|
|||
exe = executable('BubelECSTests',
|
||||
tests_src,
|
||||
include_directories : [inc, include_directories('..')],
|
||||
d_args : args,
|
||||
link_args : link_args,
|
||||
dependencies : decs_dep,
|
||||
# d_args : args,
|
||||
# link_args : link_args,
|
||||
dependencies : bubel_ecs_dep,
|
||||
)
|
||||
|
||||
test('basic-tests', exe)
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ version (unittest)
|
|||
else:
|
||||
extern (C) int main()
|
||||
{
|
||||
|
||||
version (D_BetterC)printf("BetterC\n");
|
||||
void dispatch(EntityManager.JobGroup jobs) nothrow @nogc
|
||||
{
|
||||
foreach (job; jobs.jobs)
|
||||
|
|
|
|||
116
xmake.lua
Normal file
116
xmake.lua
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
add_rules("mode.debug", "mode.release")
|
||||
|
||||
if get_config("toolchain") == "ldc" then
|
||||
add_ldflags("-linker=lld", {force = true})
|
||||
end
|
||||
|
||||
option("betterC")
|
||||
set_default(false)
|
||||
if get_config("toolchain") == "gdc" then
|
||||
add_dcflags("-fno-druntime")
|
||||
elseif get_config("toolchain") == "dmd" then
|
||||
add_dcflags("-betterC") -- DMD doesn't need -betterC flag during linking!?
|
||||
add_ldflags("-betterC", {force = true})
|
||||
add_shflags("-betterC", {force = true})
|
||||
else
|
||||
add_ldflags("-betterC", {force = true}) -- -betterC flag isn't accepted for LDC for some reason
|
||||
add_dcflags("-betterC", {force = true})
|
||||
add_shflags("-betterC", {force = true})
|
||||
end
|
||||
|
||||
target("bubel-ecs")
|
||||
set_kind("shared")
|
||||
set_basename("BubelECS")
|
||||
add_files("source/bubel/**.d")
|
||||
add_includedirs("source", {public = true})
|
||||
set_options("betterC")
|
||||
|
||||
target("tests")
|
||||
set_kind("binary")
|
||||
set_basename("BubelECSTests")
|
||||
add_ldflags("-L-rpath=.", {force = true})
|
||||
add_files("tests/*.d|tests.d")
|
||||
add_includedirs(".", {public = true})
|
||||
set_options("betterC")
|
||||
add_deps("bubel-ecs")
|
||||
add_dcflags("-unittest")
|
||||
|
||||
target("test")
|
||||
set_kind("binary")
|
||||
set_basename("BubelECSTest")
|
||||
-- add_rpathdirs(".") -- this doesn't work completely
|
||||
add_ldflags("-L-rpath=.", {force = true})
|
||||
add_files("tests/tests.d")
|
||||
add_includedirs(".", {public = true})
|
||||
set_options("betterC")
|
||||
add_deps("bubel-ecs")
|
||||
|
||||
--
|
||||
-- If you want to known more usage about xmake, please see https://xmake.io
|
||||
--
|
||||
-- ## FAQ
|
||||
--
|
||||
-- You can enter the project directory firstly before building project.
|
||||
--
|
||||
-- $ cd projectdir
|
||||
--
|
||||
-- 1. How to build project?
|
||||
--
|
||||
-- $ xmake
|
||||
--
|
||||
-- 2. How to configure project?
|
||||
--
|
||||
-- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release]
|
||||
--
|
||||
-- 3. Where is the build output directory?
|
||||
--
|
||||
-- The default output directory is `./build` and you can configure the output directory.
|
||||
--
|
||||
-- $ xmake f -o outputdir
|
||||
-- $ xmake
|
||||
--
|
||||
-- 4. How to run and debug target after building project?
|
||||
--
|
||||
-- $ xmake run [targetname]
|
||||
-- $ xmake run -d [targetname]
|
||||
--
|
||||
-- 5. How to install target to the system directory or other output directory?
|
||||
--
|
||||
-- $ xmake install
|
||||
-- $ xmake install -o installdir
|
||||
--
|
||||
-- 6. Add some frequently-used compilation flags in xmake.lua
|
||||
--
|
||||
-- @code
|
||||
-- -- add debug and release modes
|
||||
-- add_rules("mode.debug", "mode.release")
|
||||
--
|
||||
-- -- add macro defination
|
||||
-- add_defines("NDEBUG", "_GNU_SOURCE=1")
|
||||
--
|
||||
-- -- set warning all as error
|
||||
-- set_warnings("all", "error")
|
||||
--
|
||||
-- -- set language: c99, c++11
|
||||
-- set_languages("c99", "c++11")
|
||||
--
|
||||
-- -- set optimization: none, faster, fastest, smallest
|
||||
-- set_optimize("fastest")
|
||||
--
|
||||
-- -- add include search directories
|
||||
-- add_includedirs("/usr/include", "/usr/local/include")
|
||||
--
|
||||
-- -- add link libraries and search directories
|
||||
-- add_links("tbox")
|
||||
-- add_linkdirs("/usr/local/lib", "/usr/lib")
|
||||
--
|
||||
-- -- add system link libraries
|
||||
-- add_syslinks("z", "pthread")
|
||||
--
|
||||
-- -- add compilation and link flags
|
||||
-- add_cxflags("-stdnolib", "-fno-strict-aliasing")
|
||||
-- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
|
||||
--
|
||||
-- @endcode
|
||||
--
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue