Skip to content

Design Questions

Why are the Inventory and Equipment Managers separate components?

The Inventory Manager can hold many items and manage their storage, stacks and so on. Equipment is the representation of items in the world, which is usually a smaller set of objects. So they certainly have different scopes.

Another important aspect is when we consider how these components should replicate. Inventory Items are only relevant to the server and their owner, which is good, because like mentioned above, an inventory could store many items and we don't need (or want) to replicate all these items to potentially many clients.

As for the equipment, things are a little different. We want to replicate equipment information to all clients because these affect how a character looks in the world. Thankfully, we have a usually much smaller collection of entities to replicate in the equipment side of things.

When should I use aggregation and when should I use inheritance for my Items?

The system was designed to have aggregation as the preffered method to your items. The tradeoff to that being the way Fragments persist their memories in item instances, which requires look-up operations whenever they must be accessed.

If you think that look-up cost might be too much for your scale, then you might want to consider standardizing your item attributes in a customized Item class, via inheritance, and then creating fragments that can access these attributes directly, instead of performing lookup operations.

Please note that even in the scenario above, aggregation is still being used as Fragments are still applied to items, but the memory design was changed via inheritance, to allow a most direct approach to memory access.