Inventory system with ES

Ok, it’s clear now. Thanks :slightly_smiling_face:

1 Like

Curious to know how do you get list of action names player can do on a selected item in inventory GUI?

for example, if it is food then displays “Eat”
if a tool then displays “Activate”, “Inactivate”, “Drop”
if a potion then displays “Drink”

I think you said you are getting them dynamically?

So do you probably use a “GetItemActionNames” script on item and dynamically fetch action names from the server (with RMI) when an item is triggered in inventory?

or use an ItemActionNames component on item that keeps a list of action names which gets updated dynamically or when calling “UpdateItemActionNames” script?

… or probably just useing an ItemCategory component (e.x. Food, Tool, Potion,…) and based on the category display inventory actions directly from client? :slightly_smiling_face:

i think this actions should be just RAW client code that only check Entity Component/values to decide what actions are possible. (so yes, it can be some category value, or just via Component type)

If client would want to hack/etc, Server would have own protection checks what client try do.

But well, it all depends also how client<->server works, so maybe could do it better.

1 Like

Yes, I will hard code the action names client-side. Anyway, the categories an item can be in, are very limited. An item is either a Food (so action name is “Eat”), or a Tool (so action name is “Equip”), or a Potion (so action name is “Drink”). I can not think of anything else :slightly_smiling_face:

Edit:

Of-course, for example, when the player clicks on a potion item in the inventory panel it will show a button with name “Drink”, when clicked, client will send the item id and the selected action name, “Drink” in this case, then server will check if that item is already in players inventory and if that has such action in it’s action list, and if so then it will run it.

well, it depends how its done, if for equip you have separate component like EquippableComponent, then you can check via component.

But it only help developer to have many components, but lower CPU speed. The more components, the more time it need, instead of just use single var pointer “category” field like you said. so its a good way imo you say.

But if its not BIG open world, its all fine in both cases.

btw.

What idea was going on my mind also, was that you could do some ECS synchronization between client<->server, where when server receive changes, client auto-pull them, and when client make changes, it push auto request to server(and it can accept request or not).

And using reflection just mark which fields/components it refer to.

It would require changes to ECS itself, idk if Zay-ES have something similar already.

But its just an idea.

1 Like

Yes, Zay-ES already does the synchronization between client-server.

1 Like

Yes, something like that. The ‘ObjectActions’ thing is client/server so for an object you can request the list of actions or execute an action by name, etc…

1 Like