mirror of
https://github.com/storytold/EventCenterPlugin.git
synced 2026-10-09 00:09:42 +00:00
First commit of EventCenterPlugin (not working, wip)
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"FileVersion": 3,
|
||||||
|
"Version": 1,
|
||||||
|
"VersionName": "1.0",
|
||||||
|
"FriendlyName": "EventCenterPlugin",
|
||||||
|
"Description": "Poll or subscribe to events, then dispatch throughout the game engine",
|
||||||
|
"Category": "Other",
|
||||||
|
"CreatedBy": "Brandon Thomas",
|
||||||
|
"CreatedByURL": "http://brand.io",
|
||||||
|
"DocsURL": "",
|
||||||
|
"MarketplaceURL": "",
|
||||||
|
"SupportURL": "",
|
||||||
|
"CanContainContent": true,
|
||||||
|
"IsBetaVersion": false,
|
||||||
|
"IsExperimentalVersion": false,
|
||||||
|
"Installed": false,
|
||||||
|
"Modules": [
|
||||||
|
{
|
||||||
|
"Name": "EventCenterPlugin",
|
||||||
|
"Type": "Runtime",
|
||||||
|
"LoadingPhase": "Default"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
using UnrealBuildTool;
|
||||||
|
|
||||||
|
public class EventCenterPlugin : ModuleRules
|
||||||
|
{
|
||||||
|
public EventCenterPlugin(ReadOnlyTargetRules Target) : base(Target)
|
||||||
|
{
|
||||||
|
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||||
|
|
||||||
|
PublicIncludePaths.AddRange(new string[] {});
|
||||||
|
|
||||||
|
PublicIncludePaths.AddRange(
|
||||||
|
new string[] {
|
||||||
|
// ... add public include paths required here ...
|
||||||
|
|
||||||
|
// NB(bt): Using the commercial Redis Plugin by GameSeed (AKA "SDRedis")
|
||||||
|
// Add this in the Unreal Engine Plugins menu.
|
||||||
|
// If not present, use the Epic Games Launcher's Unreal Library Marketplace.
|
||||||
|
"RedisPlugin/Public",
|
||||||
|
"RedisPlugin/Classes"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
PrivateIncludePaths.AddRange(
|
||||||
|
new string[] {
|
||||||
|
// ... add other private include paths required here ...
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
PublicDependencyModuleNames.AddRange(
|
||||||
|
new string[]
|
||||||
|
{
|
||||||
|
"Core",
|
||||||
|
// ... add other public dependencies that you statically link with here ...
|
||||||
|
|
||||||
|
// NB(bt): Using the commercial Redis Plugin by GameSeed (AKA "SDRedis")
|
||||||
|
// Add this in the Unreal Engine Plugins menu.
|
||||||
|
// If not present, use the Epic Games Launcher's Unreal Library Marketplace.
|
||||||
|
"RedisPlugin"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
PrivateDependencyModuleNames.AddRange(
|
||||||
|
new string[]
|
||||||
|
{
|
||||||
|
"CoreUObject",
|
||||||
|
"Engine",
|
||||||
|
"Slate",
|
||||||
|
"SlateCore",
|
||||||
|
// ... add private dependencies that you statically link with here ...
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
DynamicallyLoadedModuleNames.AddRange(
|
||||||
|
new string[]
|
||||||
|
{
|
||||||
|
// ... add any modules that your module loads dynamically here ...
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include "EventCenterPlugin.h"
|
||||||
|
|
||||||
|
#define LOCTEXT_NAMESPACE "FEventCenterPluginModule"
|
||||||
|
|
||||||
|
void FEventCenterPluginModule::StartupModule()
|
||||||
|
{
|
||||||
|
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||||||
|
}
|
||||||
|
|
||||||
|
void FEventCenterPluginModule::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
|
||||||
|
|
||||||
|
IMPLEMENT_MODULE(FEventCenterPluginModule, EventCenterPlugin)
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#include "EventSourceActor.h"
|
||||||
|
|
||||||
|
#include "UObject/Object.h"
|
||||||
|
|
||||||
|
DEFINE_LOG_CATEGORY(EventSourceLog);
|
||||||
|
|
||||||
|
AEventSourceActor::AEventSourceActor()
|
||||||
|
{
|
||||||
|
// Set this actor to call Tick() every frame.
|
||||||
|
// You can turn this off to improve performance if you don't need it.
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
|
||||||
|
//redis = NewObject<URedisObject>(this, TEXT("RedisObject"));
|
||||||
|
redis = CreateDefaultSubobject<URedisObject>(TEXT("RedisObject"));
|
||||||
|
|
||||||
|
//RootComponent = redis;
|
||||||
|
}
|
||||||
|
|
||||||
|
AEventSourceActor::~AEventSourceActor()
|
||||||
|
{
|
||||||
|
// TODO: Memory leak (somehow placing a BP derivation into the editor causes the below lines to segfault)
|
||||||
|
//delete redis;
|
||||||
|
//redis = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEventSourceActor::BeginPlay()
|
||||||
|
{
|
||||||
|
UE_LOG(EventSourceLog, Log, TEXT("BeginPlay()"));
|
||||||
|
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
UE_LOG(EventSourceLog, Log, TEXT("BeginPlay(): Redis is null? %b"), redis != nullptr);
|
||||||
|
//UE_LOG(EventSourceLog, Log, TEXT("BeginPlay(): Redis host: %s"), redisHost);
|
||||||
|
UE_LOG(EventSourceLog, Log, TEXT("BeginPlay(): Redis port: %d"), redisPort);
|
||||||
|
//UE_LOG(EventSourceLog, Log, TEXT("BeginPlay(): Redis password (no secrets): %s"), redisPassword);
|
||||||
|
|
||||||
|
//redis->Init(redisHost, redisPort, redisPassword);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEventSourceActor::BeginDestroy()
|
||||||
|
{
|
||||||
|
Super::BeginDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEventSourceActor::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
|
// NB: Handled by RedisObject internal delegate
|
||||||
|
//redis->Tick(DeltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEventSourceActor::Subscribe(const FString& Channel)
|
||||||
|
{
|
||||||
|
redis->Subscribe(Channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEventSourceActor::Unsubscribe(const FString& Channel)
|
||||||
|
{
|
||||||
|
redis->Unsubscribe(Channel);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Modules/ModuleManager.h"
|
||||||
|
|
||||||
|
class FEventCenterPluginModule : public IModuleInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** IModuleInterface implementation */
|
||||||
|
virtual void StartupModule() override;
|
||||||
|
virtual void ShutdownModule() override;
|
||||||
|
};
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Unreal Core
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "UObject/NoExportTypes.h"
|
||||||
|
|
||||||
|
// RedisPlugin
|
||||||
|
#include "RedisObject.h"
|
||||||
|
|
||||||
|
// EventCenterPlugin
|
||||||
|
#include "EventSourceActor.generated.h"
|
||||||
|
|
||||||
|
DECLARE_LOG_CATEGORY_EXTERN(EventSourceLog, Log, All);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AEventSourceActor
|
||||||
|
*
|
||||||
|
* Manages an underlying Redis pubsub subscription and coordinates dispatch to other actors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// NB(bt): "Blueprintable" seems to remove the ability to add BP event nodes.
|
||||||
|
UCLASS()
|
||||||
|
class EVENTCENTERPLUGIN_API AEventSourceActor : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
AEventSourceActor();
|
||||||
|
~AEventSourceActor();
|
||||||
|
|
||||||
|
/** Redis Hostname */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EventCenter")
|
||||||
|
FString redisHost;
|
||||||
|
|
||||||
|
/** Redis Port */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EventCenter")
|
||||||
|
int32 redisPort = 6379;
|
||||||
|
|
||||||
|
/** Redis Password */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EventCenter")
|
||||||
|
FString redisPassword;
|
||||||
|
|
||||||
|
/** Subscribe to a named Redis PubSub channel. */
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "EventCenter")
|
||||||
|
void Subscribe(const FString& Channel);
|
||||||
|
|
||||||
|
/** Unsubscribe from a named Redis PubSub channel. */
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "EventCenter")
|
||||||
|
void Unsubscribe(const FString& Channel);
|
||||||
|
|
||||||
|
/** I have no idea what do... */
|
||||||
|
UPROPERTY(BlueprintAssignable)
|
||||||
|
FSubscribeReply SubscribeReplyy;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
virtual void BeginDestroy() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
URedisObject* redis;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Called every frame
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user