public virtual bool CanDoEffect(CompAbilityUser abilityUser)
        {
            if (abilityUser == null)
            {
                return(false);
            }
            var pawn = abilityUser.AbilityUser;

            if (pawn == null)
            {
                return(false);
            }
            if (pawn.jobs == null)
            {
                return(false);
            }
            if (Props.awakeOnly && pawn?.CurJob?.def == JobDefOf.LayDown || pawn.Downed)
            {
                return(false);
            }
            if (pawn.mindState == null)
            {
                return(false);
            }
            if (Props.combatOnly && Props.combatOnly && !pawn.mindState.anyCloseHostilesRecently)
            {
                return(false);
            }
            return(true);
        }
        public virtual void Tick(CompAbilityUser abilityUser)
        {
            var rate = -1;

            switch (Props.tickerType)
            {
            case TickerType.Rare:
                rate = 250;
                break;

            case TickerType.Normal:
                rate = 60;
                break;

            case TickerType.Long:
                rate = 2000;
                break;
            }
            if (rate != -1)
            {
                if (Find.TickManager.TicksGame % rate == 0 && CanDoEffect(abilityUser))
                {
                    TryDoEffect(abilityUser);
                }
            }
        }
 public virtual void DoEffect(CompAbilityUser abilityUser)
 {
     if (Props?.hediffs is List <HediffDef> hList && !hList.NullOrEmpty())
     {
         foreach (var h in hList)
         {
             HealthUtility.AdjustSeverity(abilityUser.AbilityUser, h, 1f);
         }
     }
 }
Esempio n. 4
0
 public AbilityData(CompAbilityUser abilityUser)
 {
     abilityClass = abilityUser.GetType();
     pawn         = abilityUser.Pawn;
 }
 public virtual bool TryDoEffect(CompAbilityUser abilityUser)
 {
     DoEffect(abilityUser);
     return(true);
 }
Esempio n. 6
0
 public PawnAbility(AbilityData data)
 {
     pawn        = data.Pawn;
     abilityUser = data.Pawn.AllComps.FirstOrDefault(x => x.GetType() == data.AbilityClass) as CompAbilityUser;
     //Log.Message("PawnAbility Created: " + this.Def.defName);
 }
Esempio n. 7
0
 public PawnAbility(CompAbilityUser comp)
 {
     pawn        = comp.AbilityUser;
     abilityUser = comp;
     //Log.Message("PawnAbility Created: " + this.Def.defName);
 }
 public Command_PawnAbility(CompAbilityUser compAbilityUser, PawnAbility ability, int ticks)
 {
     this.compAbilityUser = compAbilityUser;
     pawnAbility          = ability;
     curTicks             = ticks;
 }