From b468f703f9bd782b28e637d2380b5d03fee2bf2e Mon Sep 17 00:00:00 2001 From: TjgL Date: Thu, 23 Jan 2025 21:09:06 +0100 Subject: [PATCH] Added docstrings --- Source/LegumeMix/Public/Ammo/LMAmmoData.h | 8 ++++-- .../{Private => Public}/Player/LMBulletInfo.h | 24 +++++++++++------ Source/LegumeMix/Public/Player/LMPlayer.h | 4 +++ Source/LegumeMix/Public/Weapon/LMWeaponBase.h | 26 ++++++++++++------- .../Public/Weapon/LMWeaponDataStructure.h | 8 ------ .../LegumeMix/Public/Weapon/LMWeaponState.h | 9 +++++++ 6 files changed, 52 insertions(+), 27 deletions(-) rename Source/LegumeMix/{Private => Public}/Player/LMBulletInfo.h (59%) create mode 100644 Source/LegumeMix/Public/Weapon/LMWeaponState.h diff --git a/Source/LegumeMix/Public/Ammo/LMAmmoData.h b/Source/LegumeMix/Public/Ammo/LMAmmoData.h index 89e13f1..06eb078 100644 --- a/Source/LegumeMix/Public/Ammo/LMAmmoData.h +++ b/Source/LegumeMix/Public/Ammo/LMAmmoData.h @@ -14,11 +14,15 @@ struct FLMAmmoData : public FTableRowBase EAmmoType AmmoType; UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin=1, ClampMax=1000, Uimin=1, Uimax=1000)) - int MaxAmmo; + int MaxAmmo = 32; UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin=0, Uimin=0)) - int AmmoCount; + int AmmoCount = 8; + /** + * An utility method to add and + * @param Quantity The quantity of ammo to add. + */ void AddAmmo(const int Quantity) { AmmoCount += UKismetMathLibrary::Clamp(Quantity, 0, MaxAmmo); diff --git a/Source/LegumeMix/Private/Player/LMBulletInfo.h b/Source/LegumeMix/Public/Player/LMBulletInfo.h similarity index 59% rename from Source/LegumeMix/Private/Player/LMBulletInfo.h rename to Source/LegumeMix/Public/Player/LMBulletInfo.h index 855621c..0fe06af 100644 --- a/Source/LegumeMix/Private/Player/LMBulletInfo.h +++ b/Source/LegumeMix/Public/Player/LMBulletInfo.h @@ -7,27 +7,35 @@ struct FLMBulletInfo { GENERATED_BODY() + /** The number of bullets to fire. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) int BulletCount; - + + /** The bullets' origins. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) FVector Origin; - + + /** The main direction vector. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) FVector Direction; - + + /** The Random bullet spread angle deviation. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) - FVector Spread; - + float Spread; + + /** The maximum distance before the bullet reaches minimum damages. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) float MaxDistance; - + + /** A curve multiplicating the damage of a bullet depending on the distance of the target. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) FFloatCurve Falloff; - + + /** The type of bullet that was fired. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) EAmmoType AmmoType; - + + /** The default amount of damage to apply per bullet. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) float Damage; }; diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 91f31d2..0b15b06 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "LMBulletInfo.h" #include "Camera/CameraComponent.h" #include "GameFramework/Character.h" #include "LMPlayer.generated.h" @@ -58,4 +59,7 @@ private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) TObjectPtr Camera; + +private: + FRandomStream SpreadStream; }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponBase.h b/Source/LegumeMix/Public/Weapon/LMWeaponBase.h index da9f54a..6b4839c 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponBase.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponBase.h @@ -4,7 +4,7 @@ #include "CoreMinimal.h" #include "Ammo/LMAmmo.h" -#include "LMWeaponDataStructure.h" +#include "LMWeaponState.h" #include "GameFramework/Actor.h" #include "LMWeaponBase.generated.h" @@ -41,9 +41,9 @@ public: FName GetAttachmentSocketName() const { return WeaponSocket; } protected: /* Weapon Data */ - /** The weapon static data. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) - FLMWeaponDataStructure Data; + /** The sound to play when firing. */ + UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds") + TObjectPtr FireSound; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Animations", meta=(AllowPrivateAccess=true)) TObjectPtr PrimaryFireAnimation; @@ -51,11 +51,13 @@ protected: /* Weapon Data */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Animations", meta=(AllowPrivateAccess=true)) TObjectPtr ReloadAnimation; + /** The flat damage number of one bullet. */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true)) float Damage = 10.f; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true)) - FVector WeaponSpread = FVector::ZeroVector; + /** The max angle deviation of a bullet from the original ray. In degrees.*/ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true, UIMin=0, UIMax=180)) + float WeaponSpread = 10; /** The max distance (cm) between the origin and the target before doing minimal damage. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true)) @@ -69,17 +71,23 @@ protected: /* Weapon Data */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true)) EAmmoType AmmoType; + /** The current number of ammo in the clip. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true)) int ClipAmmo; + /** The maximum amount of ammo in a clip. */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true)) + int MaxClip; + UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category=Legumix) TObjectPtr Player; + /** The current state of the weapon. */ + UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category="Legumix|Weapon") + EWeaponState State; private: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) - FDataTableRowHandle DataTableRow; - + /** An optional socket to attach the weapon to. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) FName WeaponSocket; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h index 20aa20a..7c608af 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h @@ -10,15 +10,7 @@ struct FLMWeaponDataStructure : public FTableRowBase UPROPERTY(EditAnywhere, BlueprintReadWrite) int MaxClipAmmo; - /** Mesh of the weapon display in the scene. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite) - TObjectPtr MeshWeapon; - /** The animation blueprint to animate the mesh. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) TObjectPtr AnimationBluePrint; - - /** The sound to play when firing. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite,Category=Legumix) - TObjectPtr FireSound; }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponState.h b/Source/LegumeMix/Public/Weapon/LMWeaponState.h new file mode 100644 index 0000000..286d769 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMWeaponState.h @@ -0,0 +1,9 @@ +#pragma once + +UENUM(Blueprintable) +enum class EWeaponState : uint8 +{ + EWS_Idle = 0 UMETA(DisplayName = "Idle"), + EWS_Firing = 1 UMETA(DisplayName = "Firing"), + EWS_Reloading = 2 UMETA(DisplayName = "Reloading"), +}; \ No newline at end of file