// 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(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(); NewUpgrade->SetUpgradeData(UpgradeToAdd); NewUpgrade->IncreaseUpgradeLevel(); SelectedUpgrades.Add(NewUpgrade); } void UUpgradeSubsystem::ApplyGlobalUpgrades() { }