-registering same system multiple times only replace pointer for callback
-added export attributes (required by windows to make DLL library, not work at now due to DMD bugs) -interface D files to import
This commit is contained in:
parent
cb0f56b0fb
commit
d0fcdba6cd
20 changed files with 1322 additions and 105 deletions
112
import/ecs/ecs.di
Normal file
112
import/ecs/ecs.di
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// D import file generated from 'source\ecs\ecs.d'
|
||||
module ecs.ecs;
|
||||
import std.stdio;
|
||||
version (Design)
|
||||
{
|
||||
alias SytemFuncType = void function(ref SystemCallData data, void* componentsStart);
|
||||
struct HasComponentsStore
|
||||
{
|
||||
ulong[4] bits;
|
||||
bool has(HasComponentsStore components);
|
||||
bool notIn(HasComponentsStore components);
|
||||
int length();
|
||||
}
|
||||
struct ComponentInfo
|
||||
{
|
||||
int size;
|
||||
int aligment;
|
||||
SerializeJSON funsSerJ;
|
||||
SerializeBiN funcSerB;
|
||||
}
|
||||
struct System
|
||||
{
|
||||
HasComponentsStore requiredComponents;
|
||||
HasComponentsStore absenComponents;
|
||||
HasComponentsStore maybeComponents;
|
||||
bool enabled;
|
||||
int priority;
|
||||
SytemFuncType func;
|
||||
}
|
||||
struct SystemCallData
|
||||
{
|
||||
System* system;
|
||||
int[] componentsDt;
|
||||
}
|
||||
struct EntityTypeData
|
||||
{
|
||||
HasComponentsStore components;
|
||||
int[] deltas;
|
||||
int totalSize;
|
||||
int totalAligment = 8;
|
||||
SystemCallData[] systems;
|
||||
}
|
||||
struct EntitiesBlock
|
||||
{
|
||||
EntityTypeData* typeData;
|
||||
Entity* freeEntitySlot;
|
||||
EntitiesBlock* nextBlock;
|
||||
}
|
||||
struct EntityID
|
||||
{
|
||||
ulong id = (ulong).max;
|
||||
static immutable notUsedValue = EntityID((ulong).max);
|
||||
}
|
||||
struct Entity
|
||||
{
|
||||
EntityID entityID = EntityID.notUsedValue;
|
||||
union
|
||||
{
|
||||
string name;
|
||||
Entity* nextFreeSlot;
|
||||
}
|
||||
uint group;
|
||||
EntityID entityID;
|
||||
}
|
||||
struct Template
|
||||
{
|
||||
HasComponentsStore hasComp;
|
||||
Entity* entity;
|
||||
}
|
||||
struct Manager
|
||||
{
|
||||
EntityAllocator entityArrayAllcoator;
|
||||
ComponentInfo[] components;
|
||||
System[] systems;
|
||||
HashMap!(HasComponentsStore, EntitiesBlock*) entitiesDatas;
|
||||
HashMapTwoWays!(string, Entity*) nameMap;
|
||||
HashMapTwoWays!(EntityID, Entity*) idMap;
|
||||
EntitiesBlock* getEntitiesBlock(HasComponentsStore hasComponents);
|
||||
EntitiesBlock* addNewBlock(HasComponentsStore hasComponents, EntitiesBlock* firstBlock);
|
||||
void alignNum(ref int num, int aligment);
|
||||
EntityTypeData* newEntityTypeData(HasComponentsStore hasComponents);
|
||||
void addEntity(Template* templ);
|
||||
void addSystem(Func)(int priority)
|
||||
{
|
||||
HasComponentsStore requiredComponents;
|
||||
HasComponentsStore absenComponents;
|
||||
HasComponentsStore maybeComponents;
|
||||
void systemCaller(ref SystemCallData data, void* componentsStart);
|
||||
System* system = new System(&systemCaller, entTypeData);
|
||||
systems ~= system;
|
||||
foreach (ref entTypeData; entitiesDatas)
|
||||
{
|
||||
if (!entTypeData.hasComp.has(requiredComponents) || !entTypeData.hasComp.notIn(absenComponents))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entTypeData.systems ~= system;
|
||||
}
|
||||
}
|
||||
}
|
||||
void someSystem(CompA a, CompB b, CompC* c);
|
||||
void main();
|
||||
class System
|
||||
{
|
||||
void start();
|
||||
void end();
|
||||
void update(ref ObjRend a);
|
||||
void useEvent(EventData evvv, ref ObjRend a);
|
||||
}
|
||||
alias SerializeVector = ubyte[];
|
||||
__gshared EntityManager gEntityManager;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue