# Public native buyer integration

Copyright Black Iron Spine 2026 All Rights Reserved.

This is the native companion to the editable Blueprint provider example. Include `ABKActionBarHostComponent.h` and `ABKActionProviderInterface.h` in your existing game module and add `ActionBarKit` to that module's dependency list. Source files for the minimal provider are shipped under `Source/ActionBarKit/Public/ABKDemoActionProvider.h` and `Source/ActionBarKit/Private/ABKDemoActionProvider.cpp`; read them alongside this page. The public native example records a cooldown and last accepted ID. Your own gameplay owner commits actual effects.

1. Retain your provider as an owned UObject/Actor and your host as a reflected reference. Implement `IABKActionProviderInterface` on that provider. The seven callbacks are `GetActionBarSlots`, `CanTriggerActionSlot`, `TriggerActionSlot`, `MoveActionSlot`, `ClearActionSlot`, `SetActionSlotBoundKey`, and `SetActionSlotBoundChord`; implement their `_Implementation` methods with the exact public signatures.
2. Return your data through `GetActionBarSlots_Implementation`. Positions are positive and unique; keep stable ActionId values when renaming or changing art. The snapshot contains your display, icon, enabled/usable, cooldown/count and complete chord state. Your owner decides assignment and duplicate-key rules.
3. Preflight in `CanTriggerActionSlot_Implementation` without side effects. In `TriggerActionSlot_Implementation`, validate the requested position and ActionId against current owned state, perform your game effect once, then return true. Return false before commitment when permission/resources/cooldown fail. Do not trigger the host recursively from a callback.
4. After both objects are ready, call the public binding API and branch on its actual result:

```cpp
FText Failure;
const bool bConnected = Host->BindActionProvider(Provider, Failure);
if (!bConnected)
{
    // Show/log Failure through your existing UI; another owner remains bound.
    return;
}
const bool bAccepted = Host->RequestTriggerSlot(1);
// true means the provider accepted. Never execute the effect again here.
const TArray<FABKActionSlotViewData>& Snapshot = Host->GetSlots();
```

5. To observe successful requests, declare a reflected `UFUNCTION()` receiver with `void ObserveActivation(const FABKActionSlotRequest& Request)` and use `Host->OnActionActivated.AddUniqueDynamic(this, &YourOwner::ObserveActivation)`. To open your own inventory, declare `UFUNCTION() void OpenInventoryWindow()` and bind `OnBagRequested` to it. A bag request only asks your owner to open its window; it does not create stock, handle wallet transactions or supply an inventory system.
6. During teardown, remove only your own exact callbacks using `RemoveDynamic`, then call `Host->UnbindActionProvider(Provider, true)` while the host is valid. Unbinding another owner's provider must fail. A destroyed provider cannot dispatch a stale standalone action. Keep host/provider lifetime under your game's ownership; do not use a local raw pointer as the only retained reference.
7. Change assignments through `RequestMoveSlot`/`RequestClearSlotConfirmation`; cancel with `CancelClearSlotConfirmation` or confirm with `ConfirmClearSlot`. Read the refreshed `GetSlots()` snapshot to observe accepted state. Complete chords use the public chord functions; the provider retains destination-position key ownership on a move.
8. Apply an `UABKActionBarPreset` for presentation with `InitializeFromPreset`. While your provider is connected it remains the assignment authority. Save UI presentation with `SaveCurrentSetup` and reload with `LoadUserSettings` using the same SaveGameSlotName/UserIndex. Your own gameplay system saves its own resource/assignment state; UI persistence cannot reconstruct gameplay authority.
9. Feed `RecordDamageForDps` only confirmed outgoing damage from your game. Returned DPS is optional presentation, not damage application. Reset with `ResetDpsMeter` at your chosen boundary.
10. For the optional local unarmed example, add `BISActionBarBeginnerAbilities` as an additional module dependency, include `ABKBeginnerAbilityRouterComponent.h`, initialize after local possession, inspect `RequestAutoAttack`'s `FABKAutoAttackResult`, and remove your exact `OnAutoAttackCompleted` receiver before `ShutdownBeginnerAbilityBar`. Hit/miss, reason, applied damage and punch index are returned. This example is local authority-only; it is not a network prediction/GAS or production animation-hit-timing system.

Compile your existing game module with the supported Windows toolchain. Then test: successful bind/request, invalid/missing owner, cooldown/gameplay rejection, outgoing notification once, bag owner response, assignment/key/cancel, save/reload, disconnect and rebind. Check that a callback after cleanup cannot reach the removed receiver. The native example and the Blueprint example must use the same exact installed release candidate.
