public void Flush(IChunkStorage <T> chunkStorage) { if (_chunkStorage != chunkStorage) { _chunkStorage.CopyTo(chunkStorage); } }
public void Flush(IChunkStorage <T> chunkStorage) { using (var writer = chunkStorage.OpenForWrite()) { writer.Write(_array); writer.Complete(); } }
public void CopyTo(IChunkStorage <T> chunkStorage) { if (chunkStorage is ChunkFileStorage <T> chunkFileStorage) { File.Delete(chunkFileStorage._fileName); File.Move(_fileName, chunkFileStorage._fileName); } }
/// <summary> /// ChunkStack constructor /// </summary> /// <param name="bufferSize">Memory limit for stored data</param> /// <param name="sizeCalculator">Calculator for data size calculation</param> /// <param name="chunkStorage">External data storage</param> public ChunkStack( long bufferSize, ISizeCalculator <T> sizeCalculator, IChunkStorage <T> chunkStorage) { _bufferSize = bufferSize; _sizeCalcuator = sizeCalculator; _chunkStorage = chunkStorage; }
/// <summary> /// Initializes a new <see cref="Map"/> using the specified /// <see cref="IChunkStorage"/> to load and save chunks. /// </summary> /// <param name="storage">The chunk storage</param> public Map(IChunkStorage storage) { ChunkLoader = new ChunkLoader(storage); ChunkLoader.Chunks.ItemAdded += OnChunkLoaded; ChunkLoader.Chunks.ItemRemoved += OnChunkUnloaded; _eventSource = new Subject<IGameEvent>(); // TODO: LoadMetadataAsync() should be treated like async! Metadata = storage.LoadMetadataAsync().Result; }
public FileChunkReference(long size, int count, IChunkStorage <T> chunkStorage, bool chunkWriter = false) { _chunkStorage = chunkStorage; TotalSize = size; Count = count; if (chunkWriter) { _chunkStorageWriter = chunkStorage.OpenForWrite(); } }
/// <summary> /// Initializes the statistics service. /// </summary> public override void Initialize() { Logger.Trace("init()"); // import required services. this._player = (IPlayer)this.Game.Services.GetService(typeof(IPlayer)); this._fogger = (IFogger)this.Game.Services.GetService(typeof(IFogger)); this._world = (IWorld)this.Game.Services.GetService(typeof(IWorld)); this._chunkStorage = (IChunkStorage)this.Game.Services.GetService(typeof(IChunkStorage)); this._chunkCache = (IChunkCache)this.Game.Services.GetService(typeof(IChunkCache)); base.Initialize(); }
public override void Initialize() { Logger.Trace("init()"); _spriteBatch = new SpriteBatch(Game.GraphicsDevice); _spriteFont = AssetManager.Instance.Verdana; // import service. this._camera = (ICamera)this.Game.Services.GetService(typeof(ICamera)); this._world = (IWorld)this.Game.Services.GetService(typeof(IWorld)); this._player = (IPlayer)this.Game.Services.GetService(typeof(IPlayer)); this._chunkStorage = (IChunkStorage)this.Game.Services.GetService(typeof(IChunkStorage)); }
public override void Initialize() { Logger.Trace("init()"); // import required services. this._chunkStorage = (IChunkStorage)this.Game.Services.GetService(typeof(IChunkStorage)); this._camera = (ICamera)this.Game.Services.GetService(typeof(ICamera)); this._player = (IPlayer)this.Game.Services.GetService(typeof(IPlayer)); this._fogger = (IFogger)this.Game.Services.GetService(typeof(IFogger)); this.VertexBuilder = (IVertexBuilder)this.Game.Services.GetService(typeof(IVertexBuilder)); this._timeRuler = (TimeRuler)this.Game.Services.GetService(typeof(TimeRuler)); this.Generator = new BiomedTerrain(new RainForest()); base.Initialize(); }
public override void Initialize() { Logger.Trace("init()"); // import required service. this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera)); this._world = (IWorld) this.Game.Services.GetService(typeof (IWorld)); this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer)); this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage)); this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager)); if (this._assetManager == null) throw new NullReferenceException("Can not find asset manager component."); _spriteFont = this._assetManager.Verdana; _spriteBatch = new SpriteBatch(Game.GraphicsDevice); }
/// <summary> /// Initializes the debug-bar service. /// </summary> public override void Initialize() { Logger.Trace("init()"); // import required services. this._player = (IPlayer)this.Game.Services.GetService(typeof(IPlayer)); this._fogger = (IFogger)this.Game.Services.GetService(typeof(IFogger)); this._world = (IWorld)this.Game.Services.GetService(typeof(IWorld)); this._chunkStorage = (IChunkStorage)this.Game.Services.GetService(typeof(IChunkStorage)); this._chunkCache = (IChunkCache)this.Game.Services.GetService(typeof(IChunkCache)); this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager)); if (this._assetManager == null) { throw new NullReferenceException("Can not find asset manager component."); } base.Initialize(); }
public override void Initialize() { Logger.Trace("init()"); // import required services. this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage)); this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera)); this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer)); this._fogger = (IFogger) this.Game.Services.GetService(typeof (IFogger)); this.VertexBuilder = (IVertexBuilder) this.Game.Services.GetService(typeof (IVertexBuilder)); this._timeRuler = (TimeRuler) this.Game.Services.GetService(typeof (TimeRuler)); this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager)); if (this._assetManager == null) throw new NullReferenceException("Can not find asset manager component."); this.Generator = new BiomedTerrain(new RainForest()); base.Initialize(); }
public override void Initialize() { Logger.Trace("init()"); // import required service. this._camera = (ICamera)this.Game.Services.GetService(typeof(ICamera)); this._world = (IWorld)this.Game.Services.GetService(typeof(IWorld)); this._player = (IPlayer)this.Game.Services.GetService(typeof(IPlayer)); this._chunkStorage = (IChunkStorage)this.Game.Services.GetService(typeof(IChunkStorage)); this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager)); if (this._assetManager == null) { throw new NullReferenceException("Can not find asset manager component."); } _spriteFont = this._assetManager.Verdana; _spriteBatch = new SpriteBatch(Game.GraphicsDevice); }
public SimpleMapLoader(IMapEditor map, IServer server, IChunkFactory chunkFactory, IPlayer player, IChunkStorage chunkStorage) { if (map == null) { throw new ArgumentNullException("map"); } if (server == null) { throw new ArgumentNullException("server"); } if (chunkFactory == null) { throw new ArgumentNullException("chunkFactory"); } if (player == null) { throw new ArgumentNullException("player"); } _map = map; _server = server; _server.ClientConnection.ChunkReceived += ClientConnectionOnChunkReceived; _chunkFactory = chunkFactory; _player = player; _chunkStorage = chunkStorage; _chunkStorage.Retrieved += ChunkStorageOnRetrieved; _player.Moved += OnPlayerMoved; _oldPlayerChunkPosition = Chunk.ToChunkPosition(_player.Position.ToMapPosition()); foreach (var chunkPos in _map.Bounds) { if (!_map.IsChunkPresent(chunkPos)) { _server.ServerConnection.GetChunk(chunkPos); } } }
/// <summary> /// Initializes the debug-bar service. /// </summary> public override void Initialize() { Logger.Trace("init()"); // import required services. this._player = (IPlayer)this.Game.Services.GetService(typeof(IPlayer)); this._fogger = (IFogger)this.Game.Services.GetService(typeof(IFogger)); this._world = (IWorld)this.Game.Services.GetService(typeof(IWorld)); this._chunkStorage = (IChunkStorage)this.Game.Services.GetService(typeof(IChunkStorage)); this._chunkCache = (IChunkCache)this.Game.Services.GetService(typeof(IChunkCache)); this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager)); if (this._assetManager == null) throw new NullReferenceException("Can not find asset manager component."); base.Initialize(); }
public ChunkServer(IChunkStorage chunkStorage, ILogger logger = null) { ChunkStorage = chunkStorage; Logger = logger ?? Log.Default; }
public override void Initialize() { Logger.Trace("init()"); _spriteBatch = new SpriteBatch(Game.GraphicsDevice); _spriteFont = Game.Content.Load<SpriteFont>("Fonts//CalibriDebug"); // import service. this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera)); this._world = (IWorld) this.Game.Services.GetService(typeof (IWorld)); this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer)); this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage)); }
/// <summary> /// Initializes the statistics service. /// </summary> public override void Initialize() { Logger.Trace("init()"); // import required services. this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer)); this._fogger = (IFogger) this.Game.Services.GetService(typeof (IFogger)); this._world = (IWorld) this.Game.Services.GetService(typeof (IWorld)); this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage)); this._chunkCache = (IChunkCache) this.Game.Services.GetService(typeof (IChunkCache)); base.Initialize(); }
void ReopenStorage() { _kvdb.Dispose(); _kvdb = new KeyValueDB(_fileCollection); _cs = _kvdb.GetSubDB <IChunkStorage>(1); }
public ChunkStorageTest() { _fileCollection = new InMemoryFileCollection(); _kvdb = new KeyValueDB(_fileCollection); _cs = _kvdb.GetSubDB <IChunkStorage>(1); }
public void CreateChunkStorageSubDB() { _fileCollection = new InMemoryFileCollection(); _kvdb = new KeyValueDB(_fileCollection); _cs = _kvdb.GetSubDB<IChunkStorage>(1); }
void ReopenStorage() { _kvdb.Dispose(); _kvdb = new KeyValueDB(_fileCollection); _cs = _kvdb.GetSubDB<IChunkStorage>(1); }
public void AddStorage(IChunkStorage storage) { Secondary.Add(storage); }
/// <summary> /// Initializes a new ChunkLoader utilizing the specified /// IChunkStorage to load and save chunks. /// </summary> /// <param name="storage">Chunk Storage</param> /// public ChunkLoader(IChunkStorage storage) { Storage = storage; }
public ChunkProvider(IChunkStorage chunkStorage, IChunkCreator chunkCreator) { _chunkStorage = chunkStorage; _chunkCreator = chunkCreator; }
public override void Initialize() { Logger.Trace("init()"); // import required services. this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage)); this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera)); this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer)); this._fogger = (IFogger) this.Game.Services.GetService(typeof (IFogger)); this.VertexBuilder = (IVertexBuilder) this.Game.Services.GetService(typeof (IVertexBuilder)); this._timeRuler = (TimeRuler) this.Game.Services.GetService(typeof (TimeRuler)); this.Generator = new BiomedTerrain(new RainForest()); base.Initialize(); }
public override void Initialize() { Logger.Trace("init()"); _spriteBatch = new SpriteBatch(Game.GraphicsDevice); _spriteFont = AssetManager.Instance.Verdana; // import service. this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera)); this._world = (IWorld) this.Game.Services.GetService(typeof (IWorld)); this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer)); this._chunkStorage = (IChunkStorage) this.Game.Services.GetService(typeof (IChunkStorage)); }