70 lines
1.3 KiB
C++
70 lines
1.3 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#include "ResComApartmentManager.h"
|
|
|
|
// Sets default values
|
|
UResComApartmentManager::UResComApartmentManager()
|
|
{
|
|
}
|
|
|
|
void UResComApartmentManager::Push(FApartment apartment)
|
|
{
|
|
apartments.Push(apartment);
|
|
}
|
|
|
|
void UResComApartmentManager::ClearFavorites()
|
|
{
|
|
for (auto& ap : apartments)
|
|
ap.favorite = false;
|
|
}
|
|
|
|
bool UResComApartmentManager::IsValid(FApartment apartment) const
|
|
{
|
|
return !(apartment.id == FApartment().id);
|
|
}
|
|
|
|
FApartment& UResComApartmentManager::GetByID(int32 id)
|
|
{
|
|
for (auto& ap : apartments)
|
|
{
|
|
if (ap.id == id)
|
|
return ap;
|
|
}
|
|
return notValid;
|
|
}
|
|
|
|
FApartment& UResComApartmentManager::GetByLoc(FApartmentLocation loc)
|
|
{
|
|
for (auto& ap : apartments)
|
|
{
|
|
if (ap.loc == loc)
|
|
return ap;
|
|
}
|
|
return notValid;
|
|
}
|
|
|
|
|
|
TArray<FApartment> UResComApartmentManager::GetFavorites()
|
|
{
|
|
TArray<FApartment> favorites;
|
|
for (auto& ap : apartments)
|
|
if (ap.favorite)
|
|
favorites.Push(ap);
|
|
return favorites;
|
|
}
|
|
|
|
void UResComApartmentManager::SortByLoc()
|
|
{
|
|
apartments.Sort([](const FApartment& apa1, const FApartment& apa2)
|
|
{
|
|
return apa1.loc.AsNum() > apa2.loc.AsNum();
|
|
});
|
|
}
|
|
|
|
void UResComApartmentManager::SortByID()
|
|
{
|
|
apartments.Sort([](const FApartment& apa1, const FApartment& apa2)
|
|
{
|
|
return apa1.id > apa2.id;
|
|
});
|
|
} |