feat: Enhance interaction and inventory systems with new components and functionality
- Added BPC_UsableWorldObjectSystem for handling various interactable world objects with detailed manual implementation guide. - Introduced BPC_ActiveItemSystem to manage quick slots and active item usage, including cycling and selection logic. - Implemented BPC_DocumentArchiveSystem for managing collectible documents with read tracking and categorization. - Developed BPC_JournalSystem for narrative entries with auto-adding features based on gameplay events. - Created BPC_KeyItemSystem for key management with consumable and persistent key support. - Enhanced BPC_FirearmSystem for ranged weapon mechanics, including hitscan and projectile firing. - Updated BPC_MeleeSystem for melee combat with combo and blocking mechanics. - Established BPC_ReloadSystem for managing weapon reloading processes, including partial reloads and state management.
This commit is contained in:
@@ -370,4 +370,137 @@ Interact_Implementation
|
||||
### Anti-Cheat
|
||||
- Server validates player is within interaction range before opening door.
|
||||
- Server validates key item is in player inventory before unlocking.
|
||||
- Server validates barricade damage source.
|
||||
- Server validates barricade damage source.
|
||||
|
||||
---
|
||||
|
||||
## 14. Manual Implementation Guide
|
||||
|
||||
### 14.1 Class Setup
|
||||
1. Create Blueprint Class: Parent = `Actor`, Name = `BP_DoorActor`
|
||||
2. Add components: `DoorRoot` (SceneComponent), `DoorFrame` (StaticMesh — static), `DoorMesh` (StaticMesh — rotates/slides), `InteractionCollision` (Box or Sphere)
|
||||
3. Implement Interfaces: `I_Interactable`, `I_Persistable`
|
||||
4. Set `Replicates` = true in Class Defaults
|
||||
|
||||
### 14.2 Variable Defaults
|
||||
| Variable | Default |
|
||||
|----------|---------|
|
||||
| `CurrentState` | `Closed` |
|
||||
| `CurrentLockState` | `Unlocked` |
|
||||
| `CurrentBarricadeHealth` | `100.0` |
|
||||
| `AutoCloseDelay` | `3.0` (0 = never) |
|
||||
| `OpenAngle` | `90.0` |
|
||||
| `OpenSpeed` | `2.0` |
|
||||
| `CloseSpeed` | `1.5` |
|
||||
|
||||
### 14.3 Function Node-by-Node
|
||||
|
||||
#### `BeginPlay`
|
||||
```
|
||||
Event BeginPlay
|
||||
→ Cache OwningActor (Self)
|
||||
→ Get DoorMesh by tag/name → Cache DoorMeshComponent
|
||||
→ Spawn Audio Component → Cache DoorAudioComponent
|
||||
→ Apply DefaultState from DoorConfig:
|
||||
Switch on DoorConfig.DefaultState:
|
||||
Closed → (nothing, already closed)
|
||||
Locked → Call LockDoor
|
||||
Open → Call ForceSetState(Open) ← for save/load or pre-opened doors
|
||||
```
|
||||
|
||||
#### `Interact_Implementation(Instigator: Actor)` — I_Interactable
|
||||
```
|
||||
Switch on CurrentState:
|
||||
Closed → Call TryOpen(Instigator)
|
||||
Open → Call TryClose(Instigator)
|
||||
Locked → Call TryUnlockWithItem(Instigator)
|
||||
Branch on result:
|
||||
True → Call UnlockDoor → Call TryOpen(Instigator)
|
||||
False → Call PlayLockedFeedback → Fire OnInteractionFailed
|
||||
Barricaded → Call DamageBarricade(Instigator)
|
||||
If attack breaks barricade → OnBarricadeBroken → SetState Closed
|
||||
Opening/Closing → Return (ignored during animation)
|
||||
```
|
||||
|
||||
#### `TryOpen(Instigator)` — **Must check HasAuthority() for MP**
|
||||
```
|
||||
Branch: CurrentState != Closed → Return false
|
||||
If DoorConfig.IsOneWay:
|
||||
Check player side (dot product of door forward vs player forward)
|
||||
If wrong side → Play locked feedback → Return false
|
||||
SetWeaponState(Opening)
|
||||
Fire OnDoorStateChanged
|
||||
PlayOpenAnimation() ← uses Timeline, not Timer
|
||||
```
|
||||
|
||||
#### `PlayOpenAnimation` — **Key node setup:**
|
||||
```
|
||||
Create Timeline (float track, 0→1 over OpenSpeed seconds)
|
||||
Timeline Update pin:
|
||||
→ Get DoorMesh → Set Relative Rotation:
|
||||
Lerp (Quat): startRotation to startRotation + Rotator(0, OpenAngle, 0) by Timeline Alpha
|
||||
Timeline Finished pin:
|
||||
→ Call OnOpenComplete
|
||||
Play Sound: AudioConfig.OpenSound at DoorMesh location via SS_AudioManager
|
||||
```
|
||||
|
||||
#### `OnOpenComplete`
|
||||
```
|
||||
Set CurrentState = Open
|
||||
Fire OnDoorOpened(Instigator, bIsOpenFromFront)
|
||||
If AutoCloseDelay > 0:
|
||||
Set Timer by Event (AutoCloseDelay) → Call TryClose(Self)
|
||||
Use "Self" as instigator for auto-close
|
||||
Notify LinkedActors with "Open" event
|
||||
```
|
||||
|
||||
#### `TryClose(Instigator)`
|
||||
```
|
||||
Branch: CurrentState != Open → Return false
|
||||
Set CurrentState = Closing
|
||||
Clear AutoCloseTimer (if running — prevents auto-close during manual close)
|
||||
Fire OnDoorStateChanged
|
||||
PlayCloseAnimation()
|
||||
```
|
||||
|
||||
#### `TryUnlockWithItem(Instigator)` → `Boolean`
|
||||
```
|
||||
If CurrentLockState == KeyRequired:
|
||||
Get RequiredItemTag from DoorConfig
|
||||
Get Instigator → Get BPC_InventorySystem → Call HasItemQuantity(RequiredItemTag, 1)
|
||||
If found:
|
||||
If DoorConfig.RemoveItemOnUse:
|
||||
BPC_InventorySystem.RemoveItemByTag(RequiredItemTag, 1)
|
||||
Return true
|
||||
Return false
|
||||
If CurrentLockState == PuzzleLinked:
|
||||
Get LinkedPuzzle → Call IsPuzzleSolved
|
||||
Return result
|
||||
```
|
||||
|
||||
#### `DamageBarricade(Instigator, DamageAmount)`
|
||||
```
|
||||
Branch: CurrentState != Barricaded → Return
|
||||
CurrentBarricadeHealth -= DamageAmount
|
||||
If CurrentBarricadeHealth <= 0:
|
||||
Set CurrentBarricadeHealth = 0
|
||||
Set CurrentState = Closed
|
||||
Fire OnBarricadeBroken(Instigator)
|
||||
Fire OnDoorStateChanged
|
||||
Mark variable dirty (replication)
|
||||
```
|
||||
|
||||
### 14.4 Blueprint Build Checklist
|
||||
- [ ] Create BP_DoorActor with DoorFrame + DoorMesh + InteractionCollision
|
||||
- [ ] Add all config variables (S_DoorConfig, S_DoorAudioConfig, LinkedActors)
|
||||
- [ ] Set DoorMesh mobility to Movable (for rotation during animation)
|
||||
- [ ] Implement I_Interactable with Interact_Implementation
|
||||
- [ ] Build TryOpen/TryClose with state validation
|
||||
- [ ] Create Timeline for door open/close animation (NOT Timer — Timeline for smooth interpolation)
|
||||
- [ ] Implement auto-close timer with reset on re-open
|
||||
- [ ] Build TryUnlockWithItem querying player inventory
|
||||
- [ ] Implement lock/barricade damage with health tracking
|
||||
- [ ] Add DoorAudioComponent for spatialized sounds
|
||||
- [ ] Set up LinkedActors — designer assigns in editor
|
||||
- [ ] Add networking: replicated CurrentState, Server_Interact RPC
|
||||
- [ ] Test: approach → interact → door opens → auto-closes → locked door → use key → unlocks
|
||||
Reference in New Issue
Block a user