public static TstComplexContext CreateAndInitContext() { var invokingInMainThread = DefaultInvokerInMainThreadFactory.Create(); var appName = AppDomain.CurrentDomain.FriendlyName; _logger.Log($"appName = {appName}"); var supportBasePath = Path.Combine(Environment.GetEnvironmentVariable("APPDATA"), "SymOntoClay", appName); _logger.Log($"supportBasePath = {supportBasePath}"); var result = new TstComplexContext(); var logDir = Path.Combine(Directory.GetCurrentDirectory(), "NpcLogs"); var worldSettings = new WorldSettings(); worldSettings.EnableAutoloadingConvertors = true; worldSettings.SharedModulesDirs = new List <string>() { Path.Combine(Directory.GetCurrentDirectory(), "Source", "Modules") }; worldSettings.ImagesRootDir = Path.Combine(Directory.GetCurrentDirectory(), "Images"); worldSettings.TmpDir = Path.Combine(Environment.GetEnvironmentVariable("TMP"), "SymOntoClay", appName); worldSettings.HostFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\World\HelloWorld.world"); worldSettings.Logging = new LoggingSettings() { LogDir = logDir, RootContractName = "Hi1", PlatformLoggers = new List <IPlatformLogger>() { ConsoleLogger.Instance /*, CommonNLogLogger.Instance */ }, Enable = true, EnableRemoteConnection = true }; worldSettings.InvokerInMainThread = invokingInMainThread; _logger.Log($"worldSettings = {worldSettings}"); var worldContext = new WorldContext(); worldContext.SetSettings(worldSettings); var npcSettings = new HumanoidNPCSettings(); npcSettings.Id = "#020ED339-6313-459A-900D-92F809CEBDC5"; //npcSettings.HostFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\Hosts\PeaceKeeper\PeaceKeeper.host"); npcSettings.LogicFile = Path.Combine(Directory.GetCurrentDirectory(), @"Source\Apps\PeaceKeeper\PeaceKeeper.sobj"); npcSettings.PlatformSupport = new PlatformSupportCLIStub(); _logger.Log($"npcSettings = {npcSettings}"); var entityLogger = new LoggerImpementation(); var tmpDir = Path.Combine(worldSettings.TmpDir, npcSettings.Id); Directory.CreateDirectory(worldSettings.TmpDir); //var standaloneStorageSettings = new StandaloneStorageSettings(); //standaloneStorageSettings.Id = npcSettings.Id; //standaloneStorageSettings.IsWorld = false; //standaloneStorageSettings.AppFile = npcSettings.HostFile; //standaloneStorageSettings.Logger = entityLogger; //standaloneStorageSettings.Dictionary = worldContext.SharedDictionary.Dictionary; //standaloneStorageSettings.ModulesStorage = worldContext.ModulesStorage.ModulesStorage; //standaloneStorageSettings.ParentStorage = worldContext.StandaloneStorage.StandaloneStorage; #if DEBUG //_logger.Log($"standaloneStorageSettings = {standaloneStorageSettings}"); #endif //var _hostStorage = new StandaloneStorage(standaloneStorageSettings); var coreEngineSettings = new EngineSettings(); coreEngineSettings.Id = npcSettings.Id; coreEngineSettings.AppFile = npcSettings.LogicFile; coreEngineSettings.Logger = entityLogger; coreEngineSettings.SyncContext = worldContext.ThreadsComponent; coreEngineSettings.ModulesStorage = worldContext.ModulesStorage.ModulesStorage; //coreEngineSettings.ParentStorage = _hostStorage; coreEngineSettings.TmpDir = tmpDir; coreEngineSettings.HostSupport = new TstHostSupportComponent(npcSettings.PlatformSupport); #if DEBUG _logger.Log($"coreEngineSettings = {coreEngineSettings}"); #endif #if DEBUG //_logger.Log($"Begin worldContext.Start()"); #endif worldContext.Start(); result.WorldContext = worldContext; #if DEBUG //_logger.Log($"After worldContext.Start()"); #endif var context = EngineContextHelper.CreateAndInitContext(coreEngineSettings); #if DEBUG //_logger.Log($"After var context = EngineContextHelper.CreateAndInitContext(coreEngineSettings);"); #endif context.CommonNamesStorage.LoadFromSourceCode(); #if DEBUG //_logger.Log($"After context.CommonNamesStorage.LoadFromSourceCode();"); #endif context.Storage.LoadFromSourceCode(); #if DEBUG //_logger.Log($"After context.Storage.LoadFromSourceCode();"); #endif context.StandardLibraryLoader.LoadFromSourceCode(); #if DEBUG //_logger.Log($"After context.StandardLibraryLoader.LoadFromSourceCode();"); #endif context.StatesStorage.LoadFromSourceCode(); #if DEBUG //_logger.Log($"After context.StatesStorage.LoadFromSourceCode();"); #endif context.InstancesStorage.LoadFromSourceFiles(); result.EngineContext = context; return(result); }