#Design: Weapon + Mags + Inventory + Loadout
1 messages · Page 1 of 1 (latest)
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.
it's okay
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
AGItemclass that thisUGItemDefinitionrepresents
- Actual
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
UGItemDefinitionasset - Loads and spawns the
ItemActorClassand assigns the loadedUGItemDefinitionto it - Stores the spawned
AGItemwithinItemsarray and returns it
- Loads the specific
AGItem : AActor
- Generic Item Actor class
Properties
- ItemDefinition : TObjectPtr<UGItemDefinition>
Functions
- virtual void Initialize(const UGItemDefinition* InItemDefinition)
- Used to set inner
UGItemDefinitionand initialize the specificAGItem - Meant to be overridden by child classes to handle more specific
UGItemDefinition
- Used to set inner
AGWeapon : AGItem
- Weapon-specific Item class
- Has Properties/Function that are specific for this Item (e.g., a MeshComponent)
- Overrides
Initializeto set itself up
Properties
- CurrentNumBullets : uint8
AGCharacter : ACharacter
Properties
- InventoryComponent : UGInventoryComponent
- Loadout : FPrimaryAssetId -> Type:
CharacterLoadout
Functions
- void Initialize()
- Loads the specific
UGCharacterLoadoutasset - Asks
InventoryComponentto spawn innerUGWeaponDefinitions - Either handles equipping of Weapons itself or maybe introduce a Component that handles the Weapons specifically
- Loads the specific
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.
Thank you for this. It'd help me. THANK YOU!
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.
yeah, if i get stuck or couldn't understand. i'll leave a text here?
Might take a bit for me to answer though, so just wait a bit if I don't reply.