82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
// Copyright 2016 Mookie. All Rights Reserved.
|
|
|
|
#include "EBWeaponConfiguration.h"
|
|
#include "EBBulletProperties.h"
|
|
#include "EBGun.h"
|
|
|
|
bool UEBWeaponConfiguration::IsFireModeAvailable(EFireMode FireMode) const
|
|
{
|
|
return FireControlConfig.AvailableFireModes.Contains(FireMode);
|
|
}
|
|
|
|
bool UEBWeaponConfiguration::IsBulletTypeCompatible(UEBBulletPropertiesAsset* BulletType) const
|
|
{
|
|
if (!BulletType)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Check if it's the default bullet type
|
|
if (BulletType == DefaultBulletType)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// Check if it's in the compatible list
|
|
return CompatibleBulletTypes.Contains(BulletType);
|
|
}
|
|
|
|
float UEBWeaponConfiguration::GetEffectiveFireRate(EFireMode FireMode) const
|
|
{
|
|
// Base fire rate
|
|
float BaseFireRate = (FireControlConfig.FireRateMin + FireControlConfig.FireRateMax) / 2.0f;
|
|
|
|
// Adjust based on fire mode
|
|
switch (FireMode)
|
|
{
|
|
case EFireMode::FM_Semiauto:
|
|
return FMath::Min(BaseFireRate, 300.0f); // Cap semi-auto at 300 RPM
|
|
case EFireMode::FM_Auto:
|
|
return BaseFireRate;
|
|
case EFireMode::FM_Burst:
|
|
case EFireMode::FM_InterBurst:
|
|
return BaseFireRate * 1.2f; // Burst fire is slightly faster
|
|
case EFireMode::FM_Gatling:
|
|
return BaseFireRate * 2.0f; // Gatling guns fire much faster
|
|
case EFireMode::FM_Manual:
|
|
return 60.0f; // Manual actions are slow
|
|
case EFireMode::FM_Slamfire:
|
|
return BaseFireRate * 0.8f; // Slamfire is slightly slower
|
|
default:
|
|
return BaseFireRate;
|
|
}
|
|
}
|
|
|
|
FString UEBWeaponConfiguration::GetWeaponDisplayName() const
|
|
{
|
|
if (!Model.IsEmpty())
|
|
{
|
|
return FString::Printf(TEXT("%s %s"), *Manufacturer, *Model);
|
|
}
|
|
return WeaponName;
|
|
}
|
|
|
|
FString UEBWeaponConfiguration::GetFullWeaponName() const
|
|
{
|
|
FString FullName = GetWeaponDisplayName();
|
|
|
|
if (!Caliber.IsEmpty())
|
|
{
|
|
FullName += FString::Printf(TEXT(" (%s)"), *Caliber);
|
|
}
|
|
|
|
return FullName;
|
|
}
|
|
|
|
void UEBWeaponConfiguration::ApplyConfigurationToGun(AEBGun* Gun) const
|
|
{
|
|
if (Gun)
|
|
{
|
|
// Gun->ApplyWeaponConfiguration(const_cast<UEBWeaponConfiguration*>(this));
|
|
}
|
|
}
|