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(); }
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(); }
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(); }
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)); }
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}"); }
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(); }
public MightAbility(Pawn user, AbilityUser.AbilityDef pdef) : base(user, pdef) { }
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); });
public ForceAbility(Pawn user, AbilityUser.AbilityDef pdef) : base(user, pdef) { }
// 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)
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()); } }
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)
public void RemovePawnAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, this.AbilityData.Powers);
public void RemoveWeaponAbility(AbilityDef abilityDef) { RemoveAbilityInternal(abilityDef, AbilityData.TemporaryWeaponPowers); }
public virtual bool CanOverpowerTarget(Pawn user, Thing target, AbilityDef ability) => true;
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(); }
public void RemoveApparelAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, this.AbilityData.TemporaryApparelPowers);
public void RemoveWeaponAbility(AbilityDef abilityDef) => this.RemoveAbilityInternal(abilityDef, this.AbilityData.TemporaryWeaponPowers);
//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); }
// 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(); }
public void AddApparelAbility(AbilityDef abilityDef, bool activenow = true, float savedTicks = -1) { AddAbilityInternal(abilityDef, AbilityData.TemporaryApparelPowers, activenow, savedTicks); }
public void AddWeaponAbility(AbilityDef abilityDef, bool activenow = true, float savedTicks = -1) => this.AddAbilityInternal(abilityDef, this.AbilityData.TemporaryWeaponPowers, activenow, savedTicks);
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); } } } } }
public void RemoveApparelAbility(AbilityDef abilityDef) { RemoveAbilityInternal(abilityDef, AbilityData.TemporaryApparelPowers); }
public virtual void PostAbilityAttempt(Pawn caster, AbilityDef ability) { return; }