Add network execution helper for visual scripting instructions#8
Add network execution helper for visual scripting instructions#8andreathar wants to merge 1 commit intoatharmcpfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case NetworkExecutionMode.AllClients: | ||
| if (context.IsServer) | ||
| { | ||
| // Execute locally on the server and broadcast to every other client | ||
| await action(); |
There was a problem hiding this comment.
AllClients/ServerAuthority instructions never run remotely
ExecuteNetworked registers the action delegate only on the local process before invoking network RPCs (case NetworkExecutionMode.AllClients here); the RPC handlers in NetworkInstructionAdapter look up the delegate in their own static registry (NetworkInstructionAdapter.cs:23-48, 64-82, 89-107), which is empty on other peers. Consequently AllClients runs only on the server and remote clients log “action not found”, and ServerAuthority calls from a client are dropped because the server cannot resolve the action. An instruction such as InstructionNetworkDebugLog executed in AllClients/ServerAuthority mode will never execute on remote peers, defeating those modes.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task
🔧 This PR introduces a centralized network execution helper system for visual scripting instructions, enabling proper multiplayer coordination by routing instruction execution through different network modes (owner-only, server-only, all clients, etc.) and refactors the character network adapter to use a cleaner interface-based approach.
🔍 Detailed Analysis
Key Changes
NetworkInstructionExtensionsclass providing a unifiedExecuteNetworked()method that handles different network execution modes (LocalOnly, OwnerOnly, ServerOnly, AllClients, ServerAuthority)NetworkGameCreatorCharacterV2to implementINetworkCharacterAdapterinterface, moving from disabling the Character component to using adapter pattern for better integrationInstructionNetworkDebugLogto use the new helper system, demonstrating the pattern for other network-aware instructionsTechnical Implementation
sequenceDiagram participant I as Instruction participant H as NetworkHelper participant C as NetworkContext participant N as NetworkManager I->>H: ExecuteNetworked(action, mode, args) H->>C: FromGameObject(contextObject) C->>H: Network context info alt LocalOnly H->>I: Execute action locally else OwnerOnly alt IsOwner H->>I: Execute action else Not Owner H->>I: Skip execution end else ServerOnly alt IsServer H->>I: Execute action else Not Server H->>I: Skip execution end else AllClients alt IsServer H->>I: Execute locally H->>N: Broadcast to all clients else Not Server H->>I: Execute locally (fallback) end else ServerAuthority alt IsServer H->>I: Execute action H->>N: Broadcast result else Not Server H->>N: Request server execution end endImpact
Created with Palmier