Replies: 3 comments 1 reply
-
|
Hi, The idea makes a lot of sense and Speaking off the top of my head, this is the approach I would take to implement something like that:
Anyways, right now, I would suggest against taking the constraints approach for a few reasons:
Hope this helped. |
Beta Was this translation helpful? Give feedback.
-
|
I opened a separate issue for adding |
Beta Was this translation helpful? Give feedback.
-
|
just out of curiosity, what would be the limitations in having arrays inside prototypes? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on a project that utilizes many different inventory grids with different purposes - a normal inventory, as well as individual slots for equipment, a furnace grid for smelting, a workbench grid for milling, a combining grid for synthesizing, etc.
TL;DR: I'm wondering where I should integrate these new constraints to Gloot to support this functionality for all inventory types in the cleanest way possible. This could also be a feature request, but I'm keen on having it somewhat quickly so I can just add it myself and submit a PR!
Each grid is allowed to accept certain categories of items, but not accept others. I plan to implement this with a blacklist and a required list.
Items will contain a "flags" property which is an array of all the categories they belong to.
A sword might be
[item, equippable, weapon, sword]. A piece of raw meat might be[item, food, raw], whereas cooked meat might be[item, food, cooked, consumable].Blacklist:
Array[Enum.ITEM_CATEGORIES]A list of item categories that cannot be inserted into this inventory. If an item contains any of the blacklisted categories, the item transfer will fail.
Required list:
Array[Enum.ITEM_CATEGORIES]A list of item categories that are required to be inserted into this inventory. If an item does not contain all of the required categories, the item transfer will fail.
Examples of how this is used:
['item'].['food']but a blacklist of['cooked'].['smeltable'].['equipment', 'helmet']but a blacklist of['broken']The goal here being to encode lots of gameplay rules into the required/blacklist system and drastically cut down on bespoke validation logic all over the place - let the inventory system manage all of this for us.
I was looking through the codebase (which I am admittedly not super familiar with) and originally implemented a hacky version of this at the control level. However after digging a bit more, it seems like the
ConstraintManagerand specifically adding a new constraint (or two) for the required vs. blacklist logic might seem like the best course of action. Do you have any advice on how to tackle this problem?Thanks for reading.
Beta Was this translation helpful? Give feedback.
All reactions