예제 #1
0
        public void CastPsycast(Pawn hitPawn, Pawn sourcePawn)
        {
            if (Rand.Value < Props.psycastChance)
            {
                if (hitPawn != null & hitPawn.health != null)
                {
                    if (sourcePawn.psychicEntropy == null)
                    {
                        sourcePawn.psychicEntropy = new Pawn_PsychicEntropyTracker(sourcePawn);
                    }
                    string     psycastName = Props.psycastsToUse[Rand.Range(0, Props.psycastsToUse.Count)];
                    AbilityDef psycastDef  = DefDatabase <AbilityDef> .GetNamed(psycastName);

                    Psycast psycast = new Psycast(sourcePawn, psycastDef);
                    psycast.Activate(hitPawn, sourcePawn);
                }
            }
        }
예제 #2
0
        public override void CompTick()
        {
            base.CompTick();

            tickCounter++;
            if (tickCounter > Props.psycastFrequency)
            {
                tickCounter = 0;
                if (this.parent is Pawn sourcePawn && sourcePawn != null)
                {
                    bool isAwake = !sourcePawn.Dead && !sourcePawn.Downed && sourcePawn.Map != null && !sourcePawn.stances.stunner.Stunned && sourcePawn.TryGetComp <CompCanBeDormant>().Awake;
                    if (sourcePawn.psychicEntropy == null)
                    {
                        sourcePawn.psychicEntropy = new Pawn_PsychicEntropyTracker(sourcePawn);
                    }
                    if (isAwake)
                    {
                        string psycastName = Props.psycastsToUse[Rand.Range(0, Props.psycastsToUse.Count)];
                        foreach (Thing thing in GenRadial.RadialDistinctThingsAround(sourcePawn.Position, sourcePawn.Map, Props.psycastRange, true))
                        {
                            if (thing != null && thing is Pawn targetPawn && targetPawn != sourcePawn && targetPawn.health != null)
                            {
                                if (targetPawn.RaceProps.IsMechanoid && targetPawn.Faction == Faction.OfMechanoids)
                                {
                                    AbilityDef psycastDef = DefDatabase <AbilityDef> .GetNamed(psycastName);

                                    Psycast psycast = new Psycast(sourcePawn, psycastDef);
                                    psycast.Activate(targetPawn, sourcePawn);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }