Add RemoteActionQueue and descriptor animation sync

Add a RemoteActionComponent (header + impl) implementing RemoteActionSnapshot and RemoteActionQueue to capture, queue (max 16) and replay discrete remote actions with comprehensive logging. Integrate the action queue into ProxyActorSlot by including the new header and adding an actionQueue member. Replace string-based per-frame animation writes with a descriptor-based bulk sync function (ApplyProxyAnimationFromRemoteStateDescriptorBased) that builds indexed AnimationVariableSnapshot and calls descriptor.LoadAnimationVariablesToCache for a single bulk write (reduces string lookups and improves performance). Update docs/dev-log with Phase 5 summary and details of the action replay and descriptor-based animation sync changes.
This commit is contained in:
2026-06-03 17:05:49 +12:00
parent e14b91d94e
commit 40bc637103
5 changed files with 433 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
#pragma once
#include <cstdint>
#include <vector>
#include <chrono>
#include "F4AnimationDescriptor.h"
#include "RE/A/Actor.h"
namespace F4T::RemoteActionComponent
{
// Represents a remote action event to be replayed on a proxy actor
// Includes animation state snapshot and actor state at the time of capture
struct RemoteActionSnapshot
{
std::uint32_t actionType{}; // Action enum value
std::string eventName; // Human-readable event name
AnimationDescriptor::AnimationVariableSnapshot animationVariables; // Graph variables at action time
std::uint32_t actorStateFlags1{}; // Actor state flags1 at action time
std::uint32_t actorStateFlags2{}; // Actor state flags2 at action time
std::chrono::steady_clock::time_point captureTime{}; // When action was captured
};
// Manages action queue for a single remote player's proxy actor
// Queues discrete actions and replays them with proper state synchronization
class RemoteActionQueue
{
public:
// Initialize empty queue
RemoteActionQueue() = default;
// Prevent copies
RemoteActionQueue(const RemoteActionQueue&) = delete;
RemoteActionQueue& operator=(const RemoteActionQueue&) = delete;
// Enqueue an action for replay
void Enqueue(const RemoteActionSnapshot& a_action);
// Clear all pending actions
void Clear();
// Get number of pending actions
std::size_t GetPendingActionCount() const { return m_actionQueue.size(); }
// Replay next action on proxy actor
// Returns true if an action was replayed, false if queue empty
bool ReplayNextAction(RE::Actor& a_proxy);
private:
std::vector<RemoteActionSnapshot> m_actionQueue;
std::size_t m_maxQueueSize{ 16 }; // Prevent excessive queuing
// Helper: Apply action state to proxy and trigger animation
bool ApplyActionToProxy(RE::Actor& a_proxy, const RemoteActionSnapshot& a_action);
// Helper: Set actor state flags from snapshot
void ApplyActorStateFromSnapshot(RE::Actor& a_proxy, const RemoteActionSnapshot& a_action);
// Helper: Load animation variables and trigger action animation
void TriggerActionAnimation(RE::Actor& a_proxy, const RemoteActionSnapshot& a_action);
};
}