mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-02 04:38:15 +00:00
CogAbility: Apply tweaks at start and when an new actor is spawned
The data asset is now loaded directly by the windows.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "CogImGuiHelper.h"
|
||||
#include "CogWindowHelper.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
@@ -26,6 +27,8 @@ void UCogEngineWindow_Collisions::RenderHelp()
|
||||
UCogEngineWindow_Collisions::UCogEngineWindow_Collisions()
|
||||
{
|
||||
bHasMenu = true;
|
||||
|
||||
SetAsset(FCogWindowHelper::GetFirstAssetByClass<UCogEngineDataAsset>());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -3,8 +3,16 @@
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "CogEngineReplicator.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCogEngineWindow_Spawns::UCogEngineWindow_Spawns()
|
||||
{
|
||||
Asset = FCogWindowHelper::GetFirstAssetByClass<UCogEngineDataAsset>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawns::RenderHelp()
|
||||
{
|
||||
|
||||
@@ -15,11 +15,7 @@ public:
|
||||
|
||||
UCogEngineWindow_Collisions();
|
||||
|
||||
const UCogEngineDataAsset* GetAsset() const { return Asset.Get(); }
|
||||
|
||||
void SetAsset(const UCogEngineDataAsset* Value);
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
|
||||
@@ -27,6 +23,8 @@ private:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void SetAsset(const UCogEngineDataAsset* Value);
|
||||
|
||||
struct FChannel
|
||||
{
|
||||
bool IsValid = false;
|
||||
|
||||
@@ -15,9 +15,7 @@ class COGENGINE_API UCogEngineWindow_Spawns : public UCogWindow
|
||||
|
||||
public:
|
||||
|
||||
const UCogEngineDataAsset* GetAsset() const { return Asset.Get(); }
|
||||
|
||||
void SetAsset(const UCogEngineDataAsset* Value) { Asset = Value; }
|
||||
UCogEngineWindow_Spawns();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ private:
|
||||
void Initialize();
|
||||
|
||||
FCogImguiTextureManager TextureManager;
|
||||
|
||||
ImFontAtlas DefaultFontAtlas;
|
||||
|
||||
bool bEnabledInput = true;
|
||||
|
||||
bool bIsInitialized = false;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AssetRegistry/AssetRegistryModule.h"
|
||||
#include "AssetRegistry/IAssetRegistry.h"
|
||||
|
||||
class COGWINDOW_API FCogWindowHelper
|
||||
{
|
||||
public:
|
||||
|
||||
template<typename T>
|
||||
static T* GetFirstAssetByClass()
|
||||
{
|
||||
IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry")).Get();
|
||||
|
||||
TArray<FAssetData> Assets;
|
||||
AssetRegistry.GetAssetsByClass(T::StaticClass()->GetClassPathName(), Assets, true);
|
||||
if (Assets.Num() == 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UObject* Asset = Assets[0].GetAsset();
|
||||
T* CastedAsset = Cast<T>(Asset);
|
||||
return CastedAsset;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user