static FVector2D VectorGPS(FVector loc) {
// Get server grid
const auto grid = static_cast<UShooterGameInstance*>(
ArkApi::GetApiUtils().GetWorld()->OwningGameInstanceField())->
GridInfoField();
// Convert to GPS coords
FVector2D gps;
grid->ServerLocationToGPSLocation(&gps, grid->GetCurrentServerId(), loc);
return gps;
};
static FVector2D ActorGPS(AActor* a) {
// Get actor location
return VectorGPS(a->RootComponentField()->RelativeLocationField());
};
(edited)const int MinFoundations = 30; // could be any number
UWorld* world = ArkApi::GetApiUtils().GetWorld();
TArray<AActor*> new_actors;
TArray<AActor*> actors_ignore;
TArray<TEnumAsByte<enum EObjectTypeQuery>> types;
UKismetSystemLibrary::SphereOverlapActors_NEW(
world,
_this->RootComponentField()->RelativeLocationField(),
static_cast<float>((MinFoundations * 300)),
&types,
APrimalStructure::GetPrivateStaticClass(),
&actors_ignore,
&new_actors);
Notes:
1. where is searches
2. sphere starting position
3. sphere radius
4. actor types
5. actors of which class it looks for
6. actors which are ignored
7. TArray which will get populated with the found actors
(edited)struct FEngramEntries
{
TArray<struct UClass*> EngramEntries;
};
bool CanUnlock(UPrimalEngramEntry* Engram)
{
if (!Engram->bCanBeManuallyUnlocked().Get()) { return false; }
auto EngramRequirementSets = Engram->EngramRequirementSetsField();
for (auto&& E : Engram->EngramRequirementSetsField()) {
for (auto&& F : E.EngramEntries) {
if (!CanUnlock((UPrimalEngramEntry*)F->GetDefaultObject(true))) {
return false;
}
}
}
return true;
}
void UnlockEngrams_Cmd(AShooterPlayerController* PlayerController, FString* message, int mode)
{
auto Singleton = (UPrimalGlobals*)Globals::GEngine().Get()->GameSingletonField();
auto GameData = Singleton->PrimalGameDataOverrideField() ? Singleton->PrimalGameDataOverrideField() : Singleton->PrimalGameDataField();
auto EngramClasses = GameData->EngramBlueprintEntriesField();
for (auto&& Engram : EngramClasses)
{
if (CanUnlock(Engram))
{
((AShooterPlayerState*)PlayerController->PlayerStateField())->ServerUnlockEngram(Engram->BluePrintEntryField(), true, true);
}
}
}
FString GetBlueprint(UObjectBase* object)
{
if (object != nullptr && object->ClassField() != nullptr)
{
FString path_name;
object->ClassField()->GetDefaultObject(true)->GetFullName(&path_name, nullptr);
if (int find_index = 0; path_name.FindChar(' ', find_index))
{
path_name = "Blueprint'" + path_name.Mid(find_index + 1,
path_name.Len() - (find_index + (path_name.EndsWith(
"_C", ESearchCase::
CaseSensitive)
? 3
: 1))) + "'";
return path_name.Replace(L"Default__", L"", ESearchCase::CaseSensitive);
}
}
return FString("");
}
UPrimalGameData* Game_Data = static_cast<UPrimalGameData*>(static_cast<UPrimalGlobals*>(Globals::GEngine()()->GameSingletonField())->PrimalGameDataOverrideField());