- Started work on giving UComboActions their own automatically-recognised events in Blueprints, just like UInputAssets have in the EnhancedInput plugin.

- Also gave the data assets a factory class and organised them into the Input category to make them look like a proper Unreal asset.
This commit is contained in:
Jamie Greunbaum
2023-09-12 01:39:23 -04:00
parent 3e71bb31ae
commit 445895b77b
10 changed files with 789 additions and 88 deletions
@@ -2,20 +2,130 @@
#include "ComboInputEditor.h"
#include "ComboInputAssets.h"
#include "ToolMenuSection.h"
#include "AssetTypeActions/AssetTypeActions_DataAsset.h"
#include "Interfaces/IPluginManager.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(ComboInputEditor)
#define LOCTEXT_NAMESPACE "FComboInputEditorModule"
EAssetTypeCategories::Type FComboInputEditorModule::ComboAssetsCategory;
class FAssetTypeActions_ComboAction : public FAssetTypeActions_DataAsset
{
public:
virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboAction", "Combo Action"); }
virtual uint32 GetCategories() override { return FComboInputEditorModule::GetInputAssetsCategory(); }
virtual FColor GetTypeColor() const override { return FColor(255, 127, 255); }
virtual FText GetAssetDescription(const FAssetData &AssetData) const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboActionDesc", "An action that can be executed as part of a combo sequence. This is essentially a representation of an attack, and can be sent to the Animation Graph to play an attack animation and the like."); }
virtual UClass *GetSupportedClass() const override { return UComboAction::StaticClass(); }
};
class FAssetTypeActions_ComboSequenceNode : public FAssetTypeActions_DataAsset
{
public:
virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboSequenceNode", "Combo Sequence Node"); }
virtual uint32 GetCategories() override { return FComboInputEditorModule::GetInputAssetsCategory(); }
virtual FColor GetTypeColor() const override { return FColor(255, 127, 255); }
virtual FText GetAssetDescription(const FAssetData &AssetData) const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboSequenceNodeDesc", "This represents a node in the combo graph, with each key in the ComboBranch being an input this node can react to, and each value containing the action to be executed next, and the node to activate after the action is complete."); }
virtual UClass *GetSupportedClass() const override { return UComboSequenceNode::StaticClass(); }
};
class FAssetTypeActions_ComboInputAsset : public FAssetTypeActions_DataAsset
{
public:
virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboInputAsset", "Combo Input Asset"); }
virtual uint32 GetCategories() override { return FComboInputEditorModule::GetInputAssetsCategory(); }
virtual FColor GetTypeColor() const override { return FColor(255, 127, 255); }
virtual FText GetAssetDescription(const FAssetData &AssetData) const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboInputAssetDesc", "This maps a sequence of button inputs from EnhancedInput to a combo action that can be used to execute a sequence of moves.This gets sent from the input buffer subsystem to the player controller's ComboManagerComponent, which executes the associated action in the current ComboSequenceNode."); }
virtual UClass *GetSupportedClass() const override { return UComboInputAsset::StaticClass(); }
};
UComboAction_Factory::UComboAction_Factory(const FObjectInitializer &ObjectInitializer)
: Super(ObjectInitializer)
{
SupportedClass = UComboAction::StaticClass();
bEditAfterNew = true;
bCreateNew = true;
}
UObject *UComboAction_Factory::FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn)
{
if (this->ComboActionClass != nullptr)
{
return NewObject<UComboAction>(InParent, this->ComboActionClass, Name, Flags | RF_Transactional, Context);
}
else
{
check(Class->IsChildOf(UComboAction::StaticClass()));
return NewObject<UComboAction>(InParent, Class, Name, Flags | RF_Transactional, Context);
}
}
UComboSequenceNode_Factory::UComboSequenceNode_Factory(const FObjectInitializer &ObjectInitializer)
: Super(ObjectInitializer)
{
SupportedClass = UComboSequenceNode::StaticClass();
bEditAfterNew = true;
bCreateNew = true;
}
UObject *UComboSequenceNode_Factory::FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn)
{
if (this->ComboSequenceNodeClass != nullptr)
{
return NewObject<UComboSequenceNode>(InParent, this->ComboSequenceNodeClass, Name, Flags | RF_Transactional, Context);
}
else
{
check(Class->IsChildOf(UComboSequenceNode::StaticClass()));
return NewObject<UComboSequenceNode>(InParent, Class, Name, Flags | RF_Transactional, Context);
}
}
UComboInputAsset_Factory::UComboInputAsset_Factory(const FObjectInitializer &ObjectInitializer)
: Super(ObjectInitializer)
{
SupportedClass = UComboInputAsset::StaticClass();
bEditAfterNew = true;
bCreateNew = true;
}
UObject *UComboInputAsset_Factory::FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn)
{
if (this->ComboInputAssetClass != nullptr)
{
return NewObject<UComboInputAsset>(InParent, this->ComboInputAssetClass, Name, Flags | RF_Transactional, Context);
}
else
{
check(Class->IsChildOf(UComboInputAsset::StaticClass()));
return NewObject<UComboInputAsset>(InParent, Class, Name, Flags | RF_Transactional, Context);
}
}
void FComboInputEditorModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
// Register combo action asset
IAssetTools &AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
FComboInputEditorModule::ComboAssetsCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("Input")), LOCTEXT("InputAssetsCategory", "Input"));
this->RegisterAssetTypeActions(AssetTools, MakeShareable(new FAssetTypeActions_ComboAction));
this->RegisterAssetTypeActions(AssetTools, MakeShareable(new FAssetTypeActions_ComboSequenceNode));
this->RegisterAssetTypeActions(AssetTools, MakeShareable(new FAssetTypeActions_ComboInputAsset));
}
void FComboInputEditorModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE