将 openspec skills 迁移到全局 + 定义后续 proto 类型
This commit is contained in:
@@ -7,13 +7,13 @@ namespace Network.NetworkApplication
|
||||
{
|
||||
public sealed class ClientPredictionBuffer
|
||||
{
|
||||
private readonly List<PlayerInput> pendingInputs = new();
|
||||
private readonly List<MoveInput> pendingInputs = new();
|
||||
|
||||
public long? LastAuthoritativeTick { get; private set; }
|
||||
|
||||
public IReadOnlyList<PlayerInput> PendingInputs => pendingInputs;
|
||||
public IReadOnlyList<MoveInput> PendingInputs => pendingInputs;
|
||||
|
||||
public void Record(PlayerInput input)
|
||||
public void Record(MoveInput input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace Network.NetworkApplication
|
||||
pendingInputs.Add(input);
|
||||
}
|
||||
|
||||
public bool TryApplyAuthoritativeState(PlayerState state, out IReadOnlyList<PlayerInput> replayInputs)
|
||||
public bool TryApplyAuthoritativeState(PlayerState state, out IReadOnlyList<MoveInput> replayInputs)
|
||||
{
|
||||
if (state == null)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace Network.NetworkApplication
|
||||
|
||||
if (LastAuthoritativeTick.HasValue && state.Tick <= LastAuthoritativeTick.Value)
|
||||
{
|
||||
replayInputs = Array.Empty<PlayerInput>();
|
||||
replayInputs = Array.Empty<MoveInput>();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,4 +47,4 @@ namespace Network.NetworkApplication
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Network.NetworkApplication
|
||||
private static readonly IReadOnlyDictionary<MessageType, DeliveryPolicy> DefaultPolicies =
|
||||
new Dictionary<MessageType, DeliveryPolicy>
|
||||
{
|
||||
{ MessageType.PlayerInput, DeliveryPolicy.HighFrequencySync },
|
||||
{ MessageType.MoveInput, DeliveryPolicy.HighFrequencySync },
|
||||
{ MessageType.PlayerState, DeliveryPolicy.HighFrequencySync }
|
||||
};
|
||||
|
||||
@@ -19,4 +19,4 @@ namespace Network.NetworkApplication
|
||||
: DeliveryPolicy.ReliableOrdered;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Network.Defines;
|
||||
@@ -39,9 +38,9 @@ namespace Network.NetworkApplication
|
||||
{
|
||||
switch (messageType)
|
||||
{
|
||||
case MessageType.PlayerInput:
|
||||
case MessageType.MoveInput:
|
||||
{
|
||||
var input = PlayerInput.Parser.ParseFrom(payload);
|
||||
var input = MoveInput.Parser.ParseFrom(payload);
|
||||
streamKey = $"input:{Normalize(sender)}:{input.PlayerId}";
|
||||
sequence = input.Tick;
|
||||
return true;
|
||||
@@ -67,4 +66,4 @@ namespace Network.NetworkApplication
|
||||
return sender == null ? "unknown" : sender.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user