Esempio n. 1
0
        /// <summary>
        /// Tries to apply this hediff giver
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <param name="cause">The cause.</param>
        /// <param name="mutagen">The mutagen.</param>
        public void TryApply(Pawn pawn, Hediff cause, MutagenDef mutagen)
        {
            MutationDef mut   = GetRandomMutation(pawn); //grab a random mutation
            int         mPart = mut.parts?.Count ?? 0;

            int maxCount;

            if (mPart == 0)
            {
                maxCount = 0;
            }
            else
            {
                maxCount = GetMaxCount(pawn, mut.parts);
            }


            if (MutationUtilities.AddMutation(pawn, mut, maxCount))
            {
                IntermittentMagicSprayer.ThrowMagicPuffDown(pawn.Position.ToVector3(), pawn.MapHeld);

                var comp = cause.TryGetComp <HediffComp_Single>();
                if (comp != null)
                {
                    comp.stacks--;
                    if (comp.stacks <= 0)
                    {
                        pawn.health.RemoveHediff(cause);
                    }
                }
            }
        }
        private bool CheckMutation(MutationDef arg)
        {
            foreach (var blackMorph in blackListCategories.MakeSafe().SelectMany(c => c.AllMorphsInCategories))
            {
                if (arg.classInfluence == blackMorph)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        ///     checks if this mutation blocks the addition of the otherMutation.
        /// </summary>
        /// checks if this mutation on the 'thisPart' blocks the addition of the otherMutation on the 'addPart'
        /// checks if this mutation on the 'thisPart' blocks the addition of the otherMutation on the 'addPart'
        /// <param name="otherMutation">The other mutation.</param>
        /// <param name="thisPart">The part this mutation is already on.</param>
        /// <param name="addPart">The  part the otherMutation will be added to.</param>
        /// <returns></returns>
        public bool BlocksMutation([NotNull] MutationDef otherMutation, [CanBeNull] BodyPartRecord thisPart,
                                   [CanBeNull] BodyPartRecord addPart)
        {
            if (blockSites?.Contains(addPart?.def) == true)
            {
                return(true);
            }
            BlockEntry entry = blockList?.FirstOrDefault(e => e.mutation == otherMutation);

            if (entry == null)
            {
                return(false);
            }
            return(thisPart == addPart || entry.blockOnAnyPart);
        }
Esempio n. 4
0
        bool CanTag(MutationDef mDef)
        {
            var   curve = Curve;
            float chance;

            if (curve != null)
            {
                chance = curve.Evaluate(mDef.value);
            }
            else
            {
                chance = CompProps_MutationTagger.DEFAULT_TAG_CHANCE;
            }

            return(Rand.Chance(chance));
        }
Esempio n. 5
0
            /// <summary>
            /// Checks if the given source mutation blocks the given otherMutation being added at the given part
            /// </summary>
            /// <param name="sourceMutation">The source mutation.</param>
            /// <param name="otherMutation">The other mutation.</param>
            /// <param name="addPart">The add part.</param>
            /// <returns></returns>
            public bool Blocks([NotNull] Hediff_AddedMutation sourceMutation, [NotNull] MutationDef otherMutation, [CanBeNull] BodyPartRecord addPart)
            {
                if (sourceMutation == null)
                {
                    throw new ArgumentNullException(nameof(sourceMutation));
                }
                if (otherMutation == null)
                {
                    throw new ArgumentNullException(nameof(otherMutation));
                }

                if (otherMutation != mutation)
                {
                    return(false);
                }

                return(blockOnAnyPart || addPart == sourceMutation.Part);
            }