Files
2025-07-04 03:26:03 -07:00

310 lines
9.4 KiB
C++

// Copyright 2016 Mookie. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "EBBulletProperties.h"
#include "EBMaterialResponseMap.h"
#include "EBMagazine.h"
#include "EBWeaponConfiguration.generated.h"
UENUM(BlueprintType)
enum class EFireMode : uint8
{
FM_Auto UMETA(DisplayName = "Full Auto"),
FM_Semiauto UMETA(DisplayName = "Semiauto"),
FM_Burst UMETA(DisplayName = "Burst"),
FM_InterBurst UMETA(DisplayName = "Interruptible Burst"),
FM_Manual UMETA(DisplayName = "Manual"),
FM_Slamfire UMETA(DisplayName = "Slam Fire"),
FM_Gatling UMETA(DisplayName = "Gatling")
};
USTRUCT(BlueprintType)
struct FBarrelConfiguration
{
GENERATED_USTRUCT_BODY()
// Barrel Properties
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Barrel")
float BarrelLength = 16.0f; // inches
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Barrel")
float RiflingTwist = 7.0f; // 1:X twist rate
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Barrel")
float BoreRadius = 0.112f; // inches
// Muzzle Velocity
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics")
float MuzzleVelocityMin = 91440.0f; // cm/s (~3000 fps)
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics")
float MuzzleVelocityMax = 91440.0f; // cm/s (~3000 fps)
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics")
float MuzzleVelocityVariation = 0.02f; // +/- 2% variation
// Accuracy
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Accuracy")
float InherentAccuracy = 0.001f; // MOA in radians
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Accuracy")
float SpreadMin = 0.0f; // radians
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Accuracy")
float SpreadMax = 0.001f; // radians
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Accuracy")
float SpreadBias = 0.0f;
// Recoil
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil")
float RecoilMultiplier = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil")
FVector RecoilDirection = FVector(0, 0, 1);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil")
float RecoilRecoveryTime = 0.2f;
FBarrelConfiguration()
{
BarrelLength = 16.0f;
RiflingTwist = 7.0f;
BoreRadius = 0.112f;
MuzzleVelocityMin = 91440.0f;
MuzzleVelocityMax = 91440.0f;
MuzzleVelocityVariation = 0.02f;
InherentAccuracy = 0.001f;
SpreadMin = 0.0f;
SpreadMax = 0.001f;
SpreadBias = 0.0f;
RecoilMultiplier = 1.0f;
RecoilDirection = FVector(0, 0, 1);
RecoilRecoveryTime = 0.2f;
}
};
USTRUCT(BlueprintType)
struct FFireControlConfiguration
{
GENERATED_USTRUCT_BODY()
// Fire Modes
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fire Control")
TArray<EFireMode> AvailableFireModes;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fire Control")
EFireMode DefaultFireMode = EFireMode::FM_Semiauto;
// Fire Rate
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fire Rate")
float FireRateMin = 600.0f; // RPM
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fire Rate")
float FireRateMax = 650.0f; // RPM
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fire Rate")
float CyclicRateVariation = 0.05f; // +/- 5% variation
// Burst Fire
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Burst Fire")
int32 BurstCount = 3;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Burst Fire")
float BurstCooldown = 0.1f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Burst Fire")
bool bInterruptibleBurst = false;
// Gatling Properties
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gatling")
float GatlingSpoolUpTime = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gatling")
float GatlingSpoolDownTime = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Gatling")
bool bGatlingAutoSpool = true;
// Safety
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Safety")
bool bHasSafety = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Safety")
bool bDefaultSafetyOn = false;
// Trigger
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Trigger")
float TriggerWeight = 5.5f; // pounds
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Trigger")
float TriggerTravel = 0.25f; // inches
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Trigger")
bool bTwoStage = false;
FFireControlConfiguration()
{
AvailableFireModes.Add(EFireMode::FM_Semiauto);
DefaultFireMode = EFireMode::FM_Semiauto;
FireRateMin = 600.0f;
FireRateMax = 650.0f;
CyclicRateVariation = 0.05f;
BurstCount = 3;
BurstCooldown = 0.1f;
bInterruptibleBurst = false;
GatlingSpoolUpTime = 1.0f;
GatlingSpoolDownTime = 1.0f;
bGatlingAutoSpool = true;
bHasSafety = true;
bDefaultSafetyOn = false;
TriggerWeight = 5.5f;
TriggerTravel = 0.25f;
bTwoStage = false;
}
};
USTRUCT(BlueprintType)
struct FReliabilityConfiguration
{
GENERATED_USTRUCT_BODY()
// Reliability
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reliability")
float MalfunctionRate = 0.0001f; // Per round fired
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reliability")
float JamClearTime = 2.0f; // seconds
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reliability")
float DirtSensitivity = 0.1f; // 0-1 scale
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reliability")
float WearFactor = 0.0001f; // Per round fired
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reliability")
int32 ServiceLife = 10000; // Rounds before overhaul
// Environmental
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Environmental")
float TemperatureSensitivity = 0.001f; // Per degree C
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Environmental")
float MinOperatingTemp = -40.0f; // Celsius
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Environmental")
float MaxOperatingTemp = 60.0f; // Celsius
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Environmental")
bool bWaterResistant = true;
FReliabilityConfiguration()
{
MalfunctionRate = 0.0001f;
JamClearTime = 2.0f;
DirtSensitivity = 0.1f;
WearFactor = 0.0001f;
ServiceLife = 10000;
TemperatureSensitivity = 0.001f;
MinOperatingTemp = -40.0f;
MaxOperatingTemp = 60.0f;
bWaterResistant = true;
}
};
UCLASS(BlueprintType)
class EASYBALLISTICS_API UEBWeaponConfiguration : public UDataAsset
{
GENERATED_BODY()
public:
// Weapon Identity
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Info")
FString WeaponName = "M4 Carbine";
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Info")
FString Manufacturer = "Colt";
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Info")
FString Model = "M4A1";
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Info")
FString Caliber = "5.56x45mm NATO";
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Info")
FString Description = "Standard issue carbine";
// Configuration Sections
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Barrel Configuration")
FBarrelConfiguration BarrelConfig;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fire Control Configuration")
FFireControlConfiguration FireControlConfig;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Reliability Configuration")
FReliabilityConfiguration ReliabilityConfig;
// Default Ammunition
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ammunition")
UEBBulletPropertiesAsset* DefaultBulletType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ammunition")
TArray<UEBBulletPropertiesAsset*> CompatibleBulletTypes;
// Magazine Configuration
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Magazine")
int32 DefaultMagazineCapacity = 30;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Magazine")
EMagazineType DefaultMagazineType = EMagazineType::MT_Standard;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Magazine")
bool bAllowMixedAmmo = true;
// Material Response
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics")
UEBMaterialResponseMap* MaterialResponseMap;
// Physics Settings
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physics")
bool bUseMathematicalPhysics = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physics")
bool bUseNewImpactSystem = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Physics")
bool bEnableSpalling = true;
// Networking
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Networking")
bool bReplicateVariables = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Networking")
bool bReplicateShotEvents = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Networking")
bool bClientSideAim = false;
// Utility Functions
UFUNCTION(BlueprintPure, Category = "Weapon Configuration")
bool IsFireModeAvailable(EFireMode FireMode) const;
UFUNCTION(BlueprintPure, Category = "Weapon Configuration")
bool IsBulletTypeCompatible(UEBBulletPropertiesAsset* BulletType) const;
UFUNCTION(BlueprintPure, Category = "Weapon Configuration")
float GetEffectiveFireRate(EFireMode FireMode) const;
UFUNCTION(BlueprintPure, Category = "Weapon Configuration")
FString GetWeaponDisplayName() const;
UFUNCTION(BlueprintPure, Category = "Weapon Configuration")
FString GetFullWeaponName() const;
UFUNCTION(BlueprintCallable, Category = "Weapon Configuration")
void ApplyConfigurationToGun(class AEBGun* Gun) const;
};