Inherits: InventoryConstraint
A constraint that limits the inventory to a given weight capacity.
The constraint implements a weight-based inventory where the total sum of the item weights cannot exceed the configured capacity of the inventory.
capacity: float
- Maximum weight the inventory can hold.
get_occupied_space() -> float
- Returns the total sum of the item weights.get_free_space() -> float
- Returns the available space in the inventory.get_item_weight(item: InventoryItem) -> float
- Returns the weight of the given item (i.e. theweight
property).set_item_weight(item: InventoryItem, weight: float) -> void
- Sets the weight of the given item (i.e. theweight
property).get_space_for(item: InventoryItem) -> int
- Returns the number of times this constraint can receive the given item.has_space_for(item: InventoryItem) -> bool
- Checks if the constraint can receive the given item.reset() -> void
- Resets the constraint, i.e. sets its capacity to default (1.0
).serialize() -> Dictionary
- Serializes the constraint into aDictionary
.deserialize(source: Dictionary) -> bool
- Loads the constraint data from the givenDictionary
.