-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CR] Implement item type slots for items to be of multiple types. #10402
Conversation
Using a pointer to the ammo type is completely fine here.
This looks like the first step to item composition, likely a very good and useful thing. I don't really find the I have one minor quibble: I'd drop the "_slot" from the name. They're armor properties, you may as well be accessing them as P.S.: Fix yo' compile errors. ;) |
Fix a bug in the consistency checking in item_factory: check tool != null and tool exists. Add checking for it_ammo container being valid.
Also remove an outdated debug message. It does not matter whether the item is armor, the item functions used there will work fine for non-armor.
Instead of assuming that is_* of the item type will only be true for exactly one function (either tool or gun or gunmod or ...) it checks all types. This allows proper initialization for all types in one item. Also do the same thing in item::info. Remove redundant writing of charges=-1, this is already done by item::init. And the check should be directly for count_by_charges, because that what's important here: starting with item::charges > 0 instead of the default -1.
food in a container and food outside of it uses the same code now.
Use item::get_remaining_capacity_for_liquid instead.
This slot stores container content size (not item size).
Removes the IS_ARMOR tag because the presence of the armor slot data makes the item armor.
Compiler errors? What compiler errors. There are now compile errors. (fixed and rebased) I also renamed the
That's the goal. |
This ready to go? |
Awesome, just what I was hoping for. |
Also moves them from being common flags into container specific members. Update documentation, add lines for each container property into the item info data.
I added documentation and moved the container flags into boolean members. Those container flags are now shown in the item description, along with the content size of the container (this already included in some item descriptions but not in all and getting the content size from the item type directly makes sure it's always correct). And I declare this ready. |
Item slots replace (partially) the specific item subtypes: instead of an item type being
it_armor
, it is now of the baseitype
plus an armor slot. The armor slot contains the properties that have previously been stored in theit_armor
.This allows all items types to have armor properties, as all item types can have an armor slot. Access to the armor slot is wrapped in the item class (as was access to members of
it_armor
).The same is done for containers.
I added the armor slot to all bows in archery.json, so they can be worn without modifications, but I'm not a bow person, so this is very much open for discussion. I also added the armor slot the wearable containers.
See #4189
TODO: document the stuffSome things to consider:
I'd like to move the flags SEALS, WATERTIGHT, PRESERVES, RIGID into boolean properties of the container slot. They are of no use and no meaning outside of it (on non-container items).item::charges
for the very same thing (chapters for books, amount of loaded ammo for guns and tools, number of items for ammo and food). This limits the the compatibility: an item can not be a book and a tool (with charges).