UnrealModFramework
Mod framework API
Loading...
Searching...
No Matches
ModBehavior.h
Go to the documentation of this file.
1// Copyright (c) 2026 Nelaric Contributors
3#pragma once
4
6#include "UObject/Object.h"
7
8#include "ModBehavior.generated.h"
9
11UCLASS(Abstract, BlueprintType, Blueprintable, MinimalAPI, meta = (DontUseGenericSpawnObject))
12class UModBehavior : public UObject
13{
14 GENERATED_BODY()
15
16public:
18 UFUNCTION(BlueprintCallable, Category = "Mod|Event")
19 MODLOADER_API void UnbindEvent(const FModExtensionToken& Token);
20
21public:
23 MODLOADER_API UWorld* GetWorld() const override;
24
25protected:
27 MODLOADER_API bool ResolveBehaviorTarget(FName TypeId, const TCHAR* Signature, uint64& Context, uint64& Object);
29 static MODLOADER_API bool ResolveBehaviorArgument(UObject& Owner, UModBehavior& Argument, FName TypeId,
30 const TCHAR* Signature, uint64& Context, uint64& Object);
32 static MODLOADER_API UModBehavior* MakeBoundBehavior(UClass* Class, UObject& Owner, uint64 Context, uint64 Object,
33 bool bBorrowed);
35 MODLOADER_API UModBehavior* WrapBehaviorResult(UClass* Class, uint64 Context, uint64 Object);
37 static MODLOADER_API UModBehavior* FindBoundBehavior(UClass* Class, UObject* Owner, FName Alias, FName TypeId,
38 bool bPlayerProvider);
40 MODLOADER_API int32 BindBehaviorEvent(FName Id, const TCHAR* Signature, FName SourceType,
41 const FModBehaviorEvent& Delegate, FModExtensionToken& Token);
43 MODLOADER_API UObject* GetBehaviorOwner() const;
44
46 virtual void RegisterBehavior()
47 {
48 }
49
50private:
51 friend struct FModExtensionWorld;
52 friend class UModExtensionSubsystem;
53 MODLOADER_API void ReleaseBehavior();
54 TWeakObjectPtr<UObject> BindingOwner;
55 uint64 BoundContext = 0;
56 uint64 BoundObject = 0;
57 bool bBorrowedBinding = false;
58 bool bReleased = false;
59};
A Mod-owned behavior instance attached to its authorized World.
Definition ModBehavior.h:13
MODLOADER_API void UnbindEvent(const FModExtensionToken &Token)
Unsubscribes a delegate installed on this behavior.
MODLOADER_API UModBehavior * WrapBehaviorResult(UClass *Class, uint64 Context, uint64 Object)
Wraps an object result with the lifetime of the current call target.
MODLOADER_API bool ResolveBehaviorTarget(FName TypeId, const TCHAR *Signature, uint64 &Context, uint64 &Object)
Resolves the checked call target of an exported API.
MODLOADER_API UWorld * GetWorld() const override
Returns the World that owns the behavior instance.
virtual void RegisterBehavior()
Registers generated Hook and Event overrides during World preparation.
Definition ModBehavior.h:46
static MODLOADER_API bool ResolveBehaviorArgument(UObject &Owner, UModBehavior &Argument, FName TypeId, const TCHAR *Signature, uint64 &Context, uint64 &Object)
Resolves an object argument within the calling Mod and World.
MODLOADER_API UObject * GetBehaviorOwner() const
Returns the host-created Mod owner for this behavior.
MODLOADER_API int32 BindBehaviorEvent(FName Id, const TCHAR *Signature, FName SourceType, const FModBehaviorEvent &Delegate, FModExtensionToken &Token)
Binds a delegate to a published Event on this behavior.
static MODLOADER_API UModBehavior * FindBoundBehavior(UClass *Class, UObject *Owner, FName Alias, FName TypeId, bool bPlayerProvider)
Finds a typed reference using an alias authorized by the game.
static MODLOADER_API UModBehavior * MakeBoundBehavior(UClass *Class, UObject &Owner, uint64 Context, uint64 Object, bool bBorrowed)
Creates a typed reference from a host-issued binding.
Prepares and owns the extension plan for a single game World.
Definition ModExtensionSubsystem.h:203
Identifies a registration owned by one mod and World.
Definition ModExtensionLibrary.h:48