private static void Postfix(bool __result, InspirationHandler __instance, InspirationDef def, string reason = null)
 {
     if (__result)
     {
         VSIE_Utils.SocialInteractionsManager.TryRegisterNewIspiration(__instance.pawn, def);
     }
 }
Example #2
0
 public Aspiration(Pawn pawn, InspirationDef inspirationDef, int finalCount, ThoughtDef thoughtDefSuccess, ThoughtDef thoughtDefFail)
 {
     this.pawn              = pawn;
     this.inspirationDef    = inspirationDef;
     this.finalCount        = finalCount;
     this.thoughtDefSuccess = thoughtDefSuccess;
     this.thoughtDefFail    = thoughtDefFail;
 }
Example #3
0
 public void Notify_InspirationExpired(Pawn pawn, InspirationDef inspirationDef)
 {
     if (activeAspirations.TryGetValue(pawn, out var aspiration) && inspirationDef == aspiration.inspirationDef)
     {
         Log.Message(pawn + " aspiration is expired: " + aspiration.inspirationDef);
         aspiration.OnExpired();
         activeAspirations.Remove(pawn);
     }
 }
Example #4
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            if (--ticksToInspire <= 0)
            {
                InspirationDef inspiration = Props.inspirationDef ?? DefDatabase <InspirationDef> .AllDefs.Where(x => x.Worker.InspirationCanOccur(Pawn)).RandomElementByWeightWithFallback(x => x.Worker.CommonalityFor(Pawn));

                TaggedString reason = "LuluInspirationChip_Reason".Translate(Pawn.Named("PAWN"), parent.LabelBase.Named("HEDIFF"));
                Pawn.mindState.inspirationHandler.TryStartInspiration_NewTemp(inspiration, reason);
                ResetTicksToInspire();
            }
        }
Example #5
0
 public AspirationDef GetAspirationDefFor(InspirationDef inspirationDef)
 {
     foreach (var aspirationDef in DefDatabase <AspirationDef> .AllDefs)
     {
         if (aspirationDef.inspirationDef == inspirationDef)
         {
             return(aspirationDef);
         }
     }
     return(null);
 }
Example #6
0
        public void TryRegisterNewIspiration(Pawn pawn, InspirationDef inspirationDef)
        {
            if (activeAspirations.ContainsKey(pawn))
            {
                activeAspirations.Remove(pawn);
            }
            var aspirationDef = GetAspirationDefFor(inspirationDef);

            if (aspirationDef != null)
            {
                activeAspirations[pawn] = new Aspiration(pawn, inspirationDef, aspirationDef.workCount, aspirationDef.thoughtDefSuccess, aspirationDef.thoughtDefFail);
            }
        }
        private void Inspire(Pawn pawn)
        {
            InspirationDef randomInsDef = (from x in DefDatabase <InspirationDef> .AllDefsListForReading
                                           where x.Worker.InspirationCanOccur(pawn)
                                           select x).RandomElementByWeightWithFallback((InspirationDef x) => x.Worker.CommonalityFor(pawn), null);

            if (randomInsDef != null)
            {
                if (randomInsDef.Worker.InspirationCanOccur(pawn))
                {
                    pawn.mindState.inspirationHandler.TryStartInspiration(randomInsDef, this.parent.Label);
                }
            }
        }
 public InspirationAction(InspirationDef inspDef, string category = "Colonist State")
 {
     defName          = inspDef.defName;
     defLabel         = inspDef.label;
     Name             = defLabel;
     Description      = "Give the best colonist at the job this inspiration";
     ShouldShowAmount = true;
     Prefix           = "Trigger";
     Category         = category;
     inspirationDef   = inspDef;
     LocalCooldownMs  = 30000;
     GlobalCooldownMs = 15000;
     CostSilverStore  = 300;
     BitStoreSKU      = "";
 }
 public static void CheckStartTrait_RandomInspiration(InspirationHandler __instance)
 {
     if (!__instance.Inspired && __instance?.pawn?.story != null)
     {
         List <Trait> allTraits = __instance.pawn.story.traits.allTraits;
         for (int m = 0; m < allTraits.Count; m++)
         {
             RandomInspirationMtbDays currentData = allTraits[m].CurrentData as RandomInspirationMtbDays;
             if (currentData != null && currentData.randomInspirationMtbDays > 0f && Rand.MTBEventOccurs(currentData.randomInspirationMtbDays, 60000f, 100f))
             {
                 InspirationDef randomAvailableInspirationDef = GetRandomAvailableInspirationDef(__instance);
                 if (randomAvailableInspirationDef != null)
                 {
                     __instance.TryStartInspiration(randomAvailableInspirationDef);
                 }
             }
         }
     }
 }
Example #10
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);
            }
        }
 public void ApplyComponentConditions(string condition, float value = 0f)
 {
     if (condition == "NameOfTheWind")
     {
         windSpeed        = 2f;
         windSpeedEndTick = Find.TickManager.TicksGame + Rand.Range(160000, 240000);
     }
     if (condition == "ArcaneInspiration")
     {
         IEnumerable <Pawn> colonists = this.map.mapPawns.FreeColonistsSpawned.InRandomOrder();
         int count = Mathf.Clamp(Rand.RangeInclusive(1, 3), 1, this.map.mapPawns.FreeColonistsSpawned.Count);
         foreach (var colonist in colonists)
         {
             InspirationDef id = TM_Calc.GetRandomAvailableInspirationDef(colonist);
             colonist.mindState.inspirationHandler.TryStartInspiration_NewTemp(id);
         }
     }
     if (condition == "AllowAllIncidents")
     {
         this.allowAllIncidents = true;
     }
 }
        private static void Postfix(ref float __result, Pawn pawn, InspirationDef ___def)
        {
            float num = 1f;

            if (pawn.skills != null && ___def.associatedSkills != null)
            {
                for (int i = 0; i < ___def.associatedSkills.Count; i++)
                {
                    SkillDef skillDef = ___def.associatedSkills[i];
                    for (int j = 0; j < pawn.skills.skills.Count; j++)
                    {
                        SkillRecord skillRecord = pawn.skills.skills[j];
                        if (skillDef == skillRecord.def)
                        {
                            int s = (int)pawn.skills.skills[j].passion;
                            num = Mathf.Max(num, InterestBase.GetInspirationFactor(s));
                        }
                    }
                }
            }
            __result = ___def.baseCommonality * num;
        }
 private static IAction CreateActionFromDef(InspirationDef inspirationDef)
 {
     return(new InspirationAction(inspirationDef));
 }
Example #14
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            bool flag = base.Pawn != null;

            if (flag)
            {
                if (initializing)
                {
                    initializing = false;
                    this.Initialize();
                }
            }
            if (Find.TickManager.TicksGame % 600 == 0)
            {
                MagicPowerSkill pwr = this.Pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Inspire.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Inspire_pwr");
                MagicPowerSkill ver = this.Pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Inspire.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Inspire_ver");
                this.pwrVal = pwr.level;
                this.verVal = ver.level;
            }
            Map  map       = base.Pawn.Map;
            int  tickTimer = 1000 - (pwrVal * 100);
            bool flag4     = Find.TickManager.TicksGame % tickTimer == 0;

            if (flag4 && map != null)
            {
                CellRect cellRect = CellRect.CenteredOn(base.Pawn.Position, 3);
                cellRect.ClipInsideMap(map);

                IntVec3 curCell      = cellRect.RandomCell;
                Pawn    inspiredPawn = curCell.GetFirstPawn(map);
                if (inspiredPawn != null && inspiredPawn.IsColonist && inspiredPawn.RaceProps.Humanlike && !inspiredPawn.Inspired && inspiredPawn != this.Pawn)
                {
                    InspirationDef id           = TM_Calc.GetRandomAvailableInspirationDef(inspiredPawn);
                    bool           flag1        = id.defName == "ID_MiningFrenzy" || id.defName == "ID_FarmingFrenzy";
                    bool           flag2        = id.defName == "ID_Introspection" || id.defName == "ID_Outgoing";
                    bool           flag3        = id.defName == "ID_ManaRegen" || id.defName == "ID_Champion";
                    Vector3        drawPosAbove = inspiredPawn.DrawPos;
                    drawPosAbove.z += .5f;
                    if (verVal == 0 && !flag1 && !flag2 && !flag3)
                    {
                        inspiredPawn.mindState.inspirationHandler.TryStartInspiration(id);
                        TM_MoteMaker.ThrowExclamationMote(drawPosAbove, inspiredPawn.Map, .5f);
                    }
                    else if (verVal == 1 && !flag2 && !flag3)
                    {
                        inspiredPawn.mindState.inspirationHandler.TryStartInspiration(id);
                        TM_MoteMaker.ThrowExclamationMote(drawPosAbove, inspiredPawn.Map, .7f);
                    }
                    else if (verVal == 2 && !flag3)
                    {
                        inspiredPawn.mindState.inspirationHandler.TryStartInspiration(id);
                        TM_MoteMaker.ThrowExclamationMote(drawPosAbove, inspiredPawn.Map, Rand.Range(.5f, .7f));
                        TM_MoteMaker.ThrowExclamationMote(drawPosAbove, inspiredPawn.Map, Rand.Range(.5f, .7f));
                    }
                    else if (verVal == 3)
                    {
                        inspiredPawn.mindState.inspirationHandler.TryStartInspiration(id);
                        TM_MoteMaker.ThrowExclamationMote(drawPosAbove, inspiredPawn.Map, Rand.Range(.5f, .7f));
                        TM_MoteMaker.ThrowExclamationMote(drawPosAbove, inspiredPawn.Map, Rand.Range(.5f, .7f));
                        TM_MoteMaker.ThrowExclamationMote(drawPosAbove, inspiredPawn.Map, Rand.Range(.5f, .7f));
                    }
                    else
                    {
                        //failed inspiration due to type
                    }
                }
            }
        }