#Design: Weapon + Mags + Inventory + Loadout

1 messages · Page 1 of 1 (latest)

heavy tree
#

Gonna make this a thread to not spam too much.

#

This will only be very rough for now, cause I don't have much time.

mint gazelle
#

it's okay

heavy tree
#

Adding "G" as prefix for class names. Stands for "Game", just to be able to write AGCharacter and similar.
"Properties" and "Functions" aren't going to list all of them. Just the ones that are relevant. The classes will probably have a bunch more.

UGItemDefinition : UDataAsset

  • Defines a generic Item Definition that is handled by UGInventoryComponent (explained further down)
  • Read-only META data
  • FPrimaryAssetId::PrimaryAssetType = "ItemDefinition"

Properties

  • ItemId : FGameplayTag
    • Tag representing a unique Id
    • Used for FPrimaryAssetId::PrimaryAssetName
  • ItemActorClass : TSoftClassPtr<AGItem>
    • Actual AGItem class that this UGItemDefinition represents

UGWeaponDefinition : UGItemDefinition

  • FPrimaryAssetId::PrimaryAssetType = "WeaponDefinition"

Properties

  • MagazineItemId : FPrimaryAssetId -> Type: MagazineDefinition
    • Matching Magazine for this Weapon
  • NumMaxMagazines : uint8

UGMagazineDefinition -> UGItemDefinition

  • FPrimaryAssetId::PrimaryAssetType = "MagazineDefinition"

Properties

  • WeaponItemId : FPrimaryAssetId -> Type: WeaponDefinition
    • Matching Weapon for this Magazine
  • NumMaxBullets : uint8

UGLoadout : UDataAsset

  • Defines a generic Loadout definition
  • Read-only META data
  • FPrimaryAssetId::PrimaryAssetType = "Loadout"

Properties

  • LoadoutId : FGameplayTag
    • Tag representing a unique Id
    • Used for FPrimaryAssetId::PrimaryAssetName

UGCharacterLoadout : UGLoadout

  • FPrimaryAssetId::PrimaryAssetType = "CharacterLoadout"

Properties

  • PrimaryWeaponId : FPrimaryAssetId -> Type: WeaponDefinition
  • SecondaryWeaponId : FPrimaryAssetId -> Type: WeaponDefinition
#

UGInventoryComponet : UActorComponent

  • Handles Items

Properties

  • Items : TArray<AGItem>
    • Currently spawned Items, kept alive

Functions

  • AGItem* SpawnItem(const FPrimaryAssetId ItemDefinitionId)
    • Loads the specific UGItemDefinition asset
    • Loads and spawns the ItemActorClass and assigns the loaded UGItemDefinition to it
    • Stores the spawned AGItem within Items array and returns it

AGItem : AActor

  • Generic Item Actor class

Properties

  • ItemDefinition : TObjectPtr<UGItemDefinition>

Functions

  • virtual void Initialize(const UGItemDefinition* InItemDefinition)
    • Used to set inner UGItemDefinition and initialize the specific AGItem
    • Meant to be overridden by child classes to handle more specific UGItemDefinition

AGWeapon : AGItem

  • Weapon-specific Item class
  • Has Properties/Function that are specific for this Item (e.g., a MeshComponent)
  • Overrides Initialize to set itself up

Properties

  • CurrentNumBullets : uint8

AGCharacter : ACharacter

Properties

  • InventoryComponent : UGInventoryComponent
  • Loadout : FPrimaryAssetId -> Type: CharacterLoadout

Functions

  • void Initialize()
    • Loads the specific UGCharacterLoadout asset
    • Asks InventoryComponent to spawn inner UGWeaponDefinitions
    • Either handles equipping of Weapons itself or maybe introduce a Component that handles the Weapons specifically
#

There, enjoy :P If you need more detail on something, let me know. This is mainly the class/properties/function layout.

#

btw, this makes use of UDataAssets and FPrimaryAssetId. If you haven't used that yet, now's the time.

mint gazelle
heavy tree
#

Also keep in mind that this is coming from the mind of someone who's worked with the engine for 10+ years now. This could be overwhelming, idk.

mint gazelle
#

yeah, if i get stuck or couldn't understand. i'll leave a text here?

heavy tree
#

Might take a bit for me to answer though, so just wait a bit if I don't reply.