Ejemplo n.º 1
0
        public static void DoProcess(World world, BCMCmdArea command, BCCommandAbstract cmdRef)
        {
            if (command.Opts.ContainsKey("forcesync"))
            {
                BCCommandAbstract.SendOutput("Processing Command synchronously...");
                ProcessCommand(world, command, cmdRef);

                return;
            }

            if (BCCommandAbstract.SenderInfo.NetworkConnection != null && !(BCCommandAbstract.SenderInfo.NetworkConnection is TelnetConnection))
            {
                BCCommandAbstract.SendOutput("Processing Async Command... Sending output to log");
            }
            else
            {
                BCCommandAbstract.SendOutput("Processing Async Command...");
            }

            BCTask.AddTask(
                command.CmdType,
                ThreadManager.AddSingleTask(
                    info => ProcessCommand(world, command, cmdRef),
                    null,
                    (info, e) => BCTask.DelTask(command.CmdType, info.GetHashCode()))
                .GetHashCode(),
                command);
        }
Ejemplo n.º 2
0
        public static void DoCleanup(World world, ChunkManager.ChunkObserver co, string commandType, int ts = 0, ThreadManager.TaskInfo taskInfo = null)
        {
            var bcmTask = BCTask.GetTask(commandType, taskInfo?.GetHashCode());

            for (var i = 0; i < ts; i++)
            {
                if (bcmTask != null)
                {
                    bcmTask.Output = new { timer = i, total = ts }
                }
                ;
                Thread.Sleep(1000);
            }
            world.m_ChunkManager.RemoveChunkObserver(co);
        }
Ejemplo n.º 3
0
        public static void ChunkObserver(BCMCmdArea command, World world, int timeoutSec)
        {
            var pos           = command.HasPos ? command.Position.ToV3() : command.ChunkBounds.ToV3();
            var viewDim       = !command.Opts.ContainsKey("r") ? command.Radius : command.ChunkBounds.GetRadius();
            var chunkObserver = world.m_ChunkManager.AddChunkObserver(pos, false, viewDim, -1);

            var timerSec = 60;

            if (command.Opts.ContainsKey("ts") && command.Opts["ts"] != null)
            {
                int.TryParse(command.Opts["ts"], out timerSec);
            }
            timerSec += timeoutSec;
            BCTask.AddTask(
                command.CmdType,
                ThreadManager.AddSingleTask(
                    info => DoCleanup(world, chunkObserver, command.CmdType, timerSec, info),
                    null,
                    (info, e) => BCTask.DelTask(command.CmdType, info.GetHashCode(), 120)
                    ).GetHashCode(),
                command);
        }