public GameWorld( WorldType worldType, WorldInstanceId id, ILogger logger, IServerConfig config, OutgoingServerChannel channelManager, IGameWorldLoader gameWorldLoader) { this.WorldType = worldType; this.InstanceId = id; this._logger = logger ?? throw new ArgumentNullException(nameof(logger)); this._isStopped = false; this._world = new World(config.Ecs); this._fixedTick = config.Simulation.FixedTick; this._channelManager = channelManager ?? throw new ArgumentNullException(nameof(channelManager)); this._simulationSynchronizer = new SimulationSynchronizer(this._world); this._entityGridMap = new EntityGridMap(config.Replication.GridSize); this._players = new WorldPlayers( config.Replication, config.PlayerInput, config.PlayerConnection.Capacity.InitialConnectionsCapacity); this._replicationManager = new WorldReplicationManager(config.Replication, this._players, this._entityGridMap); this._physicsWorld = new VolatilePhysicsWorld(config.Replication.PhysicsHistoryCount); this._systems = new Systems(this._world) .Add(new PhysicsSystem()) .Add(new ServerEntityReplicationSystem()) .Add(new JiggleSystem()) .Inject(this._physicsWorld) .Inject(new ReplicationDataBroker(config.Replication.Capacity, this._replicationManager)) .Inject(this._entityGridMap); this._simulation = new ServerSimulation <InputComponent>( config.Simulation, this._world, this._systems); this._simulation.Create(); gameWorldLoader.LoadWorld(this.WorldType, this._world, this._physicsWorld); }
public WorldMap(int qtdPlayers) { var amtOfChunks = qtdPlayers * PLAYERS_CHUNKS; var amtOfTiles = amtOfChunks * TILES_IN_CHUNK; var arraySize = (int)Math.Ceiling(Math.Sqrt(amtOfTiles)); var extraNeeded = CHUNK_SIZE - arraySize % CHUNK_SIZE; var tilesX = arraySize + extraNeeded; var tilesY = arraySize + extraNeeded; TileGrid = new Tile[tilesX, tilesY]; ChunkGrid = new ChunkMap(tilesX / CHUNK_SIZE, tilesY / CHUNK_SIZE); Players = new WorldPlayers(); Players.MaxPlayers = qtdPlayers; Fog = new FogOfWar(this); Units = new WorldUnits(this); }