Shops.png

ItemDef.png

WeaponDef.png

InvenEquip.png

bool AShootWeapon::EquipModing(EModingSlot ModingSlot, UModingInstance* ModeInstance)
{
	if (ModeInstance == nullptr)
		return false;

	EquipModingMap.Add(ModingSlot, ModeInstance);

	if (ModeInstance->GetModeEffectClass() != nullptr)
	{
		EquipModingEffectClassMap.Add(ModingSlot, ModeInstance->GetModeEffectClass());
	}
	else
	{
		EquipModingEffectClassMap.Remove(ModingSlot);
	}

	ApplyCurrentModing();
	return true;
}

...

void AShootWeapon::ApplyCurrentModing()
{
	FShootWeaponStats ShootStat = ShootWeaponStatBase;

	for (const auto& Pair : EquipModingMap)
	{
		UModingInstance* ModingIns = Pair.Value;
		if (ModingIns == nullptr)
			continue;

		UShootWeaponDefinition* ShootDef = Cast<UShootWeaponDefinition>(ModingIns->GetModeWeaponDef());
		if (ShootDef == nullptr)
			continue;

		FShootWeaponStats& ModingStat = ShootDef->ShootWeaponStat;
		EWeaponModifier ModifierType = ModingIns->GetModeApplyType();
		
		ApplyStat(ModingStat, ModifierType, ShootStat);
	}

	ShootWeaponStat = ShootStat;

	AmmoChangeUIBroadCast();
}

...

void AShootWeapon::ApplyStat(const FShootWeaponStats& ModingStat, EWeaponModifier ModifierType, FShootWeaponStats& OutStat)
{
	switch (ModifierType)
	{
	case EWeaponModifier::EWM_Add:
	{
		OutStat.AttackPower += ModingStat.AttackPower;
		OutStat.AttackRate	+= ModingStat.AttackRate;
		OutStat.Magazine	+= ModingStat.Magazine;
		OutStat.ReloadTime	+= ModingStat.ReloadTime;
		OutStat.SpareAmmo	+= ModingStat.SpareAmmo;
	}
		break;
	case EWeaponModifier::EWM_Percent:
	{
		OutStat.AttackPower *= (1.0f + ModingStat.AttackPower);
		OutStat.AttackRate	*= (1.0f + ModingStat.AttackRate);
		OutStat.Magazine	*= (1.0f + ModingStat.Magazine);
		OutStat.ReloadTime	*= (1.0f + ModingStat.ReloadTime);
		OutStat.SpareAmmo	*= (1.0f + ModingStat.SpareAmmo);
	}
		break;
	case EWeaponModifier::EWM_Multiple:
	{
		OutStat.AttackPower	*= ModingStat.AttackPower;
		OutStat.AttackRate	*= ModingStat.AttackRate;
		OutStat.Magazine	*= ModingStat.Magazine;
		OutStat.ReloadTime	*= ModingStat.ReloadTime;
		OutStat.SpareAmmo	*= ModingStat.SpareAmmo;
	}
		break;
	}
}