Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to use Single Param Functions from code #14

Closed
jtarczykowski opened this issue Mar 4, 2021 · 5 comments
Closed

A way to use Single Param Functions from code #14

jtarczykowski opened this issue Mar 4, 2021 · 5 comments
Labels

Comments

@jtarczykowski
Copy link

For the start - I love this tool, both the concept execution. But I'd love use this system from code as well as BP. It was pretty easy to bind and emit an event withouth a param, but I'm trying to figure out - is there any straightforward way to use One Param version from C++?

@getnamo getnamo added the enhancement New feature or request label Mar 5, 2021
@getnamo
Copy link
Owner

getnamo commented Mar 5, 2021

Let's see, behind the curtain the function that calls it is

https://github.com/getnamo/global-event-system-ue4/tree/be3836f3648c9fca7a19db116c52c2de8f525517/Source/GlobalEventSystem/Private/GlobalEventSystemBPLibrary.cpp#L47

and that is handled by this class which has a static handler:

https://github.com/getnamo/global-event-system-ue4/tree/be3836f3648c9fca7a19db116c52c2de8f525517/Source/GlobalEventSystem/Private/GESHandler.h#L7

you have a bunch of overloaded emits here:
https://github.com/getnamo/global-event-system-ue4/tree/be3836f3648c9fca7a19db116c52c2de8f525517/Source/GlobalEventSystem/Private/GESHandler.h#L52, the only one not relevant for c++ is probably the one param version which converts a uproperty pointer (https://github.com/getnamo/global-event-system-ue4/tree/be3836f3648c9fca7a19db116c52c2de8f525517/Source/GlobalEventSystem/Private/GESHandler.h#L59, don't use this one)

Only major problem in using this is that it is in the private folder, so to use it outside, the class would need to be moved out.

To summarize, you want to do something like

	//assuming e.g. this struct you want to emit (and it can be blueprint accessible type too)
	USTRUCT()
	struct FTestCppStruct
	{
		GENERATED_BODY()

		UPROPERTY()
		int32 Index;

		UPROPERTY()
		float SomeNumber;

		UPROPERTY()
		FString Name;
	};

	//...

	//Set your struct variables
	FTestCppStruct TestStruct;
	TestStruct.Name = TEXT("George");
	TestStruct.Index = 5;
	TestStruct.SomeNumber = 5.123f;


	FGESEmitData EmitData;
	EmitData.bPinned = true;	//or false
	EmitData.Domain = TEXT("global.default");	
	EmitData.Event = TEXT("MyAwesomeEvent");
	EmitData.WorldContext = WorldContextObject;	//you need WCO from e.g. an actor or a world.

	FGESHandler::DefaultHandler()->EmitEvent(EmitData, FTestCppStruct::StaticStruct(), &TestStruct);

I'm going to spend a few minutes to expose this so it's usable

@getnamo
Copy link
Owner

getnamo commented Mar 5, 2021

going to combine it with the convenience receiver actor feature branch here: https://github.com/getnamo/global-event-system-ue4/tree/feature-base-component-receiver

@jtarczykowski
Copy link
Author

Thanks a lot, works like a charm!

@getnamo
Copy link
Owner

getnamo commented Mar 5, 2021

Merged to master with convenience actor component receivers (see https://github.com/getnamo/global-event-system-ue4/blob/master/Source/GlobalEventSystem/Public/GESBaseReceiverComponent.h & https://github.com/getnamo/global-event-system-ue4/tree/master/Content/GenericComponentReceivers). Now going to work on a bind to c++ lambda variant which should make the receiving side of c++ a bit easier.

@getnamo
Copy link
Owner

getnamo commented Apr 5, 2021

Early release https://github.com/getnamo/global-event-system-ue4/releases/tag/0.7.0e closing issue. Re-open a new issue if some bugs crop up

@getnamo getnamo closed this as completed Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants