Hello! I would like to know if anyone here managed to store Colyseus data into the state via a Quadtree.
Thank you in advance,
virtumonde
Hello! I would like to know if anyone here managed to store Colyseus data into the state via a Quadtree.
Thank you in advance,
virtumonde
Hi !
I have done HashMaps but not Quadtree, however I think this is possible as you can nest objects into custom structure, I did not tested but recursivity may not be a problem.
Something like (not tested, just a draft) :
import { Schema, type } from "@colyseus/schema";
class Node extends Schema {
@type([Node])
nodes = new ArraySchema<Node>();
@type([Entity])
entities = new ArraySchema<Entity>();
}
class MyState extends Schema {
@type(Node)
node: Node = new Node();
}
On each Node
you may have 4 child Nodes
, each nodes can have 0 to many Entity
. It may be a good idea to write a NodeManager attached to the State
for building and update the tree !