public override string CompInspectStringExtra()
        {
            if (!this.Active)
            {
                return(null);
            }
            StringBuilder stringBuilder = new StringBuilder();
            RotStage      stage         = this.Stage;

            if (stage != RotStage.Fresh)
            {
                if (stage != RotStage.Rotting)
                {
                    if (stage == RotStage.Dessicated)
                    {
                        stringBuilder.Append("RotStateDessicated".Translate() + ".");
                    }
                }
                else
                {
                    stringBuilder.Append("RotStateRotting".Translate() + ".");
                }
            }
            else
            {
                stringBuilder.Append("RotStateFresh".Translate() + ".");
            }
            float num = (float)this.PropsRot.TicksToRotStart - this.RotProgress;

            if (num > 0f)
            {
                float num2 = this.parent.AmbientTemperature;
                num2 = (float)Mathf.RoundToInt(num2);
                float num3 = GenTemperature.RotRateAtTemperature(num2);
                int   ticksUntilRotAtCurrentTemp = this.TicksUntilRotAtCurrentTemp;
                stringBuilder.AppendLine();
                if (num3 < 0.001f)
                {
                    stringBuilder.Append("CurrentlyFrozen".Translate() + ".");
                }
                else if (num3 < 0.999f)
                {
                    stringBuilder.Append("CurrentlyRefrigerated".Translate(new object[]
                    {
                        ticksUntilRotAtCurrentTemp.ToStringTicksToPeriodVague(true, true)
                    }) + ".");
                }
                else
                {
                    stringBuilder.Append("NotRefrigerated".Translate(new object[]
                    {
                        ticksUntilRotAtCurrentTemp.ToStringTicksToPeriodVague(true, true)
                    }) + ".");
                }
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 2
0
 public static void Postfix(CompRottable __instance, RotStage __result)
 {
     if (__result == RotStage.Dessicated && __instance.parent is Corpse corpse &&
         (corpse.InnerPawn?.health?.hediffSet?.HasHediff(AlteredCarbonDefOf.AC_CorticalStack) ?? true))
     {
         var corticalStack = ThingMaker.MakeThing(AlteredCarbonDefOf.AC_FilledCorticalStack) as CorticalStack;
         corticalStack.SavePawnToCorticalStack(corpse.InnerPawn);
         GenPlace.TryPlaceThing(corticalStack, corpse.Position, corpse.Map, ThingPlaceMode.Near);
         corpse.InnerPawn.health.hediffSet.hediffs.RemoveAll(x => x.def == AlteredCarbonDefOf.AC_CorticalStack);
     }
 }
Ejemplo n.º 3
0
        public static bool CompInspectStringCustomHopper(CompRottable __instance, ref string __result)
        {
            IEnumerable <Thing> things = GetCompRottableThings(__instance);

            if (things.OfType <NPDHopper_Storage>().Any())
            {
                Thing         t             = things.OfType <NPDHopper_Storage>().First();
                StringBuilder stringBuilder = new StringBuilder();
                RotStage      stage         = __instance.Stage;
                if (stage != RotStage.Fresh)
                {
                    if (stage != RotStage.Rotting)
                    {
                        if (stage == RotStage.Dessicated)
                        {
                            stringBuilder.Append("RotStateDessicated".Translate() + ".");
                        }
                    }
                    else
                    {
                        stringBuilder.Append("RotStateRotting".Translate() + ".");
                    }
                }
                else
                {
                    stringBuilder.Append("RotStateFresh".Translate() + ".");
                }
                float num = (float)__instance.PropsRot.TicksToRotStart - __instance.RotProgress;
                if (num > 0f)
                {
                    float num2 = t.TryGetComp <CompPowerTrader>().PowerOn ? (float)Mathf.RoundToInt(things.OfType <NPDHopper_Storage>().First().def.GetModExtension <HopperCustom>().setTemperature)
                        : __instance.parent.AmbientTemperature;
                    float num3 = GenTemperature.RotRateAtTemperature(num2);
                    int   ticksUntilRotAtCurrentTemp = TicksUntilRotAtSetTemp(__instance, num2);
                    stringBuilder.AppendLine();
                    if (num3 < 0.001f)
                    {
                        stringBuilder.Append("CurrentlyFrozen".Translate() + ".");
                    }
                    else if (num3 < 0.999f)
                    {
                        stringBuilder.Append("CurrentlyRefrigerated".Translate(ticksUntilRotAtCurrentTemp.ToStringTicksToPeriod()) + ".");
                    }
                    else
                    {
                        stringBuilder.Append("NotRefrigerated".Translate(ticksUntilRotAtCurrentTemp.ToStringTicksToPeriod()) + ".");
                    }
                }
                __result = stringBuilder.ToString();
                return(false);
            }
            return(true);
        }
        public static IEnumerable <Thing> Postfix(IEnumerable <Thing> entries, Corpse __instance, Pawn butcher)
        {
            RotStage stage = __instance.GetRotStage();

            foreach (Thing entry in entries)
            {
                if (stage != RotStage.Fresh)
                {
                    CompRottable comp = entry.TryGetComp <CompRottable>();

                    if (entry.GetStatValue(StatDefOf.DeteriorationRate) > 0.5)
                    {
                        entry.Destroy();
                        continue;
                    }
                    else if (comp != null)
                    {
                        if ((stage == RotStage.Dessicated) || comp.PropsRot.rotDestroys)
                        {
                            entry.Destroy();
                            continue;
                        }
                        else
                        {
                            comp.RotImmediately();
                        }
                    }
                }
                yield return(entry);
            }

            if (stage == RotStage.Rotting)
            {
                butcher.needs.mood.thoughts.memories.TryGainMemory(MyDefOf.LuluButcherRotten_ButcheredRotten);
                FilthMaker.TryMakeFilth(butcher.Position, butcher.Map, ThingDefOf.Filth_CorpseBile, __instance.InnerPawn.LabelIndefinite());
            }
        }
Ejemplo n.º 5
0
 public void ButcherProducts(Corpse corpse)
 {
     if (corpse.InnerPawn != null)
     {
         if (corpse.InnerPawn.RaceProps.Humanlike)
         {
             IntVec3 pos = corpse.PositionHeld;
             if (corpse.InnerPawn.equipment != null)
             {
                 corpse.InnerPawn.equipment.DropAllEquipment(pos, true);
             }
             if (corpse.InnerPawn.apparel != null)
             {
                 corpse.InnerPawn.apparel.DropAll(pos, true);
             }
             if (corpse.InnerPawn.inventory != null)
             {
                 corpse.InnerPawn.inventory.DropAllNearPawn(pos, true);
             }
         }
         if (corpse.InnerPawn.RaceProps.meatDef != null)
         {
             int count = GenMath.RoundRandom(corpse.InnerPawn.GetStatValue(StatDefOf.MeatAmount, true));
             if (count > 0)
             {
                 Thing thing = ThingMaker.MakeThing(corpse.InnerPawn.RaceProps.meatDef, null);
                 thing.stackCount = count;
                 if (thing.stackCount >= 2)
                 {
                     RotStage rotStage = corpse.GetRotStage();
                     if (rotStage == RotStage.Rotting)
                     {
                         thing.stackCount = count / 2;
                     }
                 }
                 GenPlace.TryPlaceThing(thing, corpse.Position, corpse.Map, ThingPlaceMode.Direct, out Thing meat, null);
                 if (meat != null)
                 {
                     meat.SetForbidden(true);
                 }
             }
         }
         if (corpse.InnerPawn.RaceProps.leatherDef != null)
         {
             int count = GenMath.RoundRandom(corpse.InnerPawn.GetStatValue(StatDefOf.LeatherAmount, true));
             if (count > 0)
             {
                 Thing thing = ThingMaker.MakeThing(corpse.InnerPawn.RaceProps.leatherDef, null);
                 thing.stackCount = count;
                 if (thing.stackCount >= 2)
                 {
                     RotStage rotStage = corpse.GetRotStage();
                     if (rotStage == RotStage.Rotting)
                     {
                         thing.stackCount = count / 2;
                     }
                 }
                 GenPlace.TryPlaceThing(thing, corpse.Position, corpse.Map, ThingPlaceMode.Direct, out Thing leather, null);
                 if (leather != null)
                 {
                     leather.SetForbidden(true);
                 }
             }
         }
         if (corpse.InnerPawn.RaceProps.BloodDef != null)
         {
             FilthMaker.MakeFilth(corpse.Position, corpse.Map, corpse.InnerPawn.RaceProps.BloodDef, corpse.InnerPawn.LabelIndefinite(), 1);
         }
     }
 }