mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
106 lines
2.9 KiB
C#
106 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
using Game.Input;
|
|
using Game.JNGFrame.Logic;
|
|
using Game.JNGFrame.Logic.Entity;
|
|
using Game.JNGFrame.Logic.System;
|
|
using Game.JNGFrame.View;
|
|
using Game.JNGState.Logic.Data;
|
|
using Game.Logic.System;
|
|
using JNGame.Sync.Entity;
|
|
using JNGame.Sync.State;
|
|
using JNGame.Sync.System;
|
|
using JNGame.Sync.System.Data;
|
|
using Plugins.JNGame.Network.Action;
|
|
|
|
namespace AppGame.Sync
|
|
{
|
|
/// <summary>
|
|
/// 状态同步[服务器]
|
|
/// </summary>
|
|
public class JNGStateServerSystem : JNSStateServerService
|
|
{
|
|
|
|
protected List<JNFrameInput> Inputs = new();
|
|
|
|
public override SLogicSystem[] NewLogicSystems()
|
|
{
|
|
return new SLogicSystem[]
|
|
{
|
|
|
|
//基础数据
|
|
new DInputSystem(), //游戏输入
|
|
new DDataSystem(), //游戏数据
|
|
|
|
//逻辑层
|
|
new DMapSystem(), //游戏地图
|
|
new DWorldSystem(), //游戏逻辑
|
|
new DPlayerSystem(), //玩家逻辑
|
|
|
|
};
|
|
}
|
|
|
|
public override SDataSystemBase[] NewDataSystems()
|
|
{
|
|
return new SDataSystemBase[] {
|
|
new EDNodeDataSystem(SStateDataEnum.ServerClient), //游戏数据
|
|
new EDPlayerDataSystem(SStateDataEnum.ServerClient), //游戏数据
|
|
};
|
|
}
|
|
|
|
public override SViewSystem[] NewViewSystems()
|
|
{
|
|
return new SViewSystem[]
|
|
{
|
|
//视图层
|
|
new DViewSystem(), //游戏视图
|
|
};
|
|
}
|
|
|
|
public override JNContexts CreateContexts()
|
|
{
|
|
return new EDContexts();
|
|
}
|
|
|
|
protected override void OnRunSimulate()
|
|
{
|
|
|
|
//插入未处理输入
|
|
foreach (var input in Inputs)
|
|
{
|
|
GetSystem<DInputSystem>().Enqueue(input);
|
|
}
|
|
Inputs.Clear();
|
|
base.OnRunSimulate();
|
|
|
|
//发送输入
|
|
OnSendInput();
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 发送输入 (正常服务器是不需要发送输入的 这里用于测试)
|
|
/// </summary>
|
|
protected void OnSendInput()
|
|
{
|
|
var inputs = GetSystem<DInputSystem>().Dequeue();
|
|
if (inputs.Inputs.Count > 0)
|
|
{
|
|
//发送帧数据给服务端
|
|
App.Socket.Send((int)NActionEnum.NSyncFrameInput,inputs);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加输入
|
|
/// </summary>
|
|
public void AddInput(JNFrameInfo info)
|
|
{
|
|
foreach (var input in info.Messages)
|
|
{
|
|
Inputs.Add(input);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |