Exemple #1
0
        private static void HandleColonistReactions(Pawn original, Pawn transformedPawn, FormerHumanReactionStatus reactionStatus, EventType type,
                                                    IEnumerable <Pawn> pawns = null)
        {
            pawns = pawns
                    ?? PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists
                    .Where(p => p != original);            //use all colonists except the original pawn as the default



            ThoughtDef defaultThought;

            switch (type)
            {
            case EventType.Transformation:
                defaultThought = ThoughtDefOfs.DefaultTransformationReaction;
                break;

            case EventType.Reverted:
                defaultThought = ThoughtDefOfs.DefaultRevertedPawnReaction;
                break;

            case EventType.PermanentlyFeral:
                defaultThought = ThoughtDefOfs.DefaultPermanentlyFeralReaction;
                break;

            case EventType.Merged:
                defaultThought = ThoughtDefOfs.DefaultMergedThought;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            int defaultStage = (int)reactionStatus;

            defaultStage = Mathf.Min(defaultStage, (defaultThought?.stages?.Count - 1) ?? 0);


            foreach (Pawn reactor in pawns)
            {
                if (reactor == transformedPawn)
                {
                    continue;                            //make sure pawns don't react to themselves as if they were a different pawn
                }
                ThoughtDef opinionThought = GetOpinionThought(original, reactor, type);
                ThoughtDef def;
                if (opinionThought != null)
                {
                    def          = opinionThought;
                    defaultStage = 0;
                }
                else
                {
                    def = defaultThought;
                }

                if (def == null)
                {
                    continue;
                }
                if (ThoughtUtility.CanGetThought(reactor, def))
                {
                    var memory = ThoughtMaker.MakeThought(def, defaultStage);
                    reactor.TryGainMemory(memory);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// call when a pawn is reverted from an animal to handle giving the correct thoughts to colonists
 /// </summary>
 /// <param name="originalPawn">The original pawn.</param>
 /// <param name="animalPawn">The animal pawn.</param>
 /// <param name="reactionStatus">The reaction status of the original pawn</param>
 public static void OnPawnReverted(Pawn originalPawn, Pawn animalPawn, FormerHumanReactionStatus reactionStatus = FormerHumanReactionStatus.Wild)
 {
     HandleColonistReactions(originalPawn, animalPawn, reactionStatus, EventType.Reverted);
     HandleRelatedPawnsReaction(originalPawn, animalPawn, EventType.Reverted);
 }
Exemple #3
0
 /// <summary>
 /// call when an animal goes permanently feral to handle giving the correct thoughts to colonists
 /// </summary>
 /// <param name="originalPawn">The original pawn.</param>
 /// <param name="animalPawn">The animal pawn.</param>
 /// <param name="reactionStatus">The reaction status.</param>
 /// <exception cref="ArgumentNullException">originalPawn
 /// or
 /// animalPawn</exception>
 public static void OnPawnPermFeral([NotNull] Pawn originalPawn, [NotNull] Pawn animalPawn, FormerHumanReactionStatus reactionStatus = FormerHumanReactionStatus.Wild)
 {
     if (originalPawn == null)
     {
         throw new ArgumentNullException(nameof(originalPawn));
     }
     if (animalPawn == null)
     {
         throw new ArgumentNullException(nameof(animalPawn));
     }
     if (originalPawn.Faction == Faction.OfPlayer || animalPawn.Faction == Faction.OfPlayer) //only give thoughts to colonists if the original pawn or animal is part of the player faction
     {
         HandleColonistReactions(originalPawn, animalPawn, reactionStatus, EventType.PermanentlyFeral);
     }
     HandleRelatedPawnsReaction(originalPawn, animalPawn, EventType.PermanentlyFeral);
 }
Exemple #4
0
        /// <summary>
        /// call when the original pawn transforms into the transformedPawn
        /// </summary>
        /// <param name="original">The original.</param>
        /// <param name="transformedPawn">The transformed pawn.</param>
        /// <param name="reactionStatus">The reaction status.</param>
        public static void OnPawnTransforms(Pawn original, Pawn transformedPawn, FormerHumanReactionStatus reactionStatus = FormerHumanReactionStatus.Wild)
        {
            HandleColonistReactions(original, transformedPawn, reactionStatus, EventType.Transformation);

            HandleRelatedPawnsReaction(original, transformedPawn, EventType.Transformation);
        }