#INetworkSerliazble abstraction workaround

1 messages · Page 1 of 1 (latest)

edgy bough
#

Hello,

In my game I was going to create an Action System to sync game state between client and server

Usually I would create an abstract class or an interface and inherit from them

but since INetworkSerializable doesn't support that I couldn't

I thought about creating a big struct that includes members for all my actions
and have an enum with the action type

and depending on the action type serialize only the needed values

I think that would work but it feels more like a workaround than a proper solution
What should I do? Is there a better way to do this?

trim sandal
#

I guess it kind of depends on what kind of data you are sending with your Actions. And how many actions you ultimately have. I've used Scriptable Objects sending an ActionID, Target, and Caster.

edgy bough
#

data is a little different for each action hence the separation

I can kind of put them all in one big class but that wouldn't be very clean

I've used Scriptable Objects sending an ActionID, Target, and Caster.
can you elaborate on this? how did you use a scriptable object?

trim sandal
#

My actions(spells) didn't have a lot of different parameters. I had a Resources folder with all the different spells in it that i can load into a big list. Then I could just say that Player 1 cast Spell37 on Player 2 or NPC53.

edgy bough
#

Interesting