Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Extending Plugin ‒ Creating New Containers

Nazake edited this page Jan 26, 2024 · 1 revision

Creating New Containers

To create a new container, follow these steps:

  1. Create a new actor component that inherits from the GameplayContainerComponent class. If implementing a different type of container, note that inventory, hotbar, and equipment components are available for use.

  2. Create a new Gameplay Tag to represent the container type. Add this tag to the owned tags of the newly created container component to uniquely define its type.

  3. Create a new blueprint class inheriting from GameplayContainerDefinition to define the container, its configuration, and its representation in the user interface. Specify the number and type of slots, the widget for the container, and any supported notifications. Assign this definition to the container component.

  4. Create a new Gameplay Tag to represent the slot type. Then, create a slot definition by making a blueprint that inherits from GameplayContainerSlotDefinition. In this definition, assign the slot type tag, UI widgets, tags for the slot, colors, brushes, sound effects, drag-and-drop operations, etc.

  5. Assign the slot definition to the container definition, specifying how many slots of that type to create.

  6. Optionally, add items to the startup items list for the new container component. This involves assigning an item definition, quantity, and slot type. Check bAddStartupItemsOnBeginPlay in the container component's advanced settings if you want startup items added when BeginPlay is called; otherwise, manually call AddStartupItems as needed.

  7. Ensure your new container is added to an actor (e.g., Character, Pawn, Player state, Player controller, Actor, etc.).

Note: For player-owned containers, register them with an ability system component using RegisterWithAbilitySystem and provide a reference to the ability system. Unregister using UnregisterAbilitySystem when no longer needed and requiring uninitialized state.

Note: For containers not owned by a player or owned by other players, if it meets any conditions you might have for a player to use them, you need to call RegisterUser and then pass in their ability system component reference for a player to be able to use those containers. When done you can call UnregisterUser to unregister the user's ability system component and prevent it from using the other container again.