Class ItemBehaviour
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
[DisallowMultipleComponent]
[RequireComponent(typeof(InteractiveBehaviour))]
[RequireComponent(typeof(AddressableReference))]
[DefaultExecutionOrder(-1)]
public class ItemBehaviour : MonoBehaviour
- Inheritance
-
objectItemBehaviour
Fields
- Container
The container this item is stored IN (e.g. the hero's inventory, a chest, a bag). Set by AddItem(ItemBehaviour, Vector3) / RemoveItem(ItemBehaviour).
- OwnContainer
This item's own inventory container, if this item IS a container (e.g. a bag or chest). Not the same as Container — that tracks where this item is stored.
- Tags
Runtime-only string tags for bot and system use. Not saved or serialized. Common tags:
"no-loot"(auto-loot skips this item). Tags are cleared of"no-loot"automatically when the item enters any inventory.
Properties
- ColorHex
Hex color string for this item's rarity (e.g. "#4D80E6"). Handy for UI mods.
- IsEquipped
Returns true if this item is currently equipped on a character.
- IsWeapon
Returns true if this item is a weapon (has WeaponBehaviour component).
Methods
- CollectSameKindNeighbours(InteractiveBehaviour, HeroController)
Points the hover at every neighbouring item of the same kind, so loot that picks itself up on hover is collected as a whole pile instead of one stack per pass of the pointer.
Why it has to exist: gold, arrows and cursed coins are never dragged - their OnEnable clears OnDrag - and they collect themselves from their hover handler (GoldBehaviour.OnPlayerHover, and the OnHover subscribers in QuiverBehaviour and CursedCoinBehaviour all call PickUp). Hover is therefore the only way to pick them up, and hovering a pile of drops used to collect only the stack the ray happened to hit. The owner asked for the group to come up as a whole (2026-09-23: "when it is grouped, let it collect everything").
Same kind is the displayed name, NOT the GameObject name: names are rewritten for some loot (a cursed coin renames itself to "Coin") and would not survive a rename or a prefab rename. The comparison goes through SameKind(string, int, string, int), the same rule the nameplate piles use. An inactive neighbour is skipped, which is what keeps an already collected stack from being collected twice, and the reentrancy flag stops a neighbour's own hover from scanning the pile again (each neighbour collects itself, exactly once).
- NameAmountPrefixLength(string, int)
Length of the "<amount> " prefix the game writes into a stack's displayed name - "10 Gold" gives 4, "Sword" gives 0. Returned as a length rather than as a cut string, because this is asked for every pair of names, every frame (the nameplate pile rule) and on every pickup (the hover collect): cutting the string out would allocate once per call. The leading number is read digit by digit and has to equal the item's own amount, so a name that merely starts with a digit ("3rd Relic") is never mistaken for a stack prefix.
Why the prefix has to come off at all: ItemBehaviour.GenerateName writes the amount straight into the name, so two gold stacks read "10 Gold" and "15 Gold" - comparing the names as written never matches and nothing of one kind is ever recognised as such (measured 2026-09-23, on the piles).
- SameKind(string, int, string, int)
True when two things are the same kind: their displayed names compared with each stack's own amount taken off, so "10 Gold" and "15 Gold" are both Gold. This is the one rule the nameplate piles and the hover-pickup collect both use, so a pile shown as one label is exactly the set that gets picked up together. Compares in place (no copies of the strings), so it costs no allocation per frame.