Example #1
0
        /// <summary>
        /// When a research is cancelled, removes from the queue if SHIFT clicked.
        /// </summary>
        /// <param name="targetTech">The technology to queue.</param>
        /// <returns>true to remove the technology normally, or false if this method already
        /// removed the technology.</returns>
        private static bool OnResearchCanceled(Tech targetTech)
        {
            var controller = Global.Instance.GetInputManager()?.GetDefaultController();
            var screen     = ManagementMenu.Instance?.researchScreen as ResearchScreen;
            var research   = Research.Instance;
            // If SHIFT is down (have to use reflection!)
            bool shiftDown = activeModifiers != null && (activeModifiers.GetValue(controller)
                                                         is Modifier mods) && mods == Modifier.Shift, cont = true;

            if (research != null && screen != null && !targetTech.IsComplete())
            {
#if DEBUG
                PUtil.LogDebug("Dequeue tech: " + targetTech.Name);
#endif
                // Remove from queue
                screen.CancelResearch();
                research.CancelResearch(targetTech);
                var queue = research.GetResearchQueue();
                // Restack research
                int n = queue.Count;
                research.SetActiveResearch((n > 0) ? queue[n - 1].tech : null, false);
                // The original method would immediately deselect this item, avoid that
                cont = false;
            }
            return(cont);
        }
Example #2
0
        /// <summary>
        /// When a research is cancelled, removes from the queue if SHIFT clicked.
        /// </summary>
        /// <param name="targetTech">The technology to queue.</param>
        /// <returns>true to remove the technology normally, or false if this method already
        /// removed the technology.</returns>
        private static bool OnResearchCanceled(Tech targetTech)
        {
            var controller = Global.Instance.GetInputManager()?.GetDefaultController();
            var inst       = ManagementMenu.Instance;
            var screen     = (inst == null) ? null : RESEARCH_SCREEN.Get(inst);
            var research   = Research.Instance;
            // If SHIFT is down (have to use reflection!)
            bool shiftDown = (ACTIVE_MODIFIERS.Get(controller) & Modifier.Shift) != 0, cont =
                true;

            if (research != null && screen != null && !targetTech.IsComplete())
            {
#if DEBUG
                PUtil.LogDebug("Dequeue tech: " + targetTech.Name);
#endif
                // Remove from queue
                screen.CancelResearch();
                research.CancelResearch(targetTech);
                var queue = research.GetResearchQueue();
                // Restack research
                int n = queue.Count;
                research.SetActiveResearch((n > 0) ? queue[n - 1].tech : null, false);
                // The original method would immediately deselect this item, avoid that
                cont = false;
            }
            return(cont);
        }
    public bool IsRequiredTechUnlocked()
    {
        if (string.IsNullOrEmpty(requiredTech))
        {
            return(true);
        }
        Tech tech = Db.Get().Techs.Get(requiredTech);

        return(tech.IsComplete());
    }