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.
49 lines
999 B
49 lines
999 B
// 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()
|
|
{
|
|
|
|
}
|