player-03 / echoes Goto Github PK
View Code? Open in Web Editor NEWA macro-based Entity Component System framework, focusing on ease of use.
License: MIT License
A macro-based Entity Component System framework, focusing on ease of use.
License: MIT License
Do you use vscode with the Haxe compilation server mode? I had a lot of ramp up issues when using Echoes because macro issues would often get the server into a permanent broken state.
Now I trained myself to restart the Haxe compilation server whenever I see huge cryptic compiler errors :)
Just wanted to point this out in case anyone searches for the this. It's probably an issue in Haxe, but hard to repro. But maybe there are things this repo could do to avoid falling into those issues.
Sorry that I don't have a repro case right now.
When I compile a project and set the echoes_profiling
flag, it gives a build error in
System.hx:193: characters 38-52 : Float should be Int
From the code:
public function getStatistics():SystemDetails {
return {
name: Std.string(this)
#if echoes_profiling , deltaTime: __updateTime__ #end
};
}
It looks like __updateTime__
is a Float while deltaTime
is an Int
This framework was designed and implemented by deepcake, and is now maintained by player-03.
This sentence makes me think that https://github.com/deepcake/echo is no longer maintained. Is this really true? Can we add more context? What is the story behind this repo? Why did you create this separate repo? Would be curious to know :)
EDIT: maybe we can add a note to deepcake/echo
pointing here if it's really true that it is now maintained here.
Bear with me; this is complicated.
Due to the order of these two lines, @removed
listeners will be called before the component is actually removed. It's pretty easy to see this in action:
@removed private function onFooRemoved(foo:Foo, entity:Entity):Void {
trace(foo == entity.get(Foo)); //true
}
At first this seems weird but harmless. However, problems arise if you try to replace one component with another.
@removed private function onFooRemoved(foo:Foo, entity:Entity):Void {
entity.add(new Bar());
}
@added private function onFooBar(foo:Foo, bar:Bar):Void {
throw "Entity should not have both Foo and Bar components!";
}
This occurs because during onFooRemoved
, the Foo
component is still there. If you add Bar
, then the entity will be added to ViewOfFooBar
, triggering onFooBar
.
But it gets worse:
@removed private function onFooRemoved(foo:Foo, entity:Entity):Void {
entity.add(new Foo());
}
@update private function updateFoo(foo:Foo):Void {
trace(foo); //null
}
Due to the order of events, Foo
is removed after the add(new Foo())
line, meaning the entity remains in ViewOfFoo
even though the component is gone. Then the view will continue calling updateFoo()
.
Lots of problems caused by that particular ordering of lines. So why don't we just swap them?
The reason is that in order to dispatch @removed
events at all, the entity's components must still exist. One final lookup is performed to find all the arguments to pass.
Possible solutions:
@removed
event using the cached value to fill in the blank. Problem is, dispatchRemovedCallback()
would have to be massively rewritten. I'm not sure such a rewrite is even viable, and if it was, I doubt it'd be efficient.entity.add()
call until after remove()
is fully resolved. Use an event queue or something. Problem is, when you call add()
you expect to be able to call get()
right after.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.