Code Design Question

Options
I seem to be chasing my tail at the moment about deciding where to store player stats when the game is in session. Currently I have a list that is synced across all clients that contains information about each clients BoltConnection, BoltEntitiy ,their PlayerCallbacks and a unique ID that can be used to identify them. Originally I was going to start storing data in there as well (just so everything is convenient and in one place for reference). But I quickly realised that having to resync all this data every time a property changed is a huge waste of resources, furthermore working out some bit flagging/marking properties as dirty just hurt my head further. Also, most of the player data should really only be shared between the server and the respective player. Other players don't need to know about the contents of my inventory, how much money I have etc.

I was thinking of just storing the data on each players individual callbacks, rather than in a set list. This way it might be a bit easier to manage syncing (in a way similar to SyncVars in UNET). But any thoughts or design opinions are appreciated.

I should also mention that the reason I'm not just using Bolt's inbuilt state stuff is because some of the data I need to sync is of custom data types, like structs, etc. Also, the player is instantiated on the controlling client, rather than the server. For my controller I need the player to be authoritative on its movement (with the server checking every now and again to make sure it doesn't cheat), but the server to be authoritative of the players stats.

TL;DR: I wish Bolt had SyncVars

Comments

  • Wizzard
    Wizzard
    edited September 2015
    Options
    You can mix authoritative and non-authoritative code with the built-in states.
    They can be used in the same exact way as SyncVars, but also a lot more ways.
    Manmax75 said:

    I should also mention that the reason I'm not just using Bolt's inbuilt state stuff is because some of the data I need to sync is of custom data types, like structs, etc.

    Bolt supports custom structures in states via "objects" in the assets window.
    You can consider extending the generated object in order to add methods to it.