Exemplo n.º 1
0
        // Token: 0x0600006A RID: 106 RVA: 0x00004BBC File Offset: 0x00002DBC
        public static Toil FinalizeFeeding(TargetIndex feedable, TargetIndex food)
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Job          curJob      = toil.actor.CurJob;
                Thing        thing       = curJob.GetTarget(feedable).Thing;
                Thing        excessThing = null;
                CompAquarium AQComp      = thing.TryGetComp <CompAquarium>();
                if (AQComp != null)
                {
                    int numFoodToAdd = AQUtility.GetFoodNumToFullyFeed(AQComp);
                    if (numFoodToAdd > 0)
                    {
                        Thing foodybits = curJob.GetTarget(food).Thing;
                        if (foodybits != null)
                        {
                            int numFoodHave = foodybits.stackCount;
                            int numAdding;
                            if (numFoodHave <= numFoodToAdd)
                            {
                                numAdding = numFoodHave;
                                foodybits.Destroy(DestroyMode.Vanish);
                            }
                            else
                            {
                                numAdding             = numFoodToAdd;
                                foodybits.stackCount -= numAdding;
                                GenPlace.TryPlaceThing(foodybits, toil.actor.Position, toil.actor.Map, ThingPlaceMode.Near, out Thing newFoodDrop, null, null, default);
Exemplo n.º 2
0
        // Token: 0x06000085 RID: 133 RVA: 0x00004F68 File Offset: 0x00003168
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Thing  f      = null;
            JobDef useDef = null;

            if (AQUtility.AddOrRemove(t, out bool Add, out ThingDef fAddDef, out bool Remove))
            {
                if (Add)
                {
                    f = AQUtility.GetClosestFishInBag(pawn, fAddDef, t);
                    if (f != null)
                    {
                        useDef = DefDatabase <JobDef> .GetNamed("AQManagingAdd", false);
                    }
                }
                else if (Remove)
                {
                    useDef = DefDatabase <JobDef> .GetNamed("AQManagingRemove", false);
                }
            }
            Job newJob = null;

            if (useDef != null)
            {
                newJob = new Job(useDef, t, f);
            }
            return(newJob);
        }
Exemplo n.º 3
0
        // Token: 0x06000059 RID: 89 RVA: 0x000042F0 File Offset: 0x000024F0
        protected override void WaitTickAction()
        {
            float num = AQUtility.GetJoyGainFactor(FishyThing.GetStatValue(StatDefOf.Beauty, true) / FishyThing.def.GetStatValueAbstract(StatDefOf.Beauty, null), FishyThing);
            float extraJoyGainFactor = (num > 0f) ? num : 0f;

            pawn.GainComfortFromCellIfPossible(false);
            JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, (Building)FishyThing);
            AQUtility.ApplyMoodBoostAndInspire(pawn, FishyThing);
        }
Exemplo n.º 4
0
        // Token: 0x06000045 RID: 69 RVA: 0x0000409D File Offset: 0x0000229D
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(Feedable);
            AddEndCondition(delegate
            {
                if (AQComp.foodPct > 0.95f)
                {
                    return(JobCondition.Succeeded);
                }
                return(JobCondition.Ongoing);
            });
            yield return(Toils_General.DoAtomic(delegate
            {
                job.count = AQUtility.GetFoodNumToFullyFeed(AQComp);
            }));

            Toil reserveFood = Toils_Reserve.Reserve(Foodybits, 1, -1, null);

            yield return(reserveFood);

            yield return(Toils_Goto.GotoThing(Foodybits, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(Foodybits).FailOnSomeonePhysicallyInteracting(Foodybits));

            yield return(Toils_Haul.StartCarryThing(Foodybits, false, true, false).FailOnDestroyedNullOrForbidden(Foodybits));

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveFood, Foodybits, TargetIndex.None, true, null));

            yield return(Toils_Goto.GotoThing(Feedable, PathEndMode.Touch));

            yield return(Toils_General.Wait(FeedDuration, TargetIndex.None).FailOnDestroyedNullOrForbidden(Foodybits).FailOnDestroyedNullOrForbidden(Feedable).FailOnCannotTouch(Feedable, PathEndMode.Touch).WithProgressBarToilDelay(Feedable, false, -0.5f));

            yield return(Toils_AQFeed.FinalizeFeeding(Feedable, Foodybits));

            if (!job.GetTarget(Foodybits).HasThing)
            {
                EndJobWith(JobCondition.Incompletable);
            }
            yield return(Toils_Reserve.Reserve(Foodybits, 1, -1, null));

            yield return(Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null));

            yield return(Toils_Goto.GotoThing(Foodybits, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(Foodybits, false, false, false));

            Toil carry = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carry);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carry, true, false));

            yield break;
        }
        // Token: 0x06000080 RID: 128 RVA: 0x00004EC4 File Offset: 0x000030C4
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            JobDef feeddef = DefDatabase <JobDef> .GetNamed("AQFeeding", false);

            Thing feed   = AQUtility.GetClosestFeed(pawn, t);
            Job   newJob = null;

            if (feeddef != null && feed != null)
            {
                newJob = new Job(feeddef, t, feed);
            }
            return(newJob);
        }
 // Token: 0x0600007F RID: 127 RVA: 0x00004E68 File Offset: 0x00003068
 public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
 {
     if (pawn.CanReserveAndReach(t, PathEndMode.Touch, Danger.None, 1, -1, null, false))
     {
         CompAquarium CA = t.TryGetComp <CompAquarium>();
         if (CA != null)
         {
             float trigger = Controller.Settings.RespondFood / 100f;
             if (CA.foodPct <= trigger && CA.numFish > 0 && AQUtility.GetClosestFeed(pawn, t) != null)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 7
0
 // Token: 0x06000014 RID: 20 RVA: 0x000029CC File Offset: 0x00000BCC
 public override void CompTick()
 {
     base.CompTick();
     if (parent.IsHashIntervalTick(bagTicks))
     {
         bool died = false;
         age += bagTicks;
         if (age + (int)CompAquarium.RandomFloat(-450000f, 450000f) > CompAquarium.oldFishAge)
         {
             fishhealth--;
         }
         if (parent.Spawned)
         {
             ticksInBagRemain -= bagTicks;
             if (ticksInBagRemain <= 0)
             {
                 fishhealth--;
             }
             if (parent.AmbientTemperature < 1f || parent.AmbientTemperature > 55f)
             {
                 fishhealth--;
             }
         }
         if (fishhealth <= 0)
         {
             died = true;
         }
         if (died)
         {
             if (parent.Spawned)
             {
                 ThingWithComps parent = this.parent;
                 if ((parent?.Map) != null && this.parent.Map.ParentFaction == Faction.OfPlayerSilentFail)
                 {
                     if (Controller.Settings.DoDeathMsgs)
                     {
                         Messages.Message("Aquarium.FishDied".Translate(), this.parent, MessageTypeDefOf.NegativeEvent, false);
                     }
                     AQUtility.DoSpawnTropicalFishMeat(this.parent, age);
                 }
             }
             parent.Destroy(DestroyMode.Vanish);
         }
     }
 }
Exemplo n.º 8
0
        // Token: 0x0600003E RID: 62 RVA: 0x00003FC8 File Offset: 0x000021C8
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            AddEndCondition(delegate
            {
                if (AQComp.cleanPct > 0.95f)
                {
                    return(JobCondition.Succeeded);
                }
                return(JobCondition.Ongoing);
            });
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(AQUtility.GetCleanTime(AQComp), TargetIndex.None).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f).WithEffect(EffecterDefOf.Clean, TargetIndex.A).PlaySustainerOrSound(() => SoundDefOf.Interact_CleanFilth));

            yield return(Toils_AQClean.FinalizeCleaning(TargetIndex.A));

            yield break;
        }
Exemplo n.º 9
0
        // Token: 0x0600005E RID: 94 RVA: 0x00004464 File Offset: 0x00002664
        public override Job TryGiveJob(Pawn pawn)
        {
            bool allowedOutside = JoyUtility.EnjoyableOutsideNow(pawn, null);
            var  tankDefs       = (from tankDef in DefDatabase <ThingDef> .AllDefsListForReading where tankDef.defName.StartsWith("AQFishTank") select tankDef.defName).ToList();

            foreach (var tankDef in tankDefs)
            {
                try
                {
                    ThingDef AQBowlDef = ThingDef.Named(tankDef);
                    candidates.AddRange(pawn.Map.listerThings.ThingsOfDef(AQBowlDef).Where(delegate(Thing thing)
                    {
                        if (!AQUtility.HasFish(thing))
                        {
                            return(false);
                        }
                        if (thing.Faction != Faction.OfPlayer || thing.IsForbidden(pawn) || (!allowedOutside && !thing.Position.Roofed(thing.Map)) || !pawn.CanReserveAndReach(thing, PathEndMode.Touch, Danger.None, 1, -1, null, false) || !thing.IsPoliticallyProper(pawn))
                        {
                            return(false);
                        }
                        Room room = thing.GetRoom(RegionType.Set_Passable);
                        return(room != null && AQUtility.IsValidAquaRoom(pawn, room));
                    }));
                } catch
                {
                }
            }
            Job result2;

            if (!candidates.TryRandomElementByWeight((Thing target) => Mathf.Max(target.GetStatValue(StatDefOf.Beauty, true), 0.5f), out Thing result))
            {
                result2 = null;
            }
            else
            {
                result2 = JobMaker.MakeJob(def.jobDef, result);
            }
            candidates.Clear();
            return(result2);
        }
Exemplo n.º 10
0
 // Token: 0x06000084 RID: 132 RVA: 0x00004F20 File Offset: 0x00003120
 public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
 {
     return(pawn.CanReserveAndReach(t, PathEndMode.Touch, Danger.None, 1, -1, null, false) && AQUtility.AddOrRemove(t, out bool Add, out ThingDef fdef, out bool Remove) && ((Add && AQUtility.GetClosestFishInBag(pawn, fdef, t) != null) || Remove));
 }