9#include "Subsystems/WorldSubsystem.h"
11#include "ModExtensionSubsystem.generated.h"
18class FModBehaviorEvent;
21struct FModExtensionWorld;
24namespace Mod::Extension
49 TArray<FString> Candidates;
57 UClass* AssetType =
nullptr;
58 TMap<FName, FSoftObjectPath> Defaults;
59 bool bAllowProvide =
true;
60 bool bAllowReplace =
false;
63 bool bAllowDisable =
false;
64 bool bRequired =
true;
106 TMap<FString, TSet<FName>> Grants;
113 TMap<FContentKey, FString> ContentWinners;
221 MODAPI_API
bool RegisterAnchor(FName Id, ULevel& Level,
const FTransform& Transform, FName Permission,
226 MODAPI_API TOptional<Mod::Extension::FPatchOrigin>
GetPatchOrigin(
const UObject& Effect)
const;
264 const TCHAR* Signature);
277 virtual void Initialize(FSubsystemCollectionBase& Collection)
override;
278 virtual void Deinitialize()
override;
282 TFunctionRef<
bool(
float)> ValidateInput,
283 TFunctionRef<
bool(
float)> ValidateResult);
290 TFunctionRef<
bool(T)> ValidateResult);
296 template <
class T>
Mod::API::EError PublishBlueprintScalar(UObject& Source, FName Id, T Value);
297 MODAPI_API
Mod::API::EError PublishBlueprint(UObject& Source, FName Id,
float Value);
300 bool AcquireNativeService(
UModInstance& Consumer, FName Id, FName TypeId,
const TCHAR* Signature,
301 uint64& OutContext, uint64& OutObject);
318 FName SourceType,
const FModBehaviorEvent& Delegate,
327 virtual bool DoesSupportWorldType(EWorldType::Type WorldType)
const override;
331 friend class UModAPIHostSubsystem;
334 void OnWorldTearDown(UWorld* World);
335 void OnWorldTickStart(UWorld* World, ELevelTick TickType,
float DeltaSeconds);
336 void OnLevelRemoved(ULevel* Level, UWorld* World);
339 bool GetCallerGrants(
const UModInstance& Owner, TSet<FName>& Grants)
const;
340 TSharedPtr<FModExtensionWorld> State;
341 FDelegateHandle TearDownHandle;
342 FDelegateHandle TickHandle;
343 FDelegateHandle LevelRemovedHandle;
EError
Recoverable failures of generated synchronous API calls.
Definition ModAPIResult.h:11
@ None
The operation succeeded.
Definition ModAPIResult.h:13
ESubscriptionStatus
Publication state of a subscription token.
Definition ModExtensionSubsystem.h:128
@ Pending
The requested handler is waiting for the dispatch boundary.
Definition ModExtensionSubsystem.h:132
@ Inactive
The token has expired, was removed, or its batch was rejected.
Definition ModExtensionSubsystem.h:130
@ Active
The handler belongs to the current published snapshot.
Definition ModExtensionSubsystem.h:134
DECLARE_DELEGATE_OneParam(FOnWorldFailure, const FWorldFailure &)
Receives an extension failure after gameplay entry points are closed.
EContentStatus
The result of resolving a logical content ID.
Definition ModExtensionSubsystem.h:34
@ Missing
The content could not resolve.
Definition ModExtensionSubsystem.h:36
@ Available
The selected asset is ready.
Definition ModExtensionSubsystem.h:40
@ Disabled
The selected action is disable.
Definition ModExtensionSubsystem.h:38
TPair< FName, FName > FContentKey
A stable key for content selected by a game-defined slot.
Definition ModExtensionSubsystem.h:30
TCoreResult< float > FCoreResult
Float Core result used by the original extension contract.
Definition ModExtension.h:182
THookResult< float > FHookResult
Float Hook result used by the original extension contract.
Definition ModExtension.h:180
EOperation
Operations the host can grant for an individual Hook.
Definition ModExtension.h:96
EStage
The synchronous stages at which Mods can participate.
Definition ModExtension.h:83
Reads and publishes complete save envelopes on the game thread.
Definition ModExtensionSave.h:98
Game Thread handshake on UE's pending connection.
Definition ModExtensionSession.h:19
One World payload with owned struct storage or a weak object identity.
Definition ModExtensionPayload.h:18
A synchronous API result containing either a value or a stable error.
Definition ModAPIResult.h:47
A Mod-owned behavior instance attached to its authorized World.
Definition ModBehavior.h:13
Prepares and owns the extension plan for a single game World.
Definition ModExtensionSubsystem.h:203
MODAPI_API bool IsReady() const
Reports whether this World may start extension-aware gameplay.
MODAPI_API Mod::Extension::FResolvedContent ResolveContent(FName Slot, FName Id) const
Reads the selected content and its source on the game thread.
MODAPI_API TMap< FString, FString > GetPackageRevisions() const
Copies the selected package revisions for game save metadata.
MODAPI_API FString GetGameplayDigest() const
Returns the published plan digest on the game thread, or an empty ID.
MODAPI_API void Withdraw(UModInstance &Owner, FName Id)
Revokes the named service owned by this mod on the game thread.
Mod::API::EError RegisterBlueprintBehavior(UObject &Owner, FName Id, const TCHAR *Signature, FName Function, Mod::Extension::EStage Stage, FName SourceType)
Registers a Blueprint behavior override during World preparation.
MODAPI_API bool MatchesGameplayDigest(const FString &Digest) const
Returns whether this World accepted an authoritative plan digest.
MODAPI_API uint32 ReflectNativeMod(const FString &ModId, const UMF_NativeReflectionRequestV2 &Request, UMF_NativeReflectionReplyV2 &Reply)
Inspects one active native Mod's own objects on the Game Thread.
MODAPI_API void SetFailureHandler(Mod::Extension::FOnWorldFailure Handler)
Installs a game-thread callback for the terminal failure of this World.
MODAPI_API bool Prepare(Mod::Extension::FWorldPolicy Policy, FString &OutError)
Prepares mounted extensions on the game thread.
bool FindBlueprintBehaviorObject(UObject &Owner, FName Alias, FName TypeId, bool bPlayerProvider, uint64 &Context, uint64 &Object)
Finds a behavior target through the game-authored World alias policy.
MODAPI_API TModResult< Mod::Extension::FSubscription > Register(UModInstance &Owner, FName Id, const FString &Signature, Mod::Extension::FHandler Handler)
Registers a callback for the current mod and returns its revocation token.
Mod::API::EError BindBlueprintBehaviorEvent(UModBehavior &Behavior, FName Id, const TCHAR *Signature, FName SourceType, const FModBehaviorEvent &Delegate, FModExtensionToken &Token)
Registers a delegate on an authorized behavior.
Mod::API::EError ContinueBlueprintBehavior(UObject &Owner)
Invokes the active synchronous Blueprint Wrap continuation.
void UnbindBlueprintBehaviorEvent(UModBehavior &Behavior, const FModExtensionToken &Token)
Removes a registration belonging to the behavior.
MODAPI_API bool RegisterAnchor(FName Id, ULevel &Level, const FTransform &Transform, FName Permission, Mod::Extension::FPatchAnchorRules Rules={})
Registers an anchor on the game thread.
MODAPI_API void RemoveAnchor(FName Id, ULevel &Level)
Releases one anchor's effects at a game-thread safe point.
MODAPI_API TModResult< void > Provide(UModInstance &Owner, const Mod::Extension::FService &Service, UObject *Instance)
Publishes a service from this mod's registration callback.
MODAPI_API Mod::Extension::FWorldFailure GetFailure() const
Returns the terminal extension failure on the game thread, if any.
MODAPI_API TOptional< Mod::Extension::FPatchOrigin > GetPatchOrigin(const UObject &Effect) const
Reports the provenance of a tracked Patch Actor or component.
MODAPI_API TModResult< Mod::API::FObjectBinding > Bind(UModInstance &Consumer, FName Id, FName TypeId, const TCHAR *Signature)
Obtains a generated, revocable service binding on the game thread.
MODAPI_API Mod::Extension::ESubscriptionStatus GetSubscriptionStatus(const UModInstance &Owner, const Mod::Extension::FSubscription &Token) const
Reports the token's publication state on the game thread.
MODAPI_API bool DefineContentSlot(FName Id, Mod::Extension::FContentSlot Slot)
Defines a content slot on the game thread before Prepare.
MODAPI_API void Stop()
Stops entry and releases resources once in-flight callbacks return.
bool GetBlueprintBehaviorSource(UObject &Owner, FName TypeId, const TCHAR *Signature, FModPayloadObject &OutSource)
Returns the active behavior callback's opaque source view.
MODAPI_API Mod::Extension::FPatchData ResolvePatchData(FName Anchor, FName DataId) const
Reads active Patch data and provenance on the game thread.
MODAPI_API void Unregister(UModInstance &Owner, const Mod::Extension::FSubscription &Token)
Requests ordinary unsubscription at the next game-thread safe point.
A game-thread Mod entry point owned by one game instance.
Definition ModInstance.h:52
Identifies a registration owned by one mod and World.
Definition ModExtensionLibrary.h:48
A read-only object borrowed for one extension callback.
Definition ModExtensionLibrary.h:62
Host rules for one slot, including its base game defaults.
Definition ModExtensionSubsystem.h:56
TFunction< bool(const UObject &)> ValidateAsset
Applies game-specific rules to loaded assets on the game thread.
Definition ModExtensionSubsystem.h:68
bool bAllowReplaceProvided
Allows replacement of an ID supplied by a declared dependency.
Definition ModExtensionSubsystem.h:62
bool bLoadOnDemand
Loads optional content on first resolution instead of at the gate.
Definition ModExtensionSubsystem.h:70
FSoftObjectPath Fallback
Optional host asset used when an optional winner cannot be loaded.
Definition ModExtensionSubsystem.h:66
A cached link from a host call site to the current World's channel.
Definition ModExtension.h:345
One resolved handler bound to its original owner and exact signature.
Definition ModExtension.h:200
Game-owned authorization and conflict choices for one World.
Definition ModExtensionSubsystem.h:75
bool bCreate
Whether this alias may construct a plain UObject.
Definition ModExtensionSubsystem.h:85
FName Permission
Grant required to use this alias.
Definition ModExtensionSubsystem.h:79
bool bReadOnly
Whether this alias permits only const exported calls.
Definition ModExtensionSubsystem.h:89
TWeakObjectPtr< UObject > Object
Live object offered by this alias, when configured.
Definition ModExtensionSubsystem.h:81
bool bRetain
Whether a Mod may keep the object alive through a strong reference.
Definition ModExtensionSubsystem.h:87
FSoftClassPath Class
Exact class path offered for loading or creation, when configured.
Definition ModExtensionSubsystem.h:83
FName TypeId
The exact exported World view shared with the native Mod.
Definition ModExtensionSubsystem.h:77
An explicitly offered native local-player provider.
Definition ModExtensionSubsystem.h:94
TWeakObjectPtr< ULocalPlayer > Player
The local player scoped to this World.
Definition ModExtensionSubsystem.h:100
FName TypeId
The exact exported local-player provider type.
Definition ModExtensionSubsystem.h:96
FName Permission
Grant required to use this alias.
Definition ModExtensionSubsystem.h:98
How to order this registration relative to other participating Mods.
Definition ModExtension.h:148
Host-owned operations enabled for an anchor.
Definition ModExtensionSubsystem.h:139
TWeakObjectPtr< USceneComponent > Attachment
Optional registered scene component approved as an attachment parent.
Definition ModExtensionSubsystem.h:143
bool bAllowSpawnActor
Authorizes spawning a Mod Actor in this anchor's level.
Definition ModExtensionSubsystem.h:141
UClass * DataAssetType
Optional UDataAsset subclass accepted by the anchor's data registry.
Definition ModExtensionSubsystem.h:145
An asset registered by an active World Patch.
Definition ModExtensionSubsystem.h:167
TWeakObjectPtr< UDataAsset > Asset
Cooked asset held while the registration is active.
Definition ModExtensionSubsystem.h:169
FPatchOrigin Origin
Owning package revision and anchor activation.
Definition ModExtensionSubsystem.h:171
Provenance for an effect created by the current World Patch plan.
Definition ModExtensionSubsystem.h:150
FName Anchor
Host-defined anchor identity.
Definition ModExtensionSubsystem.h:158
FString Revision
Exact archive SHA-256 for the applied revision.
Definition ModExtensionSubsystem.h:156
FString ModId
Package that requested the Actor.
Definition ModExtensionSubsystem.h:152
uint64 AnchorGeneration
Generation of the anchor activation that owns the effect.
Definition ModExtensionSubsystem.h:162
uint64 WorldGeneration
Generation of the World that produced the Actor.
Definition ModExtensionSubsystem.h:160
FName PatchId
ID declared by that package.
Definition ModExtensionSubsystem.h:154
The winning content and its provenance, valid in the current World.
Definition ModExtensionSubsystem.h:45
bool bUsedFallback
Whether the game supplied the asset after the selected asset failed.
Definition ModExtensionSubsystem.h:51
Describes a precompiled cross-Mod service supplied by one Mod instance.
Definition ModExtensionSubsystem.h:190
Revocation identity, valid only for the issuing World generation.
Definition ModExtension.h:288
Describes why an extension World lost its gameplay gate.
Definition ModExtensionSubsystem.h:176
FString Detail
Human-readable origin and failure details.
Definition ModExtensionSubsystem.h:180
Mod::API::EError Error
Stable reason for closing the plan.
Definition ModExtensionSubsystem.h:178
bool bRestartRequired
A new process is required to release uncertain state.
Definition ModExtensionSubsystem.h:182
Rules supplied by the game before preparing a World.
Definition ModExtensionSubsystem.h:105
TSet< FString > EnabledMods
Restricts participation when the set is populated.
Definition ModExtensionSubsystem.h:112
TFunction< FString(const Mod::Loader::FMountedPackage &)> GameplayReleaseId
Resolves an admitted archive to a stable gameplay release ID.
Definition ModExtensionSubsystem.h:119
Mod::Loader::FPackageSelection Selection
An explicit filter also supports a session with zero enabled mods.
Definition ModExtensionSubsystem.h:115
TMap< FName, FNativeObjectRule > NativeObjects
Explicit names and grants for native object lookup and construction.
Definition ModExtensionSubsystem.h:108
TFunction< bool(FString &)> StageSavedState
Stages validated save data against resolved logical content.
Definition ModExtensionSubsystem.h:123
FString ExpectedGameplayDigest
Optional authoritative fingerprint to match before opening gameplay.
Definition ModExtensionSubsystem.h:117
TFunction< bool(FString &)> ValidatePreparation
Optional host admission check before loading extension resources.
Definition ModExtensionSubsystem.h:121
TMap< FName, FNativePlayerRule > NativePlayers
Explicit aliases for generated local-player provider calls.
Definition ModExtensionSubsystem.h:110
Result of the host's original operation.
Definition ModExtension.h:165
Status and complete result of a generated Hook call.
Definition ModExtension.h:156
Content described by a mounted mod package.
Definition ModLoader.h:113
Host selection applied before mounting or freezing a session.
Definition ModLoader.h:76
A host-owned buffer for reflection output.
Definition ModExtensionABI.h:297
Borrowed inputs to a Mod-owned reflection or archive operation.
Definition ModExtensionABI.h:285