| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Lattice.ECS.Session |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// 当前 Session 的正式运行时类型。 |
| | | 7 | | /// </summary> |
| | | 8 | | public enum SessionRuntimeKind |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// 纯 C#、单线程、固定顺序、可回滚的最小预测运行时。 |
| | | 12 | | /// </summary> |
| | | 13 | | MinimalPrediction = 0, |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// 纯 C#、单线程、固定顺序的本地权威运行时。 |
| | | 17 | | /// 该模式保留固定帧推进与显式 checkpoint,但不承诺预测验证与 rewind 玩法入口。 |
| | | 18 | | /// </summary> |
| | | 19 | | LocalAuthoritative = 1 |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// 当前 Session 公开承诺的运行能力。 |
| | | 24 | | /// </summary> |
| | | 25 | | [Flags] |
| | | 26 | | public enum SessionRuntimeCapability |
| | | 27 | | { |
| | | 28 | | None = 0, |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// 支持本地固定帧推进。 |
| | | 32 | | /// </summary> |
| | | 33 | | LocalPredictionStep = 1 << 0, |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// 支持最小验证与回滚修正。 |
| | | 37 | | /// </summary> |
| | | 38 | | PredictionVerification = 1 << 1, |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// 支持本地 rewind 玩法入口。 |
| | | 42 | | /// </summary> |
| | | 43 | | LocalRewind = 1 << 2, |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// 支持显式 checkpoint 保存与恢复。 |
| | | 47 | | /// </summary> |
| | | 48 | | CheckpointRestore = 1 << 3 |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// 当前 Session 未作为正式能力承诺的运行面。 |
| | | 53 | | /// </summary> |
| | | 54 | | [Flags] |
| | | 55 | | public enum UnsupportedSessionRuntimeCapability |
| | | 56 | | { |
| | | 57 | | None = 0, |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// 不支持多线程系统调度。 |
| | | 61 | | /// </summary> |
| | | 62 | | ThreadedScheduling = 1 << 0, |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// 不支持资源化 / 配置化多模式启动。 |
| | | 66 | | /// </summary> |
| | | 67 | | ResourceConfiguredBoot = 1 << 1, |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// 不支持完整网络会话管理。 |
| | | 71 | | /// </summary> |
| | | 72 | | FullNetworkSession = 1 << 2, |
| | | 73 | | |
| | | 74 | | /// <summary> |
| | | 75 | | /// 不支持玩家映射、房间态与传输层。 |
| | | 76 | | /// </summary> |
| | | 77 | | PlayerMappingAndTransport = 1 << 3 |
| | | 78 | | } |
| | | 79 | | |
| | | 80 | | /// <summary> |
| | | 81 | | /// Session 运行边界描述。 |
| | | 82 | | /// 用于把“当前正式支持什么、不支持什么”显式暴露在代码层,而不只停留在文档。 |
| | | 83 | | /// </summary> |
| | | 84 | | public sealed class SessionRuntimeBoundary |
| | | 85 | | { |
| | 3 | 86 | | public SessionRuntimeBoundary( |
| | 3 | 87 | | SessionRuntimeKind runtimeKind, |
| | 3 | 88 | | SessionRuntimeCapability supportedCapabilities, |
| | 3 | 89 | | UnsupportedSessionRuntimeCapability unsupportedCapabilities) |
| | | 90 | | { |
| | 3 | 91 | | RuntimeKind = runtimeKind; |
| | 3 | 92 | | SupportedCapabilities = supportedCapabilities; |
| | 3 | 93 | | UnsupportedCapabilities = unsupportedCapabilities; |
| | 3 | 94 | | } |
| | | 95 | | |
| | | 96 | | /// <summary> |
| | | 97 | | /// 当前运行时类型。 |
| | | 98 | | /// </summary> |
| | 9 | 99 | | public SessionRuntimeKind RuntimeKind { get; } |
| | | 100 | | |
| | | 101 | | /// <summary> |
| | | 102 | | /// 当前正式支持的运行能力。 |
| | | 103 | | /// </summary> |
| | 622 | 104 | | public SessionRuntimeCapability SupportedCapabilities { get; } |
| | | 105 | | |
| | | 106 | | /// <summary> |
| | | 107 | | /// 当前明确不承诺的运行能力。 |
| | | 108 | | /// </summary> |
| | 8 | 109 | | public UnsupportedSessionRuntimeCapability UnsupportedCapabilities { get; } |
| | | 110 | | |
| | | 111 | | public bool Supports(SessionRuntimeCapability capability) |
| | | 112 | | { |
| | 622 | 113 | | return (SupportedCapabilities & capability) == capability; |
| | | 114 | | } |
| | | 115 | | |
| | | 116 | | public bool ExplicitlyDoesNotSupport(UnsupportedSessionRuntimeCapability capability) |
| | | 117 | | { |
| | 8 | 118 | | return (UnsupportedCapabilities & capability) == capability; |
| | | 119 | | } |
| | | 120 | | } |
| | | 121 | | } |