Beispiel #1
0
        protected override ThoughtState CurrentStateInternal(Pawn pawn)
        {
            AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>();
            PackComp           packComp           = pawn.TryGetComp <PackComp>();

            if (!(avaliThoughtDriver == null))
            {
                if (pawn.Awake())
                {
                    if (pawn.CheckIfPackmatesInRoom())
                    {
                        return(ThoughtState.ActiveDefault);
                    }
                    else
                    {
                        return(ThoughtState.Inactive);
                    }
                }
                else
                {
                    return(ThoughtState.Inactive);
                }
            }
            else
            {
                return(ThoughtState.Inactive);
            }
        }
Beispiel #2
0
 public void UpdateSharedRoomThought(Pawn pawn)
 {
     if (pawn.Awake())
     {
         AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>();
         if (RimValiUtility.CheckIfPackmatesInRoom(pawn))
         {
             RimValiUtility.AddThought(pawn, avaliThoughtDriver.Props.inSameRoomThought);
         }
         else
         {
             RimValiUtility.RemoveThought(pawn, avaliThoughtDriver.Props.inSameRoomThought);
         }
     }
     else
     {
         AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>();
         if (RimValiUtility.PackInBedroom(pawn))
         {
             RimValiUtility.AddThought(pawn, avaliThoughtDriver.Props.sharedBedroomThought);
         }
         else
         {
             RimValiUtility.AddThought(pawn, avaliThoughtDriver.Props.sleptApartThought);
         }
     }
 }
Beispiel #3
0
        public void UpdatePawns(Map map)
        {
            IEnumerable <Pawn> pawns = RimValiUtility.CheckAllPawnsInMapAndFaction(map, Faction.OfPlayer).Where(x => x.def == AvaliDefs.RimVali);

            foreach (Pawn pawn in pawns)
            {
                AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>();
                PackComp           packComp           = pawn.TryGetComp <PackComp>();
                if (!(avaliThoughtDriver == null))
                {
                    if (pawn.def == AvaliDefs.RimVali)
                    {
                        if (RimValiUtility.GetPackSize(pawn, avaliThoughtDriver.Props.relationDef) > 1)
                        {
                            PawnRelationDef relationDef = avaliThoughtDriver.Props.relationDef;
                            UpdateSharedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.inSameRoomThought);
                            UpdateBedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.sharedBedroomThought, avaliThoughtDriver.Props.sleptApartThought);
                        }
                    }
                }
                if (!(packComp == null))
                {
                    if (packComp.Props.canHaveAloneThought)
                    {
                        UpdateThought(pawn, packComp.Props.relation, packComp.Props.aloneThought);
                    }
                }
            }
        }
Beispiel #4
0
 public void UpdateSharedRoomThought(Pawn pawn, PawnRelationDef relationDef, ThoughtDef thought)
 {
     if (pawn.Awake())
     {
         AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>();
         if (RimValiUtility.CheckIfPackmatesInRoom(pawn, relationDef))
         {
             RimValiUtility.AddThought(pawn, thought);
         }
         else
         {
             RimValiUtility.RemoveThought(pawn, thought);
         }
     }
 }
Beispiel #5
0
        public void UpdatePackLoss(Pawn pawn)
        {
            AvaliThoughtDriver thoughtComp = pawn.TryGetComp <AvaliThoughtDriver>();
            PackComp           packComp    = pawn.TryGetComp <PackComp>();


            if (packComp.ticksSinceLastInpack == 0 && (RimValiUtility.GetPackWithoutSelf(pawn) == null || RimValiUtility.GetPackWithoutSelf(pawn).size < 2))
            {
                packComp.ticksSinceLastInpack = Find.TickManager.TicksGame;
            }
            else if (RimValiUtility.GetPackWithoutSelf(pawn) != null && RimValiUtility.GetPackWithoutSelf(pawn).size > 1)
            {
                packComp.ticksSinceLastInpack = 0;
            }
        }
Beispiel #6
0
        public void UpdatePawns(Map map)
        {
            AvaliPackDriver         AvaliPackDriver = Current.Game.GetComponent <AvaliPackDriver>();
            IEnumerable <Pawn>      pawns           = RimValiUtility.CheckAllPawnsInMapAndFaction(map, Faction.OfPlayer).Where(x => AvaliPackDriver.racesInPacks.Contains(x.def));
            IEnumerable <AvaliPack> packs           = AvaliPackDriver.packs;

            foreach (Pawn pawn in pawns)
            {
                AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>();
                PackComp           packComp           = pawn.TryGetComp <PackComp>();
                if (!(avaliThoughtDriver == null))
                {
                    //Log.Message("Pawn has pack comp, moving to next step...");
                    if (AvaliPackDriver.packs == null || AvaliPackDriver.packs.Count == 0)
                    {
                        //Log.Message("How did we get here? [Pack list was 0 or null]");
                        return;
                    }
                    AvaliPack pawnPack = null;
                    //This errors out when pawns dont have a pack, in rare cases. That is bad. This stops it from doing that.
                    try { pawnPack = pawn.GetPack(); }
                    catch
                    {
                        return;
                    }
                    //Log.Message("Tried to get packs pack, worked.");
                    if (pawnPack == null)
                    {
                        //Log.Message("How did we get here? [Pack was null.]");
                        break;
                    }
                    foreach (Pawn packmate in pawnPack.pawns)
                    {
                        Thought_Memory thought_Memory2 = (Thought_Memory)ThoughtMaker.MakeThought(packComp.Props.togetherThought);
                        if (!(packmate == pawn) && packmate != null && pawn != null)
                        {
                            bool bubble;
                            if (!thought_Memory2.TryMergeWithExistingMemory(out bubble))
                            {
                                //Log.Message("Adding thought to pawn.");
                                pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory2, packmate);
                            }
                        }
                    }
                }
            }
        }
Beispiel #7
0
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            PackComp           packComp    = p.TryGetComp <PackComp>();
            AvaliThoughtDriver thoughtComp = p.TryGetComp <AvaliThoughtDriver>();

            if (thoughtComp == null)
            {
                return(ThoughtState.Inactive);
            }
            foreach (Hediff hediff in p.health.hediffSet.hediffs)
            {
                if (thoughtComp.Props.packLossPreventers.Contains(hediff.def))
                {
                    return(ThoughtState.Inactive);
                }
            }
            if (!LoadedModManager.GetMod <RimValiMod>().GetSettings <RimValiModSettings>().packLossEnabled)
            {
                return(ThoughtState.Inactive);
            }
            if (packComp == null)
            {
                return(ThoughtState.Inactive);
            }
            UpdatePackLoss(p);
            int timeAlone = Find.TickManager.TicksGame - packComp.ticksSinceLastInpack;

            if (timeAlone == Find.TickManager.TicksGame)
            {
                return(ThoughtState.Inactive);
            }
            if (timeAlone >= 240000)
            {
                return(ThoughtState.ActiveAtStage(2));
            }
            if (timeAlone > 120000)
            {
                return(ThoughtState.ActiveAtStage(1));
            }
            if (timeAlone > 60000)
            {
                return(ThoughtState.ActiveAtStage(0));
            }

            return(ThoughtState.ActiveAtStage(3));
        }
Beispiel #8
0
        public void UpdatePawns(Map map)
        {
            List <ThingDef>    races = RimvaliPotentialPackRaces.potentialPackRaces.ToList <ThingDef>();
            IEnumerable <Pawn> pawns = RimValiUtility.CheckAllPawnsInMapAndFaction(map, Faction.OfPlayer);

            foreach (Pawn pawn in pawns)
            {
                if (pawn.IsHashIntervalTick(120))
                {
                    AvaliThoughtDriver avaliThoughtDriver = pawn.TryGetComp <AvaliThoughtDriver>();
                    if (pawn.def == AvaliDefs.RimVali)
                    {
                        if (RimValiUtility.GetPackSize(pawn, avaliThoughtDriver.Props.relationDef) > 0)
                        {
                            PawnRelationDef relationDef = avaliThoughtDriver.Props.relationDef;
                            UpdateSharedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.inSameRoomThought);
                            UpdateBedRoomThought(pawn, relationDef, avaliThoughtDriver.Props.sharedBedroomThought, avaliThoughtDriver.Props.sleptApartThought);
                        }
                    }
                }
            }
        }