Beispiel #1
0
        public Option <T> Set <T>(Option <T> value) where T : IComponent
        {
            if (typeof(T) == typeof(Block))
            {
                throw new InvalidOperationException(
                          $"{ nameof(Block) } cannot be modified");
            }
            var handler = ChunkManager.Storage.Get <T>();

            return(handler.HasValue
                                ? (value.HasValue
                                        ? handler.Value
                                   .GetOrAdd(ChunkManager.GetOrCreateChunkEntity(Position))
                                   .Set(ChunkRelPos, value)
                                        : ChunkManager.GetChunkEntity(Position)
                                   .Map((chunk) => handler.Value.Get(chunk))
                                   .Map((storage) => storage.Remove(ChunkRelPos)))
                                : (value.HasValue
                                        ? EntityManager[GetOrCreateEntity()].Set(value)
                                        : Entity.Map((block) => EntityManager[block].Set(value))));
        }
Beispiel #2
0
 public Option <T> Set <T>(Option <T> value) where T : IComponent =>
 EntityManager[ChunkManager.GetOrCreateChunkEntity(Position)].Set <T>(value);