byteron / hypecs Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
What does this method do? What is its primary use?
I was looking for a way to find all targets of a relation, e.g.:
world.On(frank).Add(new Owes { Amount = 100 }, bob);
world.On(steve).Add(new Owes { Amount = 200 }, alice);
... and would expect ...
var creditors = world.GetTargets<Owes>(Entity.Any);
//creditors contains bob and alice, both targets of the Owes relation, i.e.
However, the method requires an Identity parameter, which semantically makes no sense to me at this stage. This almost feels like multiple relations would be possible for the same component type.
Also, from looking at the code (I may have misread it), it feels like the target isn't ever stored; only its type fingerprint.
In advance, thank you for offering some clarification :)
Entities have a "generation" associated with them but it is always set to 1 since nothing passes a generation in to the constructor.
Lines 27 to 32 in 2cc54cd
Inside Despawn() we queue up the "unused" id without incrementing the generation
Line 75 in 2cc54cd
and then inside Spawn() we pop that id without incrementing the generation
Line 37 in 2cc54cd
Additionally, functions like IsAlive() do not check the generation at all
Lines 283 to 287 in 2cc54cd
It's easy to reproduce this issue since the despawned ids are used immediately
var entity = world.Spawn().Id();
world.Despawn(entity);
var anotherEntity = world.Spawn().Id();
Assert.IsFalse(entity == anotherEntity); //entity == anotherEntity will return true
Assert.IsTrue(world.IsAlive(anotherEntity));
Assert.IsFalse(world.IsAlive(entity)); // This will of course also be true unexpectedly
The same issue exists in RelEcs Byteron/RelEcs#39
Does HypEcs supersede RelEcs? If I was to start tinkering now, which project should I use?
Archetypes.Queries seems to cache every query it comes across.
There appears no mechanism that invalidates entries in this cache.
This appears to mean that, across the runtime of a game, if you frequently query for specific relations (e.g. to partition a game world into several relationships, think units following specific leaders, locking on to specific objectives, etc.), over time, as these target entities are spawned and despawned and respawned, all the old queries from past generations stick around.
I use relations to partition my game world into sub-worlds (so there's a Tenancy relation targeting the simulation's root Entity). Simulations rarely (but not never - maybe one per second) spawn and despawn, but due to each of them holding its own physics, it seemed like it would make sense to work through the physics and coordinate transfers per-world as fast as possible, in parallel threads.
It seems query objects are actually kind of lightweight, but I wonder what the best approach to invalidate one would be.
I came across a somewhat serious bug in Archetypes.cs
while working on my fork.
This issue comes from the forward-iteration of the table while it has elements being removed from it. This skips every other Entity.
foreach (var tableWithType in tablesWithType)
{
for (var i = 0; i < tableWithType.Count; i++)
{
RemoveComponent(type, tableWithType.Identities[i]);
}
}
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.