示例#1
0
        public ServerWorldHost()
        {
            var services = new ServiceCollection();

            services.AddLogging(builder =>
            {
                builder.AddConsole();
                builder.SetMinimumLevel(LogLevel.Trace);
            });

            var commandType = typeof(GameCommand);
            IEnumerable <Type> eventTypes = new List <Type>
            {
                typeof(GameActionEvent),
            };
            IEnumerable <KeyValuePair <Type, Type> > entityTypes = new Dictionary <Type, Type>
            {
                [typeof(ServerControlledEntity)] = typeof(MyState),
                [typeof(ServerDummyEntity)]      = typeof(DummyEntityState),
                [typeof(ServerMimicEntity)]      = typeof(MyState),
            };
            var pools   = new ServerPools(commandType, eventTypes, entityTypes);
            var manager = new ServerWorld(new ServerGameProtocol(pools), pools);

            //var manager = new ServerWorld(new MessagePackServerPacketProtocol(), pools);
            services.AddSingleton(manager);

            ServiceProvider = services.BuildServiceProvider();

            InitializeCommon();
            Initialize();
        }
示例#2
0
 public ServerGameProtocol(ServerPools pools) : base(pools)
 {
 }