Пример #1
0
        public override void CompTickRare()
        {
            base.CompTickRare();

            //Applying torment
            List <Pawn> affectedPawnList = new List <Pawn> {
            };

            affectedPawnList = ToolsCell.GetPawnsInRadius(
                buildingPos.ToIntVec3(), Range, myMap,
                Props.affectsAnimals, Props.affectsHumanlike, Props.affectsMechanoids,
                Props.affectsColonists, Props.affectsNeutralOrFriends, Props.affectsEnemies,
                prcDebug
                );

            foreach (Pawn curPawn in affectedPawnList)
            {
                // Slugs are immune to this
                if (curPawn.IsSlug())
                {
                    Tools.Warn(curPawn.Label + " is slug, not affected", prcDebug);
                    continue;
                }

                // Add psychicSensitivity * SocialImpact * SocialSkill fight here
                if (ToolsBodyPart.ApplyHediffOnBodyPartTag(curPawn, BodyPartTagDefOf.ConsciousnessSource, hediffDefToApply, prcDebug))
                {
                    if (IsFlaySpot)
                    {
                        Thought_Memory MindFlayed = (Thought_Memory)ThoughtMaker.MakeThought(MyDefs.MindFlayThought);
                        curPawn.needs.mood.thoughts.memories.TryGainMemory(MindFlayed, Initiator);
                    }

                    //GfxEffects.ThrowPsycastAreaMote(curPawn.Position.ToVector3(), myMap);
                    GfxEffects.ThrowMindMote(curPawn.Position.ToVector3(), myMap, spotKind);
                    AffectedPawnsNum++;
                }
            }

            if (IsLimitExceeded)
            {
                Initiator.ApplyTiredness();
            }


            //Checking if Initiator is not mad or downed or sleepin or on fire
            if (Initiator.InMentalState || Initiator.Downed || Initiator.IsSleepingOrOnFire() || AffectedPawnsNum > Props.hediffAppliedLimit)
            {
                GfxEffects.ThrowCoupleMotes(buildingPos, myMap, spotKind);
                building.Destroy();
            }
        }
        public override bool OnHediffAdded(Pawn pawn, Hediff hediff)
        {
            if (!pawn.Spawned)
            {
                return(false);
            }

            pLabel = pawn?.LabelShort;

            if (!pawn.IsSlug())
            {
                Tools.Warn(pLabel + " is not slug - false", myDebug);
                return(false);
            }

            BodyPartRecord pawnBPR = pawn.GetVestigialShell();

            Tools.Warn(">> Entering " + pLabel + "'s vestigial HediffGiver;", myDebug);
            Tools.Warn(" hediff.def.defName: " + hediff?.def?.defName + "; this.hediff.def.defname: " + this.hediff?.defName, myDebug);
            Tools.Warn(" hediff.Part: " + hediff?.Part?.def?.defName + "; pawnBPR:" + pawnBPR.def.defName, myDebug);

            /*
             * if (hediff.Part != pawnBPR)
             * {
             *  Tools.Warn(pLabel + " h.part=" + hediff.Part.def.defName + " != " + pawnBPR.def.defName + " - false", myDebug);
             *  return false;
             * }
             */

            if (hediff.def == HediffDefOf.Anesthetic && hediff.Part == null)
            {
                Tools.Warn(pLabel + " had Anesthetic applied on whole body", myDebug);
                return(false);
            }

            /*
             * bool appliedHediff = TryApply(pawn, null);
             * if (appliedHediff)
             * {
             *  Tools.Warn(pLabel + " had " + this.hediff?.defName + " applied ", myDebug);
             *
             *
             *
             *  return true;
             * }
             */

            if (hediff.def == MyDefs.MindFondlingHediff)
            {
                ToolsAbilities.FondlerReset(pawn, myDebug);
                Tools.Warn(pLabel + " called ResetAbilities bc " + hediff.def.defName, myDebug);

                return(false);
            }
            else if (hediff.def == HediffDefOf.MissingBodyPart &&
                     hediff.Part.def.defName == MyDefs.vestigialShellName &&
                     !ToolsBodyPart.HasNaturalVestigialShell(pawn, myDebug))
            {
                ToolsAbilities.AbilitiesReset(pawn, myDebug);
                Tools.Warn(pLabel + " called ResetAbilities bc " + hediff.def.defName, myDebug);

                ToolsBodyPart.AddWaitingForVestigal(pawn, myDebug);
                Tools.Warn(pLabel + " added WaitingForVestigal", myDebug);

                return(false);
            }

            Tools.Warn(hediff.def.defName + " not applied on " + pLabel, myDebug);

            return(false);
        }