expressobits / inventory-system

Modular inventory system for godot 4 with nodes, compatible with multiplayer, separate logic from the UI, Using items as separate resources.
MIT License
407 stars 26 forks source link

Client/Server documentation #61

Closed Mazianni closed 11 months ago

Mazianni commented 11 months ago

Hello!

I am interested in using this inventory system in my project, utilizing a client-server architecture.

The given MP example does not provide an example of this, only P2P handling.

Please provide documentation on this matter!

Mazianni commented 11 months ago

I mean specifically in situations where node structure does NOT match the client 1:1 on the server.

It does not appear that there is support for this?

scriptsengineer commented 11 months ago

Hello, the model you put is to be compatible with the use of Godot's multiplayer, which is a client server, if I'm wrong, point me with details about it,

Mazianni commented 11 months ago

More specifically, I am unsure about the way this plugin handles node structure with it's networking. The represented inventories are on different node paths in my server project than they are on the client; how do I point the client inventory to listen to the server?

Mazianni commented 11 months ago

i.e in NetworkedHandler, it's specifically RPCing the multiplayer authority with the specific path of the inventory. This is not suitable for my project, because my client's inventory is located on a dedicated singleton i.e /root/InventoryManager/InventoryManager/NetworkedInventory

But on the server, the mirror inventory that the client's inventory should be 'talking' to, is located at a path like /root/Server/PlayerManager/1863323922/9bf352b7-842c-4402-a3d3-6890c26560d5/NetworkedHandler/NetworkedInventory.

So taking pick_to_inventory_rpc as an example, the node path provided by the client will not match with the node path on the server, and thus will always return null. @rpc("any_peer") func pick_to_inventory_rpc(pick_object_path : NodePath, object_path : NodePath): if not multiplayer.is_server(): return var pick_object = get_node(pick_object_path) if pick_object == null: return var object = get_node(object_path) if object == null: return var inventory = object as Inventory if inventory == null: return super.pick_to_inventory(pick_object, inventory)

scriptsengineer commented 11 months ago

The idea of the multiplayer example is to complement the asset with a resource that is used by default when a multiplayer is implemented in godot, in this way that you present it has some peculiarities that seem to me to be outside the scope of the plugin, I believe that due to the characteristics of the plugin your multiplayer you should create your own solution for multiplayer with inventory obviously using this plugin as a base.

For example, the server node stores an array of a pair of ints with item and quantity information for each slot, for example, and synchronizes with each player's inventory node.

If this structure is not your intention, I would also indicate if in doubt, see examples of multiplayer from godot https://github.com/godotengine/godot-demo-projects/tree/master/networking

Mazianni commented 11 months ago

What you ask is very difficult, unfortunately, given I do not have a deep grasp on how this plugin functions.

For reference, the provided demo implementation is what would be called 'peer to peer' (p2p), where the server is also a client, instead client-server, where the client and server are separate programs with differing internal structures.

I am not certain that it is feasible to modify this plugin, as it seems to be entirely based in the peer to peer method.

scriptsengineer commented 11 months ago

Multiplayer is just an example of how the core can be used, you can create your own solution and contribute here, but I still believe that creating a server version would be easier with the same structure of nodes. Obs.: The multiplayer example takes Client-Server structure but with Host, You can have several clients connected to the server, be it a client or not.

Mazianni commented 11 months ago

While the core is interesting, the primary issue is that I do not understand how it works enough to build my own version of the plugin to work with my structure, and restructuring my server project is not a viable option given design concerns.

While it's certainly not impossible to achieve the above goals with this plugin, I feel that there is not enough documentation on how the internal processes function in order to achieve my own implementation in a reasonable amount of time.

scriptsengineer commented 11 months ago

I agree, there really is still a lack of good documentation for this plugin, I'll link the issue about documentation here. It would be great if you can contribute by creating a possible structure that would be useful to understand this asset, in my view I intend to divide each script into a page, but we may have topics that go beyond this concept.

See here #9