Replies: 1 comment
-
Looks like I missed this, sorry. The Discussions tab doesn't have an indicator, so I simply never clicked it until now. Sorry! I know you've moved on to other projects, but I'll answer the question in case anyone else stumbles across this. I eventually came up with a similar idea on my own. //Call `getComponents()` and immediately convert to `Map`.
var components:Map<String, Dynamic> = entity.getComponents();
//The map now contains the component names and values.
for(name => component in components) {
trace(name + ": " + component);
}
//You can use this to get specific components, but there's no advantage over `entity.get()`.
var string:String = components["String"];
var arrayOfBool:Array<Bool> = components["Array<StdTypes.Bool>"]; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there, I'm also working with the echo library from Deepcake (in fact I'd have forked yours had I realized it existed at the time). I can see you're actively working with it. Have you tackled serialization yet? I'm trying to do it and its kinda been a pain. I'd love to do a something like
entity.getComps
and serialize each component to be saved, but the closest I have is theprint
function that spits out a string that isn't compatible with haxe.Serializer or hxBit.Serializer. If I could get the containers to grab all of their components, that'd work too, but I don't see a way to do that.If you haven't tackled it, do you have any thoughts how you'd go about it? The most brute force way I can think of is to make a macro that collects all component classes into an array and tests them against each entity when I serialize them... but man does that feel a tad ridiculous.
Beta Was this translation helpful? Give feedback.
All reactions