PedrelliLuca / ScalarField

A TopDown RPG Game, where magic works by interacting with the environment.
4 stars 0 forks source link

Pickup Interactable #40

Closed PedrelliLuca closed 1 year ago

PedrelliLuca commented 1 year ago

image Current Components (a.k.a. Modules) Diagram for the Inventory and Pickup systems. Arrows are source code dependencies: the black ones are #includes in .h files, and the blue ones are in .cpp files.

@startuml
skinparam sequenceArrowThickness 2
skinparam sequenceParticipant underline
skinparam linetype ortho
skinparam packageStyle rectangle

package InventoryCore {
    class UInventoryItem
    class UInventoryComponent
    class UInventoryPresenterWidget
    class UInventoryWidget
    class UInventoryItemWidget
    interface IItemDropper

    UInventoryComponent --> UInventoryItem
    UInventoryPresenterWidget --> UInventoryWidget
    UInventoryWidget --> UInventoryItem
    UInventoryWidget --> UInventoryItemWidget
    IItemDropper <|-- UInventoryWidget
    UInventoryWidget -[#blue]-> UInventoryComponent
}

package Pickups {
    class UPickupComponent
    interface IPickup
    class UPickupSpawnController
    class UPickupSpawnSettings
    class UPickupSubsystem

    UPickupSubsystem --> UPickupSpawnController
    UPickupSpawnController -[#blue]-> UPickupSpawnSettings
    IPickup <|-[#blue]- UPickupSpawnController
}

IItemDropper <-- UPickupSubsystem
UInventoryItem <-- UPickupSpawnController
IItemDropper <-- UPickupSpawnController
UInventoryComponent <-[#blue]- UPickupSpawnController
UInventoryItem <-- IPickup
UInventoryItem <-- UPickupComponent
UInventoryComponent <-[#blue]- UPickupComponent

package InteractionSystem {
    interface IInteractor
    class UInteractableComponent
}

UPickupComponent --> IInteractor
UPickupComponent --> UInteractableComponent

package InventoryService {
    class UInventorySubsystem
    class UInventoryController

    UInventorySubsystem --> UInventoryController
}

UInventoryComponent <-[#blue]- UInventoryController

package TacticalPauseSystem {
    class UTacticalPauseWorldSubsystem
}

UTacticalPauseWorldSubsystem <-[#blue]- UInventoryController

package WidgetsPresentation {
    class UWidgetsPresenterComponent
}

UInventoryComponent <-- UWidgetsPresenterComponent
UInventoryPresenterWidget <-- UWidgetsPresenterComponent

UInventorySubsystem --> UWidgetsPresenterComponent
UInventoryController --> UWidgetsPresenterComponent

package GameplayUI {
    class UHUDWidget
}

UWidgetsPresenterComponent --> UHUDWidget

@enduml
PedrelliLuca commented 1 year ago

image
High-level overview of the Components Diagram presented above. Arrows are component dependencies: the black ones are public, and the blue ones are private.

@startuml
skinparam sequenceArrowThickness 2
skinparam sequenceParticipant underline
skinparam linetype ortho
skinparam packageStyle rectangle

package InventoryCore {
}
package Pickups {
}
package InteractionSystem {
}
package InventoryService {
}
package TacticalPauseSystem {
}
package WidgetsPresentation {
}
package GameplayUI {
}

InventoryCore <-- Pickups
InventoryCore <-- WidgetsPresentation
InventoryCore <-[#blue]- InventoryService

Pickups --> InteractionSystem

InventoryService --> WidgetsPresentation
InventoryService -[#blue]-> TacticalPauseSystem

WidgetsPresentation --> GameplayUI
@enduml
PedrelliLuca commented 1 year ago

This is what the architecture looks like after the refactor. Stability is in the top to bottom direction. ScalarField is our main module.

image

@startuml
skinparam sequenceArrowThickness 2
skinparam sequenceParticipant underline
skinparam linetype ortho
skinparam packageStyle rectangle

package SkillUserFSM {}
package InventoryCore {}
package InventoryManipulation {}
package InventoryPresenter {}
package WidgetsPresentation {}
package ScalarField {}
package Pickups {}
package AbstractUI {}
package GameplayUI {}

ScalarField --> InventoryManipulation

ScalarField --> WidgetsPresentation
WidgetsPresentation --> InventoryManipulation
WidgetsPresentation --> InventoryPresenter
WidgetsPresentation --> GameplayUI
WidgetsPresentation --> AbstractUI
GameplayUI --> AbstractUI

ScalarField --> Pickups
Pickups -[#blue]-> InventoryManipulation

InventoryPresenter --> InventoryManipulation
InventoryPresenter --> AbstractUI

ScalarField --> InventoryCore
InventoryCore --> InventoryManipulation

ScalarField --> SkillUserFSM
SkillUserFSM -[#blue]-> InventoryManipulation

InventoryManipulation --> AbstractUI

@enduml
PedrelliLuca commented 1 year ago

This is a zoom on the InventoryManipulation module and how InventoryCore, InventoryPresenter, and Pickups depend on it.

image

@startuml
skinparam sequenceArrowThickness 2
skinparam sequenceParticipant underline
skinparam linetype ortho
skinparam packageStyle rectangle

package ScalarField {
    class AScalarFieldPlayerController

    class AScalarFieldPickup
}

package SkillUserFSM {
    class UInventoryLookupState
}

package InventoryCore {
    class UInventoryItem
    class UInventoryComponent

    UInventoryComponent *-- UInventoryItem
}

package InventoryPresenter {
    class UInventoryPresenterWidget
    class UInventoryWidget
    class UInventoryItemWidget

    UInventoryPresenterWidget --> UInventoryWidget
    UInventoryWidget --> UInventoryItemWidget
}

package Pickups {
    class UPickupComponent
}

AScalarFieldPickup --> UPickupComponent

package InventoryManipulation {
    class UInventoryManipulationSubsystem

    class UInventoryToggleController
    class UItemUsageController
    class UPickupSpawnController

    interface IInventoryContainerWidget
    interface IItemInventoryWidget
    interface IItemWidget

    interface IInventory
    interface IItem

    interface IPickup

    struct FItemAddResult

    IInventory --> IItem
    IInventory --> FItemAddResult

    IInventoryContainerWidget --> IInventory
    IInventoryContainerWidget --> IItemInventoryWidget
    IItemInventoryWidget --> IInventory
    IItemWidget --> IItem

    UInventoryManipulationSubsystem --> UInventoryToggleController
    UInventoryManipulationSubsystem --> UItemUsageController
    UInventoryManipulationSubsystem --> UPickupSpawnController

    UInventoryToggleController --> IInventory
    UInventoryToggleController --> IInventoryContainerWidget

    UItemUsageController --> IItemInventoryWidget

    UPickupSpawnController --> IItemInventoryWidget
    UPickupSpawnController --> IPickup
}

AScalarFieldPlayerController --> UInventoryManipulationSubsystem

UInventoryLookupState --> UInventoryManipulationSubsystem

UInventoryItem --|> IItem
UInventoryComponent --|> IInventory

UInventoryPresenterWidget --|> IInventoryContainerWidget
UInventoryWidget --|> IItemInventoryWidget
UInventoryItemWidget --|> IItemWidget
UInventoryItemWidget --> IItem

UPickupComponent --> IItem
UPickupComponent --> IInventory

AScalarFieldPickup --|> IPickup

package InteractionSystem {
    interface IInteractor
    class UInteractableComponent
}

UPickupComponent --> IInteractor
UPickupComponent --> UInteractableComponent

package AbstractUI {
    interface IPawnBindableWidget
    interface IClosableWidget
}

UInventoryToggleController --> IPawnBindableWidget
IInventoryContainerWidget --|> IClosableWidget

@enduml
PedrelliLuca commented 1 year ago

Diagram showing the command + factory pattern realized to queue a single inventory operation at a time during the tactical pause (see here)

image

@startuml
skinparam sequenceArrowThickness 2
skinparam sequenceParticipant underline
skinparam linetype ortho
skinparam packageStyle rectangle

package InventoryManipulation {
    class UItemUsageController
    class UItemUsageCommand
    class UItemUsageCommandFactory

    UItemUsageController --> UItemUsageCommandFactory
    UItemUsageCommandFactory -[#blue]-> UItemUsageCommand

    class UPickupSpawnController
    class UPickupSpawnCommand
    class UPickupSpawnCommandFactory

    UPickupSpawnController --> UPickupSpawnCommandFactory
    UPickupSpawnCommandFactory -[#blue]-> UPickupSpawnCommand
}

package TacticalPauseSystem {
    class UTacticalPauseWorldSubsystem

    interface IPauseCommand
    interface IPauseCommandFactory

    IPauseCommandFactory --> IPauseCommand

    UTacticalPauseWorldSubsystem --> IPauseCommand
}

UItemUsageCommandFactory --|> IPauseCommandFactory
UItemUsageCommand --|> IPauseCommand

UPickupSpawnCommandFactory --|> IPauseCommandFactory
UPickupSpawnCommand --|> IPauseCommand

@enduml