To get you head around the ES stuff a sample you can study helps, really. I wrote a blog article about a sample and ported that to the Zay ES wiki into the “Case Studies” section. I guess it could help to see the principles in action.
In very short:
Entity is just an id
Components are only data so you have only getters there
Systems care about the logic and what happens with the entities.
The newer Zay ES hast some kind of WatchEntity object to deal better with that, on the writting of my space invader there was none such thing, so I had to do it that way. I could control more ships (could be an upgrade) yes
Maybe I will adjust it maybe not, it is not that important to me.
yes that’s the idea and that’s the beauty IMO as it is completely independent and can be added/removed at any time without bothering much. If you have a set of systems you will be surprised that it can be used for different stuff, see the decay system. And you can by adding removing components to an entity switch on/off behaviours. Need a health bar for trees too? Just add health component to tree entities and you have it (if done already for players, enemies of course), just as an example.
Yeah that’s how I was going about it. Now my main issue is how do I know if the WatchedEntity was removed? SO that I can remove it from the InputManager
Also: Should I save the WatchedEntity in GameAppState so I don’t have to create a new one for every appstate that watches the same entity? Or should I Create a new watched entity from each appstate that uses it?
Yeah I asked my self the same question, as my original invader game (not the one in the blog) did had 3 ships (3 lives), but only one of them “active”. I guess the idea is that a watched entity never disappear from the game and you hold a “state” component instead.
But here I’m pretty unsure maybe @pspeed can shed some light? And honestly that was the reason so far, that I did not change the sample to use WatchedEntity
Your player need a position and a model, like all the other stuff you want on to see. Else it is a little bit pointless IMO?! Your control system do change that position depending with how much speed you travel when you go forward, backward, whatever. The visual system will draw depending on the new position.
Nah… but you do have to update it with applyChanges() periodically. You can watch an entity any time. It’s one of the differences between it and EntitySets.
From one of your earlier posts… ActionComponent(Spatial). Spatials are visual things… they don’t belong in the ES. In something like Model-View-Controller (MVC), Spatials are the view and the ES is the model.