You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.2 KiB
62 lines
1.2 KiB
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "UpgradeSubsystem.h"
|
|
|
|
#include "UnitUpgrade.h"
|
|
|
|
void UUpgradeSubsystem::ApplyUnitUpgrades(AUnit* Unit)
|
|
{
|
|
for (const auto Upgrade : SelectedUpgrades)
|
|
{
|
|
UUnitUpgrade* UnitUpgrade = Cast<UUnitUpgrade>(Upgrade->GetUpgradeData());
|
|
if(UnitUpgrade != nullptr)
|
|
{
|
|
for (const FString Tag : UnitUpgrade->GetApplicableTags())
|
|
{
|
|
if(Unit->UnitTags.Contains(Tag))
|
|
{
|
|
UnitUpgrade->ApplyToUnit(Unit, Upgrade->GetUpgradeLevel());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void UUpgradeSubsystem::AddUpgrade(UUpgrade* UpgradeToAdd)
|
|
{
|
|
for(const auto Upgrade : SelectedUpgrades)
|
|
{
|
|
if(Upgrade->GetUpgradeData() == UpgradeToAdd)
|
|
{
|
|
Upgrade->IncreaseUpgradeLevel();
|
|
return;
|
|
}
|
|
}
|
|
|
|
USelectedUpgrade* NewUpgrade = NewObject<USelectedUpgrade>();
|
|
NewUpgrade->SetUpgradeData(UpgradeToAdd);
|
|
NewUpgrade->IncreaseUpgradeLevel();
|
|
SelectedUpgrades.Add(NewUpgrade);
|
|
}
|
|
|
|
|
|
|
|
void UUpgradeSubsystem::ApplyGlobalUpgrades()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
USelectedUpgrade* UUpgradeSubsystem::FindSelectedUpgrade(UUpgrade* UpgradeToFind)
|
|
{
|
|
for(USelectedUpgrade* Upgrade : SelectedUpgrades)
|
|
{
|
|
if (Upgrade->GetUpgradeData() == UpgradeToFind)
|
|
{
|
|
return Upgrade;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|