#Can you review my code

1 messages · Page 1 of 1 (latest)

cedar yacht
shut stream
#

Which isn't a bad thing if you intended for this to be a template for developers new to multiplayer

cedar yacht
#

Yeah its more like a template and its purpose is to ease the creation of steam lobby having to only worry about UI code

shut stream
# cedar yacht Yeah its more like a template and its purpose is to ease the creation of steam l...

Its been a few months since ive looked at anything facepunch related, so I can't comment on if the code is logically correct.

One thing I notice is the use of OnLobbyEvent and lobbyEvent.
lobbyEvent isn't actually used in this code other than supplying a parameter to OnLobbyEvent. You don't need to store this in a variable, just instead reference the enum directly when invoking the event. for example
OnLobbyEvent?.Invoke(currentLobby, LobbyEvent.HOST_LEAVE);

conflicting to my point above, I don't think this enum is a good idea at all. You'd be forcing anyone using this lobby manager to write one method subscribing to OnLobbyEvent and write a switch statement based on the enum. Some people might just end up using that switch to call their own OnLobbyCreated, OnLobbyEntered, etc methods. It does feel awkward that all of these events are compressed into one.

For the PlayerInfo, make a constructor to require the fields to be passed in the parameters if the friend and isDeveloper are needed. This looks like it could give an error if someone just does new PlayerInfo() which you allow them to do

cedar yacht
#

Thanks for pointing out the PlayerInfo error! I would like the user to get access to those lobby events because they are more than likely needed to create your lobby ui. But is there a better way to handle this?

shut stream
#

if you just want to ensure that your methods are called first, then id just make separate events mimicing the steam ones like an OnLobbyCreated, OnLobbyEntered etc