Пример #1
0
        private static CLICommand ParseRunCommand(string[] args)
        {
            var command = new CLICommand()
            {
                Kind = KindOfCLICommand.Run
            };

            switch (args.Length)
            {
            case 1:
                command.InputDir = Directory.GetCurrentDirectory();
                command.IsValid  = true;
                return(command);

            case 2:
            {
                var inputFile = args[1];

                command.InputFile = EVPath.Normalize(inputFile);
                command.IsValid   = true;
                return(command);
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(args.Length), args.Length, null);
            }
        }
Пример #2
0
        private static void TstCLIRunHandler()
        {
            _logger.Log("Begin");

            var args = new List <string>()
            {
                "run" //,
                //"%USERPROFILE%/source/repos/SymOntoClay/TestSandbox/Source/Npcs/PeaceKeeper/PeaceKeeper.sobj"
                //"%USERPROFILE%/source/repos/SymOntoClay/TestSandbox/Source"
            }.ToArray();

            var targetDirectory = EVPath.Normalize("%USERPROFILE%/source/repos/SymOntoClay/TestSandbox/Source");

            _logger.Log($"targetDirectory = {targetDirectory}");

            Directory.SetCurrentDirectory(targetDirectory);

            var command = CLICommandParser.Parse(args);

            _logger.Log($"command = {command}");

            var targetFiles = RunCommandFilesSearcher.Run(command);

            _logger.Log($"targetFiles = {targetFiles}");

            //var logDir = Path.Combine(Directory.GetCurrentDirectory(), "NpcLogs");

            var invokingInMainThread = DefaultInvokerInMainThreadFactory.Create();

            var instance = WorldFactory.WorldInstance;

            var settings = new WorldSettings();

            settings.SharedModulesDirs = new List <string>()
            {
                targetFiles.SharedModulesDir
            };

            settings.ImagesRootDir = targetFiles.ImagesRootDir;

            settings.TmpDir = targetFiles.TmpDir;

            settings.HostFile = targetFiles.WorldFile;

            settings.InvokerInMainThread = invokingInMainThread;

            settings.Logging = new LoggingSettings()
            {
                //LogDir = logDir,
                RootContractName = "Hi1",
                PlatformLoggers  = new List <IPlatformLogger>()
                {
                    new CLIPlatformLogger()
                },
                Enable = true,
                EnableRemoteConnection = true
            };

            _logger.Log($"settings = {settings}");

            instance.SetSettings(settings);

            var platformListener = new TstPlatformHostListener();

            var npcSettings = new HumanoidNPCSettings();

            npcSettings.Id = "#020ED339-6313-459A-900D-92F809CEBDC5";
            //npcSettings.HostFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\Hosts\PeaceKeeper\PeaceKeeper.host");
            npcSettings.LogicFile       = targetFiles.LogicFile;
            npcSettings.HostListener    = platformListener;
            npcSettings.PlatformSupport = new PlatformSupportCLIStub();

            _logger.Log($"npcSettings = {npcSettings}");

            var npc = instance.GetHumanoidNPC(npcSettings);

            instance.Start();

            Thread.Sleep(50000);

            _logger.Log("End");
        }