예제 #1
0
        void SetupReplacements()
        {
            // cache the comps to avoid expensive calls every tick
            compShearable   = compShearable ?? GetComp <CompShearable>();
            compElectricity = compElectricity ?? GetComp <CompStaticElectricity>();

            // load replacements for existing graphics based on the current life stage
            replacements.Clear();

            AddReplacement(
                graphic: LoadGraphic("summer_dead"),
                condition: () => Dead && IsHot);

            AddReplacement(
                graphic: LoadGraphic("winter_dead"),
                condition: () => Dead && IsCold);

            AddReplacement(
                graphic: LoadGraphic("dead"),
                condition: () => Dead);

            AddReplacement(
                graphic: LoadGraphic("summer_sleep"),
                condition: () => IsHot && IsLyingDown);

            AddReplacement(
                graphic: LoadGraphic("winter_sleep"),
                condition: () => IsCold && IsLyingDown);

            AddReplacement(
                graphic: LoadGraphic("summer"),
                condition: () => IsHot);

            AddReplacement(
                graphic: LoadGraphic("winter"),
                condition: () => IsCold);

            AddReplacement(
                graphic: LoadGraphic("sheared_sleep"),
                condition: () => IsTamed && IsSheared && IsLyingDown);

            AddReplacement(
                graphic: LoadGraphic("sheared"),
                condition: () => IsTamed && IsSheared);

            AddReplacement(
                graphic: LoadGraphic("charged"),
                condition: () => IsEnergized);

            AddReplacement(
                graphic: LoadGraphic("sleep"),
                condition: () => IsLyingDown);

            AddReplacement(             // default graphic if no previous match
                graphic: ageTracker.CurKindLifeStage.bodyGraphicData.Graphic,
                condition: () => true);
        }
예제 #2
0
        public static int TicksTillHarvestable(this CompHasGatherableBodyResource comp)
        {
            var interval          = Traverse.Create(comp).Property("GatherResourcesIntervalDays").GetValue <int>();
            var growthRatePerTick = 1f / (interval * GenDate.TicksPerDay);

            var pawn = comp.parent as Pawn;

            if (pawn == null)
            {
                throw new ArgumentException("harvestable should always be on a Pawn");
            }
            growthRatePerTick *= PawnUtility.BodyResourceGrowthSpeed((Pawn)comp.parent);

            // Logger.Debug( $"rate: {growthRatePerTick}, interval: {interval}");

            return(Mathf.CeilToInt((1 - comp.Fullness) / growthRatePerTick));
        }
예제 #3
0
        internal static void GenerateThoughtsAbout([NotNull] Pawn doer, [NotNull] CompHasGatherableBodyResource __instance)
        {
            var selfPawn = __instance.parent as Pawn;

            if (!selfPawn.IsSapientOrFeralFormerHuman())
            {
                return;
            }

            //TODO put this in a def extension or something
            if (__instance is CompMilkable)
            {
                if (ThoughtMaker.MakeThought(PMThoughtDefOf.SapientAnimalMilked) is Thought_Memory memory)
                {
                    selfPawn.TryGainMemory(memory);
                }
            }
        }
예제 #4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            //this.FailOnDowned(TargetIndex.A);
            //this.FailOnNotCasualInterruptible(TargetIndex.A);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            Toil toil = new Toil();

            //toil.initAction = delegate
            //{
            //    Thing thing = this.CurJob.GetTarget(TargetIndex.A).Thing;
            //    if (thing != null)
            //    {
            //        PawnUtility.ForceWait(thing, this.Duration, null);
            //    }
            //};
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = this.Duration;
            toil.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            yield return(toil);

            Toil toilGather = new Toil();

            toilGather.defaultCompleteMode = ToilCompleteMode.Instant;
            toilGather.initAction          = delegate
            {
                CompHasGatherableBodyResource comp = this.GetComp(this.job.targetA.Thing);
                comp.Gathered(this.pawn);
            };
            yield return(toilGather);

            //yield return new Toil
            //{
            //    initAction = delegate
            //    {
            //        //this.GetComp((Pawn)((Thing)this.CurJob.GetTarget(TargetIndex.A))).Gathered(this.pawn);
            //        this.GetComp((Thing)this.CurJob.GetTarget(TargetIndex.A)).Gathered(this.pawn);
            //    }
            //};
            yield break;
        }
예제 #5
0
        public override bool HasJobOnThing(Pawn pawn, Thing thing, bool forced = false)
        {
            Pawn pawn2 = thing as Pawn;

            if (pawn2 == null || !pawn2.RaceProps.Humanlike)
            {
                return(false);
            }
            CompHasGatherableBodyResource comp = GetComp(pawn2);

            if (comp != null && comp.ActiveAndFull && PawnUtility.CanCasuallyInteractNow(pawn2, false) && pawn2 != pawn)
            {
                LocalTargetInfo localTargetInfo = pawn2;
                if (ReservationUtility.CanReserve(pawn, localTargetInfo, 1, -1, null, forced))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #6
0
 public static void AlphaAnimals_get_ResourceAmount_Patch(ref int __result, CompHasGatherableBodyResource __instance)
 {
     __result = (int)(__result * Genes.GetGene((Pawn)__instance.parent, AnimalGenetics.GatherYield));
 }
 public override bool CompValidator(CompHasGatherableBodyResource comp)
 {
     return(true);
 }
예제 #8
0
 public static void ChemicalsAndNeutroamine_get_ResourceAmountPatch(ref int __result, CompHasGatherableBodyResource __instance)
 {
     __result = (int)(__result * Genes.GetGene((Pawn)__instance.parent, AnimalGenetics.GatherYield));
 }
 public abstract bool CompValidator(CompHasGatherableBodyResource comp);
예제 #10
0
 public override bool CompValidator(CompHasGatherableBodyResource comp)
 {
     return(comp is CompMilkable);
 }