If I use EntityComponent for the player input, can I look up this input (and remove it once processed) inside of a for-loop going over the EntitySet.getAddedEntities? I can see there’s a method: EntityData.findEntities - maybe that’s more thread-safe ?
Is it safe to remove (one of) the component inside of the EntitySet.getAddedEntities ?
For movement, perhaps its continuously inputted (and the component is not removed). But what about input that may be continuous and may not (firing a laser continuously comes to mind). Server sees and processes the input and removes it right away, or … ?
This is a different case, you do not create a “fire laser” event with ES, when the player wants to fire a laser, the client sends a message to the server through RMI session and the server will spawn a laser entity. When the laser gets destroyed you set a decay component on the laser entity then it will be removed automatically by decay system.
I mean having a system in ES that listens to entities with a FireLaser component (which represents an event) and then creates a laser entity seems to be an OOP stuff and out of ES scope. Maybe I am wrong.
If it’s continuous then there is no reason to remove it. There is always some state… either laser firing or laser not firing.
The reason movement is done this way is because it’s sent unreliably… so you have to send ‘up’ continuously as well as ‘down’.
“Lasers” may work this way but more likely it’s another continuous ‘pressing fire button’ ‘not pressing fire button’… then the server will decide what to do with that information. For example, if the player has a laser equipped then the server-side game session will create the laser beam entity if the button is pressed and the entity is not already created. It will delete the laser beam entity if the button is released and the entity is not null.
The laser beam will deal continuous damage wherever it’s aimed as long as it exists.
If your ‘laser’ is more like the ‘pew pew pew’ blaster variety then the server side session spawns laser bolt entities while the button is pressed and time has expired since the last bolt based on rate of fire.
Never was there a need to add a component to something just to say to create this other things and add a component to it. Down that path eventually leads to crazy if you aren’t carefull. ("See… there’s a button component and a system that looks up the tool and adds a tool component… then a system that looks up the tool component to see what tool is equipped and add the laser component… and then another system to… etc…)
…when a single factory method called early would have been fine.