Пример #1
0
 static void HatchPatch(CompHatcher __instance)
 {
     if (__instance.hatcheeParent == null & __instance.Props.hatcherPawn.RaceProps.body.defName == "RimValiBody")
     {
         __instance.hatcheeFaction = Faction.OfPlayer;
     }
 }
Пример #2
0
 public static void Prefix(CompHatcher __instance)
 {
     if (__instance.hatcheeParent == null & __instance.Props.hatcherPawn.RaceProps.body.defName.ToString() == "NeziAvaliBody")
     {
         __instance.hatcheeFaction = Faction.OfPlayer;
     }
     Log.Message("Changed hatched avali's faction to player faction.", false);
 }
Пример #3
0
        public override void PreAbsorbStack(Thing otherStack, int count)
        {
            float       t    = (float)count / (float)(this.parent.stackCount + count);
            CompHatcher comp = ((ThingWithComps)otherStack).GetComp <CompHatcher>();
            float       b    = comp.gestateProgress;

            this.gestateProgress = Mathf.Lerp(this.gestateProgress, b, t);
        }
Пример #4
0
        public override void PostSplitOff(Thing piece)
        {
            CompHatcher comp = ((ThingWithComps)piece).GetComp <CompHatcher>();

            comp.gestateProgress = this.gestateProgress;
            comp.hatcheeParent   = this.hatcheeParent;
            comp.otherParent     = this.otherParent;
            comp.hatcheeFaction  = this.hatcheeFaction;
        }
Пример #5
0
        // original rebuilded
        public static bool CompTick(CompHatcher __instance)
        {
            if (WorkRebalancerMod.Instance.Prof.RestoreWhenHostileDetected &&
                HostileHandler.HostileDetected)
            {
                return(true);
            }

            if (!__instance.TemperatureDamaged)
            {
                ModifyHatcher(__instance);
            }

            return(false);
        }
Пример #6
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            bool flag = base.Pawn != null;

            if (flag)
            {
                if (!initialized)
                {
                    initialized = true;
                    this.Initialize();
                }
            }

            if (Find.TickManager.TicksGame % 16 == 0)
            {
                IEnumerable <Hediff> hdEnum = this.Pawn.health.hediffSet.GetHediffs <Hediff>();
                foreach (Hediff hd in hdEnum)
                {
                    if (hd.def.defName == "SpaceHypoxia")
                    {
                        this.Pawn.health.RemoveHediff(hd);
                        break;
                    }
                }
            }

            if (Find.TickManager.TicksGame % 6000 == 0)
            {
                TM_Action.UpdateAnimalTraining(base.Pawn);
            }
            bool flag4 = Find.TickManager.TicksGame % 600 == 0 && this.Pawn.def != TorannMagicDefOf.TM_SkeletonR && this.Pawn.def != TorannMagicDefOf.TM_GiantSkeletonR;

            if (flag4)
            {
                UpdateHediff();
                necroValid = false;
                if (base.Pawn != null && !linkedPawn.DestroyedOrNull())
                {
                    necroValid = true;
                    lichStrike = 0;
                }
                else
                {
                    lichStrike++;
                }

                if (!necroValid && lichStrike > 2)
                {
                    if (base.Pawn.Map != null)
                    {
                        TM_MoteMaker.ThrowScreamMote(base.Pawn.Position.ToVector3(), base.Pawn.Map, .8f, 255, 255, 255);
                        base.Pawn.Kill(null, null);
                    }
                    else
                    {
                        base.Pawn.Kill(null, null);
                    }
                }
                else
                {
                    List <Need> needs = base.Pawn.needs.AllNeeds;
                    for (int i = 0; i < needs.Count; i++)
                    {
                        if (needs[i].def == NeedDefOf.Food || needs[i].def == NeedDefOf.Joy || needs[i].def == NeedDefOf.Rest || needs[i].def.defName == "Mood" || needs[i].def.defName == "Beauty" ||
                            needs[i].def.defName == "Comfort" || needs[i].def.defName == "Outdoors" || needs[i].def.defName == "RoomSize")
                        {
                            needs[i].CurLevel = needs[i].MaxLevel;
                        }
                    }
                    //if (base.Pawn.needs.food != null)
                    //{
                    //    base.Pawn.needs.food.CurLevel = base.Pawn.needs.food.MaxLevel;
                    //}
                    //if (base.Pawn.needs.rest != null)
                    //{
                    //    base.Pawn.needs.rest.CurLevel = base.Pawn.needs.rest.MaxLevel;
                    //}

                    //if (base.Pawn.IsColonist)
                    //{
                    //    base.Pawn.needs.beauty.CurLevel = .5f;
                    //    base.Pawn.needs.comfort.CurLevel = .5f;
                    //    base.Pawn.needs.joy.CurLevel = .5f;
                    //    base.Pawn.needs.mood.CurLevel = .5f;
                    //    base.Pawn.needs.space.CurLevel = .5f;
                    //}
                    Pawn pawn = base.Pawn;
                    int  num  = 1;
                    int  num2 = 1;

                    using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            BodyPartRecord rec   = enumerator.Current;
                            bool           flag2 = num > 0;

                            if (flag2)
                            {
                                IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>();
                                Func <Hediff_Injury, bool>  arg_BB_1;

                                arg_BB_1 = ((Hediff_Injury injury) => injury.Part == rec);

                                foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1))
                                {
                                    bool flag3 = num2 > 0;
                                    if (flag3)
                                    {
                                        bool flag5 = current.CanHealNaturally() && !current.IsPermanent();
                                        if (flag5)
                                        {
                                            current.Heal(2.0f);
                                            num--;
                                            num2--;
                                        }
                                        else
                                        {
                                            current.Heal(1.0f);
                                            num--;
                                            num2--;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffsTendable().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.TendableNow()) // && !currentTendable.IsPermanent()
                            {
                                rec.Tended(1, 1);
                            }
                        }
                    }

                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (!rec.IsPermanent())
                            {
                                if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup") || rec.def.defName == "Abasia" || rec.def.defName == "BloodRot")
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                                if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate") || rec.def.defName == "Scaria")
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                                if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere"))
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                                if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "CatatonicBreakdown"))
                                {
                                    pawn.health.RemoveHediff(rec);
                                }
                            }
                            if (rec.def.makesSickThought)
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                            if (rec.def.defName.Contains("Pregnant") || rec.def.defName == "DrugOverdose")
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                        }
                    }
                    CompHatcher cp_h = this.Pawn.TryGetComp <CompHatcher>();
                    if (cp_h != null)
                    {
                        Traverse.Create(root: cp_h).Field(name: "gestateProgress").SetValue(0);
                    }
                    CompMilkable cp_m = this.Pawn.TryGetComp <CompMilkable>();
                    if (cp_m != null)
                    {
                        Traverse.Create(root: cp_m).Field(name: "fullness").SetValue(0);
                    }
                }
            }
        }
Пример #7
0
        protected override void Impact(Thing hitThing)
        {
            if (!this.initialized)
            {
                this.pawn = this.launcher as Pawn;
                CompAbilityUserMagic   comp        = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AccelerateTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AccelerateTime_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AccelerateTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AccelerateTime_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal = pwr.level;
                verVal = ver.level;
                if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                    pwrVal = mpwr.level;
                    verVal = mver.level;
                }
                this.arcaneDmg = comp.arcaneDmg;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.strikeDelay = this.strikeDelay - verVal;
                this.radius      = this.def.projectile.explosionRadius;
                this.duration    = Mathf.RoundToInt(this.radius * this.strikeDelay);
                this.initialized = true;
                this.targets     = GenRadial.RadialCellsAround(base.Position, this.radius, true);
                //cellList = targets.ToList<IntVec3>();
            }


            Pawn targetPawn = this.intendedTarget.Thing as Pawn;

            if (targetPawn == null)
            {
                base.Position.GetFirstPawn(this.Map);
            }

            if (targetPawn != null)
            {
                if (targetPawn.Faction != null && targetPawn.Faction == this.launcher.Faction)
                {
                    AgePawn(targetPawn, Mathf.RoundToInt((24 * 2500) * (1 + (.1f * verVal))), false);
                }
                else
                {
                    List <Pawn> pawnList = TM_Calc.FindAllPawnsAround(this.launcher.Map, base.Position, this.radius, this.launcher.Faction, false);
                    if (pawnList != null && pawnList.Count > 0)
                    {
                        for (int i = 0; i < Mathf.Clamp(pawnList.Count, 0, 2 + verVal); i++)
                        {
                            if (pawnList[i].Faction != null && !pawnList[i].Faction.HostileTo(this.pawn.Faction))
                            {
                                pawnList[i].Faction.TryAffectGoodwillWith(this.pawn.Faction, -25);
                            }

                            if (pawnList[i].Faction != null && pawnList[i].Faction != this.pawn.Faction)
                            {
                                AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                                if (pawnList[i].IsColonist && !this.pawn.IsColonist)
                                {
                                    TM_Action.SpellAffectedPlayerWarning(pawnList[i]);
                                }
                            }
                            else if (pawnList[i].Faction == null)
                            {
                                AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                            }
                        }
                    }
                }
            }
            else
            {
                List <Pawn> pawnList = TM_Calc.FindAllPawnsAround(this.launcher.Map, base.Position, this.radius, this.launcher.Faction, false);
                if (pawnList != null && pawnList.Count > 0)
                {
                    for (int i = 0; i < Mathf.Clamp(pawnList.Count, 0, 2 + verVal); i++)
                    {
                        if (pawnList[i].Faction != null && !pawnList[i].Faction.HostileTo(this.pawn.Faction))
                        {
                            pawnList[i].Faction.TryAffectGoodwillWith(this.pawn.Faction, -25);
                        }

                        targetPawn = pawnList[i];
                        if (targetPawn.Faction != null && targetPawn.Faction != this.pawn.Faction)
                        {
                            AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                        }
                        else if (targetPawn.Faction == null)
                        {
                            AgePawn(pawnList[i], Mathf.RoundToInt((2500) * (1 + (.1f * verVal))), true);
                        }
                    }
                }
            }

            List <Thing> thingList = base.Position.GetThingList(this.Map);
            Thing        thing     = null;

            if (targetPawn == null && thingList != null && thingList.Count > 0)
            {
                for (int i = 0; i < thingList.Count; i++)
                {
                    if (thingList[i] != null && !(thingList[i] is Pawn) && !(thingList[i] is Building))
                    {
                        //if (thingList[i].def.thingCategories != null && thingList[i].def.thingCategories.Count > 0 && (thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.ResourcesRaw) || thingList[i].def.thingCategories.Contains(ThingCategoryDefOf.StoneBlocks) || thingList[i].def.defName == "RawMagicyte"))
                        if (thingList[i].def.MadeFromStuff)
                        {
                            thing = thingList[i];
                            break;
                        }
                        if (!thingList[i].def.MadeFromStuff && thingList[i].TryGetComp <CompQuality>() != null)
                        {
                            thing = thingList[i];
                            break;
                        }
                    }
                }
            }

            if (thing != null)
            {
                AgeThing(thing);
            }

            List <IntVec3> cellList = targets.ToList();

            if (cellList != null && cellList.Count > 0)
            {
                for (int i = 0; i < cellList.Count; i++)
                {
                    thingList = cellList[i].GetThingList(this.Map);
                    if (thingList != null && thingList.Count > 0)
                    {
                        for (int j = 0; j < thingList.Count; j++)
                        {
                            if (thingList[j] is Plant)
                            {
                                Plant plant = thingList[j] as Plant;
                                try
                                {
                                    plant.Growth = plant.Growth + ((Rand.Range((2 + pwrVal), (4 + pwrVal)) / plant.def.plant.growDays) * this.arcaneDmg);
                                }
                                catch (NullReferenceException ex)
                                {
                                    plant.Growth *= (1.1f + (.1f * pwrVal));
                                }
                            }
                            CompHatcher compHatcher = thingList[j].TryGetComp <CompHatcher>();
                            if (compHatcher != null)
                            {
                                float gestateProgress = Traverse.Create(root: compHatcher).Field(name: "gestateProgress").GetValue <float>();
                                Traverse.Create(root: compHatcher).Field(name: "gestateProgress").SetValue((gestateProgress + Rand.Range(.3f + (.1f * pwrVal), .7f + (.1f * pwrVal))) * this.arcaneDmg);
                            }
                        }
                    }
                }
            }

            Effecter AreaAccelEffect = TorannMagicDefOf.TM_TimeAccelerationAreaEffecter.Spawn();

            AreaAccelEffect.Trigger(new TargetInfo(base.Position, this.Map, false), new TargetInfo(base.Position, this.Map, false));
            AreaAccelEffect.Cleanup();

            this.age = this.duration;
            this.Destroy(DestroyMode.Vanish);
        }
Пример #8
0
        public static void AddQuality(CompHatcher __instance)
        {
            GeneticRim_CompHatcher_Hatch_Patch.motherStored = __instance.hatcheeParent;

            GeneticRim_CompHatcher_Hatch_Patch.fatherStored = __instance.otherParent;
        }