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:
Lefteris Notas
2026-05-19 18:37:42 +03:00
parent f272257cb3
commit eeb1bf82c9
11 changed files with 1361 additions and 11 deletions

View File

@@ -51,4 +51,125 @@
## 7. Reuse Notes
- Generic base for all "press E to use" world objects
- Can be subclassed for specialized behavior
- Can be subclassed for specialized behavior
---
## 8. Manual Implementation Guide
### 8.1 Class Setup
1. Create Blueprint Class: Parent = `ActorComponent`, Name = `BPC_UsableWorldObjectSystem`
2. Attach to any world actor that should be "usable" (switches, buttons, valves, terminals, notes, audio logs)
3. The owner actor must implement `I_Interactable` (or this component implements it on behalf of owner)
### 8.2 Variable Initialization (BeginPlay)
```
Event BeginPlay
├─ Set bIsActive = true
├─ Set bHasBeenUsed = false
├─ Load InteractionData (Data Asset reference)
│ ├─ Read PromptText → store for UI
│ ├─ Read InteractionDuration → for hold interactions
│ └─ Read ObjectType → set behavior mode
└─ Set LinkedActor from owner variable (designer-assigned in editor)
```
### 8.3 Function Implementations
#### `OnUse(Instigator: Actor)` → `Boolean`
```
[Function: OnUse] — core interaction handler
Step 1: Branch on bIsActive → If false, Fire OnObjectStateChanged(false), Return false
Step 2: Branch on bSingleUse AND bHasBeenUsed:
True → Return false (already used once)
Step 3: Switch on ObjectType:
Case Switch:
- Toggle bIsActive (invert)
- Play switch animation: flip lever/button
- If LinkedActor: call I_Toggleable.Toggle(Instigator) on LinkedActor
- Start CooldownSeconds timer → bIsActive = true after cooldown
Case Button:
- Set bIsActive = false (press in)
- Play button press animation
- Notify LinkedActor if set
- Start timer → spring back: bIsActive = true
Case Valve:
- Begin rotate interaction (player holds E and moves mouse)
- Call Adjust on LinkedActor (I_Adjustable) with rotation delta
- On release: stop adjustment
Case Terminal:
- Call OpenTerminal UI on LinkedActor or self
- Set player input mode to UI Only
- On close → restore input
Case Readable:
- Get NoteText from InteractionData
- Call WBP_JournalDocumentViewer.OpenNote(NoteText)
- Play "paper rustle" sound via SS_AudioManager
Case AudioLog:
- Get AudioClip from InteractionData
- Call SS_AudioManager.PlayDialogue(AudioClip)
- Show subtitle text if available
Case Generic:
- Fire custom dispatcher or call blueprint event OnGenericUse
Step 4: Set bHasBeenUsed = true (if bSingleUse)
Step 5: Fire OnObjectUsed(Instigator)
Step 6: Return true
```
**Nodes:** `Switch on E_UsableObjectType`, `Play Animation`, `I_Toggleable.Toggle`, `Open UI Widget`, `Play Sound`
#### `SetEnabled(bEnabled: Boolean)` → `void`
```
[Function: SetEnabled]
Step 1: Set bIsActive = bEnabled
Step 2: Update visual: enable/disable highlight, change material
Step 3: Fire OnObjectStateChanged(bEnabled)
```
#### `ResetObject()` → `void`
```
[Function: ResetObject]
Step 1: Set bHasBeenUsed = false
Step 2: Set bIsActive = true
Step 3: Reset visual state to default
Step 4: Fire OnObjectStateChanged(true)
```
### 8.4 I_Interactable Implementation (on owner actor)
If the component is on an actor that implements I_Interactable:
```
[Owner Actor: I_Interactable.OnInteract(Instigator)]
Step 1: Get Component by Class (BPC_UsableWorldObjectSystem)
Step 2: Call BPC_UsableWorldObjectSystem.OnUse(Instigator)
[Owner Actor: I_Interactable.CanInteract(Instigator)]
Get UsableComp → Return UsableComp.bIsActive AND NOT (UsableComp.bSingleUse AND UsableComp.bHasBeenUsed)
[Owner Actor: I_Interactable.GetInteractionPrompt()]
Get UsableComp → Return UsableComp.InteractionData.PromptText
```
### 8.5 Blueprint Build Checklist
- [ ] Define enum E_UsableObjectType and create DA_InteractionData with usage config
- [ ] Create BPC_UsableWorldObjectSystem component
- [ ] Add variables: ObjectType, InteractionData, bIsActive, bSingleUse, bHasBeenUsed, CooldownSeconds
- [ ] Implement OnUse with type-switch for all 7 object types
- [ ] Implement SetEnabled / ResetObject
- [ ] Create owner actor (BP_UsableObject) that implements I_Interactable
- [ ] Route I_Interactable calls to this component
- [ ] Set LinkedActor reference for Switch/Button objects
- [ ] Test: place switch → press E → linked light toggles → cooldown → press again