예제 #1
0
        private void Load()
        {
#if UNITY
            // In unity editor set synchronizer from the inspector
#else
            var path   = Path.Combine(RootPath, AssetBundleName);
            var bundle = AssetBundle.LoadFromFile(path);
            if (bundle == null)
            {
                PTLogger.Error($"Failed to load ParallelTasker asset bundle from {path}.");
                return;
            }

            var prefab = bundle.LoadAsset <GameObject>("Synchronizer");
            m_synchronizer = Instantiate(prefab);
            bundle.Unload(true);
#endif

            if (m_synchronizer == null)
            {
                PTLogger.Error("Could not load synchronizers");
                return;
            }
            m_synchronizer.SetActive(true);

            foreach (var sync in m_synchronizer.GetComponents <IPTSynchronizer>())
            {
                PTLogger.Debug($"Adding {sync} to known synchronizers");
                s_synchronizers.Add(sync.EventTime, sync);
            }
        }
예제 #2
0
 internal void OnSceneChange(Scene current, Scene next)
 {
     // in KSP scene changes are done through an intermediate loading buffer scene
     if (!ResetOnSceneChange)
     {
         return;
     }
     PTLogger.Debug($"Scene change: {current.name} -> {next.name}");
     Controller?.ResetCurrentTasks();
 }
예제 #3
0
        public PTTaskQueue()
        {
            ResetCount();
#if DEBUG
            var sb      = new StringBuilder($"{this} dequeue order:\n");
            var counter = 0;
            foreach (var group in m_tasks.Keys)
            {
                sb.AppendLine($"  {(++counter).ToString()}. {group.ToString()}");
            }
            PTLogger.Debug(sb.ToString());
#endif
        }
예제 #4
0
 private void Awake()
 {
     if (m_instance == null)
     {
         PTLogger.Debug($"Singleton {this} is awake");
         m_instance = this as T;
         DontDestroyOnLoad(this);
         OnAwake();
     }
     else
     {
         PTLogger.Warning($"{this} is a Singleton but an instance already exists, destroying this instance");
         m_destroyingDuplicate = true;
         Destroy(this);
     }
 }