Skip to content

GameCore.ProtocolServerTransient ​

IProtocolServerTransient 双端 ​

命名空间 GameCore.ProtocolServerTransient

csharp
public interface IProtocolServerTransient<TSelf> : IBytesReplicableUnmanaged<TSelf>, IBytesReplicable<TSelf>, IProtocolServerTransient, IGameClass where TSelf : unmanaged, IProtocolServerTransient<TSelf>

定义泛型服务器瞬态协议接口,提供类型安全的消息处理功能

备注

此接口结合了字节序列化、协议处理和游戏类注册功能,为瞬态消息提供完整的处理框架。 实现类型必须是非托管类型以确保高效的序列化性能。

属性 ​

TypeHash 双端 ​

csharp
static int TypeHash { get; }

获取协议类型的哈希值

备注

用于在消息处理器字典中标识和查找特定的协议类型。

方法 ​

Handle 仅客户端 ​

csharp
static void Handle(ReadOnlySpan<byte> bytes)

处理从字节数据反序列化的协议消息

  • bytes — 包含协议数据的字节跨度
备注

此方法负责反序列化字节数据并调用具体的消息处理逻辑。

ProtoActorScopeTransientCreation 双端 ​

命名空间 GameCore.ProtocolServerTransient

csharp
public readonly struct ProtoActorScopeTransientCreation : IProtocolServerTransient<ProtoActorScopeTransientCreation>, IBytesReplicableUnmanaged<ProtoActorScopeTransientCreation>, IBytesReplicable<ProtoActorScopeTransientCreation>, IProtocolServerTransient, IGameClass, IActorScopeContext, IActorScopeTransientPlayContext

构造函数 ​

ProtoActorScopeTransientCreation 双端 ​

csharp
public ProtoActorScopeTransientCreation()

ProtoActorScopeTransientCreation 双端 ​

csharp
public ProtoActorScopeTransientCreation(IActorScopeContext context)

属性 ​

csharp
public ProtoIGameLink<IGameDataActorScopeOwner>? ProtoLink { get; init; }

ProtoTransientActor 双端 ​

csharp
public ProtoIGameLink<GameDataActor>? ProtoTransientActor { get; init; }

ProtoPlayer 双端 ​

csharp
public ProtoPlayer ProtoPlayer { get; init; }

ProtoEntityOrScenePoint 双端 ​

csharp
public required ProtoEntityOrScenePoint ProtoEntityOrScenePoint { get; init; }

ProtoSource 双端 ​

csharp
public required ProtoEntityOrScenePoint ProtoSource { get; init; }

Facing 双端 ​

csharp
public Angle? Facing { get; init; }

Scale 双端 ​

csharp
public float? Scale { get; init; }

Volume 双端 ​

csharp
public Vector3? Volume { get; init; }

Radius 双端 ​

csharp
public float? Radius { get; init; }

TransientDurationMilliseconds 双端 ​

csharp
public int TransientDurationMilliseconds { get; init; }

TransientLocalOffset 双端 ​

csharp
public Vector3? TransientLocalOffset { get; init; }

TransientRotation 双端 ​

csharp
public Vector3? TransientRotation { get; init; }

TransientScale 双端 ​

csharp
public Vector3? TransientScale { get; init; }

TransientAutoPlay 双端 ​

csharp
public bool TransientAutoPlay { get; init; }
csharp
public IGameLink<IGameDataActorScopeOwner>? Link { get; }

TransientActor 双端 ​

csharp
public IGameLink<GameDataActor>? TransientActor { get; }

TransientDuration 双端 ​

csharp
public TimeSpan? TransientDuration { get; }

Player 双端 ​

csharp
public Player Player { get; }

Target 双端 ​

csharp
public ITarget? Target { get; }

Source 双端 ​

csharp
public ITarget? Source { get; }

方法 ​

Handle 仅客户端 ​

csharp
public void Handle()

ProtoCmdResultNotify 双端 ​

命名空间 GameCore.ProtocolServerTransient

csharp
public struct ProtoCmdResultNotify : IProtocolServerTransient<ProtoCmdResultNotify>, IBytesReplicableUnmanaged<ProtoCmdResultNotify>, IBytesReplicable<ProtoCmdResultNotify>, IProtocolServerTransient, IGameClass

表示命令结果通知的瞬态协议消息,用于向客户端传递命令执行结果

  • cmdResult — 命令执行的结果
备注

此协议消息用于在服务器执行命令后向客户端发送执行结果的通知。 客户端接收到此消息后会触发相应的游戏事件,允许 UI 和其他系统响应命令结果。 这是游戏中命令反馈机制的重要组成部分。

构造函数 ​

ProtoCmdResultNotify 双端 ​

csharp
public ProtoCmdResultNotify(CmdResult cmdResult)

表示命令结果通知的瞬态协议消息,用于向客户端传递命令执行结果

  • cmdResult — 命令执行的结果
备注

此协议消息用于在服务器执行命令后向客户端发送执行结果的通知。 客户端接收到此消息后会触发相应的游戏事件,允许 UI 和其他系统响应命令结果。 这是游戏中命令反馈机制的重要组成部分。

属性 ​

CmdResult 双端 ​

csharp
public required ProtoIExtendableEnum<CmdResult> CmdResult { get; set; }

获取或设置命令执行的结果

备注

使用可扩展枚举包装的命令结果,支持动态添加新的结果类型。 结果包含成功、失败以及各种具体的错误信息。

方法 ​

Handle 仅客户端 ​

csharp
public readonly void Handle()

处理接收到的命令结果通知消息

备注

在客户端处理此协议消息,触发 EventGameCmdResultNotify 事件。 这允许游戏的各个系统响应命令执行结果,如显示错误信息、更新 UI 状态等。

ProtocolServerTransientExtension 仅服务端 ​

命名空间 GameCore.ProtocolServerTransient

csharp
public static class ProtocolServerTransientExtension

提供服务器瞬态协议的扩展方法,用于消息发送和广播

备注

此静态类包含用于发送瞬态协议消息的便捷方法,支持单个玩家发送和广播功能。

方法 ​

SendTo 仅服务端 ​

csharp
public static bool SendTo<TSelf>(this ref TSelf self, Player player, Func<Player, bool>? filter = null) where TSelf : unmanaged, IProtocolServerTransient<TSelf>

向指定玩家发送瞬态协议消息

  • self — 要发送的协议消息实例
  • player — 目标玩家
  • filter — 可选的玩家过滤条件

返回: 如果成功发送则返回 true;否则返回 false

备注

通过玩家的槽控制器发送消息,可以指定额外的过滤条件。

Broadcast 仅服务端 ​

csharp
public static void Broadcast<TSelf>(this ref TSelf self, Func<Player, bool>? filter = null) where TSelf : unmanaged, IProtocolServerTransient<TSelf>

向所有符合条件的玩家广播瞬态协议消息

  • self — 要广播的协议消息实例
  • filter — 可选的玩家过滤条件
备注

向所有在线玩家广播消息,可以通过过滤器限制接收的玩家范围。

ProtoScopeAction 双端 ​

命名空间 GameCore.ProtocolServerTransient

csharp
public struct ProtoScopeAction : IProtocolServerTransient<ProtoScopeAction>, IBytesReplicableUnmanaged<ProtoScopeAction>, IBytesReplicable<ProtoScopeAction>, IProtocolServerTransient, IGameClass

构造函数 ​

ProtoScopeAction 双端 ​

csharp
public ProtoScopeAction()

属性 ​

ProtoActorScope 双端 ​

csharp
public required ProtoActorScope ProtoActorScope { get; set; }

Action 双端 ​

csharp
public required ScopeAction Action { get; set; }

方法 ​

Handle 仅客户端 ​

csharp
public readonly void Handle()

ProtoServerTimeSync 双端 ​

命名空间 GameCore.ProtocolServerTransient

csharp
public struct ProtoServerTimeSync : IProtocolServerTransient<ProtoServerTimeSync>, IBytesReplicableUnmanaged<ProtoServerTimeSync>, IBytesReplicable<ProtoServerTimeSync>, IProtocolServerTransient, IGameClass

服务端在游戏启动时广播给所有客户端的时钟同步消息, 客户端据此计算 ServerTickOffset。

构造函数 ​

ProtoServerTimeSync 双端 ​

csharp
public ProtoServerTimeSync()

服务端在游戏启动时广播给所有客户端的时钟同步消息, 客户端据此计算 ServerTickOffset。

属性 ​

ServerTotalElapsedMs 双端 ​

csharp
public required int ServerTotalElapsedMs { get; set; }

服务端发送时的 TotalElapsedTickInMilliseconds 值。

方法 ​

Handle 仅客户端 ​

csharp
public readonly void Handle()

ProtoSyncIdListChange 双端 ​

命名空间 GameCore.ProtocolServerTransient

csharp
public struct ProtoSyncIdListChange : IProtocolServerTransient<ProtoSyncIdListChange>, IBytesReplicableUnmanaged<ProtoSyncIdListChange>, IBytesReplicable<ProtoSyncIdListChange>, IProtocolServerTransient, IGameClass

Protocol for synchronizing SyncIdList changes between server and client.

备注

This protocol uses the complete 64-bit property hash, which automatically encodes:

  • For host properties: propertyHash only
  • For component properties: (componentSyncId << 32) | propertyHash This allows any IPropertyOwner (host or component) to have its own SyncIdList.

属性 ​

Type 双端 ​

csharp
public required ModifyType Type { get; set; }

The type of modification (Add or Remove).

HostId 双端 ​

csharp
public required int HostId { get; set; }

The host ID (ICooldownHost.SyncId) that contains the property owner.

PropertyHash 双端 ​

csharp
public required long PropertyHash { get; set; }

The complete 64-bit property hash that uniquely identifies the SyncIdList. High 32 bits: component SyncId (0 for host properties) Low 32 bits: property hash code

ValueId 双端 ​

csharp
public required int ValueId { get; set; }

The ID value being added or removed from the list.

方法 ​

Handle 仅客户端 ​

csharp
public readonly void Handle()