You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a turn-based game where the turn order of my entities is managed using ArraySchema<string>. The element at index 0 is the current acting entity. I use turnOrder.shift() to change the turn.
I've noticed that when elements are removed from the ArraySchema, the key of the elements is not updated to match the element's index in the array. I wonder if this is correct behaviour?
Also, when I use clear to clear the ArraySchema and then push a new element to the array, the keys do not start counting from 0 and it seems like the $refId of the ArraySchema just keeps increasing.
Some time ago I had a similar project created using Colyseus 0.14 where I used the same logic for managing the turn order. I don't recall ArraySchema exhibiting this kind of behaviour.
I'm not that familiar with how the Schema internals work, but as an experiment I added this.$refId = 0; inside the clear method and that "fixes" the issue for me, at least for the clear function (it probably breaks something too, haha).
I did notice a few people mention this issue in Colyseus Discord channel, but seems like there was no good fix proposed for it.
The text was updated successfully, but these errors were encountered:
(Another workaround that might work is using array.at() / array.setAt() instead of the array accessor, but also not ideal, this should be properly fixed in the future)
Hi,
I'm working on a turn-based game where the turn order of my entities is managed using
ArraySchema<string>
. The element at index 0 is the current acting entity. I useturnOrder.shift()
to change the turn.I've noticed that when elements are removed from the
ArraySchema
, the key of the elements is not updated to match the element's index in the array. I wonder if this is correct behaviour?Also, when I use
clear
to clear theArraySchema
and then push a new element to the array, the keys do not start counting from 0 and it seems like the$refId
of theArraySchema
just keeps increasing.Some time ago I had a similar project created using Colyseus 0.14 where I used the same logic for managing the turn order. I don't recall
ArraySchema
exhibiting this kind of behaviour.I'm not that familiar with how the Schema internals work, but as an experiment I added
this.$refId = 0;
inside theclear
method and that "fixes" the issue for me, at least for theclear
function (it probably breaks something too, haha).I did notice a few people mention this issue in Colyseus Discord channel, but seems like there was no good fix proposed for it.
The text was updated successfully, but these errors were encountered: