-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add prototype quest progress loop #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ public sealed class PrototypeNearbyNpcChatBox : MonoBehaviour | |
| private string _status = "Nearby NPC chat ready"; | ||
| private Vector2 _historyScrollPosition; | ||
| private bool _societyEventRpcAvailable = true; | ||
| private CharacterMemorySync _memorySync; | ||
| private string _focusedNpcActorId; | ||
| private string _focusedNpcDisplayName; | ||
| private PrototypeAgentBrain _focusedNpcBrain; | ||
|
|
@@ -101,6 +102,7 @@ private static void AttachToGatewayOnSceneLoad() | |
| private void Awake() | ||
| { | ||
| _gateway = GetComponent<SecondSpawnGatewayClient>(); | ||
| _memorySync = GetComponent<CharacterMemorySync>(); | ||
| } | ||
|
|
||
| private void Update() | ||
|
|
@@ -278,6 +280,8 @@ private IEnumerator SendNearbyMessage(string message, List<string> explicitActor | |
| yield break; | ||
| } | ||
|
|
||
| yield return TryProgressPrototypeQuestFromNpcChat(nearbyActorIds); | ||
|
|
||
| NpcSocietyTickResponseDto tickResponse = null; | ||
| error = null; | ||
| yield return _gateway.TickNpcSociety(new NpcSocietyTickRequestDto | ||
|
|
@@ -323,6 +327,109 @@ private IEnumerator SendNearbyMessage(string message, List<string> explicitActor | |
| _busy = false; | ||
| } | ||
|
|
||
| private IEnumerator TryProgressPrototypeQuestFromNpcChat(List<string> nearbyActorIds) | ||
| { | ||
| if (_gateway == null || nearbyActorIds == null || nearbyActorIds.Count == 0) | ||
| { | ||
| yield break; | ||
| } | ||
|
|
||
| var stepId = ResolvePrototypeQuestStepId(nearbyActorIds); | ||
| if (string.IsNullOrWhiteSpace(stepId)) | ||
| { | ||
| yield break; | ||
| } | ||
|
|
||
| var actorId = ResolvePrototypeQuestActorId(nearbyActorIds, stepId); | ||
| if (string.IsNullOrWhiteSpace(actorId)) | ||
| { | ||
| yield break; | ||
| } | ||
|
|
||
| QuestProgressResponseDto response = null; | ||
| string error = null; | ||
| yield return _gateway.ProgressNakamaQuest(new QuestProgressRequestDto | ||
| { | ||
| quest_id = "prototype-ash-underpass-signal", | ||
| step_id = stepId, | ||
| actor_id = actorId, | ||
| source = "player_dialog", | ||
| amount = 1 | ||
| }, value => response = value, value => error = value); | ||
|
|
||
| if (response == null) | ||
| { | ||
| Debug.LogWarning($"[PrototypeNearbyNpcChatBox] Quest progress failed actor={actorId}, step={stepId}: {Shorten(error, 100)}"); | ||
| yield break; | ||
| } | ||
|
|
||
| if (response.changed) | ||
| { | ||
| _status = response.ready_to_claim | ||
| ? "Quest ready to claim: Check The Ash Underpass Signal." | ||
| : "Quest updated: Check The Ash Underpass Signal."; | ||
| Debug.Log($"[PrototypeNearbyNpcChatBox] Quest progress changed actor={actorId}, step={stepId}, ready={response.ready_to_claim}"); | ||
| if (_memorySync != null) | ||
| { | ||
| yield return _memorySync.Refresh(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static string ResolvePrototypeQuestStepId(List<string> actorIds) | ||
| { | ||
| foreach (var actorId in actorIds) | ||
| { | ||
| if (IsRouteOrGateQuestActor(actorId)) | ||
| { | ||
| return "ask-route-or-gate"; | ||
|
Comment on lines
+383
to
+385
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
|
|
||
| foreach (var actorId in actorIds) | ||
| { | ||
| if (IsSecondSourceQuestActor(actorId)) | ||
| { | ||
| return "confirm-second-source"; | ||
| } | ||
| } | ||
|
|
||
| return ""; | ||
| } | ||
|
|
||
| private static string ResolvePrototypeQuestActorId(List<string> actorIds, string stepId) | ||
| { | ||
| foreach (var actorId in actorIds) | ||
| { | ||
| if (stepId == "ask-route-or-gate" && IsRouteOrGateQuestActor(actorId)) | ||
| { | ||
| return actorId; | ||
| } | ||
|
|
||
| if (stepId == "confirm-second-source" && IsSecondSourceQuestActor(actorId)) | ||
| { | ||
| return actorId; | ||
| } | ||
| } | ||
|
|
||
| return ""; | ||
| } | ||
|
|
||
| private static bool IsRouteOrGateQuestActor(string actorId) | ||
| { | ||
| return actorId == "npc-route-courier-0244" || | ||
| actorId == "npc-gate-sentinel-0101" || | ||
| actorId == "npc-gate-sentinel-0627"; | ||
| } | ||
|
|
||
| private static bool IsSecondSourceQuestActor(string actorId) | ||
| { | ||
| return actorId == "npc-crossline-hunter-1058" || | ||
| actorId == "npc-crossline-hunter-5104" || | ||
| actorId == "npc-clinic-operator-0320" || | ||
| actorId == "npc-scrap-warden-0441"; | ||
| } | ||
|
|
||
| private static void ShowPlayerSpeechBubble(NetworkPlayer player, string message) | ||
| { | ||
| if (player == null || string.IsNullOrWhiteSpace(message)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResolvePrototypeQuestStepIdemitsask-route-or-gate/confirm-second-source, but the server quest catalog and progress path useask_route_or_gate/confirm_second_source(backend/nakama/modules/index.ts,prototypeQuestCatalogandrequirePrototypeQuestStep). BecausenormalizeQuestStepIddoes not convert hyphens to underscores, these chat-triggered progress RPCs hitunknown prototype quest step, so the new nearby-NPC chat loop cannot advance the quest and players can be blocked from reaching the reward-claim state through this intended path.Useful? React with 👍 / 👎.