## Public API Reference

- Main Page
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# iPcInventory Struct Reference

This is an inventory property class. More...

`#include <propclass/inv.h>`

List of all members.

## Public Member Functions

virtual bool | AddEntity (iCelEntity *entity, iCelParameterBlock *params)=0
| Add an entity on a given slot using the space system.
virtual bool | AddEntity (iCelEntity *entity)=0
| Add an entity.
virtual void | AddInventoryListener (iPcInventoryListener *listener)=0
| Add an inventory listener.
virtual void | Dump ()=0
| This is a debugging function to dump the contents of the inventory and all constraints.
virtual size_t | FindEntity (const char *name) const =0
| Find the index of some entity in the inventory by name.
virtual size_t | FindEntity (iCelEntity *entity) const =0
| Find the index of some entity in the inventory.
virtual bool | GetConstraints (const char *charName, float &minValue, float &maxValue, float &totalMaxValue) const =0
| Get the constraints for some characteristic.
virtual float | GetCurrentCharacteristic (const char *charName) const =0
| Get the current value for some characteristic.
virtual iCelEntity * | GetEntity (size_t idx) const =0
| Get some entity.
virtual size_t | GetEntityCount () const =0
| Get the number of entities in this inventory.
virtual iCelEntity * | GetEntitySlot (iCelParameterBlock *params) const =0
| Get an entity from a generic slot (space system).
virtual iCelInventorySpace * | GetSpace ()=0
| Get the used space manager.
virtual bool | HasStrictCharacteristics (const char *charName) const =0
| Return the value of 'strict characteristics'.
virtual bool | In (const char *name) const =0
| Test if some entity is in the inventory by name.
virtual bool | In (iCelEntity *entity) const =0
| Test if some entity is in the inventory.
virtual void | MarkDirty (const char *charName)=0
| Mark this characteristic as dirty for this inventory and all inventories this entity is in.
virtual bool | RemoveAll ()=0
| Remove all entities.
virtual void | RemoveAllConstraints ()=0
| Remove all constraints.
virtual void | RemoveConstraints (const char *charName)=0
| Remove constraints for a characteristic.
virtual bool | RemoveEntity (iCelParameterBlock *params)=0
| Remove an entity on a slot using the space system.
virtual bool | RemoveEntity (iCelEntity *entity)=0
| Remove an entity.
virtual void | RemoveInventoryListener (iPcInventoryListener *listener)=0
| Remove an inventory listener.
virtual bool | SetConstraints (const char *charName, float minValue, float maxValue, float totalMaxValue)=0
| Set the constraints for some characteristic.
virtual void | SetSpace (iCelInventorySpace *space)=0
| Set an optional space manager for this inventory.
virtual bool | SetStrictCharacteristics (const char *charName, bool strict)=0
| If true reject any entities that don't have this characteristic.
virtual bool | TestConstraints (const char *charName)=0
| Test constraints for this characteristic for this inventory and all inventories * this entity is in.

## Detailed Description

This is an inventory property class.

This property class can send out the following messages to the behaviour (possibly the behaviour of the child entity too): (add prefix 'cel.parameter.' to get the ID for parameters):

- pcinventory_addchild: new child will be added (entity)
- pcinventory_added: this entity is added as a new child (entity)
- pcinventory_removechild: new child will be removed (entity)
- pcinventory_removed: this entity is removed (entity)

Definition at line 164 of file inv.h.

## Member Function Documentation

virtual bool iPcInventory::AddEntity | ( | iCelEntity * | entity,
|  | iCelParameterBlock * | params |
| ) |  |  | `[pure virtual]`

Add an entity on a given slot using the space system.

Returns false if the entity could not be added (capacity exceeded for example). Note that it is safe to add entities that are already in the inventory. Nothing will happen then and true will be returned. is a generic slot specification (used by iCelInventorySpace).

virtual bool iPcInventory::AddEntity | ( | iCelEntity * | entity | ) | `[pure virtual]`

Add an entity.

Returns false if the entity could not be added (capacity exceeded for example). Note that it is safe to add entities that are already in the inventory. Nothing will happen then and true will be returned.

virtual void iPcInventory::AddInventoryListener | ( | iPcInventoryListener * | listener | ) | `[pure virtual]`

Add an inventory listener.

Inventory listeners are called right before the behaviour is called.

virtual void iPcInventory::Dump | ( |  | ) | `[pure virtual]`

This is a debugging function to dump the contents of the inventory and all constraints.

virtual size_t iPcInventory::FindEntity | ( | const char * | name | ) | const`[pure virtual]`

Find the index of some entity in the inventory by name.

Return csArrayItemNotFound if not in inventory.

virtual size_t iPcInventory::FindEntity | ( | iCelEntity * | entity | ) | const`[pure virtual]`

Find the index of some entity in the inventory.

Return csArrayItemNotFound if not in inventory.

virtual bool iPcInventory::GetConstraints | ( | const char * | charName,
|  | float & | minValue,
|  | float & | maxValue,
|  | float & | totalMaxValue |
| ) |  |  | const`[pure virtual]`

Get the constraints for some characteristic.

Returns false if there are no constraints defined.

virtual float iPcInventory::GetCurrentCharacteristic | ( | const char * | charName | ) | const`[pure virtual]`

Get the current value for some characteristic.

virtual iCelEntity* iPcInventory::GetEntity | ( | size_t | idx | ) | const`[pure virtual]`

Get some entity.

virtual size_t iPcInventory::GetEntityCount | ( |  | ) | const`[pure virtual]`

Get the number of entities in this inventory.

virtual iCelEntity* iPcInventory::GetEntitySlot | ( | iCelParameterBlock * | params | ) | const`[pure virtual]`

Get an entity from a generic slot (space system).

virtual iCelInventorySpace* iPcInventory::GetSpace | ( |  | ) | `[pure virtual]`

Get the used space manager.

virtual bool iPcInventory::HasStrictCharacteristics | ( | const char * | charName | ) | const`[pure virtual]`

Return the value of 'strict characteristics'.

virtual bool iPcInventory::In | ( | const char * | name | ) | const`[pure virtual]`

Test if some entity is in the inventory by name.

virtual bool iPcInventory::In | ( | iCelEntity * | entity | ) | const`[pure virtual]`

Test if some entity is in the inventory.

virtual void iPcInventory::MarkDirty | ( | const char * | charName | ) | `[pure virtual]`

Mark this characteristic as dirty for this inventory and all inventories this entity is in.

If 'charName' == 0 then all characteristics will be marked dirty.

virtual bool iPcInventory::RemoveAll | ( |  | ) | `[pure virtual]`

Remove all entities.

This can fail if removing entities causes upstream inventories to fail its constraints. In that case entities are removed until the first failure. To ensure correct removal for this inventory you should first clear all constraints.

virtual void iPcInventory::RemoveAllConstraints | ( |  | ) | `[pure virtual]`

Remove all constraints.

virtual void iPcInventory::RemoveConstraints | ( | const char * | charName | ) | `[pure virtual]`

Remove constraints for a characteristic.

virtual bool iPcInventory::RemoveEntity | ( | iCelParameterBlock * | params | ) | `[pure virtual]`

Remove an entity on a slot using the space system.

This can fail if removing an entity causes an upstream inventory to fail its constraints. is a generic slot specification (used by iCelInventorySpace). It can also contain additional information to specify which entity to remove from some slot (if stacked items are supported).

virtual bool iPcInventory::RemoveEntity | ( | iCelEntity * | entity | ) | `[pure virtual]`

Remove an entity.

This can fail if removing an entity causes an upstream inventory to fail its constraints.

virtual void iPcInventory::RemoveInventoryListener | ( | iPcInventoryListener * | listener | ) | `[pure virtual]`

Remove an inventory listener.

virtual bool iPcInventory::SetConstraints | ( | const char * | charName,
|  | float | minValue,
|  | float | maxValue,
|  | float | totalMaxValue |
| ) |  |  | `[pure virtual]`

Set the constraints for some characteristic.

There is a min and max value for one entity and also a total max value for the entire inventory.

This function can fail if the new constraints cause current contents to be invalidated.

virtual void iPcInventory::SetSpace | ( | iCelInventorySpace * | space | ) | `[pure virtual]`

Set an optional space manager for this inventory.

If you don't do this then the inventory system will use no space/slot system.

virtual bool iPcInventory::SetStrictCharacteristics | ( | const char * | charName,
|  | bool | strict |
| ) |  |  | `[pure virtual]`

If true reject any entities that don't have this characteristic.

By default this is false which means that the inventory will automatically assume valid values when this characteristic is not present.

This function can fail if this inventory already has contents and entities in this inventory do not satisfy the strict condition.

virtual bool iPcInventory::TestConstraints | ( | const char * | charName | ) | `[pure virtual]`

Test constraints for this characteristic for this inventory and all inventories * this entity is in.

If 'charName' == 0 then all characteristics will be tested.

The documentation for this struct was generated from the following file:

- propclass/inv.h