50 lines
1.5 KiB
Markdown
50 lines
1.5 KiB
Markdown
======server=======
|
|
Server idle tree has single field to synchronize
|
|
|
|
Code gen creates a setter for the field
|
|
|
|
Within the setter, when the value is set, it creates a packet to update the value and submits it
|
|
How does the code gen tool know how to convert the value? How does the code gen tool know how to submit it?
|
|
|
|
For enums, code gen tool creates a function in the behavior tree that converts values into shorts and attaches that value to the packet
|
|
|
|
The code gen tool is given a class name and method name for a method that will take a server packet and submit it over the network
|
|
Specifically, the server function takes an entity and a behavior tree update packet
|
|
|
|
Once this packet is sent, it arrives on client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======client=======
|
|
Client receives a behavior tree update packet
|
|
|
|
client sends this packet to a behavior tree synchronization manager
|
|
|
|
the manager finds the entity with the correct id
|
|
|
|
it then does a lookup against a table generated by the code gen tool
|
|
the table points behavior tree id to class
|
|
it gets the entity data string for the entity pointing to the behavior tree object
|
|
once it finds this object, it updates the value in the object to be the new value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
whole files generated:
|
|
* file containing the whole lookup function that takes behavior tree id number and a raw object, and returns the object cast as the correct class
|
|
|
|
|
|
functions generated:
|
|
* Within server behavior tree
|
|
- Setter that submits the packet
|
|
- Optionally, function to convert enum to short
|
|
* Within client behavior tree
|
|
- Optionally, function to convert short to enum |