Nelaric Unreal Gameplay
Gameplay framework API
Loading...
Searching...
No Matches
PawnInitStateComponent.h
Go to the documentation of this file.
1// Copyright (c) 2026 Nelaric
2
6
7#pragma once
8
11
12#include "PawnInitStateComponent.generated.h"
13
21UCLASS(Abstract, MinimalAPI)
22class UPawnInitStateComponent : public UNelaricPawnComponent, public IInitStateParticipantInterface
23{
24 GENERATED_BODY()
25
26public:
28 GAMEPLAYRUNTIME_API virtual bool IsInitApplicable() const override;
29
31 GAMEPLAYRUNTIME_API virtual bool TryChangeInitState() final override;
32
34 GAMEPLAYRUNTIME_API virtual bool CanEnterReady() final override;
35
37 GAMEPLAYRUNTIME_API virtual bool CommitReadyWithoutNotification() override;
38
42 GAMEPLAYRUNTIME_API virtual void NotifyReadyCommitted(const Nelaric::FInitStateSnapshot& Previous) override;
43
48 GAMEPLAYRUNTIME_API void RequestInitRefresh();
49
51 GAMEPLAYRUNTIME_API virtual Nelaric::EInitState GetInitState() const override;
52
54 GAMEPLAYRUNTIME_API virtual Nelaric::FInitGeneration GetInitGeneration() const override;
55
57 GAMEPLAYRUNTIME_API virtual bool HasTerminalInitFailure() const override;
58
67 GAMEPLAYRUNTIME_API bool CanApplyInitResult(const UWorld* ExpectedWorld,
68 Nelaric::FInitGeneration ExpectedGeneration) const;
69
76 GAMEPLAYRUNTIME_API static UPawnInitStateComponent*
77 ResolveInitResult(const TWeakObjectPtr<UPawnInitStateComponent>& WeakComponent, const UWorld* ExpectedWorld,
78 Nelaric::FInitGeneration ExpectedGeneration);
79
81 GAMEPLAYRUNTIME_API virtual void InvalidateInitGeneration() override;
82
84 GAMEPLAYRUNTIME_API virtual void MarkTerminalInitFailure() override;
85
86public:
87 GAMEPLAYRUNTIME_API UPawnInitStateComponent(const FObjectInitializer& ObjectInitializer);
88 GAMEPLAYRUNTIME_API virtual void OnRegister() override;
89 GAMEPLAYRUNTIME_API virtual void OnUnregister() override;
90
91protected:
97 GAMEPLAYRUNTIME_API virtual bool CanEntryDataAvailable();
98
104 GAMEPLAYRUNTIME_API virtual bool CanEntryDataInitialized();
105
113 GAMEPLAYRUNTIME_API virtual bool CanEntryReady();
114
119 GAMEPLAYRUNTIME_API virtual void OnInitReady();
120
128 GAMEPLAYRUNTIME_API virtual void OnInitGenerationInvalidated(const Nelaric::FInitStateSnapshot& Previous);
129
133 GAMEPLAYRUNTIME_API virtual void CancelInitGenerationWork();
134
135private:
136 bool CommitInitState(Nelaric::EInitState NextState);
137 Nelaric::EInitState InitState = Nelaric::EInitState::Registered;
138 Nelaric::FInitGeneration InitGeneration{1};
139 bool bTerminalInitFailure = false;
140 bool bCommittingInitState = false;
141 bool bReadyNotificationPending = false;
142 bool bLocalReadyPrepared = false;
143 bool bLeavingWorld = false;
144 bool bRefreshRequestedDuringTransition = false;
145 void NotifyInitChanged(const Nelaric::FInitStateSnapshot& Previous);
146 void FlushDeferredInitRefresh();
147};
Contract implemented by an actor component in world initialization.
Definition InitStateParticipantInterface.h:28
static GAMEPLAYRUNTIME_API UPawnInitStateComponent * ResolveInitResult(const TWeakObjectPtr< UPawnInitStateComponent > &WeakComponent, const UWorld *ExpectedWorld, Nelaric::FInitGeneration ExpectedGeneration)
Resolves a game-thread asynchronous completion for a live attempt.
GAMEPLAYRUNTIME_API bool CanApplyInitResult(const UWorld *ExpectedWorld, Nelaric::FInitGeneration ExpectedGeneration) const
Checks whether an asynchronous result may update this attempt.
virtual GAMEPLAYRUNTIME_API Nelaric::EInitState GetInitState() const override
Returns the state owned by this component.
virtual GAMEPLAYRUNTIME_API bool HasTerminalInitFailure() const override
Returns whether this attempt has failed permanently.
virtual GAMEPLAYRUNTIME_API bool IsInitApplicable() const override
Participates by default; override for conditional applicability.
virtual GAMEPLAYRUNTIME_API bool CanEntryDataInitialized()
Initializes this component's available data.
virtual GAMEPLAYRUNTIME_API bool CommitReadyWithoutNotification() override
Writes Ready without callbacks after the coordinator checks the group.
virtual GAMEPLAYRUNTIME_API void OnInitReady()
Starts gameplay after the entire readiness group entered Ready.
GAMEPLAYRUNTIME_API void RequestInitRefresh()
Requests another local coordinator pass after context changes.
virtual GAMEPLAYRUNTIME_API void CancelInitGenerationWork()
Cancels work and removes listeners for an invalidated attempt.
virtual GAMEPLAYRUNTIME_API void OnInitGenerationInvalidated(const Nelaric::FInitStateSnapshot &Previous)
Stops work and gameplay belonging to an invalidated attempt.
virtual GAMEPLAYRUNTIME_API bool TryChangeInitState() final override
Commits at most one adjacent preparation step when the derived gate passes.
virtual GAMEPLAYRUNTIME_API void InvalidateInitGeneration() override
Invalidates old work, resets state, and announces the new attempt.
virtual GAMEPLAYRUNTIME_API bool CanEnterReady() final override
Runs DataInitialized preparation until it succeeds in this generation.
virtual GAMEPLAYRUNTIME_API void NotifyReadyCommitted(const Nelaric::FInitStateSnapshot &Previous) override
Announces a committed Ready transition after the group commits.
virtual GAMEPLAYRUNTIME_API Nelaric::FInitGeneration GetInitGeneration() const override
Returns the current attempt identity owned by this component.
virtual GAMEPLAYRUNTIME_API void MarkTerminalInitFailure() override
Records terminal failure and announces it to the world.
virtual GAMEPLAYRUNTIME_API bool CanEntryReady()
Performs final local preparation before the Ready check.
virtual GAMEPLAYRUNTIME_API bool CanEntryDataAvailable()
Acquires this component's data while Registered.
Captures the stage and terminal failure of one initialization attempt.
Definition InitStateTypes.h:41