Giter Club home page Giter Club logo

tcz717 / simcivil Goto Github PK

View Code? Open in Web Editor NEW
37.0 4.0 6.0 732 KB

A C# game server simulating a civilization world allowing roles free interacting. The key goals of the game are to dynamically generate any skills, technologies, recipes, and objects according to role behavior, and imitating real-world roles interacting logic as much as possible.

License: MIT License

C# 98.83% Shell 0.12% Scilab 0.29% Dockerfile 0.35% PowerShell 0.30% Vim Snippet 0.12%
c-sharp game-server rpc mmorpg

simcivil's Introduction

SimCivil

Codacy Badge Sentry

此项目主要是游戏的服务端,负责核心逻辑处理

A C# game server simulating a civilization world allowing roles free interacting. The key goals of the game are to dynamically generate any skills, technologies, recipes, and objects according to role behavior, and imitating real-world roles interacting logic as much as possible.

介绍

服务器模拟一个非常自由或者说内容设定丰富的世界,世界里面的 所有人形生物 都是玩家写脚本自动控制的。游戏不提供官方的客户端,玩家可以选择使用人工智能、有限状态机、甚至手动控制的方式,利用服务器提供的API控制玩家的角色在游戏内生存、发展和竞争。

服务器启动方式

  1. 编译并运行SimCivil.Orleans.Server
  2. 编译并运行SimCivil.Gate

客户端

目前有一个@jykgod 基于Cocos Creator的2d客户端实现Ezgame

讨论

  • 如果对于项目设计有任何建议或者反馈,可以提交issue一起讨论
  • 错误日志汇总可以在sentry上查看

配置开发环境

Package说明

  • SimCivil.Orleans.Grains 服务端主要逻辑架构,存放所有actor的实现
  • SimCivil.Orleans.Interfaces 定义actor的接口
  • SimCivil.Orleans.Server 服务端启动的载体,读取配置并启动silo
  • SimCivil.Gate 游戏网关,用于协调客户端和silo的通信
  • SimCivil.Contract 定义客户端可用的服务接口和游戏数据结构
  • SimCivil.Rpc 自定义简单Rpc库,为游戏客户端专门设计
  • SimCivil.Utilities 通用辅助代码,例如服务和选项的自动配置
  • SimCivil.Test 服务端单元测试
  • SimCivil.IntegrationTest 基于WPF的集成测试工具
  • SimCivil.SimpleClient 简单测试用客户端,已弃用
  • SimCivil.Scripts 计划中,存储游戏逻辑的脚本代码

simcivil's People

Contributors

bruno-garcia avatar dependabot[bot] avatar panyz522 avatar tcz717 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simcivil's Issues

数据编辑器

可以读取并查看经过标记的服务器数据,导出成Excel等格式,在外部编辑后可以重新导入并存入数据库

Orleans connecting issue in Linux

Maybe relate to dotnet/orleans#5158

When running Orleans server in Linux, the client fails to connect to the server, no matter the client is in Windows or Linux. However, the server works perfectly in Windows. The client showed the following error:

Unhandled Exception: Orleans.Runtime.SiloUnavailableException: The target silo became unavailable for message: Request *cli/a309d4a6@25c70da0->S127.0.0.1:30000:0*stg/17/00000011@S00000011 #2: . Target History is: <S127.0.0.1:30000:0:*stg/17/00000011:@S00000011>. See https://aka.ms/orleans-troubleshooting for troubleshooting help.
   at Orleans.OutsideRuntimeClient.<>c__DisplayClass56_0.<<StartInternal>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Orleans.OutsideRuntimeClient.<StartInternal>g__ExecuteWithRetries|56_3(Func`1
task, Func`2 shouldRetry)
   at Orleans.OutsideRuntimeClient.StartInternal(Func`2 retryFilter)
   at Orleans.OutsideRuntimeClient.Start(Func`2 retryFilter)
   at Orleans.ClusterClient.Connect(Func`2 retryFilter)
   at SimCivil.Gate.Gate.Main(String[] args) in /home/tcz/SimCivil/SimCivil.Gate/Gate.cs:line 70
   at SimCivil.Gate.Gate.<Main>(String[] args)

And the server showed

warn: Orleans.Runtime.Messaging.IncomingMessageAcceptor[101307]
      Remote socket closed while receiving connection preamble data from endpoint 127.0.0.1:45983.

It indicated that the server had established a connection but closed then due to an unknown reason.

实现IoC服务的自动配置

Example:

[AutoService(ServiceLifetime.Singleton)]
class ServiceImpl : IServiceA
{
   ...
}

IHost host = new HostBuilder().AutoConfigureService()

探查系统

探查系统是玩家获取其他实体或者单位的方式。通过探查可以知道其他实体的类型,外观,状态和属性。一般来说同步系统只会同步实体在视野内的出现、消失和移动,而实体的详细属性需要由客户端或者玩家主动发起。不是所有属性都能被直接获取,根据玩家的感知能力,可能一些属性无法查看、得到一个范围或者精确值

  • 玩家的同步信息里除了坐标会包含名称、血量百分比、特性(可破坏、所属、资源)和外观信息
  • 玩家可以通过Inception接口查看自己或者拥有物资的详细属性

添加掉线检测

在dotnetty的pipeline里加入心跳包处理的处理层,检测到掉线以后断开连接并通知应用层

装备栏

玩家可以拥有一下装备栏:

  • 头盔
  • 面部
  • 上衣
  • 肩部
  • 腰部
  • 项链
  • 背包
  • 主武器
  • 副武器
  • 手腕
  • 手套
  • 戒指
  • 手镯
  • 裤子
  • 鞋子

一些可以从人物外观观测到效果,一些没有。 可见部分的图像索引会和玩家信息一起被动同步或者主动拉去。
cb48dedec1c61b10bb74d7562392727

TypeLoadException: Method 'RegisterLocalMessageHandler' in type 'Orleans.Runtime.Messaging.MessageCenter' from assem...

https://sentry.io/tpdt/simcivil/issues/737735031/

TypeLoadException: Method 'RegisterLocalMessageHandler' in type 'Orleans.Runtime.Messaging.MessageCenter' from assembly 'Orleans.Runtime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
  File "D:\build\agent\_work\18\s\src\Orleans.Runtime\Hosting\DefaultSiloServices.cs", line 270, in AddDefaultServices
    Void AddDefaultServices(Orleans.Hosting.HostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection)
  File "D:\build\agent\_work\18\s\src\Orleans.Runtime\Hosting\CoreHostingExtensions.cs", line 36, in ConfigureDefaults { <lambda> }
    Void <ConfigureDefaults>b__0_0(Orleans.Hosting.HostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection)
  File "D:\build\agent\_work\17\s\src\Orleans.Core\Hosting\ServiceProviderBuilder.cs", line 25, in BuildServiceProvider
    System.IServiceProvider BuildServiceProvider(Orleans.Hosting.HostBuilderContext)
  File "D:\build\agent\_work\18\s\src\Orleans.Runtime\Hosting\Generic\SiloHostBuilder.cs", line 43, in Build
    Orleans.Hosting.ISiloHost Build()
  File "E:\CCCProject\SimCivil\SimCivil.Orleans.Server\Program.cs", line 53, in Main
    Void MoveNext()
...
(3 additional frame(s) were not displayed)

Method 'RegisterLocalMessageHandler' in type 'Orleans.Runtime.Messaging.MessageCenter' from assembly 'Orleans.Runtime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

回调函数有效性检查

应该设计有一种机制允许在客户端断开之后将客户端相关的回调函数标记为无效的。

新的RPC协议

考虑优化现有的RPC协议,提升效率并增加更多功能

  • 把现有json数据包的一部分固定内容放到头部用二进制形式存储,压缩空间。例如$type, Sequence, TimeStamp, ServeceNameMethodName
  • 添加对回调函数的声明周期管理,允许指定回调函数的有效期。例如,只能调用一次,可以在一段时间内调用,手动释放。
  • 添加单向传输功能,允许客户端调用后不等待执行完毕
  • 添加流式传输,可以传输大量数据
  • 添加相关接口允许服务实现函数能够获取请求的底层信息。例如服务端的函数能够读取客户端调用时发送的数据包内的时间戳或者序列号以及IP等等。
  • 自动统计连接的延迟、RTT
  • 允许限制客户端的调用频率和连接速率
  • 服务列表,客户端可以获取服务端支持的服务和方法列表
  • 添加对protobuf序列化的支持

SocketException: 远程主机强迫关闭了一个现有的连接。

https://sentry.io/tpdt/simcivil/issues/371410549/

IOException: Unable to transfer data on the transport connection: 远程主机强迫关闭了一个现有的连接。.
  File "E:\Code\Game\SimCivil\SimCivil\Net\MatrixServer.cs", line 135, in ReadPacketAsync
    Void MoveNext()

SocketException: 远程主机强迫关闭了一个现有的连接。

Unable to transfer data on the transport connection: 远程主机强迫关闭了一个现有的连接。.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.