Removed unecessary conent + bugfixes
We had a bug where double registering a component errored. That was because I fucked up and used the wrong symbol name at one point. _size vs _sizeof Its fixed now
This commit is contained in:
parent
70b39a2b4a
commit
553b1f4166
5 changed files with 1 additions and 140 deletions
|
@ -18,7 +18,7 @@ class ComponentRegistry
|
|||
{
|
||||
///Return the existing component if it matches
|
||||
if(_componentLookup.ContainsKeyAlt<StringView>(name)
|
||||
&& Components[_componentLookup[scope .(name)]].[Friend]_packedEntities.[Friend]_size == size)
|
||||
&& Components[_componentLookup[scope .(name)]].[Friend]_packedEntities.[Friend]_sizeof == size)
|
||||
return _componentLookup[scope .(name)];
|
||||
else if(_componentLookup.ContainsKeyAlt<StringView>(name))
|
||||
{
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
namespace Theater_ECS.Example;
|
||||
|
||||
using System;
|
||||
|
||||
struct Position
|
||||
{
|
||||
public float x = (.)gRand.NextI32() % 25;
|
||||
public float y = (.)gRand.NextI32() % 25;
|
||||
|
||||
public void Update(float a, float b) mut
|
||||
{
|
||||
x += a;
|
||||
y += b;
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
namespace Theater_ECS;
|
||||
using Theater_ECS.Example;
|
||||
using Theater_ECS.Containers;
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
ECS e = scope .();
|
||||
MovementSystem s = scope .();
|
||||
s.RegisterSystem(e);
|
||||
|
||||
|
||||
for(int32 i < 500000)
|
||||
{
|
||||
var entity = e.Entity_Create();
|
||||
e.[Friend]_compRegistry.Components[s.[Friend]_Components[0]].Add(entity, &Position());
|
||||
e.[Friend]_compRegistry.Components[s.[Friend]_Components[1]].Add(entity, &Velocity());
|
||||
}
|
||||
|
||||
|
||||
System.Diagnostics.Stopwatch watch = scope .();
|
||||
for(int o < 10)
|
||||
{
|
||||
watch.Start();
|
||||
for(int ii < 10)
|
||||
{
|
||||
|
||||
s.RunSystem(e);
|
||||
|
||||
}
|
||||
Console.WriteLine(scope $"{watch.ElapsedMilliseconds}ms");
|
||||
watch.Stop();
|
||||
watch.Reset();
|
||||
}
|
||||
//Console.Read();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct waste
|
||||
{
|
||||
uint32[4] asd;
|
||||
}
|
||||
/*
|
||||
A definition of the functionality and usage of the Theater-ECS
|
||||
|
||||
Goals:
|
||||
- Fast
|
||||
The target is handling the maximum alive at one point amount ~1 048 000 components in a single frame
|
||||
- Use what you need
|
||||
Allocations should be kept at a minimum (Paging), and components and systems should not be tracked unless they
|
||||
are used and the user explicitly asks for them
|
||||
- Dynamic
|
||||
The ecs should by default be fully dynamic, meaning supporting abitrary systems and components.
|
||||
Also Types should not be hardlocked to a single component, so that one type can be used for multiple
|
||||
components.
|
||||
|
||||
Components:
|
||||
- ECS
|
||||
-CreateEntity
|
||||
Create a new entity and return it
|
||||
-DeleteEntity
|
||||
Delete the input identity
|
||||
-IsAlive
|
||||
Check wether a given identity is alive
|
||||
-GetAllData
|
||||
Return Span(ComponentId, void*) containing every component that has data on this entity
|
||||
|
||||
-RegisterComponent
|
||||
Create a new container and return the id of the component
|
||||
-GetComponentId
|
||||
Returns the component id of a given input
|
||||
-AddComponentToEntity
|
||||
creates a component data for the entry and returns a pointer to it
|
||||
-RemoveComponentFromEntity
|
||||
Deataches a component from an entity
|
||||
-GetComponentData
|
||||
Returns a Span<Entity, ComponentData> for a given component
|
||||
|
||||
-RegisterSystem
|
||||
Add a system the the ecs object
|
||||
-RunSystem
|
||||
Run a single run of a system without registering it
|
||||
-RunSystems
|
||||
Run all available systems
|
||||
-GetSystemEnumerator
|
||||
Retrieve an IEnumerable for a given set of component IDS
|
||||
*/
|
|
@ -1,9 +0,0 @@
|
|||
namespace Theater_ECS.Example;
|
||||
|
||||
using System;
|
||||
|
||||
struct Velocity
|
||||
{
|
||||
public float x = (.)gRand.NextI32() % 25;
|
||||
public float y = (.)gRand.NextI32() % 25;
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
namespace Theater_ECS;
|
||||
using Theater_ECS.Containers;
|
||||
using Theater_ECS.Example;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
@ -197,24 +196,3 @@ abstract class System
|
|||
#endregion
|
||||
|
||||
}
|
||||
|
||||
class MovementSystem : System
|
||||
{
|
||||
public override void RegisterSystem(ECS ecs)
|
||||
{
|
||||
RegisterComponent<Position>(ecs);
|
||||
RegisterComponent<Velocity>(ecs);
|
||||
}
|
||||
|
||||
public override void Run(void* pos, void* vel)
|
||||
{
|
||||
((Position*)pos).x += ((Velocity*)vel).x;
|
||||
((Position*)pos).y += ((Velocity*)vel).y;
|
||||
}
|
||||
|
||||
public override void Run(void* pos, void* waste, void* vel)
|
||||
{
|
||||
((Position*)pos).x += ((Velocity*)vel).x;
|
||||
((Position*)pos).y += ((Velocity*)vel).y;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue