Good whatever-time-of-day jMonkeys,
my project is in quite a mess currently and tired of tidying it up i decided to move on to some other parts for a couple of days. Thus i started to make some thoughts about networking, ecs, etc.
I have plans to use SimEthereal and Zay-ES and already have looked into the examples some time ago like sim-eth-es which i do understand (always feels like christmas and birthday together when playing around with new libraries)
Now trying to fit my game into the ECS style some questions popped up in my head:
question 1: a models animations are actually view only and not involved in what the server should care about, so how should the client determine the current animations to play? for the model that a specific client controls they could do it locally but how would i go about knowing which animations to play for other players that are in my view? is it reasonable to try to guess animations from known locations and calculate speed etc to decide weather to play walking or running animation? that would be quite limited though or should i add some sort of animation component? or should i seperate it from the ECS yet let it be controlled by the server by say rmi calls or the like?
question 2:i can imagine a HealthSystem, that is interested in all entities that have a health component for example when the healthComponent consists of currentHealth, maxHealth and regenerationPerSecond. So the HealthSystem can continuously regenerate an entities health.
now say i have several sources of damage (so i decide to make Damage an entity) which might have a component like Target that points to the entity that has to take the damage.
How would i do that efficiently? aside from the entitySet watching entities with Health components for the health regeneration, when i have another entitySet watching for entities with DamageTagComponent and TargetComponent, what should that TargetComponent look like? should it be an EntityId so i have to query the entityData for each entityId i find in the changed set to get its health component and deal the damage?
question 3: about threads in networking: for each connection (ie for each channel) on the client one thread is created for reading and one for writing, the clients send() method is threadsafe and message listeners can never be called in parallel even when a message is received via 2 channels simultaneously, thats what i observed, so is that correct?
im wondering about the lines
// Make sure client MessageListeners are called single-threaded
// since it could receive messages from the TCP and UDP
// thread simultaneously.
synchronized (this) {
messageListeners.messageReceived(this, m);
}
in DefaultClient.java on line 498, does it potentially slow down simEthereal dependant on how i implement messageReceived() methods? like should i rather always immediately offload the work from that method? and are rmi calls coming in basically called inside this method too, so all my objects that are called via rmi need to offload their work, too?
On the server, there is 2 threads per channel, regardless of how many clients connect? how does it behave when one client has super low bandwidth, does it stall the thread / channel? i read that there is an internal buffer and when its full it does either block or return some constant, how would i notice that when i try to send some data to a speficic client and that client has low bandwidth but i dont want to spend more than say 1ms to send data to that client so other clients wont have to wait for their messages?
EDIT: i know ConnectorAdapter has a OUTBOUND_BACKLOG and since it has a seperate writer thread per channel those wont interfere, but since i didnt see the thread count increasing on the server when starting a second client, i wonder how the server behanves
and last question: it seems you can register ComponentVisibility instances with the EntityDataWrapper to filter visibility based on some component. But imagine i have 3 more players in my team and several other players that are in enemy teams and i want an entitySet that watches entities with HealthComponent but i want to filter that, however not based on HealthComponent but based on TeamComponent, so i can only see health of those entities that are in my team?
As always, thanks a bunch in advance and many greetings from the shire,
samwise