Skip to content

Instantly share code, notes, and snippets.

@hvent90
Last active September 9, 2022 10:43
Show Gist options
  • Save hvent90/da858c607b9b00f0f0436cab00606261 to your computer and use it in GitHub Desktop.
Save hvent90/da858c607b9b00f0f0436cab00606261 to your computer and use it in GitHub Desktop.
Add these files to Engine\Content\Editor\Templates to have file templates in Jetbrains Rider
%COPYRIGHT_LINE%
%PCH_INCLUDE_DIRECTIVE%
%MY_HEADER_INCLUDE_DIRECTIVE%
%ADDITIONAL_INCLUDE_DIRECTIVES%
#include "MassStateTreeExecutionContext.h"
#include "StateTreeLinker.h"
void %PREFIXED_CLASS_NAME%::Link(FStateTreeLinker& Linker)
{
Linker.LinkExternalData(MassSignalSubsystemHandle);
Linker.LinkInstanceProperty(MyVectorHandle, STATETREE_INSTANCEDATA_PROPERTY(F$UNPREFIXED_CLASS_NAME$InstanceData, MyVector));
}
void %PREFIXED_CLASS_NAME%::EnterState(FStateTreeExecutionContext& Context,
const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) const
{
const FMassStateTreeExecutionContext& MassContext = static_cast<FMassStateTreeExecutionContext&>(Context);
FVector& MyVector = Context.GetInstanceData(MyVectorHandle);
// If desired, trigger a tick
// UMassSignalSubsystem& MassSignalSubsystem = Context.GetExternalData(MassSignalSubsystemHandle);
// MassSignalSubsystem.DelaySignalEntity(UE::Mass::Signals::StandTaskFinished, MassContext.GetEntity(), Duration);
return EStateTreeRunStatus::Running;
}
void %PREFIXED_CLASS_NAME%::ExitState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType,
const FStateTreeTransitionResult& Transition) const
{
}
EStateTreeRunStatus %PREFIXED_CLASS_NAME%::Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const
{
const FMassStateTreeExecutionContext& MassContext = static_cast<FMassStateTreeExecutionContext&>(Context);
const FMassEntityHandle Entity = MassContext.GetEntity();
FVector& MyVector = Context.GetInstanceData(MyVectorHandle);
// If desired, trigger a tick
// UMassSignalSubsystem& MassSignalSubsystem = Context.GetExternalData(MassSignalSubsystemHandle);
// MassSignalSubsystem.DelaySignalEntity(UE::Mass::Signals::StandTaskFinished, MassContext.GetEntity(), Duration);
return EStateTreeRunStatus::Running;
}
%ADDITIONAL_MEMBER_DEFINITIONS%
$COPYRIGHT_LINE$
#pragma once
#include "CoreMinimal.h"
#include "MassStateTreeTypes.h"
#include "$UNPREFIXED_CLASS_NAME$.generated.h"
USTRUCT()
struct $CLASS_MODULE_API_MACRO$ F$UNPREFIXED_CLASS_NAME$InstanceData
{
GENERATED_BODY()
UPROPERTY()
FVector MyVector = FVector::ZeroVector;
};
UCLASS(meta=(DisplayName = "$UNPREFIXED_CLASS_NAME$") )
class $CLASS_MODULE_API_MACRO$$PREFIX$$UNPREFIXED_CLASS_NAME$ : public UMassProcessor
{
GENERATED_BODY()
protected:
virtual bool Link(FStateTreeLinker& Linker) override;
virtual const UStruct* GetInstanceDataType() const override { return FMassVehicleLoiterInstanceData::StaticStruct(); }
virtual EStateTreeRunStatus EnterState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) const override;
virtual void ExitState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) const override;
virtual EStateTreeRunStatus Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const override;
TStateTreeExternalDataHandle<UMassSignalSubsystem> MassSignalSubsystemHandle;
TStateTreeInstanceDataPropertyHandle<FVector> MyVectorHandle;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment