Anything using this component should be considered an item. Required to interact with inventories.
Verse using statement |
using { /UnrealEngine.com/Itemization } |
Inheritance Hierarchy
This class is derived from component.
| Name | Description |
|---|---|
component |
Base class for authoring logic and data in the SceneGraph. Using components you can author re-usable building blocks of logic and data which can then be added to entities in the scene. Components are a very low level building block which can be used in many ways. For example:
As components are generic there is no specific way that they must be used. It is up to the needs of your experience if you use one big game component or if you break up logic into many small components. Classes deriving from component must also specify Only one instance of a component from each subclass group can be added to an entity at a time. For example, given this group of components, only one light_component can exist on a single entity. To create multiple lights you should use multiple entities. light_component := class ============================================================================== Component Lifetime Components move through a series of lifetime functions as they are added to entities, added to the scene, and begin running in the simulation. Components should override these methods to perform setup and run their simulation. As a component shuts down it will then move through shutdown version of these
functions, giving users the opportunity to clean up any retained state on the
component before it is disposed
.
Lifetime Methods:
OnAddedToScene
OnBeginSimulation -> OnSimulate |
Members
This class has both data members and functions.
Data
| Data Member Name | Type | Description |
|---|---|---|
Categories |
[]item_category |
Categories which this item can belong to. Note that some projects may only use the first entry. |
ChangeEquippedEvent |
listenable(payload) |
Broadcast when this item is equipped or unequipped. |
ChangeInventoryEvent |
listenable(payload) |
Broadcast when this item changes inventory. |
ChangeMaxStackSizeEvent |
listenable(payload) |
|
ChangeStackSizeEvent |
listenable(payload) |
|
Entity |
entity |
The parent entity of this component.
|
MaxStackSize |
??int |
Maximum stack size for this item. |
MergeableItemComponentClasses |
[]castable_subtype(item_component) |
List of item_component classes we can be merged with. |
StackSize |
?int |
Current stack size of this item. |
TickEvents |
?tick_events |
Set callbacks to |
Functions
| Function Name | Description |
|---|---|
CanMergeInto |
Succeeds if this item can be merged into the target item. Merging an entity with itself will always fail. |
Drop |
Removes the item from its inventory and places it in the simulation world. Works on orphaned items i.e. outside the world or any inventory. Fails if the item is already a pickup. The transform of the item will not be altered except to unparent it from any inventory. |
Equip |
Attempts to equip this item within the inventory it is currently in. Fails if not in an inventory or if equip_item_query_event contains any errors after querying. |
GetParentInventory |
Returns the inventory_component this item currently resides in. Fails if it cannot find a valid parent inventory. |
IsEquipped |
Succeeds if this item is considered currently within an inventory and equipped. |
IsInScene |
Succeeds if the component is currently in the scene.
|
IsSimulating |
Succeeds if the component is currently simulating.
|
MergeInto |
Attempts to merge this item into the specified item. Fails if items cannot be merged or no items are moved. If TargetAmount is specified, only that amount will try to be merged into this item. |
OnAddedToScene |
Called when the component is added to the scene by parenting it under the simulation entity or another entity already in the scene.
|
OnBeginSimulation |
|
OnBeginSimulation |
Called when the component begins simulating within the scene.
|
OnEndSimulation |
|
OnEndSimulation |
Called when the component ends simulation within the scene.
|
OnRemovingFromScene |
Called when the component is about to be removed from the scene.
|
OnSimulate |
Called when the component begins simulating within the scene.
|
PickUp |
Fails if this item is already in an inventory, or the inventory cannot accept the item. |
RemoveFromEntity |
Removes the component from the entity.
|
SendDown |
Send a scene event to this component. Return true to consume the event and halt propogation. |
SetMaxStackSize |
Sets the maximum stack size for this item. If ClampStackSize is true, StackSize will be clamped to NewMaxStackSize. |
SetStackSize |
Sets the stack size of this item. |
Take |
Takes the specified amount of this item's stack, reducing this item's stack size in the process. If taking the exact (full) amount, the item itself should be returned instead. There is no default implementation of Take i.e. by default, it will fail. If you want to allow this, you must override Take and return an entity containing a new item_component. This new entity should not be in any inventory. See the online documentation for more details. |
Unequip |
Attempts to unequip this item. Fails if not in an inventory, not currently equipped or if unequip_item_query_event contains any errors after querying. |