示例#1
0
        public bool CanUseRightNow(ThingDef searchedItem, Map map, ArmorModuleDef def, out string reason)
        {
            reason = string.Empty;

            if (searchedItem == null)
            {
                reason = "Item not found";
                return(false);
            }

            List <SlotGroup> allGroupsListForReading = map.haulDestinationManager.AllGroupsListForReading;
            bool             found = false;

            for (int i = 0; i < allGroupsListForReading.Count; i++)
            {
                SlotGroup slotGroup = allGroupsListForReading[i];
                foreach (var item in slotGroup.HeldThings)
                {
                    if (item.def == searchedItem)
                    {
                        found = true;
                    }
                }
            }

            if (!found)
            {
                reason += $"\n{"Station_ModuleItemNotFound".Translate()}";
            }

            if (searchedItem.recipeMaker != null && searchedItem.recipeMaker.researchPrerequisite != null)
            {
                float project = Find.ResearchManager.GetProgress(searchedItem.recipeMaker.researchPrerequisite);
                if (project != searchedItem.recipeMaker.researchPrerequisite.baseCost)
                {
                    reason += $"\n{"Station_NeedResearch".Translate(searchedItem.recipeMaker.researchPrerequisite.LabelCap)}";
                }
            }

            if (def.StationLevelRequired > mkStationWindow.mkStation.StationLevel)
            {
                reason += $"\n{"Station_LevelReq".Translate(def.StationLevelRequired, mkStationWindow.mkStation.StationLevel)}";
            }

            var incComp = mkStationWindow.mkStation.ContainedArmor.IncompatibleModules;

            if (incComp != null)
            {
                List <ArmorModuleDef> incModules = mkStationWindow.mkStation.ContainedArmor.IncompatibleModules.ModuleList;
                if (incModules != null)
                {
                    if (incModules.Contains(def))
                    {
                        reason += $"\n{"Station_Incopatible".Translate()}";
                    }
                }
            }

            return(string.IsNullOrEmpty(reason));
        }
示例#2
0
        private void DrawModuleTab(Rect inRect, ArmorModuleCategory selectCategory)
        {
            Rect scrollVertRectFact = new Rect(0, 0, inRect.x, DefDatabase <ArmorModuleDef> .AllDefsListForReading.Where(x => x.ModuleCategory == selectCategory).Count() * 35);

            GUI.color = MenuSectionBGBorderColor;
            Widgets.DrawLineVertical(245, inRect.y, 465);
            Widgets.DrawLineHorizontal(0, inRect.y, inRect.width);
            GUI.color = Color.white;

            Text.Anchor = TextAnchor.MiddleCenter;
            Rect rect2      = new Rect(inRect.x + 10, 0, 230, 30);
            Rect sliderRect = new Rect(inRect.x, inRect.y + 10, inRect.width, 410);

            Widgets.BeginScrollView(sliderRect, ref slider, scrollVertRectFact, false);
            foreach (var module in DefDatabase <ArmorModuleDef> .AllDefsListForReading.Where(x => x.ModuleCategory == selectCategory))
            {
                Color bColor = canUse.ContainsKey(module) ? Color.gray : Color.white;
                if (DrawCustomButton(rect2, module.LabelCap, bColor))
                {
                    currentModule = module;
                }
                rect2.y += 35;
            }
            Widgets.EndScrollView();
            Text.Anchor = TextAnchor.UpperLeft;

            Rect rect3 = new Rect(inRect.x + 240, inRect.y + 10, 470, 455);

            if (currentModule != null)
            {
                DrawModuleInfo(rect3, currentModule);
            }
        }
示例#3
0
        private void CarryModule(ArmorModuleDef def)
        {
            Thing item = FindModuleItem(def.Item);

            if (item != null)
            {
                CheckModules(def);

                mkStationWindow.Close();
                Close();

                Job job = new Job(RimArmorCore.JobDefOfLocal.SetupModuleForArmor, mkStationWindow.mkStation, item, mkStationWindow.mkStation.ContainedArmor);
                job.count = 1;
                mkStationWindow.SelPawn.jobs.TryTakeOrderedJob(job);
            }
        }
示例#4
0
        private void CheckModules(ArmorModuleDef def)
        {
            foreach (var armorSlot in mkStationWindow.mkStation.ContainedArmor.Slots)
            {
                foreach (var slot in armorSlot.Modules)
                {
                    if (def.ExcludesModules != null && slot.Module != null && def.ExcludesModules.Contains(slot.Module.def))
                    {
                        mkStationWindow.mkStation.ContainedArmor.RemoveModule(slot.Module.def, mkStationWindow.mkStation.Position, mkStationWindow.mkStation.Map, true);
                    }

                    if (slot.Module != null && slot.Module.def == def)
                    {
                        mkStationWindow.mkStation.ContainedArmor.RemoveModule(slot.Module.def, mkStationWindow.mkStation.Position, mkStationWindow.mkStation.Map, true);
                    }
                }
            }
        }
示例#5
0
        private void DrawModuleInfo(Rect rect, ArmorModuleDef module)
        {
            Rect textureRect = new Rect(rect.x + (rect.x / 2) + 50, rect.y + 30, 100, 100);

            GUI.DrawTexture(textureRect, module.IconImage);

            Rect titleRect = new Rect(rect.x, rect.y, rect.width, 25);

            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Medium;
            Widgets.Label(titleRect, module.LabelCap);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            Rect mainRect = new Rect(rect.x + 15, textureRect.y + 115, 470, 300);

            Widgets.LabelScrollable(mainRect, module.description, ref slider2);

            GUI.color = MenuSectionBGBorderColor;
            Widgets.DrawLineHorizontal(rect.x + 45, rect.y + 30, rect.width - 80);
            GUI.color = Color.white;

            Color bColor     = canUse.ContainsKey(module) ? Color.gray : Color.white;
            Rect  buttonRect = new Rect(rect.x + 15, rect.y + 315, rect.width - 20, 20);

            Text.Anchor = TextAnchor.MiddleCenter;
            if (DrawCustomButton(buttonRect, "Station_InstallModule".Translate(), bColor))
            {
                if (canUse.ContainsKey(module))
                {
                    Messages.Message("Station_ModuleCannotInstal".Translate(canUse[module]), MessageTypeDefOf.NeutralEvent, false);
                }
                else
                {
                    CarryModule(module);
                }
            }
            if (canUse.ContainsKey(module))
            {
                Widgets.Label(new Rect(rect.x + 15, buttonRect.y + 1, rect.width - 20, 70), canUse[module]);
            }
            Text.Anchor = TextAnchor.UpperLeft;
        }