示例#1
0
        // Token: 0x0600006C RID: 108 RVA: 0x00004C1C File Offset: 0x00002E1C
        public static Toil FinalizeRemoving(TargetIndex RemoveFrom)
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Job          curJob       = toil.actor.CurJob;
                Thing        thing        = curJob.GetTarget(RemoveFrom).Thing;
                Thing        removedThing = null;
                CompAquarium AQComp       = thing.TryGetComp <CompAquarium>();
                if (AQComp != null && AQComp.fishData.Count > 0)
                {
                    List <string> newList  = new List <string>();
                    int           newIndex = 0;
                    bool          removed  = false;
                    foreach (string value in AQComp.fishData)
                    {
                        newIndex++;
                        string prevDefVal = CompAquarium.StringValuePart(value, 1);
                        int    prevHealth = CompAquarium.NumValuePart(value, 2);
                        int    prevAge    = CompAquarium.NumValuePart(value, 3);
                        int    prevAct    = CompAquarium.NumValuePart(value, 4);
                        if (prevAct == 2 && !removed)
                        {
                            Thing thing2 = ThingMaker.MakeThing(ThingDef.Named(prevDefVal), null);
                            thing2.stackCount = 1;
                            GenPlace.TryPlaceThing(thing2, toil.actor.Position, toil.actor.Map, ThingPlaceMode.Near, out Thing newFishBag, null, null, default);
示例#2
0
        // Token: 0x06000005 RID: 5 RVA: 0x00002128 File Offset: 0x00000328
        internal static float GetJoyGainFactor(float beautyFactor, Thing FishyThing)
        {
            float        fishFactor = 1f;
            float        agefactor  = 1f;
            float        compare    = 30f;
            CompAquarium CompAQ     = FishyThing.TryGetComp <CompAquarium>();

            if (CompAQ != null)
            {
                List <string> list = CompAQ.fishData;
                if (list.Count > 0)
                {
                    foreach (string listing in list)
                    {
                        ThingDef fishdef = ThingDef.Named(CompAquarium.StringValuePart(listing, 1));
                        if (fishdef != null)
                        {
                            float value = Math.Max(10f, Math.Min(50f, fishdef.BaseMarketValue));
                            fishFactor *= value / compare;
                            agefactor  *= Mathf.Lerp(0.75f, 1f, Math.Min(CompAquarium.oldFishAge, CompAquarium.NumValuePart(listing, 3)) / CompAquarium.oldFishAge);
                        }
                    }
                }
            }
            return(beautyFactor * fishFactor * agefactor);
        }
示例#3
0
        // Token: 0x06000066 RID: 102 RVA: 0x00004B04 File Offset: 0x00002D04
        public static Toil FinalizeAdding(TargetIndex addable, TargetIndex fish)
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Job   curJob    = toil.actor.CurJob;
                Thing tankThing = curJob.GetTarget(addable).Thing;
                Thing fishThing = curJob.GetTarget(fish).Thing;
                if (tankThing != null && fishThing != null)
                {
                    CompAquarium AQComp = tankThing.TryGetComp <CompAquarium>();
                    if (AQComp != null)
                    {
                        List <string> newList  = new List <string>();
                        int           newIndex = 0;
                        if (AQComp.fishData.Count > 0)
                        {
                            bool tryToAdd = true;
                            foreach (string value in AQComp.fishData)
                            {
                                string prevDefVal = CompAquarium.StringValuePart(value, 1);
                                int    prevHealth = CompAquarium.NumValuePart(value, 2);
                                int    prevAge    = CompAquarium.NumValuePart(value, 3);
                                int    prevAct    = CompAquarium.NumValuePart(value, 4);
                                newIndex++;
                                if (prevAct == 1 && tryToAdd && (prevDefVal == fishThing.def.defName || prevDefVal == "AQRandomFish"))
                                {
                                    int             health = 100;
                                    int             age    = 0;
                                    CompAQFishInBag CBag   = fishThing.TryGetComp <CompAQFishInBag>();
                                    if (CBag != null)
                                    {
                                        health = CBag.fishhealth;
                                        age    = CBag.age;
                                    }
                                    string newValue = CompAquarium.CreateValuePart(newIndex, fishThing.def.defName, health, age, 0);
                                    newList.Add(newValue);
                                    AQComp.numFish++;
                                    tryToAdd = false;
                                }
                                else
                                {
                                    string newValue3 = CompAquarium.CreateValuePart(newIndex, prevDefVal, prevHealth, prevAge, prevAct);
                                    newList.Add(newValue3);
                                }
                            }
                        }
                        AQComp.fishData = newList;
                        AQComp.GenerateBeauty(AQComp.fishData);
                    }
                }
                fishThing.Destroy(DestroyMode.Vanish);
                toil.actor.skills.Learn(SkillDefOf.Animals, 75f, false);
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            return(toil);
        }
示例#4
0
        // Token: 0x0600000A RID: 10 RVA: 0x000024A4 File Offset: 0x000006A4
        internal static bool AddOrRemove(Thing t, out bool Add, out ThingDef fishAddDef, out bool Remove)
        {
            bool result = false;
            bool flag   = Remove = false;

            Add        = flag;
            fishAddDef = null;
            CompAquarium CA = t.TryGetComp <CompAquarium>();

            if (CA != null)
            {
                List <string> listing = CA.fishData;
                if (listing.Count > 0)
                {
                    foreach (string value in listing)
                    {
                        int action = CompAquarium.NumValuePart(value, 4);
                        if (action == 1)
                        {
                            Add = true;
                            var fishDefString = (CompAquarium.StringValuePart(value, 1));
                            if (fishDefString == "AQRandomFish")
                            {
                                if (hammeringCounter != 0)
                                {
                                    hammeringCounter--;
                                    return(false);
                                }
                                var reachableFish = CA.ReachableDefs;
                                if (reachableFish.Count > 0)
                                {
                                    fishDefString = reachableFish.RandomElement();
                                }
                                else
                                {
                                    hammeringCounter = 20;
                                    return(false);
                                }
                            }
                            fishAddDef = ThingDef.Named(fishDefString);
                            return(true);
                        }
                        if (action == 2)
                        {
                            Remove = true;
                            return(true);
                        }
                    }
                    return(result);
                }
            }
            return(result);
        }
示例#5
0
        // Token: 0x06000006 RID: 6 RVA: 0x00002210 File Offset: 0x00000410
        internal static void ApplyMoodBoostAndInspire(Pawn pawn, Thing FishyThing)
        {
            CompAquarium      CompAQ = FishyThing.TryGetComp <CompAquarium>();
            Pawn_NeedsTracker needs  = pawn.needs;

            if ((needs?.mood) != null)
            {
                float fishFactor = 1f;
                float agefactor  = 1f;
                float compare    = 30f;
                if (CompAQ != null && CompAQ.numFish > 0 && pawn.IsHashIntervalTick(1000))
                {
                    List <string> list = CompAQ.fishData;
                    if (list.Count > 0)
                    {
                        foreach (string listing in list)
                        {
                            ThingDef fishdef = ThingDef.Named(CompAquarium.StringValuePart(listing, 1));
                            if (fishdef != null)
                            {
                                float value = Math.Max(10f, Math.Min(50f, fishdef.BaseMarketValue));
                                fishFactor *= value / compare;
                                agefactor  *= Mathf.Lerp(0.75f, 1f, Math.Min(CompAquarium.oldFishAge, CompAquarium.NumValuePart(listing, 3)) / CompAquarium.oldFishAge);
                            }
                        }
                    }
                    if (IsInspired((int)(CompAQ.numFish * 25 * fishFactor * agefactor)))
                    {
                        ThoughtDef fishRelaxDef = ThoughtDef.Named("AQObserveFish");
                        pawn.needs.mood.thoughts.memories.TryGainMemory(fishRelaxDef, null);
                    }
                }
            }
            if (CompAQ != null && CompAQ.numFish > 0 && Controller.Settings.AllowInspire && pawn.IsHashIntervalTick(1000) && !pawn.IsPrisoner && IsInspired((int)(CompAQ.numFish * Controller.Settings.BaseInspChance)) && !pawn.mindState.inspirationHandler.Inspired)
            {
                InspirationDef IDef = (from x in DefDatabase <InspirationDef> .AllDefsListForReading
                                       where x.Worker.InspirationCanOccur(pawn)
                                       select x).RandomElementByWeightWithFallback((InspirationDef x) => x.Worker.CommonalityFor(pawn), null);
                pawn.mindState.inspirationHandler.TryStartInspiration_NewTemp(IDef, null);
            }
        }