Ejemplo n.º 1
0
        public static void HackPoorly(Pawn pawn, BodyPartRecord part, RecipeDef recipe)
        {
            pawn.health.AddHediff(WTH_DefOf.WTH_TargetingHackedPoorly, part, null);
            if (recipe.GetModExtension <DefModExtension_Recipe>() is DefModExtension_Recipe extension && extension.addsAdditionalHediff != null)
            {
                BodyPartRecord additionalHediffBodyPart = null;
                if (extension.additionalHediffBodyPart != null)
                {
                    additionalHediffBodyPart = pawn.health.hediffSet.GetNotMissingParts().FirstOrDefault((BodyPartRecord bpr) => bpr.def == extension.additionalHediffBodyPart);
                }
                pawn.health.AddHediff(extension.addsAdditionalHediff, additionalHediffBodyPart);
            }

            if (pawn.health.hediffSet.HasHediff(WTH_DefOf.WTH_RepairModule) && pawn.GetComp <CompRefuelable>() == null)
            {
                pawn.InitializeComps();
            }

            pawn.SetFaction(Faction.OfPlayer);
            if (pawn.jobs.curDriver != null)
            {
                pawn.jobs.posture = PawnPosture.LayingOnGroundNormal;
            }
            if (pawn.story == null)
            {
                pawn.story = new Pawn_StoryTracker(pawn);
            }
            Find.LetterStack.ReceiveLetter("WTH_Letter_HackedPoorly_Label".Translate(), "WTH_Letter_HackedPoorly_Description".Translate(), LetterDefOf.NegativeEvent, pawn);
            LessonAutoActivator.TeachOpportunity(WTH_DefOf.WTH_Power, OpportunityType.Important);
            LessonAutoActivator.TeachOpportunity(WTH_DefOf.WTH_Maintenance, OpportunityType.Important);
        }
Ejemplo n.º 2
0
 private static bool Prefix(RecipeDef __instance, Thing thing, ref bool __result)
 {
     if (__instance == AlteredCarbonDefOf.AC_InstallEmptyCorticalStack && thing is Pawn pawn)
     {
         var option = __instance.GetModExtension <ExcludeRacesModExtension>();
         if (option != null && option.racesToExclude.Contains(pawn.def.defName) || pawn.IsEmptySleeve())
         {
             __result = false;
             return(false);
         }
     }
     else if (__instance == AlteredCarbonDefOf.AC_InstallCorticalStack && thing is Pawn pawn2)
     {
         var option = __instance.GetModExtension <ExcludeRacesModExtension>();
         if (option != null && option.racesToExclude.Contains(pawn2.def.defName))
         {
             __result = false;
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
        public override IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
        {
            if (pawn?.story?.bodyType == null)
            {
                yield break;
            }

            if (recipe.GetModExtension <SurgeryDef>().gender != 0 &&
                pawn.gender != recipe.GetModExtension <SurgeryDef>().gender)
            {
                yield break;
            }

            var currentBody = GetCurrentBodyType(pawn);

            if (currentBody == GetTargetBody(pawn.gender == Gender.Male, recipe.GetModExtension <SurgeryDef>().bodyType))
            {
                yield break;
            }

            yield return(pawn.RaceProps.body.corePart);
        }
Ejemplo n.º 4
0
        public override IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
        {
            bool partFound = false;

            if (IsValidPawn(pawn))
            {
                //Copy from vanilla. Much more complex than needed, but does the trick
                for (int i = 0; i < recipe.appliedOnFixedBodyParts.Count; i++)
                {
                    BodyPartDef           part   = recipe.appliedOnFixedBodyParts[i];
                    List <BodyPartRecord> bpList = pawn.RaceProps.body.AllParts;
                    for (int j = 0; j < bpList.Count; j++)
                    {
                        BodyPartRecord record = bpList[j];
                        if (record.def == part && !partFound || allowMultipleParts)
                        {
                            IEnumerable <Hediff> diffs = from x in pawn.health.hediffSet.hediffs
                                                         where x.Part == record
                                                         select x;
                            if (diffs.Count <Hediff>() != 1 || diffs.First <Hediff>().def != recipe.addsHediff)
                            {
                                if (record.parent == null || pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null).Contains(record.parent))
                                {
                                    if (!pawn.health.hediffSet.PartOrAnyAncestorHasDirectlyAddedParts(record) || pawn.health.hediffSet.HasDirectlyAddedPartFor(record))
                                    {
                                        yield return(record);

                                        partFound = true;
                                    }
                                }
                            }
                        }
                    }

                    if (recipe.GetModExtension <DefModExtension_Recipe>() is DefModExtension_Recipe ext && !ext.needsFixedBodyPart && !partFound)
                    {
                        yield return(null);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
        {
            for (int i = 0; i < recipe.appliedOnFixedBodyParts.Count; i++)
            {
                BodyPartDef           part   = recipe.appliedOnFixedBodyParts[i];
                List <BodyPartRecord> bpList = pawn.RaceProps.body.AllParts;
                for (int j = 0; j < bpList.Count; j++)
                {
                    BodyPartRecord record = bpList[j];
                    if (record.def == part)
                    {
                        if (pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null).Contains(record))
                        {
                            var implants = pawn.health.hediffSet.hediffs
                                           .Where(d => d.Part == record && d is Hediff_Implant && d.Visible);
                            if (implants.Count() == 3 && pawn.health.hediffSet.HasDirectlyAddedPartFor(record))
                            {
                                yield break;
                            }

                            MSE_ImplantSystem implantSystem = recipe.GetModExtension <MSE_ImplantSystem>();
                            if (implantSystem != null && implantSystem.isSpecial)
                            {
                                if (pawn.health.hediffSet.HasDirectlyAddedPartFor(record) && !MSE_VanillaExtender.PartHasAdvancedImplantSystem(pawn, record))
                                {
                                    yield break;
                                }
                            }

                            if (!pawn.health.hediffSet.hediffs.Any((Hediff x) => x.Part == record && x.def == recipe.addsHediff))
                            {
                                yield return(record);
                            }
                        }
                    }
                }
            }
            yield break;
        }
        public static int GetNumOfUnfoundProjsByRecipe(RecipeDef recipe)
        {
            int result = 0;

            if (recipe.HasModExtension <ResearchDefModExtension>())
            {
                var temp = UndiscoveredResearchList.MainResearchDict.Where(item => item.Value.ResearchSize == recipe.GetModExtension <ResearchDefModExtension>().ResearchSize &&
                                                                           item.Value.ResearchTypes.Any(x => x == recipe.GetModExtension <ResearchDefModExtension>().researchTypes[0]));

                foreach (KeyValuePair <string, ImmersiveResearchProject> p in temp)
                {
                    if (p.Value.IsDiscovered == false)
                    {
                        result++;
                    }
                }
            }

            return(result);
        }
        // TODO: find potential way to not have to patch this?
        //MakeRecipeProducts
        public static void SetFinishedExpOnMake(ref RecipeDef recipeDef, ref Pawn worker, ref List <Thing> ingredients)
        {
            if (recipeDef.ProducedThingDef != null)
            {
                if (recipeDef.ProducedThingDef.defName == "FinishedExperiment")
                {
                    // check if we are studying an experiment instead of making one
                    // if research is not discovered, discover it
                    if (recipeDef.defName == "StudyFinishedExperiment")
                    {
                        if (ingredients[0].def.GetModExtension <ResearchDefModExtension>().ResearchDefAttachedToExperiment != "")
                        {
                            var thingcomp = ingredients[0].TryGetComp <ResearchThingComp>();
                            ingredients[0].def.GetModExtension <ResearchDefModExtension>().ResearchDefAttachedToExperiment = thingcomp.researchDefName;
                            recipeDef.ProducedThingDef.GetModExtension <ResearchDefModExtension>().ExperimentHasBeenMade   = true;
                            Current.Game.GetComponent <GameComponent_ImmersiveResearch>().MainResearchDict.MainResearchDict[thingcomp.researchDefName].IsDiscovered = true;
                        }
                    }
                    else
                    {
                        recipeDef.ProducedThingDef.GetModExtension <ResearchDefModExtension>().researchTypes.Clear();
                        recipeDef.ProducedThingDef.GetModExtension <ResearchDefModExtension>().ResearchSize = ResearchSizes.None;
                        recipeDef.ProducedThingDef.GetModExtension <ResearchDefModExtension>().ResearchDefAttachedToExperiment = "";
                        recipeDef.ProducedThingDef.GetModExtension <ResearchDefModExtension>().ExperimentHasBeenMade           = false;

                        recipeDef.ProducedThingDef.GetModExtension <ResearchDefModExtension>().researchTypes.AddRange(recipeDef.GetModExtension <ResearchDefModExtension>().researchTypes);
                        recipeDef.ProducedThingDef.GetModExtension <ResearchDefModExtension>().ResearchSize = recipeDef.GetModExtension <ResearchDefModExtension>().ResearchSize;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public static bool HasRestrictionsForPart(this RecipeDef recipe, BodyPartRecord part, HediffSet hediffSet)
        {
            var modExt = recipe.GetModExtension <InstallationRestrictions>();

            return(modExt != null && part.parent != null && !modExt.CompatibleWithPart(part.parent, hediffSet));
        }