Skip to content

Add network execution helper for visual scripting instructions#8

Open
andreathar wants to merge 1 commit intoatharmcpfrom
codex/add-inetworkcharacteradapter-implementation
Open

Add network execution helper for visual scripting instructions#8
andreathar wants to merge 1 commit intoatharmcpfrom
codex/add-inetworkcharacteradapter-implementation

Conversation

@andreathar
Copy link
Owner

@andreathar andreathar commented Nov 26, 2025

Summary

  • add a reusable helper to execute visual scripting instructions according to network execution modes
  • integrate the network debug log instruction with the helper so it can broadcast or delegate execution per mode

Testing

  • Not run (not requested)

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

  • Network Execution Helper: Added NetworkInstructionExtensions class providing a unified ExecuteNetworked() method that handles different network execution modes (LocalOnly, OwnerOnly, ServerOnly, AllClients, ServerAuthority)
  • Character Network Adapter: Refactored NetworkGameCreatorCharacterV2 to implement INetworkCharacterAdapter interface, moving from disabling the Character component to using adapter pattern for better integration
  • Visual Scripting Integration: Updated InstructionNetworkDebugLog to use the new helper system, demonstrating the pattern for other network-aware instructions

Technical 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
    end
Loading

Impact

  • Code Reusability: Eliminates boilerplate RPC code across visual scripting instructions by providing a centralized execution helper
  • Network Coordination: Ensures proper multiplayer behavior by respecting ownership and authority patterns for different instruction types
  • Architecture Improvement: Character network integration now uses adapter pattern instead of disabling components, maintaining GameCreator's intended behavior while adding network capabilities
  • Developer Experience: Simplified API for creating network-aware visual scripting instructions with consistent execution patterns

Created with Palmier

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +86 to +90
case NetworkExecutionMode.AllClients:
if (context.IsServer)
{
// Execute locally on the server and broadcast to every other client
await action();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant