4.7 KiB
4.7 KiB
State Management Assets — Enums, Structs, Data Asset
UE5 Path:
Content/Framework/State/Assets: 4 Enums + 3 Structs + 1 Data Asset + 1 Component
Enums — Create All (4 assets)
E_PlayerActionState (42 values)
- Content Browser →
Content/Framework/State/ - Right-click → Blueprint → Enumeration
- Name:
E_PlayerActionState
Values to Add:
Idle, Walking, Sprinting, Crouching, Jumping, Falling, Landing,
Sliding, Vaulting, Mantling, Climbing, Swimming, Crawling,
Firing, Aiming, Reloading, Melee, Blocking, Throwing,
Interacting, Inspecting, UsingItem, ConsumingItem,
Hiding, Peeking, HoldingBreath, Lockpicking, Hacking,
Dialoguing, Reading, Examining, Crafting,
Dead, Dying, Unconscious, Staggered, KnockedDown,
CutsceneBound, VoidSpace, Menu, Inventory, Journal
E_OverlayState (18 values)
- Name:
E_OverlayState
Values:
None, Aiming, Firing, Reloading, MeleeAttack, Blocking,
UsingItem, Inspecting, Interacting, Throwing,
HoldingBreath, Peeking, Dialoguing, Injured,
Staggered, Carrying, WristwatchActive, MapActive
E_PlayerVitalSignals (5 values)
- Name:
E_PlayerVitalSignals
Values:
Calm, Elevated, Stressed, Panic, Critical
E_ActionRequestResult (8 values)
- Name:
E_ActionRequestResult
Values:
Granted, Denied, BlockedByForce, AlreadyActive,
InvalidState, RequesterNotFound, CooldownActive, VitalThreshold
Structs — Create All (3 assets)
S_StateChangeRequest
- Content Browser →
Content/Framework/State/ - Right-click → Blueprint → Structure
- Name:
S_StateChangeRequest
| Field | Type |
|---|---|
RequestedState |
GameplayTag |
Requester |
Actor (Object Reference) |
Priority |
Integer |
Reason |
String |
Timestamp |
Float |
S_StateGatingRule
- Name:
S_StateGatingRule
| Field | Type |
|---|---|
ActionTag |
GameplayTag |
BlockedByStates |
Array<GameplayTag> |
RequiresStates |
Array<GameplayTag> |
BlockedByOverlays |
Array<GameplayTag> |
bRequiresAuthority |
Boolean |
CooldownSeconds |
Float |
RulePriority |
Integer |
S_ActionPermissionResult
- Name:
S_ActionPermissionResult
| Field | Type |
|---|---|
bPermitted |
Boolean |
ResultCode |
E_ActionRequestResult |
BlockingState |
GameplayTag |
BlockReason |
String |
Data Asset — DA_StateGatingTable
Create
- Content Browser →
Content/Framework/State/ - Right-click → Miscellaneous → Data Asset
- Class:
PrimaryDataAsset - Name:
DA_StateGatingTable
Variables to Add
| Variable | Type | Default |
|---|---|---|
GatingRules |
Array<S_StateGatingRule> |
Empty — populate below |
ForceStackRules |
Array<S_StateGatingRule> |
Empty |
Populate GatingRules (37 action rules — key examples)
| Action | Blocked By |
|---|---|
Framework.State.Action.Sprint |
Crouching, Aiming, Firing, Injured |
Framework.State.Action.Fire |
Sprinting, Reloading, Dead, Menu |
Framework.State.Action.Reload |
Sprinting, Firing, Melee, Dead |
Framework.State.Action.Jump |
Crouching, Dead, CutsceneBound |
Framework.State.Action.Interact |
Sprinting, Firing, Dead, Menu |
Framework.State.Action.Hide |
Sprinting, Firing, Carrying |
Framework.State.Action.Melee |
Reloading, Inspecting, Dead |
Framework.State.Action.UseItem |
Dead, Staggered, CutsceneBound |
Framework.State.Action.Crouch |
Sprinting, Falling, Vaulting |
Framework.State.Action.Inspect |
Sprinting, Hiding, Dead, Menu |
Framework.State.Action.Dialogue |
Sprinting, Firing, Hiding, Dead |
Framework.State.Action.Vault |
Crouching, Aiming, Firing, Carrying |
Framework.State.Action.Aim |
Sprinting, Reloading, Melee, Dead |
Framework.State.Action.Menu |
Dead, CutsceneBound (always permitted otherwise) |
Framework.State.Action.Dead |
Always permitted (force-state — overrides everything) |
Component — BPC_StateManager
Already covered in C++ (Source/PG_Framework/Public/Player/BPC_StateManager.h).
Attach to Pawn
- Open player pawn Blueprint
- Add Component → BPC_StateManager
- In Details →
Gating Table→ assignDA_StateGatingTable - Set
Default Action State→Framework.State.Action.Idle
Test It
- All 4 enums created with correct values
- All 3 structs created with correct fields
DA_StateGatingTablepopulated with 37 rules- PIE:
IsActionPermitted(SprintTag)returnsfalsewhen crouching RequestStateChange(Fire)returnsGrantedwhen idleForceStateChange(Dead)→IsActionPermitted(AnyTag)returnsfalseRestorePreviousState()→ previous state restored