6.7 KiB
6.7 KiB
Network MVP TODO
Goal
Implement the networking MVP described in MobaSyncMVP.md:
- Client sends only movement and shooting inputs
- Server is authoritative for gameplay state
- Server sends authoritative state and combat events
- Client performs local prediction for movement and interpolation/reconciliation for presentation
Checklist
1. Split Network Message Types
- Add
MoveInput,ShootInput, andCombatEventtoAssets/Scripts/Network/Defines/MessageType.cs - Add matching protobuf definitions in the source
.protofile - Regenerate
Assets/Scripts/Network/Defines/Message.cs - Stop using one broad
PlayerInputmessage to carry both movement and shooting
Acceptance:
MoveInput,ShootInput, andCombatEventcan be referenced independently in code- The project builds successfully after regeneration
2. Update Delivery Policy Mapping
- Update
Assets/Scripts/Network/NetworkApplication/DefaultMessageDeliveryPolicyResolver.cs - Map
MoveInputtoHighFrequencySync - Map
PlayerStatetoHighFrequencySync - Map
ShootInputtoReliableOrdered - Map
CombatEventtoReliableOrdered
Acceptance:
MessageManagerroutes movement/state messages to the sync laneMessageManagerroutes shooting/combat-result messages to the reliable lane
3. Update Sequence Filtering For High-Frequency Messages
- Modify
Assets/Scripts/Network/NetworkApplication/SyncSequenceTracker.cs - Replace
PlayerInput-based stale filtering withMoveInput - Keep stale filtering for
PlayerState - Do not apply stale-drop logic to
ShootInput - Do not apply stale-drop logic to
CombatEvent
Acceptance:
- Older
MoveInputpackets are dropped - Older
PlayerStatepackets are dropped ShootInputis not silently discarded by sequence filtering
4. Narrow Prediction Buffer To Movement
- Modify
Assets/Scripts/Network/NetworkApplication/ClientPredictionBuffer.cs - Store
MoveInputinstead of broadPlayerInput - Continue pruning buffered inputs using authoritative
PlayerState.Tick - Keep shooting outside the prediction replay path
Acceptance:
- Local movement prediction still works
- Authoritative
PlayerStatestill prunes acknowledged movement inputs - Shooting does not depend on prediction buffer replay
5. Preserve And Use Dual-Transport Runtime Wiring
- Verify
Assets/Scripts/Network/NetworkApplication/SharedNetworkRuntime.csis used with both reliable and sync transports - Verify
Assets/Scripts/Network/NetworkHost/ServerNetworkHost.csis used with both reliable and sync transports - Keep the current dual-transport constructor shape for MVP
- Do not expand
ITransportyet unless MVP proves it is necessary
Acceptance:
- Client runtime can start with two distinct transport instances
- Server host can start with two distinct transport instances
MoveInput/PlayerStatecan flow through the sync transportShootInput/CombatEventcan flow through the reliable transport
6. Finalize MVP Message Fields
- Define
MoveInputfields:playerId,tick,moveX,moveY - Define
ShootInputfields:playerId,tick,dirX,dirY, optionaltargetId - Define
PlayerStatefields:playerId,tick,position,rotation,hp, optionalvelocity - Define
CombatEventfields:tick,eventType,attackerId,targetId,damage, optionalhitPosition - Add
CombatEventTypeif needed
Acceptance:
- MVP gameplay data can be expressed without ad hoc payload extensions
- Position, HP, and combat results all have explicit authoritative messages
7. Add Message Routing Tests
- Extend
Assets/Tests/EditMode/Network/MessageManagerTests.cs - Add
SendMessage_MoveInput_UsesSyncLanePolicy - Add
SendMessage_ShootInput_UsesReliableLanePolicy - Add
SendMessage_CombatEvent_UsesReliableLanePolicy - Add
Receive_StaleMoveInput_IsDropped - Add
Receive_ShootInput_IsNotDroppedBySequenceTracker
Acceptance:
- Lane selection is covered by tests for all new MVP messages
- High-frequency stale-drop behavior is covered by tests
8. Add Sync Strategy Tests
- Extend
Assets/Tests/EditMode/Network/SyncStrategyTests.cs - Add
ClientPredictionBuffer_AuthoritativeState_PrunesAcknowledgedMoveInputs - Add
ServerNetworkHost_RejectsStaleMoveInputPerPeerWithoutCrossPeerInterference
Acceptance:
- Prediction buffer still behaves correctly after switching to
MoveInput - Multi-session stale filtering remains isolated per peer
9. Wire Dual Transports In The Integration Layer
- Update the client integration entry point, likely
Assets/Scripts/NetworkManager.cs - Update the server startup integration point
- Instantiate one reliable transport and one sync transport
- Ensure runtime construction uses both transports instead of a single shared instance
Acceptance:
- Runtime uses logical dual-lane routing backed by two transport instances
- Logging or tests confirm movement/state traffic and reliable event traffic are separated
10. Build And Test
- Run
dotnet build Network.EditMode.Tests.csproj -v minimal - Run
dotnet test Network.EditMode.Tests.csproj --no-build -v minimal
Acceptance:
- Build succeeds
- Edit-mode network tests succeed
- New MVP regression tests succeed
Recommended Order
- Split protocol and message types
- Update delivery policy mapping
- Update sequence filtering
- Narrow prediction buffer
- Add and update tests
- Wire dual transports in integration
- Build and run tests