ActionManager - vr4vet/Blue-Sector GitHub Wiki
A singleton “logger” MonoBehaviour that tracks player interactions, task progress, chat history, and idle time between tasks, then packages it all into an UploadDataDTO
for AIRequest
to send to Chat-Service
-
Prefab:
ActionManager
, located inVR4VET/Components/ActionManager
-
Required Components on the GameObject:
ActionManager.cs
IdleTimer
-
Also requires to function properly:
- Optional
Grabber
instances (for grab/release events) - A running Task system via
WatchManager
(definesTask.Task
,Task.Subtask
,Task.Step
) - A chat/NPC AI implementation (to consume global chat logs)
- A way to send the global chat logs (Handled by
AIRequest.cs
throughAIConversationController.cs
- Ideally Chat-Service running on a server somewhere
- Optional
-
Scene Changes
- Registers
SceneManager.sceneLoaded
→OnSceneLoaded
- Writes
scene.name
into_uploadData.scene_name
- Registers
-
Grab & Release
- Finds all
Grabber
components in the scene atOnEnable()
- Hooks
onAfterGrabEvent
→OnGrabEvent(Grabbable grabbable)
- Hooks
onReleaseEvent
→OnReleaseEvent(Grabbable grabbable)
- Finds all
To add e.g. UI-button events:
- Register listeners in
OnEnable()
- Unregister in
OnDisable()
- Implement your handler methods on the same pattern.
- Hierarchy:
Task (ScriptableObject)
└─ Subtask (ScriptableObject)
└─ Step (ScriptableObject)
-
Initialization:
- Call
ActionManager.Instance.LogTaskHierarchy(taskList)
after yourTaskHolder
has loaded or reset the list of tasks. -
taskList
should be aList<Task.Task>
(as used inWatchManager
andTaskHolder
).
- Call
-
Step Completion:
- When a step is completed (typically from
WatchManager.CompleteStep
), call:
- When a step is completed (typically from
ActionManager.Instance.LogStepCompletion(finishedStep);
-
finishedStep
should be a reference to the completedTask.Step
instance.
-
Summary Generation:
- To generate a progress summary (for display in the tablet UI, for example), call:
ActionManager.Instance.TaskSummary();
- The summary is stored in
ActionManager.Instance.LatestSummary
as an HTML-formatted string with colored progress stats
(this should be updated to Text Fields on gameObjects or the like... at least it shouldn't be in the ActionManager
....
-
Global Chat Logs:
- Add messages via
AddChatMessage(Message msg)
- Retrieve via
GetGlobalChatLogs()
- Add messages via
- Message DTO:
public class Message {
public string role; // e.g. "user" or "assistant"
public string content;
}
-
AI Functionality Toggle:
- Controlled by
SetToggleBool(bool)
/GetToggleBool()
- Used by AI NPCs (e.g. “AIna” in ReceptionOutdoor scene) to determine if AI features are enabled
- Controlled by
-
Data Collector:
- All info is built into
_uploadData
(typeUploadDataDTO
) - Sent to
AIRequest
when conversing with an NPC
- All info is built into
- Recording Custom Actions:
ActionManager.Instance.GetUploadData()
.user_actions
.Add("myCustomAction: details");
// Optionally trim:
// ActionManager.Instance.ShortenList(ActionManager.Instance.GetUploadData().user_actions, 20);
-
Common Warnings:
-
“IdleTimer component not found…” → add
IdleTimer
to prefab -
“Could not find step X” → ensure
LogStepCompletion
is called with the correctStep
instance
-
“IdleTimer component not found…” → add
- Resetting Logs for Tests:
ActionManager.Instance.GetUploadData().user_actions.Clear();
ActionManager.Instance.GetGlobalChatLogs().Clear();
// or replace with new List<T>()