Exemplo n.º 1
0
 public PawnAbility(Pawn user, AbilityDef pdef)
 {
     pawn        = user;
     powerdef    = pdef;
     powerButton = pdef.uiIcon;
     //Log.Message("PawnAbility Created: " + this.Def.defName);
 }
 public void Launch(Thing launcher, AbilityDef abilityDef, Vector3 origin, LocalTargetInfo targ, Thing equipment = null, List <ApplyHediffs> applyHediffs = null, List <ApplyMentalStates> applyMentalStates = null, List <SpawnThings> spawnThings = null)
 {
     //Log.Message("Projectile_AbilityBase");
     this.localApplyHediffs      = applyHediffs;
     this.localApplyMentalStates = applyMentalStates;
     this.localSpawnThings       = spawnThings;
     this.localAbilityDef        = abilityDef;
     base.Launch(launcher, origin, targ, equipment);
 }
        public void AddPawnAbility(AbilityDef psydef)
        {
            if (!this.CompAbilityUser.Powers.Any(x => x.powerdef.defName == psydef.defName))
            {
                this.CompAbilityUser.Powers.Add(new PawnAbility(this.CompAbilityUser.abilityUser, psydef));
            }

            this.CompAbilityUser.UpdateAbilities();
        }
Exemplo n.º 4
0
        private void AddAbilityInternal(AbilityDef abilityDef, List <PawnAbility> thelist, bool activenow,
                                        float savedTicks)
        {
            var pa = (PawnAbility)Activator.CreateInstance(abilityDef.abilityClass);

            pa.Pawn = AbilityUser;
            pa.Def  = abilityDef;
            thelist.Add(pa);
            UpdateAbilities();
        }
Exemplo n.º 5
0
        private void AddAbilityInternal(AbilityDef abilityDef, List <PawnAbility> thelist, bool activenow, float savedTicks)
        {
            PawnAbility pa = (PawnAbility)Activator.CreateInstance(abilityDef.abilityClass);

            //Log.Message(abilityDef.abilityClass.ToString());
            pa.Pawn = this.AbilityUser;
            pa.Def  = abilityDef;
            thelist.Add(pa);
            this.UpdateAbilities();
        }
        public void RemovePawnAbility(AbilityDef abilityDef)
        {
            PawnAbility abilityToRemove = this.CompAbilityUser.Powers.FirstOrDefault(x => x.powerdef.defName == abilityDef.defName);

            if (abilityToRemove != null)
            {
                this.CompAbilityUser.Powers.Remove(abilityToRemove);
            }

            this.CompAbilityUser.UpdateAbilities();
        }
Exemplo n.º 7
0
        internal void Initialize(CompAbilityUser abilityUser, AbilityDef powerDef, int ticksUntilCasting)
        {
            if (abilityUser.Pawn == null)
            {
                throw new ArgumentNullException("comp.Pawn cannot be null");
            }
            DebugMessage($"PawnAbility.Initialize({this}, {abilityUser}, {powerDef}, {ticksUntilCasting})");
#pragma warning disable CS0618 // Type or member is obsolete
            this.abilityUser = abilityUser;
#pragma warning restore CS0618 // Type or member is obsolete
            this.powerDef          = powerDef;
            this.ticksUntilCasting = ticksUntilCasting;
        }
 public override bool CanOverpowerTarget(Pawn user, Thing target, AbilityUser.AbilityDef abilityDef)
 {
     if (target is ProjectJedi.PawnGhost)
     {
         Messages.Message("PJ_ForceResisted".Translate(new object[]
         {
             target.LabelShort,
             user.LabelShort,
             abilityDef.label
         }), MessageSound.Negative);
         return(false);
     }
     return(base.CanOverpowerTarget(user, target, abilityDef));
 }
Exemplo n.º 9
0
 public PawnAbility(Pawn user, AbilityDef pdef)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user cannot be null");
     }
     if (pdef == null)
     {
         throw new ArgumentNullException("pdef cannot be null");
     }
     abilityUser = user.GetCompAbilityUser();
     powerDef    = pdef;
     DebugMessage($"new PawnAbility({user}, {pdef}) => abilityUser={abilityUser}");
 }
Exemplo n.º 10
0
        private void RemoveAbilityInternal(AbilityDef abilityDef, List <PawnAbility> thelist)
        {
            var abilityToRemove = thelist.FirstOrDefault(x => x.Def == abilityDef);

            if (abilityToRemove != null)
            {
                thelist.Remove(abilityToRemove);
            }
            abilityToRemove = AbilityData.Powers.FirstOrDefault(x => x.Def == abilityDef);
            if (abilityToRemove != null)
            {
                AbilityData.Powers.Remove(abilityToRemove);
            }
            UpdateAbilities();
        }
Exemplo n.º 11
0
 public MightAbility(Pawn user, AbilityUser.AbilityDef pdef) : base(user, pdef)
 {
 }
Exemplo n.º 12
0
        public static Action TryCastAbility(Pawn pawn, LocalTargetInfo target, CompAbilityUser compAbilityUser, Verb_UseAbility verb, AbilityDef psydef)
        {
            Action act = new Action(delegate
            {
                compAbilityUser.CurTarget   = null;
                compAbilityUser.CurTarget   = target;
                compAbilityUser.curVerb     = verb;
                compAbilityUser.curPower    = psydef;
                compAbilityUser.curRotation = Rot4.South;
                if (target != null && target.Thing != null)
                {
                    compAbilityUser.curRotation = target.Thing.Rotation;
                }

                Job job;
                if (target != null)
                {
                    job = CompAbilityUser.AbilityJob(verb.UseAbilityProps.AbilityTargetCategory, target);
                }
                else
                {
                    job = CompAbilityUser.AbilityJob(verb.UseAbilityProps.AbilityTargetCategory, pawn);
                }
                job.playerForced = true;
                job.verbToUse    = verb;
                if (target != null)
                {
                    if (target.Thing is Pawn pawn2)
                    {
                        job.killIncappedTarget = pawn2.Downed;
                    }
                }

                pawn.jobs.TryTakeOrderedJob(job);
            });
Exemplo n.º 13
0
 public ForceAbility(Pawn user, AbilityUser.AbilityDef pdef) : base(user, pdef)
 {
 }
Exemplo n.º 14
0
        //        public Dictionary<PawnAbility, Verb_UseAbility> pawnAbilities = new Dictionary<PawnAbility, Verb_UseAbility>();

        /*
         * if (!this.Powers.Any(x => x.powerdef.defName == abilityDef.defName))
         * {
         *  this.Powers.Add(new PawnAbility(this.abilityUser, abilityDef));
         * }
         *
         * this.UpdateAbilities();
         */
        public void AddPawnAbility(AbilityDef abilityDef, bool activenow = true) => this.AddAbilityInternal(abilityDef, ref this.Powers, activenow); public void AddWeaponAbility(AbilityDef abilityDef, bool activenow = true) => this.AddAbilityInternal(abilityDef, ref this.temporaryWeaponPowers, activenow); public void AddApparelAbility(AbilityDef abilityDef, bool activenow = true) => this.AddAbilityInternal(abilityDef, ref this.temporaryApparelPowers, activenow); private void AddAbilityInternal(AbilityDef abilityDef, ref List <PawnAbility> thelist, bool activenow)
Exemplo n.º 15
0
 public void ApplyHediffsAndMentalStates(Pawn victim, Pawn caster, List <ApplyMentalStates> localApplyMentalStates, AbilityDef localAbilityDef)
 {
     try
     {
         //Log.Message("ApplyHediffsAndMentalStates");
         AbilityEffectUtility.ApplyMentalStates(victim, caster, localApplyMentalStates, localAbilityDef, this);
         AbilityEffectUtility.ApplyHediffs(victim, caster, localApplyHediffs, null);
     }
     catch (NullReferenceException e)
     {
         Log.Message(e.ToString());
     }
 }
Exemplo n.º 16
0
 public void RemovePawnAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, ref this.Powers); public void RemoveWeaponAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, ref this.temporaryWeaponPowers); public void RemoveApparelAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, ref this.temporaryApparelPowers); private void RemoveAbilityInternal(AbilityDef abilityDef, ref List <PawnAbility> thelist)
Exemplo n.º 17
0
 public void RemovePawnAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, this.AbilityData.Powers);
Exemplo n.º 18
0
 public void RemoveWeaponAbility(AbilityDef abilityDef)
 {
     RemoveAbilityInternal(abilityDef, AbilityData.TemporaryWeaponPowers);
 }
Exemplo n.º 19
0
 public virtual bool CanOverpowerTarget(Pawn user, Thing target, AbilityDef ability) => true;
Exemplo n.º 20
0
        public void RemovePawnAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, ref this.Powers); public void RemoveWeaponAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, ref this.temporaryWeaponPowers); public void RemoveApparelAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, ref this.temporaryApparelPowers); private void RemoveAbilityInternal(AbilityDef abilityDef, ref List <PawnAbility> thelist)
        {
            PawnAbility abilityToRemove = thelist.FirstOrDefault(x => x.powerdef.defName == abilityDef.defName);

            if (abilityToRemove != null)
            {
                thelist.Remove(abilityToRemove);
            }

            this.UpdateAbilities();
        }
Exemplo n.º 21
0
 public void RemoveApparelAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, this.AbilityData.TemporaryApparelPowers);
Exemplo n.º 22
0
 public void RemoveWeaponAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, this.AbilityData.TemporaryWeaponPowers);
Exemplo n.º 23
0
        //public List<Verb_UseAbility> AbilityVerbs = new List<Verb_UseAbility>();

        public void AddPawnAbility(AbilityDef abilityDef, bool activenow = true, float savedTicks = -1)
        {
            AddAbilityInternal(abilityDef, AbilityData.Powers, activenow, savedTicks);
        }
Exemplo n.º 24
0
        //        public Dictionary<PawnAbility, Verb_UseAbility> pawnAbilities = new Dictionary<PawnAbility, Verb_UseAbility>();

        /*
         * if (!this.Powers.Any(x => x.powerdef.defName == abilityDef.defName))
         * {
         *  this.Powers.Add(new PawnAbility(this.abilityUser, abilityDef));
         * }
         *
         * this.UpdateAbilities();
         */
        public void AddPawnAbility(AbilityDef abilityDef, bool activenow = true) => this.AddAbilityInternal(abilityDef, ref this.Powers, activenow); public void AddWeaponAbility(AbilityDef abilityDef, bool activenow = true) => this.AddAbilityInternal(abilityDef, ref this.temporaryWeaponPowers, activenow); public void AddApparelAbility(AbilityDef abilityDef, bool activenow = true) => this.AddAbilityInternal(abilityDef, ref this.temporaryApparelPowers, activenow); private void AddAbilityInternal(AbilityDef abilityDef, ref List <PawnAbility> thelist, bool activenow)
        {
            PawnAbility pa = new PawnAbility(this.AbilityUser, abilityDef);

            if (activenow == false)
            {
                pa.TicksUntilCasting = (int)(pa.powerdef.MainVerb.SecondsToRecharge * GenTicks.TicksPerRealSecond);
            }
            thelist.Add(pa);
            this.UpdateAbilities();
        }
Exemplo n.º 25
0
 public void AddApparelAbility(AbilityDef abilityDef, bool activenow = true, float savedTicks = -1)
 {
     AddAbilityInternal(abilityDef, AbilityData.TemporaryApparelPowers, activenow, savedTicks);
 }
Exemplo n.º 26
0
 public void AddWeaponAbility(AbilityDef abilityDef, bool activenow  = true, float savedTicks = -1) => this.AddAbilityInternal(abilityDef, this.AbilityData.TemporaryWeaponPowers, activenow, savedTicks);
Exemplo n.º 27
0
 public void RemovePawnAbility(AbilityDef abilityDef)
 {
     RemoveAbilityInternal(abilityDef, AbilityData.Powers);
 }
    public static void ApplyMentalStates(Pawn victim, Pawn caster, List <ApplyMentalStates> localApplyMentalStates, AbilityUser.AbilityDef localAbilityDef, Projectile_AbilityBase abilityProjectile)
    {
        if (localApplyMentalStates != null)
        {
            if (localApplyMentalStates.Count > 0)
            {
                foreach (var mentalStateGiver in localApplyMentalStates)
                {
                    var success    = false;
                    var checkValue = Rand.Value;
                    var str        = localAbilityDef.LabelCap + " (" + caster.LabelShort + ")";
                    if (checkValue <= mentalStateGiver.applyChance)
                    {
                        if (mentalStateGiver.mentalStateDef == MentalStateDefOf.Berserk &&
                            victim.RaceProps.intelligence < Intelligence.Humanlike)
                        {
                            if (caster == victim || abilityProjectile?.CanOverpower(caster, victim) != false)
                            {
                                success = true;
                                victim.mindState.mentalStateHandler.TryStartMentalState(
                                    MentalStateDefOf.Manhunter, str, true);
                            }
                        }
                        else
                        {
                            if (caster == victim || abilityProjectile?.CanOverpower(caster, victim) != false)
                            {
                                success = true;
                                victim.mindState.mentalStateHandler.TryStartMentalState(
                                    mentalStateGiver.mentalStateDef, str, true);
                            }
                        }
                    }

                    if (success)
                    {
                        victim.Drawer.Notify_DebugAffected();
                        MoteMaker.ThrowText(victim.DrawPos, victim.Map,
                                            mentalStateGiver.mentalStateDef.LabelCap + ": " + StringsToTranslate.AU_CastSuccess,
                                            -1f);
                    }
                    else
                    {
                        MoteMaker.ThrowText(victim.DrawPos, victim.Map,
                                            mentalStateGiver.mentalStateDef.LabelCap + ": " + StringsToTranslate.AU_CastFailure,
                                            -1f);
                    }
                }
            }
        }
    }
Exemplo n.º 29
0
 public void RemoveApparelAbility(AbilityDef abilityDef)
 {
     RemoveAbilityInternal(abilityDef, AbilityData.TemporaryApparelPowers);
 }
Exemplo n.º 30
0
 public virtual void PostAbilityAttempt(Pawn caster, AbilityDef ability)
 {
     return;
 }