public static void FastTravelToLocation(string chosenScene, string chosenLocation) { if (Application.isPlaying) { DynamicObjectManager.MovePlayer(chosenScene, chosenLocation, false); } else { EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes; string scenePath = null; for (int i = 0; i < scenes.Length; i++) { if (Path.GetFileNameWithoutExtension(scenes[i].path) == chosenScene) { scenePath = scenes[i].path; } } if (scenePath != null) { if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single); if (Locations.GetLocationBounds(chosenScene, chosenLocation, out Bounds bounds)) { SceneView.lastActiveSceneView.Frame(bounds, false); } } } else { Debug.LogWarning("No Scene Found: " + chosenScene); } } }
void HandleClickObjects() { if (Input.GetMouseButtonDown(0)) { if (GameManager.playerExists) { Ray ray = GameManager.playerCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, ConsoleSettings.instance.clickMask, QueryTriggerInteraction.Ignore)) { GameObject hitObject = hit.transform.gameObject; DynamicObject dynamicObject = hitObject.GetComponentInParent <DynamicObject>(); if (dynamicObject != null) { string id = dynamicObject.GetID(); string msg = "Clicked Object: '" + hitObject.name + "', Dynamic Object ID: " + id; if (DynamicObjectManager.IDHasAlias(id, out string alias)) { msg += ", Alias: '" + alias + "'"; } Warn(msg); GUIUtility.systemCopyBuffer = id; } else { Warn("Clicked Object: '" + hitObject.name + "'"); GUIUtility.systemCopyBuffer = hitObject.name; } } } } }
public void SpawnObjects(string scene, RandomEncounterSpot spot) { this.aliasPrefix = scene + "." + spot.name + "." + name + "."; RandomEncounterSpawn[] spawns = GetComponentsInChildren <RandomEncounterSpawn>(); for (int i = 0; i < spawns.Length; i++) { RandomEncounterSpawn s = spawns[i]; Transform t = s.transform; var getPrefabsRuntimeSubjects = new Dictionary <string, object> () { { "Encounter", this }, { "EncounterSpot", spot } }; DynamicObjectManager.AddNewAliasedObject(aliasPrefix + s.name, s.prefab.GetPrefab(getPrefabsRuntimeSubjects), scene, t.position, t.rotation, false, out _); } }
internal static ServiceManager.IServiceManagerAdministration CreateFileParsingSetup(Assembly testAssembly, params ScriptFile[] files) { ServiceManager.IServiceManagerAdministration services = ServiceManager.Create(); LastServiceManager = services; IService service; var addonManager = new AddonManager(null, out service); services.Manager.Register(service); var objectManager = new DynamicObjectManager(out service); services.Manager.Register(service); var loadedFiles = new LoadedFilesManager(out service); services.Manager.Register(service); var mainLogger = new MainLogger(out service); services.Manager.Register(service); var taskManager = new TaskManager(out service); services.Manager.Register(service); TaskContextDummy taskContext = new TaskContextDummy(); services.StartServices(taskContext); addonManager.AddAssembly(typeof(System.Convert).Assembly, false); addonManager.AddAssembly(typeof(Math).Assembly, false); addonManager.AddAssembly(typeof(Enumerable).Assembly, false); addonManager.AddAssembly(AddonManager.StepBroCoreAssembly, true); if (testAssembly != null) { addonManager.AddAssembly(testAssembly, false); } foreach (var f in files) { loadedFiles.RegisterLoadedFile(f); } return(services); }
internal static void DeinitializeInternal(bool reset) { m_loadedFilesManager.UnloadAllFilesWithoutDependants(); TaskContextDummy taskContext = new TaskContextDummy(); m_serviceManagerAdmin.StopServices(taskContext, reset); if (reset) { m_serviceManagerAdmin = null; m_mainLogger = null; m_loadedFilesManager = null; m_addonManager = null; m_logSinkManager = null; m_scriptExecutionManager = null; m_dynamicObjectManager = null; m_uiCalculator = null; m_serviceManagerAdmin = ServiceManager.Create(); } }
public ObjectLoadState GetSpawnedObject(string key, out object obj) { return(DynamicObjectManager.GetObjectByAlias(aliasPrefix + key, out obj)); }
public void DoFastTravel(DynamicObject obj) { DynamicObjectManager.MoveObject(obj, location); }
public static void TagRenderers(string doKey, BasicColor color, bool overlay, bool flash) { TagRenderers(DynamicObjectManager.GetDynamicObjectFromKey(doKey), color, overlay, flash); }
public static void VisualizeColliders(string doKey) { VisualizeColliders(DynamicObjectManager.GetDynamicObjectFromKey(doKey)); }
public static void HighlightRenderers(string doKey, BasicColor color, bool overlay, string collection) { HighlightRenderers(DynamicObjectManager.GetDynamicObjectFromKey(doKey), color, overlay, collection); }
public static void Initialize(IEnumerable <IService> hostServices = null) { IService service; m_mainLogger = new MainLogger(out service); m_rootLogger = m_mainLogger.Logger.RootLogger; m_serviceManagerAdmin.Manager.Register(service); m_loadedFilesManager = new LoadedFilesManager(out service); m_serviceManagerAdmin.Manager.Register(service); m_addonManager = new AddonManager( (IAddonManager m) => { // **** LOAD THE ADDON MODULES **** m.AddAssembly(typeof(DateTime).Assembly, false); m.AddAssembly(typeof(Enumerable).Assembly, false); m.AddAssembly(typeof(Math).Assembly, false); m.AddAssembly(AddonManager.StepBroCoreAssembly, true); var modulesFolder = Path.Combine(Path.GetDirectoryName(typeof(AddonManager).Assembly.Location), "Modules"); foreach (var f in Directory.GetFiles(modulesFolder, "*.dll")) { m.LoadAssembly(f, false); } }, out service); m_serviceManagerAdmin.Manager.Register(service); m_logSinkManager = new LogSinkManager(out service); m_serviceManagerAdmin.Manager.Register(service); m_taskManager = new TaskManager(out service); m_serviceManagerAdmin.Manager.Register(service); m_hostActions = new HostApplicationActionQueue(out service); m_serviceManagerAdmin.Manager.Register(service); m_scriptExecutionManager = new ScriptExecutionManager(out service); m_serviceManagerAdmin.Manager.Register(service); m_dynamicObjectManager = new DynamicObjectManager(out service); m_serviceManagerAdmin.Manager.Register(service); m_uiCalculator = new UICalculator(out service); m_serviceManagerAdmin.Manager.Register(service); if (hostServices != null) { foreach (var hs in hostServices) { m_serviceManagerAdmin.Manager.Register(hs); } } TaskContextDummy taskContext = new TaskContextDummy(); try { m_serviceManagerAdmin.StartServices(taskContext); } catch (Exception ex) { // Roll back (stop) the services that actually did start. try { m_serviceManagerAdmin.StopServices(taskContext); } catch { /* Ignore exceptions during stop */ } throw new Exception("Failed to start all services. " + ex.GetType().Name + ", " + ex.ToString()); } m_initialized = true; m_initIndex++; }