187 lines
4.8 KiB
C++
187 lines
4.8 KiB
C++
// Copyright 2016 Mookie. All Rights Reserved.
|
|
|
|
#include "EBWeaponData.h"
|
|
#include "EBBarrel.h"
|
|
|
|
UEBWeaponData::UEBWeaponData()
|
|
{
|
|
// Set default values
|
|
WeaponName = FText::FromString(TEXT("Weapon"));
|
|
WeaponDescription = FText::FromString(TEXT("A standard weapon"));
|
|
WeaponType = EWeaponType::Rifle;
|
|
WeaponIcon = nullptr;
|
|
WeaponTier = 1;
|
|
|
|
// Visuals
|
|
FirstPersonMesh = nullptr;
|
|
ThirdPersonMesh = nullptr;
|
|
StaticMesh = nullptr;
|
|
|
|
// Ballistics
|
|
BulletProperties = nullptr;
|
|
Damage = 30.0f;
|
|
FireRate = 600.0f;
|
|
MuzzleVelocity = 91440.0f;
|
|
Accuracy = 0.95f;
|
|
RecoilStrength = 1.0f;
|
|
EffectiveRange = 300.0f;
|
|
|
|
// Magazine
|
|
MagazineSize = 30;
|
|
MaxReserveAmmo = 120;
|
|
ReloadTime = 2.5f;
|
|
TacticalReloadTime = 2.0f;
|
|
|
|
// Fire modes
|
|
AvailableFireModes.Add(EFireMode::FM_Auto);
|
|
AvailableFireModes.Add(EFireMode::FM_Semiauto);
|
|
DefaultFireMode = EFireMode::FM_Auto;
|
|
BurstCount = 3;
|
|
|
|
// Attachments
|
|
MuzzleSocketName = TEXT("MuzzleSocket");
|
|
ScopeSocketName = TEXT("ScopeSocket");
|
|
GripSocketName = TEXT("GripSocket");
|
|
LaserSocketName = TEXT("LaserSocket");
|
|
|
|
// Advanced
|
|
WeaponWeight = 3.5f;
|
|
ADSTime = 0.3f;
|
|
SprintToFireTime = 0.25f;
|
|
EquipTime = 0.75f;
|
|
bCanDualWield = false;
|
|
bHasSafety = true;
|
|
bSuppressorCompatible = true;
|
|
|
|
// Niagara advanced features
|
|
bUseGPUSimulation = true;
|
|
bEnableEffectLOD = true;
|
|
WeaponDataInterface = nullptr;
|
|
MaxHeatLevel = 100.0f;
|
|
HeatDecayRate = 10.0f;
|
|
HeatPerShot = 5.0f;
|
|
CurrentHeat = 0.0f;
|
|
|
|
// Debug settings
|
|
bEnableFireDebug = false;
|
|
DebugArrowSize = 100.0f;
|
|
bDebugImpactInfo = false;
|
|
bDebugTrajectory = false;
|
|
bDebugPhysics = false;
|
|
bDebugPerformance = false;
|
|
bDebugBallistics = false;
|
|
bDebugSpalling = false;
|
|
}
|
|
|
|
FString UEBWeaponData::GetWeaponTypeString() const
|
|
{
|
|
switch (WeaponType)
|
|
{
|
|
case EWeaponType::Rifle: return TEXT("Rifle");
|
|
case EWeaponType::Pistol: return TEXT("Pistol");
|
|
case EWeaponType::Shotgun: return TEXT("Shotgun");
|
|
case EWeaponType::SMG: return TEXT("SMG");
|
|
case EWeaponType::LMG: return TEXT("LMG");
|
|
case EWeaponType::Sniper: return TEXT("Sniper");
|
|
case EWeaponType::Launcher: return TEXT("Launcher");
|
|
case EWeaponType::Melee: return TEXT("Melee");
|
|
case EWeaponType::Special: return TEXT("Special");
|
|
default: return TEXT("Unknown");
|
|
}
|
|
}
|
|
|
|
void UEBWeaponData::AddHeat(float Amount)
|
|
{
|
|
float HeatToAdd = (Amount < 0.0f) ? HeatPerShot : Amount;
|
|
CurrentHeat = FMath::Clamp(CurrentHeat + HeatToAdd, 0.0f, MaxHeatLevel);
|
|
}
|
|
|
|
void UEBWeaponData::UpdateHeat(float DeltaTime)
|
|
{
|
|
if (CurrentHeat > 0.0f)
|
|
{
|
|
CurrentHeat = FMath::Max(0.0f, CurrentHeat - (HeatDecayRate * DeltaTime));
|
|
}
|
|
}
|
|
|
|
// ========================================
|
|
// DEBUG UTILITY FUNCTIONS
|
|
// ========================================
|
|
|
|
void UEBWeaponData::SetBulletDebugCategory(const FString& CategoryName, bool bEnabled)
|
|
{
|
|
if (CategoryName == TEXT("Trajectory"))
|
|
{
|
|
bDebugTrajectory = bEnabled;
|
|
}
|
|
else if (CategoryName == TEXT("Impact"))
|
|
{
|
|
bDebugImpactInfo = bEnabled;
|
|
}
|
|
else if (CategoryName == TEXT("Physics"))
|
|
{
|
|
bDebugPhysics = bEnabled;
|
|
}
|
|
else if (CategoryName == TEXT("Performance"))
|
|
{
|
|
bDebugPerformance = bEnabled;
|
|
}
|
|
else if (CategoryName == TEXT("Ballistics"))
|
|
{
|
|
bDebugBallistics = bEnabled;
|
|
}
|
|
else if (CategoryName == TEXT("Spalling"))
|
|
{
|
|
bDebugSpalling = bEnabled;
|
|
}
|
|
}
|
|
|
|
void UEBWeaponData::SetAllBulletDebugCategories(bool bEnabled)
|
|
{
|
|
bDebugTrajectory = bEnabled;
|
|
bDebugImpactInfo = bEnabled;
|
|
bDebugPhysics = bEnabled;
|
|
bDebugPerformance = bEnabled;
|
|
bDebugBallistics = bEnabled;
|
|
bDebugSpalling = bEnabled;
|
|
}
|
|
|
|
FString UEBWeaponData::GetBulletDebugInfo() const
|
|
{
|
|
TArray<FString> EnabledCategories;
|
|
|
|
if (bDebugTrajectory) EnabledCategories.Add(TEXT("Trajectory"));
|
|
if (bDebugImpactInfo) EnabledCategories.Add(TEXT("Impact"));
|
|
if (bDebugPhysics) EnabledCategories.Add(TEXT("Physics"));
|
|
if (bDebugPerformance) EnabledCategories.Add(TEXT("Performance"));
|
|
if (bDebugBallistics) EnabledCategories.Add(TEXT("Ballistics"));
|
|
if (bDebugSpalling) EnabledCategories.Add(TEXT("Spalling"));
|
|
|
|
if (EnabledCategories.Num() == 0)
|
|
{
|
|
return TEXT("No debug categories enabled");
|
|
}
|
|
|
|
return FString::Printf(TEXT("Enabled Debug Categories: %s | Arrow Size: %.0f"),
|
|
*FString::Join(EnabledCategories, TEXT(", ")), DebugArrowSize);
|
|
}
|
|
|
|
void UEBWeaponData::ApplyDebugSettingsToBarrel(class UEBBarrel* Barrel) const
|
|
{
|
|
if (!Barrel)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Apply debug arrow size
|
|
Barrel->DebugArrowSize = DebugArrowSize;
|
|
Barrel->DebugImpactInfo = bDebugImpactInfo;
|
|
|
|
// Apply debug categories through barrel's functions
|
|
Barrel->SetBulletDebugCategory(TEXT("Trajectory"), bDebugTrajectory);
|
|
Barrel->SetBulletDebugCategory(TEXT("Impact"), bDebugImpactInfo);
|
|
Barrel->SetBulletDebugCategory(TEXT("Physics"), bDebugPhysics);
|
|
Barrel->SetBulletDebugCategory(TEXT("Performance"), bDebugPerformance);
|
|
Barrel->SetBulletDebugCategory(TEXT("Ballistics"), bDebugBallistics);
|
|
Barrel->SetBulletDebugCategory(TEXT("Spalling"), bDebugSpalling);
|
|
} |