Commit 34ee4afd authored by Kyrium's avatar Kyrium
Browse files

Merge branch 'dev' into 'main'

Dev

See merge request !5
parents 633568be 00d10e7a
......@@ -8,6 +8,7 @@
#include "BFL/KBFL_Asset.h"
#include "Engine/AssetManager.h"
#include "Registry/ModContentRegistry.h"
#include "Subsystems/KBFLAssetDataSubsystem.h"
#include "Subsystems/KBFLContentCDOHelperSubsystem.h"
#include "Subsystems/KBFLCustomizerSubsystem.h"
#include "Subsystems/KBFLResourceNodeSubsystem.h"
......@@ -112,39 +113,41 @@ void UKBFLWorldModule::RegisterKBFLLogicContent()
if(AssetRegistry.GetAssetsByPath(Options.GetPath(), AssetDatas, Options.Recursive))
for (FAssetData AssetData : AssetDatas)
{
if(Options.bRegisterSchematics)
{
TSubclassOf<UFGSchematic> SchematicClass;
if(UKBFL_Asset::GetSubclassFromAsset<UFGSchematic>(AssetData, SchematicClass)) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Register Schematic (%s) in ModContentRegistry"), *SchematicClass->GetName());
ModContentRegistry->RegisterSchematic(GetOwnerModReference(), SchematicClass);
if(UKBFLAssetDataSubsystem::FilterAsset(AssetData)){
if(Options.bRegisterSchematics)
{
TSubclassOf<UFGSchematic> SchematicClass;
if(UKBFL_Asset::GetSubclassFromAsset<UFGSchematic>(AssetData, SchematicClass)) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Register Schematic (%s) in ModContentRegistry"), *SchematicClass->GetName());
ModContentRegistry->RegisterSchematic(GetOwnerModReference(), SchematicClass);
// is a fix for SF+ Content remover!
mSchematics.AddUnique(SchematicClass);
continue;
// is a fix for SF+ Content remover!
mSchematics.AddUnique(SchematicClass);
continue;
}
}
}
if(Options.bRegisterResearchTrees)
{
TSubclassOf<UFGResearchTree> ResearchTreeClass;
if(UKBFL_Asset::GetSubclassFromAsset<UFGResearchTree>(AssetData, ResearchTreeClass)) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Register ResearchTree (%s) in ModContentRegistry"), *AssetData.AssetName.ToString());
ModContentRegistry->RegisterResearchTree(GetOwnerModReference(), ResearchTreeClass);
// is a fix for SF+ Content remover!
mResearchTrees.AddUnique(ResearchTreeClass);
continue;
if(Options.bRegisterResearchTrees)
{
TSubclassOf<UFGResearchTree> ResearchTreeClass;
if(UKBFL_Asset::GetSubclassFromAsset<UFGResearchTree>(AssetData, ResearchTreeClass)) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Register ResearchTree (%s) in ModContentRegistry"), *AssetData.AssetName.ToString());
ModContentRegistry->RegisterResearchTree(GetOwnerModReference(), ResearchTreeClass);
// is a fix for SF+ Content remover!
mResearchTrees.AddUnique(ResearchTreeClass);
continue;
}
}
}
if(Options.bRegisterRecipes)
{
TSubclassOf<UFGRecipe> RecipeClass;
if(UKBFL_Asset::GetSubclassFromAsset<UFGRecipe>(AssetData, RecipeClass)) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Register Recipe (%s) in ModContentRegistry"), *AssetData.AssetName.ToString());
ModContentRegistry->RegisterRecipe(GetOwnerModReference(), RecipeClass);
continue;
if(Options.bRegisterRecipes)
{
TSubclassOf<UFGRecipe> RecipeClass;
if(UKBFL_Asset::GetSubclassFromAsset<UFGRecipe>(AssetData, RecipeClass)) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Register Recipe (%s) in ModContentRegistry"), *AssetData.AssetName.ToString());
ModContentRegistry->RegisterRecipe(GetOwnerModReference(), RecipeClass);
continue;
}
}
}
}
......@@ -193,24 +196,27 @@ void UKBFLWorldModule::FindAllCDOs()
if(AssetRegistry.GetAssetsByPath(Options.GetPath(), AssetDatas, Options.Recursive))
for (FAssetData AssetData : AssetDatas)
{
TSubclassOf<UKBFL_CDOHelperClass_Base> CDOHelperClass;
if(UKBFL_Asset::GetSubclassFromAsset<UKBFL_CDOHelperClass_Base>(AssetData, CDOHelperClass)) {
if(Options.bFindCDOHelpers)
{
if(
!CDOHelperClass->IsChildOf(UKBFL_CDOHelperClass_RemoverBase::StaticClass()) && Options.bFindCDOHelpers ||
CDOHelperClass->IsChildOf(UKBFL_CDOHelperClass_RemoverBase::StaticClass()) && Options.bFindRemover
) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Found CDO helper (%s) and add to map"), *CDOHelperClass->GetName());
if(mCDOInformationMap.Contains(Options.bPutInPhase))
{
mCDOInformationMap[Options.bPutInPhase].mOtherCDOHelpers.mClassHelperSubclass.AddUnique(CDOHelperClass);
}
else
{
FKBFLCDOInformation Information = FKBFLCDOInformation();
Information.mOtherCDOHelpers.mClassHelperSubclass.AddUnique(CDOHelperClass);
mCDOInformationMap.Add(Options.bPutInPhase, Information);
if(UKBFLAssetDataSubsystem::FilterAsset(AssetData))
{
TSubclassOf<UKBFL_CDOHelperClass_Base> CDOHelperClass;
if(UKBFL_Asset::GetSubclassFromAsset<UKBFL_CDOHelperClass_Base>(AssetData, CDOHelperClass)) {
if(Options.bFindCDOHelpers)
{
if(
!CDOHelperClass->IsChildOf(UKBFL_CDOHelperClass_RemoverBase::StaticClass()) && Options.bFindCDOHelpers ||
CDOHelperClass->IsChildOf(UKBFL_CDOHelperClass_RemoverBase::StaticClass()) && Options.bFindRemover
) {
UE_LOG(KBFLWorldModuleLog, Warning, TEXT("Found CDO helper (%s) and add to map"), *CDOHelperClass->GetName());
if(mCDOInformationMap.Contains(Options.bPutInPhase))
{
mCDOInformationMap[Options.bPutInPhase].mOtherCDOHelpers.mClassHelperSubclass.AddUnique(CDOHelperClass);
}
else
{
FKBFLCDOInformation Information = FKBFLCDOInformation();
Information.mOtherCDOHelpers.mClassHelperSubclass.AddUnique(CDOHelperClass);
mCDOInformationMap.Add(Options.bPutInPhase, Information);
}
}
}
}
......
......@@ -41,6 +41,11 @@ void UKBFLAssetDataSubsystem::Initialize(FSubsystemCollectionBase& Collection)
Super::Initialize(Collection);
}
bool UKBFLAssetDataSubsystem::ShouldCreateSubsystem(UObject* Outer) const
{
return Super::ShouldCreateSubsystem(Outer) && mShouldInit;
}
void UKBFLAssetDataSubsystem::InitAssetFinder()
{
const FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(AssetRegistryConstants::ModuleName);
......@@ -54,47 +59,50 @@ void UKBFLAssetDataSubsystem::InitAssetFinder()
TSubclassOf<UFGItemDescriptor> Item;
TSubclassOf<AFGBuildable> Buildable;
// Schematic
if(UKBFL_Asset::GetSubclassFromAsset(Asset, Schematic))
if(Local_FilterAsset(Asset))
{
if(Schematic)
// Schematic
if(UKBFL_Asset::GetSubclassFromAsset(Asset, Schematic))
{
mAllFoundedSchematics.AddUnique(Schematic);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Schematic->GetName());
mAssetClassMap.Add(Schematic, Asset);
if(Schematic)
{
mAllFoundedSchematics.AddUnique(Schematic);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Schematic->GetName());
mAssetClassMap.Add(Schematic, Asset);
}
}
}
// Recipe
else if(UKBFL_Asset::GetSubclassFromAsset(Asset, Recipe))
{
if(Recipe)
// Recipe
else if(UKBFL_Asset::GetSubclassFromAsset(Asset, Recipe))
{
mAllFoundedRecipes.AddUnique(Recipe);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Recipe->GetName());
mAssetClassMap.Add(Recipe, Asset);
if(Recipe)
{
mAllFoundedRecipes.AddUnique(Recipe);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Recipe->GetName());
mAssetClassMap.Add(Recipe, Asset);
}
}
}
// Item
else if(UKBFL_Asset::GetSubclassFromAsset(Asset, Item))
{
if(Item)
// Item
else if(UKBFL_Asset::GetSubclassFromAsset(Asset, Item))
{
mAllFoundedItems.AddUnique(Item);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Item->GetName());
mAssetClassMap.Add(Item, Asset);
if(Item)
{
mAllFoundedItems.AddUnique(Item);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Item->GetName());
mAssetClassMap.Add(Item, Asset);
}
}
}
// Buildable
else if(UKBFL_Asset::GetSubclassFromAsset(Asset, Buildable))
{
if(Buildable)
// Buildable
else if(UKBFL_Asset::GetSubclassFromAsset(Asset, Buildable))
{
mAllFoundedBuildables.AddUnique(Buildable);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Buildable->GetName());
mAssetClassMap.Add(Buildable, Asset);
if(Buildable)
{
mAllFoundedBuildables.AddUnique(Buildable);
UE_LOG(AssetDataSubsystemLog, Log, TEXT("Add To Subsystem > %s"), *Buildable->GetName());
mAssetClassMap.Add(Buildable, Asset);
}
}
}
}
......@@ -102,6 +110,39 @@ void UKBFLAssetDataSubsystem::InitAssetFinder()
UE_LOG(AssetDataSubsystemLog, Error, TEXT("FAIL TO FIND ASSET PATH"));
}
bool UKBFLAssetDataSubsystem::FilterAsset(const FAssetData& AssetData)
{
FString ExportedPath;
if (!AssetData.GetTagValue(FBlueprintTags::GeneratedClassPath, ExportedPath))
return false;
if(ExportedPath.Contains("PassiveMode"))
return false;
FString AssetClassName = AssetData.AssetClass.ToString();
if(AssetClassName.IsEmpty())
return false;
if(AssetClassName == "Blueprint")
return true;
return false;
}
bool UKBFLAssetDataSubsystem::Local_FilterAsset(const FAssetData& AssetData) const
{
FString ExportedPath;
if (!AssetData.GetTagValue(FBlueprintTags::GeneratedClassPath, ExportedPath))
return false;
for (auto String : mPreventStrings)
if(ExportedPath.Contains(String))
return false;
FString AssetClassName = AssetData.AssetClass.ToString();
if(AssetClassName.IsEmpty())
return false;
if(AssetClassName == "Blueprint")
return true;
return false;
}
void UKBFLAssetDataSubsystem::GetItemsOfForms(TArray<EResourceForm> Forms, TArray<TSubclassOf<UFGItemDescriptor>>& Out_Items)
{
FCriticalSection Mutex;
......
......@@ -85,7 +85,7 @@ void AKBFLUtilSubsystem::Tick(float DeltaSeconds)
if(bIsNoFuel != mCheatManager->NoFuel_Get())
mCheatManager->NoFuel(bIsNoFuel);
}
else
else if(!bIsCheatEnabled)
{
if(mCheatManager->PlayerAllFly_Get())
{
......
......@@ -10,16 +10,19 @@
/**
*
*/
UCLASS()
UCLASS(Blueprintable)
class KBFL_API UKBFLAssetDataSubsystem : public UWorldSubsystem
{
GENERATED_BODY()
/** Implement this for initialization of instances of the system */
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
public:
void InitAssetFinder();
static bool FilterAsset(const FAssetData& AssetData);
bool Local_FilterAsset(const FAssetData& AssetData) const;
// Begin Items
/** Get All Items that hit the Forms (Fast version with ParallelFor) */
......@@ -102,4 +105,12 @@ class KBFL_API UKBFLAssetDataSubsystem : public UWorldSubsystem
public:
TMap<UClass*, FAssetData> mAssetClassMap;
UPROPERTY(EditDefaultsOnly, Category="Subsystem")
bool mShouldInit = true;
UPROPERTY(EditDefaultsOnly, Category="Subsystem")
TArray<FString> mPreventStrings = {
"PassiveMode"
};
};
......@@ -77,7 +77,7 @@ class KBFL_API AKBFLUtilSubsystem : public AModSubsystem, public IFGSaveInterfac
bool bIsHostEnableCheatMode;
UPROPERTY(SaveGame, Replicated, BlueprintReadOnly)
bool bIsCheatEnabled;
bool bIsCheatEnabled = true;
UPROPERTY(SaveGame, Replicated, BlueprintReadOnly)
bool bIsFlyEnabled;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment