doraku / defaultecs Goto Github PK
View Code? Open in Web Editor NEWEntity Component System framework aiming for syntax and usage simplicity with maximum performance for game development.
License: MIT No Attribution
Entity Component System framework aiming for syntax and usage simplicity with maximum performance for game development.
License: MIT No Attribution
Hi,
First... wow... It's still updated. Good job.
I'm making a terminal game (like in PowerShell or something). I have a problem with creating a game loop. I looked and you used some XNA feature to do it, but that's not gonna work for me.
Should I make a SequentialSystem
and update it in some while(true) kind of loop?
First of all. Great project. I really appreciate it and I'm gonna use it in my own project.
My proposition is, could you create Discord server or something like Discrord, where all users (and you) could cooperate?
Seem to be related to DVFS
Have already something like that in my game prototype, move it here?
Could probavly use World.AliveFlag to enable/disable entities from pool on EntitySet but that would leave the component alive in ComponentPool making World.GetAllComponent and AComponentSystem kinda a false representation. Knowing this on a peoject basis is ok but framework wide seems weird.
Does this need an api to initialize/cleanup entities or is that the user responsability?
Probably goes in pair with #13 and #12
useful collection types:
So it seems my little trick to handle unmanaged and other type with a single method has a problem https://github.com/dotnet/coreclr/issues/23722
Need to do proper runtime detection of unmanaged type!
Hi
Have you thought about implementing staging instead of command buffers?
https://github.com/SanderMertens/flecs/blob/master/Manual.md#staging
What do you think about it?
Adding two filter ComponentEnum in EntitySet to handle one case of those rules would be easy but it would double the checks needed on component change.
It would also be possible to add one filter for each of those rules so that you could define multiple family (WithOneOf<A, B>().WithOneOf<C, D>()
should this be handled as WithOneOf<A, B, C, D>()
or two separate rules?) then each familly would add one check, kinda snowballing...
There may be a way to simplify the rules application so we don't add needless check when a group is not defined. To look into.
bad method names pending
edit: doing it
handling of type with no default constructor can be done using FormatterServices.GetUninitializedObject but require moving to netstandard2.0. wondering if it is okay to lose the compatibility.
Seems no usage of LINQ loops could make this faster?
Hi
Is it possible to detect when the component has changed?
This is important as it greatly simplifies gameplay logic.
Current target API:
public readonly struct Entity
{
public bool IsEnabled { get; } // can't have set because of readonly struct
public void Enable();
public void Disable();
}
Only problem is that disabling an Entity only removes it from EntitySet, its components are still present when doing World.GetAllComponent() and will still be exposed in AComponentSystem<TState, TComponent>.
Need to decide whether this is correct (making an action on a component, independently of its Entity state) or not.
Currently the EntitySetBuilder uses generics on all but WithAny. Generics limits the ability to create entitysets from unknown types at runtime. For example, referring to #20 , the use of generics makes that issue impossible to resolve because type names read from a file cannot be parsed into generic arguments (as of C# 7.2).
Return current world and override with no max count, using max entity count
Look seems to be hot and with boxing. Is it possible to avoid? If not - please add comment why not.
I'm running into this issue regularly and it's pretty easy to reproduce. Basically, the following code ends up falling through to the log
call. Now the odd bit is that it isn't 100% of the time. If I create 50 Entities about 25 of them will exhibit the bug.
entities[i].Remove<BoxCollider>();
var hasBoxCollider = entities[i].Has<BoxCollider>();
if (hasBoxCollider)
Debug.Logger.log("why do we still have a BoxCollider???");
To reproduce
Remove
then check for the Component with Has
I am not sure if this is related or not, but the System is also getting duplicate Entities in the EntitySet:
Any ideas what is going on with this one? I don't see any obvious issues in the Remove
or Has
code paths...
gives an easy way to enable/disable system built in.
Adding this now would break compatibility with existing code, wait for c#8 default interface implementation or screw it let's do it now?
Create global message to enable/disable everything into the framework or leave it to the user?
Is using the flag the callee or the caller responsabilities?
Current target API:
public interface ISerializer
{
public Func<World, Entity> CreateFactory(Stream stream);
// or
public Func<World, IEnumerble<Entity>> CreateFactory(Stream stream);
}
What are your thoughts about the visualization of the world state?
For example, in Entitas (In Unity) we have the ability to see all executing systems and all entities with all components and the ability to add/change/remove components
Maybe you have implemented something for XNA already?
This will be difficult to include in the serialization of the world.
Either find a way to save it or remove the feature for coherence sake.
Benchmark if this is really an issue
I see Tasks are used. May be replace with ValueTask?
There is probably some component type which you do not want serialization (texture, ...), their should be a way to ignore them.
Each EntitySet created add subscriptions for add/remove component operation on entities. Getting a single EntitySet with successive builder creations on the same filter would cut those subscriptions/calls.
Concerned events:
EntityCreated
EntityDisposed
EntityEnabled
?EntityDisabled
?EntityComponentAdded<T>
?EntityComponentRemoved<T>
?EntityComponentEnabled<T>
?EntityComponentDisabled<T>
?First idea was to handle it like #34 but it seems unnatural to pass an observer to a world constructor like for an entityset to me. Also added generic events for component notification would be impossible. Maybe for world events it would be better to use the publish/subscribe mechanism. Also current namespace observer is bad a bad >_<
Next seems will not work in AOT.
Any other approaches? May be client site typed builder-combinator? Compile time code gen?
to give user the possibility to provide custom implementation, not sure if there is some value in it. An empty world can already be used as a hub to communicate across a whole game if needed but it still expose the ecs features so... maybe it would be a good idea to separate the two?
As entities and components are added/removed, the layout in memory may not be in the order of ids since last element takes the place of removed item.
It could be interesting to allow the sorting of the memory through the api to optimize the layout (for example when presenting a frame ect...).
Something like this?
public class World
{
// completely reorder layout to be optimized
public void Optimize();
// reorder layout as long as a cancellation is not requested
public void Optimize(CancellationToken token);
}
Current target API:
public readonly struct Entity
{
public bool IsEnabled<T>();
public void Enable<T>();
public void Disable<T>();
}
some sort of static delegate would be nice to keep inlining possible
This isn't really an issue but an enhancement request. Currently, parenting Entities only allows an Entity to fetch it's children. There is no way to get a parent without looping through all the Entities and enumerating their Children.
When dealing with parented Entities in a spatial system (typical Transform component), you have to calculate the transform matrices top-down which isn't currently possible. Pseudo code:
It's not possible to add/remove components or create/dispose entities when updating a system. There should be an easy mechanism to deffer those action at the end of a multithreading update. Problem is we do not want to stress gc so the model need to be allocation free apart from the initialization. How to handle component operations that way? custom memory allocator?
All Entity operations should be available.
edit: this will probably be used for #20 afterward.
Reproduce by creating a Dummy with a virtual method. Derive from Dummy with a new FlailingDummy, Subscriber method not called by world.Publish.
The reflection strategy doesn't appear to detect SubscriberAttributes on overriden virtual methods.
I don't know this fits in with your design for your ECS.
I propose a addition to ISystem with Added/Removed methods that deal with Entities being added/removed from the world (or activated/deactivated).
This would be useful for dealing with collections that depend on a Entity being active in the world or not and knowing when it is not so that it can be removed from the list/collection.
Even better would be for systems like AEntitySystem to automatically filter Entities based on their relevancy to that system's EntitySet.
Or create a public subscribe event for the end developer to hook into when a entity is added/removed.
If none of those are feasible or in the design strategy, please let me know. If there is a way to do that in the existing design, I'm all ears.
It would be nice to see what you can create with your framework. Also think about adding compiled and zipped games in Relase section on GitHub for quick download ๐
Hi :D
There is one more feature I used all the time in Entitas https://github.com/mzaks/EntitasCookBook/blob/master/chapters/1_ingredients/106_index.md
TLDR: Have an API to find an entity OR entities with a specified component value
Use cases:
What do you think about it?
It's possible to get away with messages, yes.
Hi
Would you use that system for saving/loading in your game?
What could go wrong?
Benchmark if this is worth it
No need for that. See if shifting entities on remove to keep order is also possible perf wise instead of permuting the last entity with the removed one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.