public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn)
        {
            foreach (FloatMenuOption fmo in base.GetFloatMenuOptions(selPawn))
            {
                yield return(fmo);
            }

            if (!selPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Deadly))
            {
                yield return(new FloatMenuOption("CannotUseNoPath".Translate().CapitalizeFirst(), null));

                yield break;
            }

            if (selPawn.skills.GetSkill(SkillDefOf.Construction).Level < jobConstructionSkillMin)
            {
                yield return(new FloatMenuOption("ConstructionSkillTooLow".Translate().CapitalizeFirst() + ": " + "MinSkill".Translate() + " " + jobConstructionSkillMin.ToString(), null));

                yield break;
            }


            ThingDef ingredientDef = DefDatabase <ThingDef> .GetNamed(ingredientDefName);

            ThingDef ingredient2Def = DefDatabase <ThingDef> .GetNamed(ingredient2DefName);

            int availableResources; int availableResources2;

            AIRobot_Helper.FindAvailableNearbyResources(ingredientDef, selPawn, out availableResources);
            AIRobot_Helper.FindAvailableNearbyResources(ingredient2Def, selPawn, out availableResources2);

            bool resourcesOk = true;

            if (resourcesOk && availableResources < this.ingredientNeedCount)
            {
                resourcesOk = false;
                yield return(new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst() + ": " + "NotEnoughStoredLower".Translate() + " (" + availableResources.ToString() + " / " + ingredientNeedCount.ToString() + " " + ingredientDef.LabelCap + ")", null));
            }
            if (resourcesOk && availableResources2 < this.ingredient2NeedCount)
            {
                resourcesOk = false;
                yield return(new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst() + ": " + "NotEnoughStoredLower".Translate() + " (" + availableResources2.ToString() + " / " + ingredient2NeedCount.ToString() + " " + ingredient2Def.LabelCap + ")", null));
            }
            if (resourcesOk)
            {
                //yield return new FloatMenuOption("(Not implemented) "+ "AIRobot_RepairRobot".Translate(), null);
                //yield return new FloatMenuOption("AIRobot_RepairRobot".Translate() + " --- STILL NOT WORKING !!! ", delegate { StartRepairJob2(selPawn); });
                yield return(new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst(), delegate { StartRepairJob2(selPawn); }));
            }

            //yield return new FloatMenuOption("AIRobot_DismantleRobot".Translate(), delegate { StartDismantleJob(selPawn); });
        }
Beispiel #2
0
        public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn, X2_AIRobot_disabled disabledRobot)
        {
            if (!selPawn.CanReach(disabledRobot, PathEndMode.InteractionCell, Danger.Deadly))
            {
                yield return(new FloatMenuOption("CannotUseNoPath".Translate().CapitalizeFirst(), null));

                yield break;
            }

            if (selPawn.skills.GetSkill(SkillDefOf.Construction).Level < X2_AIRobot_disabled.jobConstructionSkillMin)
            {
                yield return(new FloatMenuOption("ConstructionSkillTooLow".Translate().CapitalizeFirst() + ": " + "MinSkill".Translate() + " " + X2_AIRobot_disabled.jobConstructionSkillMin.ToString(), null));

                yield break;
            }


            ThingDef ingredientDef = disabledRobot.def.costList[0].thingDef;  // DefDatabase<ThingDef>.GetNamed(ingredientDefName);
            ThingDef ingredient2Def = disabledRobot.def.costList[1].thingDef; //DefDatabase<ThingDef>.GetNamed(ingredient2DefName);
            int      availableResources; int availableResources2;

            AIRobot_Helper.FindAvailableNearbyResources(ingredientDef, selPawn, out availableResources);
            AIRobot_Helper.FindAvailableNearbyResources(ingredient2Def, selPawn, out availableResources2);

            bool resourcesOk = true;

            if (resourcesOk && availableResources < disabledRobot.def.costList[0].count) //X2_AIRobot_disabled.ingredientNeedCount)
            {
                resourcesOk = false;
                yield return(new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst() + ": " + "NotEnoughStoredLower".Translate() + " (" + availableResources.ToString() + " / " + disabledRobot.def.costList[0].count.ToString() + " " + ingredientDef.LabelCap + ")", null));
            }
            if (resourcesOk && availableResources2 < disabledRobot.def.costList[1].count) //X2_AIRobot_disabled.ingredient2NeedCount)
            {
                resourcesOk = false;
                yield return(new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst() + ": " + "NotEnoughStoredLower".Translate() + " (" + availableResources2.ToString() + " / " + disabledRobot.def.costList[1].count.ToString() + " " + ingredient2Def.LabelCap + ")", null));
            }
            if (resourcesOk)
            {
                yield return(new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst(), delegate { X2_AIRobot_disabled.StartRepairJob2(selPawn, disabledRobot); }));
            }

            //yield return new FloatMenuOption("AIRobot_DismantleRobot".Translate(), delegate { StartDismantleJob(selPawn); });
        }
Beispiel #3
0
        private static Boolean AreAllNeededResourcesAvailable(Dictionary <ThingDef, int> resources, Pawn pawn)
        {
            List <string> missingResources = new List <string>();

            foreach (ThingDef ingredientDef in resources.Keys)
            {
                int availableResources;
                AIRobot_Helper.FindAvailableNearbyResources(ingredientDef, pawn, out availableResources);

                if (availableResources < resources[ingredientDef])
                {
                    missingResources.Add("(" + availableResources.ToString() + " / " + resources[ingredientDef].ToString() + " " + ingredientDef.LabelCap + ")");
                }
            }

            if (missingResources.Count == 0)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public static List <string> GetStationRepairJobMissingThingStrings(Dictionary <ThingDef, int> resources, Pawn pawn)
        {
            List <string> missingResources = new List <string>();

            if (resources == null)
            {
                return(missingResources);
            }

            foreach (ThingDef ingredientDef in resources.Keys)
            {
                int availableResources;
                AIRobot_Helper.FindAvailableNearbyResources(ingredientDef, pawn, out availableResources);

                if (availableResources < resources[ingredientDef])
                {
                    missingResources.Add("(" + availableResources.ToString() + " / " + resources[ingredientDef].ToString() + " " + GetThingDefLabel(ingredientDef) + ")");
                    //return new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst() + ": " + "NotEnoughStoredLower".Translate() + " (" + availableResources.ToString() + " / " + resources[ingredientDef].ToString() + " " + ingredientDef.LabelCap + ")", null);
                }
            }
            return(missingResources);
        }
Beispiel #5
0
        private static Boolean AreAllNeededResourcesAvailable(Dictionary <ThingDef, int> resources, Pawn pawn)
        {
            List <string> missingResources = new List <string>();

            foreach (ThingDef ingredientDef in resources.Keys)
            {
                int availableResources;
                AIRobot_Helper.FindAvailableNearbyResources(ingredientDef, pawn, out availableResources);

                if (availableResources < resources[ingredientDef])
                {
                    missingResources.Add("(" + availableResources.ToString() + " / " + resources[ingredientDef].ToString() + " " + ingredientDef.LabelCap + ")");
                    //return new FloatMenuOption("AIRobot_RepairRobot".Translate().CapitalizeFirst() + ": " + "NotEnoughStoredLower".Translate() + " (" + availableResources.ToString() + " / " + resources[ingredientDef].ToString() + " " + ingredientDef.LabelCap + ")", null);
                }
            }

            if (missingResources.Count == 0)
            {
                return(true);
            }
            return(false);
        }