Exemple #1
0
        /// <summary>
        /// change the given pawn to the hybrid race of the desired morph
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <param name="morph">the morph to change the pawn to</param>
        /// <param name="addMissingMutations">if true, any missing mutations will be applied to the pawn</param>
        /// <param name="displayNotifications">if set to <c>true</c> display race shit notifications.</param>
        /// <exception cref="ArgumentNullException">
        /// pawn
        /// or
        /// morph
        /// </exception>
        public static void ChangePawnToMorph([NotNull] Pawn pawn, [NotNull] MorphDef morph, bool addMissingMutations = true, bool displayNotifications = true)
        {
            if (pawn == null)
            {
                throw new ArgumentNullException(nameof(pawn));
            }
            if (morph == null)
            {
                throw new ArgumentNullException(nameof(morph));
            }
            if (morph.hybridRaceDef == null)
            {
                Log.Error($"tried to change pawn {pawn.Name.ToStringFull} to morph {morph.defName} but morph has no hybridRace!");
            }
            if (pawn.def != ThingDefOf.Human && !pawn.IsHybridRace())
            {
                return;
            }

            //apply mutations
            if (addMissingMutations)
            {
                SwapMutations(pawn, morph);
            }

            var hRace = morph.hybridRaceDef;

            MorphDef.TransformSettings tfSettings = morph.transformSettings;
            HandleGraphicsChanges(pawn, morph);
            ChangePawnRace(pawn, hRace, true);

            if (pawn.IsColonist)
            {
                PortraitsCache.SetDirty(pawn);
            }

            if (displayNotifications && (pawn.IsColonist || pawn.IsPrisonerOfColony))
            {
                SendHybridTfMessage(pawn, tfSettings);
            }



            if (tfSettings?.transformTale != null)
            {
                TaleRecorder.RecordTale(tfSettings.transformTale, pawn);
            }
            pawn.TryGainMemory(tfSettings?.transformationMemory ?? PMThoughtDefOf.DefaultMorphTfMemory);
        }
Exemple #2
0
        private static void SendHybridTfMessage(Pawn pawn, MorphDef.TransformSettings tfSettings)
        {
            string label;

            label = string.IsNullOrEmpty(tfSettings?.transformationMessage)
                        ? RACE_CHANGE_MESSAGE_ID.Translate(pawn.LabelShort)
                        : tfSettings.transformationMessage.Formatted(pawn.LabelShort);

            label = label.CapitalizeFirst();



            var messageDef = tfSettings.messageDef ?? MessageTypeDefOf.NeutralEvent;

            Messages.Message(label, pawn, messageDef);
        }
Exemple #3
0
        private static void FindMissingMorphReactions()
        {
            var missingMorphs = new List <MorphDef>();


            foreach (MorphDef morphDef in MorphDef.AllDefs)
            {
                MorphDef.TransformSettings tfSettings = morphDef.transformSettings;
                if (IsTODOThought(tfSettings?.transformationMemory) || IsTODOThought(tfSettings?.revertedMemory))
                {
                    missingMorphs.Add(morphDef);
                }
            }

            string msgText = missingMorphs.Select(m => m.defName).Join(delimiter: "\n");

            Log.Message(msgText);
        }