Beispiel #1
0
        public Pipeline Finally <TBlock>(int threadCount = 1, BlockArgs args = null) where TBlock : FinalBlock <TOutput>, new()
        {
            if (args == null)
            {
                args = new BlockArgs();
            }

            args.ThreadCount = threadCount;

            return(Finally <TBlock>(args));
        }
Beispiel #2
0
        public TBlock Then <TBlock>(int threadCount = 1, int bufferCapacity = int.MaxValue, BlockArgs args = null) where TBlock : Block, IConsumer <TOutput>, new()
        {
            if (args == null)
            {
                args = new BlockArgs();
            }

            args.ThreadCount    = threadCount;
            args.BufferCapacity = bufferCapacity;

            return(Then <TBlock>(args));
        }
Beispiel #3
0
        public static TBlock First <TBlock>(int threadCount = 1, int bufferCapacity = int.MaxValue, BlockArgs args = null) where TBlock : Block, new()
        {
            if (args == null)
            {
                args = new BlockArgs();
            }

            args.ThreadCount    = threadCount;
            args.BufferCapacity = bufferCapacity;

            return(First <TBlock>(args));
        }
Beispiel #4
0
        public static TBlock First <TBlock>(BlockArgs args) where TBlock : Block, new()
        {
            TBlock   block    = new TBlock();
            Pipeline pipeline = new Pipeline();

            block.Pipeline  = pipeline;
            block.Arguments = args;

            pipeline.Add(block);

            return(block);
        }
Beispiel #5
0
        public TBlock Then <TBlock>(BlockArgs args) where TBlock : Block, IConsumer <TOutput>, new()
        {
            TBlock block = new TBlock()
            {
                Pipeline  = Pipeline,
                Source    = Output,
                Arguments = args
            };

            Pipeline.Add(block);

            return(block);
        }
Beispiel #6
0
 private void PlayerBlock(Player player, BlockArgs e, bool sendPlayer)
 {
     if (sendPlayer)
     {
         if (!player.level.SetBlock(player, e.X, e.Y, e.Z, e.Type))
         {
             Protocol.BlockPacket(e.X, e.Y, e.Z, player.level[e.X, e.Y, e.Z]).Send(player);
         }
     }
     else
     {
         player.level.PlayerSetBlock(player, e.X, e.Y, e.Z, e.Type);
     }
 }
Beispiel #7
0
        public Pipeline Finally <TBlock>(BlockArgs args) where TBlock : FinalBlock <TOutput>, new()
        {
            TBlock block = new TBlock()
            {
                Pipeline  = Pipeline,
                Source    = Output,
                Arguments = args
            };

            Pipeline.Add(block);

            Pipeline.Start();

            return(block);
        }
Beispiel #8
0
        public Pipeline Start()
        {
            if (_isRunning)
            {
                throw new InvalidOperationException("Pipeline is already running");
            }

            _tasks = new List <Task>();

            foreach (Block block in _blocks)
            {
                BlockArgs config = block.Arguments;

                for (int i = 0; i < config.ThreadCount; i++)
                {
                    Task task = Task.Factory.StartNew(() => block.Run(), _tokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
                    _tasks.Add(task);
                }
            }

            _isRunning = true;

            return(this);
        }
 private void Grid3D_OnTileAdded(object sender, BlockArgs e)
 {
     UpdateResources(CurrentResources - e.ObjectData.Cost);
 }
Beispiel #10
0
 public override void Initialize(BlockArgs args)
 {
 }
Beispiel #11
0
 public abstract void Initialize(BlockArgs args);