153 lines
4.7 KiB
Markdown
153 lines
4.7 KiB
Markdown
# 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)
|
|
1. Content Browser → `Content/Framework/State/`
|
|
2. Right-click → **Blueprint → Enumeration**
|
|
3. 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)
|
|
1. 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)
|
|
1. Name: `E_PlayerVitalSignals`
|
|
|
|
**Values:**
|
|
```
|
|
Calm, Elevated, Stressed, Panic, Critical
|
|
```
|
|
|
|
### E_ActionRequestResult (8 values)
|
|
1. Name: `E_ActionRequestResult`
|
|
|
|
**Values:**
|
|
```
|
|
Granted, Denied, BlockedByForce, AlreadyActive,
|
|
InvalidState, RequesterNotFound, CooldownActive, VitalThreshold
|
|
```
|
|
|
|
---
|
|
|
|
## Structs — Create All (3 assets)
|
|
|
|
### S_StateChangeRequest
|
|
1. Content Browser → `Content/Framework/State/`
|
|
2. Right-click → **Blueprint → Structure**
|
|
3. Name: `S_StateChangeRequest`
|
|
|
|
| Field | Type |
|
|
|-------|------|
|
|
| `RequestedState` | `GameplayTag` |
|
|
| `Requester` | `Actor` (Object Reference) |
|
|
| `Priority` | `Integer` |
|
|
| `Reason` | `String` |
|
|
| `Timestamp` | `Float` |
|
|
|
|
### S_StateGatingRule
|
|
1. Name: `S_StateGatingRule`
|
|
|
|
| Field | Type |
|
|
|-------|------|
|
|
| `ActionTag` | `GameplayTag` |
|
|
| `BlockedByStates` | `Array<GameplayTag>` |
|
|
| `RequiresStates` | `Array<GameplayTag>` |
|
|
| `BlockedByOverlays` | `Array<GameplayTag>` |
|
|
| `bRequiresAuthority` | `Boolean` |
|
|
| `CooldownSeconds` | `Float` |
|
|
| `RulePriority` | `Integer` |
|
|
|
|
### S_ActionPermissionResult
|
|
1. Name: `S_ActionPermissionResult`
|
|
|
|
| Field | Type |
|
|
|-------|------|
|
|
| `bPermitted` | `Boolean` |
|
|
| `ResultCode` | `E_ActionRequestResult` |
|
|
| `BlockingState` | `GameplayTag` |
|
|
| `BlockReason` | `String` |
|
|
|
|
---
|
|
|
|
## Data Asset — DA_StateGatingTable
|
|
|
|
### Create
|
|
1. Content Browser → `Content/Framework/State/`
|
|
2. Right-click → **Miscellaneous → Data Asset**
|
|
3. Class: `PrimaryDataAsset`
|
|
4. 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
|
|
1. Open player pawn Blueprint
|
|
2. **Add Component → BPC_StateManager**
|
|
3. In Details → `Gating Table` → assign `DA_StateGatingTable`
|
|
4. 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_StateGatingTable` populated with 37 rules
|
|
- [ ] PIE: `IsActionPermitted(SprintTag)` returns `false` when crouching
|
|
- [ ] `RequestStateChange(Fire)` returns `Granted` when idle
|
|
- [ ] `ForceStateChange(Dead)` → `IsActionPermitted(AnyTag)` returns `false`
|
|
- [ ] `RestorePreviousState()` → previous state restored
|