public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed) { if (dinfo.Def != null && base.parent is Pawn pawn && pawn != null && !Props.BypassingDamageDefs.Any(def => dinfo.Def == def)) { absorbed = true; SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(base.parent.Position, base.parent.Map, false)); Vector3 impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle); Vector3 loc = base.parent.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f; float num = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f); MoteMaker.MakeStaticMote(loc, base.parent.Map, ThingDefOf.Mote_ExplosionFlash, num); int num2 = (int)num; for (int i = 0; i < num2; i++) { Rand.PushState(); MoteMaker.ThrowDustPuff(loc, base.parent.Map, Rand.Range(0.8f, 1.2f)); float angle = (float)Rand.Range(0, 360); Rand.PopState(); float num3 = Mathf.Lerp(1.2f, 1.55f, 2f); Vector3 vector = pawn.Drawer.DrawPos; vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead); int num4 = Find.TickManager.TicksGame - this.lastAbsorbDamageTick; if (num4 < 8) { float num5 = (float)(8 - num4) / 8f * 0.05f; vector += impactAngleVect * num5; num3 -= num5; } Vector3 s = new Vector3(num3, 1f, num3); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s); #pragma warning disable CS0436 // Type conflicts with imported type Graphics.DrawMesh(MeshPool.plane10, matrix, CompInvunerableSaveOGStatic.BubbleMat, 0); #pragma warning restore CS0436 // Type conflicts with imported type } this.lastAbsorbDamageTick = Find.TickManager.TicksGame; }
public override bool CheckPreAbsorbDamage(DamageInfo dinfo) { if (ShieldMax <= 0 || shieldInit > 0) { //受到伤害时重置启动倒计时 shieldInit = shieldInitSec.SecondsToTicks(); return(false); } dinfo.SetAmount(dinfo.Amount / shieldDamagedRate); float impact = dinfo.Amount; if (impact > shieldCur) { dinfo.SetAmount(-shieldCur); shieldCur = 0; shieldInit = shieldInitSec.SecondsToTicks(); //剩余护盾相对冲击量越高,抵挡最后一次伤害的概率就越高 return(Rand.Chance(shieldCur / impact)); } else { shieldCur -= impact; SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(Wearer.Position, Wearer.Map, false)); impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle); Vector3 loc = Wearer.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f; float num = Mathf.Min(10f, 2f + dinfo.Amount / 10f); MoteMaker.MakeStaticMote(loc, Wearer.Map, ThingDefOf.Mote_ExplosionFlash, num); int num2 = (int)num; for (int i = 0; i < num2; i++) { MoteMaker.ThrowDustPuff(loc, Wearer.Map, Rand.Range(0.8f, 1.2f)); } int gt = Find.TickManager.TicksGame; lastAbsorbDamageTick = gt; lastKeepDisplayTick = gt; } return(true); }
public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed) { if (dinfo.Def == AdeptusDamageDefOf.OG_WarpStormStrike) { absorbed = true; SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(base.parent.Position, base.parent.Map, false)); Vector3 impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle); Vector3 loc = base.parent.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f; float num = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f); MoteMaker.MakeStaticMote(loc, base.parent.Map, ThingDefOf.Mote_ExplosionFlash, num); int num2 = (int)num; for (int i = 0; i < num2; i++) { Rand.PushState(); MoteMaker.ThrowDustPuff(loc, base.parent.Map, Rand.Range(0.8f, 1.2f)); Rand.PopState(); } } else { base.PostPreApplyDamage(dinfo, out absorbed); } }
public override void CompTick() { base.CompTick(); if (this.parent is Pawn pawn && pawn.Spawned && Find.TickManager.TicksGame >= readyToUseTicks) { readyToUseTicks = Find.TickManager.TicksGame + Props.interval.RandomInRange; var victims = pawn.Map.mapPawns.AllPawns.Where(x => x.Position.DistanceTo(pawn.Position) < Props.maxDistance); MoteMaker.MakeStaticMote(pawn.Position, pawn.Map, ThingDefOf.Mote_PsycastAreaEffect, Props.maxDistance); foreach (var victim in victims) { if (victim != pawn && !victim.RaceProps.IsMechanoid) { var stunPeriod = Props.stunPeriod; if (victim.story?.traits?.GetTrait(TraitDefOf.PsychicSensitivity) != null) { stunPeriod /= victim.story.traits.GetTrait(TraitDefOf.PsychicSensitivity).Degree; } victim.stances.stunner.StunFor_NewTmp(stunPeriod, pawn, true); } } } }
protected override IEnumerable <Toil> MakeNewToils() { AddFailCondition(() => !pawn.IsColonistPlayerControlled || pawn.Downed || pawn.drafter == null || pawn.GetBattleStation() == null); var toil = new Toil { initAction = () => { pawn.drafter.Drafted = true; var position = RCellFinder.BestOrderedGotoDestNear(TargetLocA, pawn); var job = JobMaker.MakeJob(JobDefOf.Goto, position); job.locomotionUrgency = LocomotionUrgency.Sprint; pawn.jobs.TryTakeOrderedJob(job, JobTag.DraftedOrder); #if RIMWORLD_1_2 // MoteMaker.MakeStaticMote(position, pawn.Map, ThingDefOf.Mote_FeedbackGoto); MoteMaker.MakeStaticMote(position, pawn.Map, ThingDefOf.Mote_FeedbackGoto); #else MoteMaker.MakeStaticMote(position, pawn.Map, ThingDefOf.Mote_RolePositionHighlight); #endif } }; yield return(toil); }
public override IEnumerable <PreCastAction> GetPreCastActions() { if (Props.type == DeepStrikeType.Teleport) { yield return(new PreCastAction { action = delegate(LocalTargetInfo t, LocalTargetInfo d) { if (!this.parent.def.HasAreaOfEffect) { Pawn pawn = t.Pawn; if (pawn != null) { MoteMaker.MakeAttachedOverlay(pawn, ThingDefOf.Mote_PsycastSkipFlashEntry, Vector3.zero, 1f, -1f).detachAfterTicks = 5; } else { MoteMaker.MakeStaticMote(t.CenterVector3, this.parent.pawn.Map, ThingDefOf.Mote_PsycastSkipFlashEntry, 1f); } MoteMaker.MakeStaticMote(d.Cell, this.parent.pawn.Map, ThingDefOf.Mote_PsycastSkipInnerExit, 1f); } if (this.Props.destination != AbilityEffectDestination.RandomInRange) { MoteMaker.MakeStaticMote(d.Cell, this.parent.pawn.Map, ThingDefOf.Mote_PsycastSkipOuterRingExit, 1f); } if (!this.parent.def.HasAreaOfEffect) { SoundDefOf.Psycast_Skip_Entry.PlayOneShot(new TargetInfo(t.Cell, this.parent.pawn.Map, false)); SoundDefOf.Psycast_Skip_Exit.PlayOneShot(new TargetInfo(d.Cell, this.parent.pawn.Map, false)); } }, ticksAwayFromCast = 5 }); } yield break; }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); if (hitThing != null) { int damageAmountBase = def.projectile.damageAmountBase; ThingDef equipmentDef = this.equipmentDef; DamageDefExtensionCE damDefCE = def.projectile.damageDef.GetModExtension <DamageDefExtensionCE>() ?? new DamageDefExtensionCE(); DamageInfo dinfo = new DamageInfo( def.projectile.damageDef, damageAmountBase, ExactRotation.eulerAngles.y, launcher, null, def); // Set impact height BodyPartDepth partDepth = damDefCE != null && damDefCE.harmOnlyOutsideLayers ? BodyPartDepth.Outside : BodyPartDepth.Undefined; BodyPartHeight partHeight = new CollisionVertical(hitThing).GetCollisionBodyHeight(Height); dinfo.SetBodyRegion(partHeight, partDepth); if (damDefCE != null && damDefCE.harmOnlyOutsideLayers) { dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); } // Apply primary damage hitThing.TakeDamage(dinfo); } else { SoundDefOf.BulletImpactGround.PlayOneShot(new TargetInfo(base.Position, map, false)); MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); } }
public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed) { base.PostPreApplyDamage(dinfo, out absorbed); if (absorbed) { return; } float impact = dinfo.Amount * shieldDamagedRate; if (impact > shieldCur) { dinfo.SetAmount(-shieldCur); shieldCur = 0; shieldInit = shieldInitTick; //剩余护盾相对冲击量越高,抵挡最后一次伤害的概率就越高 absorbed = Rand.Chance(shieldCur / impact); } else { shieldCur -= impact; SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(parent.Position, parent.Map, false)); impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle); Vector3 loc = parent.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f; float num = Mathf.Min(10f, 2f + dinfo.Amount / 10f); MoteMaker.MakeStaticMote(loc, parent.Map, ThingDefOf.Mote_ExplosionFlash, num); int num2 = (int)num; for (int i = 0; i < num2; i++) { MoteMaker.ThrowDustPuff(loc, parent.Map, Rand.Range(0.8f, 1.2f)); } int gt = Find.TickManager.TicksGame; lastAbsorbDamageTick = gt; lastKeepDisplayTick = gt; absorbed = true; } }
// Token: 0x06000035 RID: 53 RVA: 0x00002C3C File Offset: 0x00000E3C protected virtual void ImpactDirectly(Thing hitThing, Map map) { base.Impact(hitThing); BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, null); Find.BattleLog.Add(battleLogEntry_RangedImpact); if (hitThing != null) { int damageAmountBase = this.def.projectile.GetDamageAmount(this.launcher); DamageDef damageDef = this.def.projectile.damageDef; float y = this.ExactRotation.eulerAngles.y; Thing launcher = this.launcher; ThingDef equipmentDef = this.equipmentDef; DamageInfo dinfo = new DamageInfo(damageDef, damageAmountBase, 0, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown); hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact); return; } SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false)); MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); if (base.Position.GetTerrain(map).takeSplashes) { MoteMaker.MakeWaterSplash(this.ExactPosition, map, (float)((double)Mathf.Sqrt((float)this.def.projectile.GetDamageAmount(this.launcher)) * 1.0), 4f); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef); Find.BattleLog.Add(battleLogEntry_RangedImpact); if (hitThing != null) { DamageDef damageDef = this.def.projectile.damageDef; float damageAmountMax = (float)base.DamageAmount; float damageAmount = Rand.Range(0, damageAmountMax); float armorPenetration = base.ArmorPenetration; float y = this.ExactRotation.eulerAngles.y; Thing launcher = this.launcher; ThingDef equipmentDef = this.equipmentDef; DamageInfo dinfo = new DamageInfo(damageDef, damageAmount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing); hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact); Pawn pawn = hitThing as Pawn; if (pawn != null && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f) { pawn.stances.StaggerFor(95); } } else { SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false)); MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); if (base.Position.GetTerrain(map).takeSplashes) { MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f); } } }
/// <summary> /// Impacts a pawn/object or the ground. /// </summary> protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); if (hitThing != null) { ThingDef equipmentDef = this.equipmentDef; DamageInfo dinfo = new DamageInfo(def.projectile.damageDef, DamageAmount, ArmorPenetration, this.ExactRotation.eulerAngles.y, this.launcher, null, equipmentDef); hitThing.TakeDamage(dinfo); if (hitThing is Pawn pawn && !pawn.Downed && Rand.Value < compED.chanceToProc) { MoteMaker.ThrowMicroSparks(this.destination, Map); hitThing.TakeDamage(new DamageInfo(DefDatabase <DamageDef> .GetNamed(compED.damageDef, true), compED.damageAmount, ArmorPenetration, this.ExactRotation.eulerAngles.y, this.launcher, null, null)); } } else { SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false)); MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); ThrowMicroSparksBlue(this.ExactPosition, Map); } }
private void Break() { //float overkill = Math.Min(EnergyMax * 10 / 3, -energy); float overkill = Math.Min(OverKillUpLimit, -energy); if (overkill >= FragemntPerCharge) { SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(parent.Position, parent.Map)); MoteMaker.MakeStaticMote(parent.TrueCenter(), parent.Map, ThingDefOf.Mote_ExplosionFlash, 12f); overkilled = true; } else { SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(parent.Position, parent.Map)); } for (int i = 0; i < 6; i++) { MoteMaker.ThrowDustPuff(parent.TrueCenter() + (Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f)), parent.Map, Rand.Range(0.8f, 1.2f)); } //energy = 0f; energy = -Math.Min(EnergyMax * 10 / 3, overkill * 3); pendingCharge = 0f; ticksToReset = StartingTicksToReset; }
public override bool TryCastShot() { //Reduce ammunition if (CompAmmo != null) { if (!CompAmmo.TryReduceAmmoCount(VerbPropsCE.ammoConsumedPerShotCount)) { return(false); } } Vector3 muzzlePos = Caster.DrawPos; if (turretGun != null) { if (turretGun.UseAmmo) { bool playerpawn = this.CasterIsPawn && this.Caster.Faction == Faction.OfPlayer; if (turretGun.HasAmmo) { turretGun.UsedOnce(); } else { return(false); } if (turretGun.RemainingCharges == 0) { if (turretGun.Props.soundEmptyWarning != null && playerpawn) { turretGun.Props.soundEmptyWarning.PlayOneShot(new TargetInfo(this.Caster.Position, this.Caster.Map, false)); } if (!turretGun.Props.messageEmptyWarning.NullOrEmpty() && playerpawn) { MoteMaker.ThrowText(Caster.Position.ToVector3(), Caster.Map, turretGun.Props.messageEmptyWarning.Translate(EquipmentSource.LabelCap, Caster.LabelShortCap), 3f); } } float a = turretGun.RemainingCharges; float b = turretGun.MaxCharges; int remaining = (int)(a / b * 100f); if (remaining == 50 && warningticks == 0) { warningticks = this.verbProps.ticksBetweenBurstShots + 1; if (turretGun.Props.soundHalfRemaningWarning != null && playerpawn) { turretGun.Props.soundHalfRemaningWarning.PlayOneShot(new TargetInfo(this.Caster.Position, this.Caster.Map, false)); } if (!turretGun.Props.messageHalfRemaningWarning.NullOrEmpty() && playerpawn) { MoteMaker.ThrowText(Caster.Position.ToVector3(), Caster.Map, turretGun.Props.messageHalfRemaningWarning.Translate(EquipmentSource.LabelCap, Caster.LabelShortCap, remaining), 3f); } } if (remaining == 25 && warningticks == 0) { warningticks = this.verbProps.ticksBetweenBurstShots + 1; if (turretGun.Props.soundQuaterRemaningWarning != null && playerpawn) { turretGun.Props.soundQuaterRemaningWarning.PlayOneShot(new TargetInfo(this.Caster.Position, this.Caster.Map, false)); } if (!turretGun.Props.messageQuaterRemaningWarning.NullOrEmpty() && playerpawn) { MoteMaker.ThrowText(Caster.Position.ToVector3(), Caster.Map, turretGun.Props.messageQuaterRemaningWarning.Translate(EquipmentSource.LabelCap, Caster.LabelShortCap, remaining), 3f); } } muzzlePos = MuzzlePosition(this.Caster, this.currentTarget, Offset); } } // if (base.TryCastShot()) if (TryCastShotFrom(muzzlePos)) { //Required since Verb_Shoot does this but Verb_LaunchProjectileCE doesn't when calling base.TryCastShot() because Shoot isn't its base if (ShooterPawn != null) { ShooterPawn.records.Increment(RecordDefOf.ShotsFired); } //Drop casings if (VerbPropsCE.ejectsCasings && projectilePropsCE.dropsCasings) { ThrowEmptyCasing(caster.DrawPos, caster.Map, ThingDef.Named(projectilePropsCE.casingMoteDefname)); } // This needs to here for weapons without magazine to ensure their last shot plays sounds if (CompAmmo != null && !CompAmmo.HasMagazine && CompAmmo.UseAmmo) { if (!CompAmmo.Notify_ShotFired()) { if (VerbPropsCE.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(caster.Position, caster.Map, ThingDefOf.Mote_ShotFlash, VerbPropsCE.muzzleFlashScale); } if (VerbPropsCE.soundCast != null) { VerbPropsCE.soundCast.PlayOneShot(new TargetInfo(caster.Position, caster.Map)); } if (VerbPropsCE.soundCastTail != null) { VerbPropsCE.soundCastTail.PlayOneShotOnCamera(); } if (ShooterPawn != null) { if (ShooterPawn.thinker != null) { ShooterPawn.mindState.lastEngageTargetTick = Find.TickManager.TicksGame; } } } return(CompAmmo.Notify_PostShotFired()); } return(true); } return(false); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn pawn) { if (gun != null) { return(base.GetFloatMenuOptions(pawn)); } // Do only, when no gun installed List <FloatMenuOption> list = new List <FloatMenuOption>(); if (gun != null) { return(null); } //is not a memory // Check if this is reservable by the pawn if (!pawn.CanReserve(this, 1)) { FloatMenuOption item = new FloatMenuOption("CannotUseReserved".Translate(), null, MenuOptionPriority.Default, null, null); list.Add(item); return(list.AsEnumerable()); } // Check if this is reachable by the pawn if (!pawn.CanReach(this, PathEndMode.Touch, Danger.Deadly)) { FloatMenuOption item = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null); list.Add(item); return(list.AsEnumerable()); } // find available guns for possible use IEnumerable <Thing> foundThings = Map.listerThings.AllThings.Where(t => t.def.IsRangedWeapon && !t.IsForbidden(pawn.Faction)); List <Thing> foundThingList; if (foundThings != null) { foundThingList = foundThings.ToList(); } else { foundThingList = null; } // only guns inside the home area are valid List <IntVec3> HomeAreaCells = null; if (Map.areaManager.Home.ActiveCells.FirstOrDefault <IntVec3>() != null) { HomeAreaCells = Map.areaManager.Home.ActiveCells.ToList(); } List <Thing> availableGuns = new List <Thing>(); if (foundThingList != null && HomeAreaCells != null) { for (int w = 0; w < foundThingList.Count; w++) { Thing thing = foundThingList[w]; // don't use selfdestroying weapons if (thing.def.destroyOnDrop) { continue; } // only use weapons inside the home area if (!HomeAreaCells.Contains(thing.Position)) { continue; } // can not reserve or reach? if (!pawn.CanReserveAndReach(thing, PathEndMode.Touch, Danger.Deadly, 1)) { continue; } availableGuns.Add(thing); } } availableGuns.Sort(CompareThings); int shownEntries = floatMenuShowEntries; int maxThings = floatMenuMaxEntries; int lastShownEntry = 0; // Make one entry per gun type found int availableGunsCount = availableGuns.Count; for (int i = shownEntries; i < availableGuns.Count; i++) { Thing haulThing = availableGuns[i]; if (haulThing.IsForbidden(pawn.Faction) || !pawn.CanReserveAndReach(haulThing, PathEndMode.Touch, Danger.Deadly, 1)) { IEnumerable <Thing> allAvailableThings = Map.listerThings.AllThings.Where(t => t.def.defName == availableGuns[i].def.defName && !t.IsForbidden(pawn.Faction) && pawn.CanReserveAndReach(t, PathEndMode.Touch, Danger.Deadly, 1)); haulThing = CommonMisc.Helper.FindNearestThing(allAvailableThings, Position); } if (haulThing == null) { continue; } Action action = delegate { Job job = new Job(DefDatabase <JobDef> .GetNamed("InstallWeaponOnTurretBase"), haulThing, Position) { count = 1, haulOpportunisticDuplicates = false, haulMode = HaulMode.ToCellNonStorage }; pawn.jobs.TryTakeOrderedJob(job); pawn.Reserve(this, job, 1); // Allow this building to search for a gun this.collectingGunAllowed = true; }; Action hoverAction = delegate { if (haulThing != null) { MoteMaker.MakeStaticMote(haulThing.Position, Map, ThingDefOf.Mote_FeedbackGoto); } }; list.Add(new FloatMenuOption(txtFloatMenuInstallWeapon.Translate() + " " + haulThing.Label, action, MenuOptionPriority.Default, hoverAction)); // save shown item position for next call lastShownEntry = i; // make max. x entries if (list.Count >= maxThings) { break; } } // add entry for more items: '<' and '>' if (availableGuns.Count > maxThings) { Action switchPageNext = null; if (floatMenuShowEntries + maxThings < availableGuns.Count - 1) { switchPageNext = delegate { floatMenuShowEntries = lastShownEntry; }; } list.Add(new FloatMenuOption(">", switchPageNext, MenuOptionPriority.Low)); Action switchPageLast = null; if (floatMenuShowEntries > 0) { switchPageLast = delegate { floatMenuShowEntries = floatMenuShowEntries - floatMenuMaxEntries; if (floatMenuShowEntries < 0) { floatMenuShowEntries = 0; } }; } list.Add(new FloatMenuOption("<", switchPageLast, MenuOptionPriority.Low)); } // No usable weapons found if (list.Count == 0) { list.Add(new FloatMenuOption("NoWeaponFoundForTurretBase".Translate(), null, MenuOptionPriority.Low)); } return(list.AsEnumerable()); }
protected override bool TryCastShot() { if (yes != 1) { NeededFloat = this.VerbPropsCE.warmupTime; yes = 1; } if (Myself.TryGetComp <Biped2>() != null) { if (Myself.TryGetComp <Biped2>().BipodSetUp) { Log.Error(NeededFloat.ToString()); this.VerbPropsCE.warmupTime = NeededFloat / 2; Log.Error(this.VerbPropsCE.warmupTime.ToString()); } else { this.VerbPropsCE.warmupTime = NeededFloat; Log.Error(this.VerbPropsCE.warmupTime.ToString()); } } else { Log.Error("missing comp"); } bool flag = base.CompAmmo != null; if (flag) { bool flag2 = !base.CompAmmo.TryReduceAmmoCount(base.VerbPropsCE.ammoConsumedPerShotCount); if (flag2) { return(false); } } bool flag3 = base.TryCastShot(); bool result; if (flag3) { bool flag4 = base.ShooterPawn != null; if (flag4) { base.ShooterPawn.records.Increment(RecordDefOf.ShotsFired); } bool flag5 = base.VerbPropsCE.ejectsCasings && base.projectilePropsCE.dropsCasings; bool flag6 = base.CompAmmo != null && !base.CompAmmo.HasMagazine && base.CompAmmo.UseAmmo; if (flag6) { bool flag7 = !base.CompAmmo.Notify_ShotFired(); if (flag7) { bool flag8 = base.VerbPropsCE.muzzleFlashScale > 0.01f; if (flag8) { MoteMaker.MakeStaticMote(this.caster.Position, this.caster.Map, ThingDefOf.Mote_ShotFlash, base.VerbPropsCE.muzzleFlashScale); } bool flag9 = base.VerbPropsCE.soundCast != null; if (flag9) { base.VerbPropsCE.soundCast.PlayOneShot(new TargetInfo(this.caster.Position, this.caster.Map, false)); } bool flag10 = base.VerbPropsCE.soundCastTail != null; if (flag10) { base.VerbPropsCE.soundCastTail.PlayOneShotOnCamera(null); } bool flag11 = base.ShooterPawn != null; if (flag11) { bool flag12 = base.ShooterPawn.thinker != null; if (flag12) { base.ShooterPawn.mindState.lastEngageTargetTick = Find.TickManager.TicksGame; } } } result = base.CompAmmo.Notify_PostShotFired(); } else { result = true; } } else { result = false; } return(result); }
protected void TryCastNextBurstShot() { LocalTargetInfo localTargetInfo = currentTarget; if (Available() && TryCastShot()) { if (verbProps.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(caster.Position, caster.Map, ThingDefOf.Mote_ShotFlash, verbProps.muzzleFlashScale); } if (verbProps.soundCast != null) { verbProps.soundCast.PlayOneShot(new TargetInfo(caster.Position, caster.Map)); } if (verbProps.soundCastTail != null) { verbProps.soundCastTail.PlayOneShotOnCamera(caster.Map); } if (CasterIsPawn) { if (CasterPawn.thinker != null) { CasterPawn.mindState.Notify_EngagedTarget(); } if (CasterPawn.mindState != null) { CasterPawn.mindState.Notify_AttackedTarget(localTargetInfo); } if (CasterPawn.MentalState != null) { CasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo); } if (TerrainDefSource != null) { CasterPawn.meleeVerbs.Notify_UsedTerrainBasedVerb(); } if (CasterPawn.health != null) { CasterPawn.health.Notify_UsedVerb(this, localTargetInfo); } if (EquipmentSource != null) { EquipmentSource.Notify_UsedWeapon(CasterPawn); } if (!CasterPawn.Spawned) { return; } } if (verbProps.consumeFuelPerShot > 0f) { caster.TryGetComp <CompRefuelable>()?.ConsumeFuel(verbProps.consumeFuelPerShot); } burstShotsLeft--; } else { burstShotsLeft = 0; } if (burstShotsLeft > 0) { ticksToNextBurstShot = verbProps.ticksBetweenBurstShots; if (CasterIsPawn) { CasterPawn.stances.SetStance(new Stance_Cooldown(verbProps.ticksBetweenBurstShots + 1, currentTarget, this)); } return; } state = VerbState.Idle; if (CasterIsPawn) { CasterPawn.stances.SetStance(new Stance_Cooldown(verbProps.AdjustedCooldownTicks(this, CasterPawn), currentTarget, this)); } if (castCompleteCallback != null) { castCompleteCallback(); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); if (hitThing != null) { int damageAmountBase = def.projectile.damageAmountBase; ThingDef equipmentDef = this.equipmentDef; DamageDef_CE damDefCE = def.projectile.damageDef as DamageDef_CE; DamageInfo dinfo = new DamageInfo( def.projectile.damageDef, damageAmountBase, ExactRotation.eulerAngles.y, launcher, null, equipmentDef); // if (damDefCE != null && damDefCE.harmOnlyOutsideLayers) dinfo.ForceHitPart.depth = BodyPartDepth.Outside; ProjectilePropertiesCE propsCE = def.projectile as ProjectilePropertiesCE; if (propsCE != null && !propsCE.secondaryDamage.NullOrEmpty()) { // Log.Message("propsCE: " + propsCE.ToString()); // Get the correct body part Pawn pawn = hitThing as Pawn; if (pawn != null && def.projectile.damageDef.workerClass == typeof(DamageWorker_AddInjuryCE)) { BodyPartRecord exactPartFromDamageInfo = DamageWorker_AddInjuryCE.GetExactPartFromDamageInfo(dinfo, pawn); dinfo = new DamageInfo( dinfo.Def, dinfo.Amount, dinfo.Angle, dinfo.Instigator, exactPartFromDamageInfo = (DamageWorker_AddInjuryCE.GetExactPartFromDamageInfo(dinfo, pawn)), dinfo.WeaponGear); } List <DamageInfo> dinfoList = new List <DamageInfo>() { dinfo }; foreach (SecondaryDamage secDamage in propsCE.secondaryDamage) { dinfoList.Add(new DamageInfo( secDamage.def, secDamage.amount, dinfo.Angle, dinfo.Instigator, dinfo.ForceHitPart, dinfo.WeaponGear)); } foreach (DamageInfo curDinfo in dinfoList) { hitThing.TakeDamage(curDinfo); } } else { hitThing.TakeDamage(dinfo); } } else { SoundDefOf.BulletImpactGround.PlayOneShot(new TargetInfo(base.Position, map, false)); MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); } }
protected new void TryCastNextBurstShot() { // Log.Messageage("TryCastNextBurstShot "); LocalTargetInfo localTargetInfo = this.currentTarget; if (this.Available() && this.TryCastShot()) { // Log.Messageage("TryCastNextBurstShot Available TryCastShot"); if (this.verbProps.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(MuzzlePosition(this.Caster, this.currentTarget, this.turretGun.Props.projectileOffset), this.caster.Map, ThingDefOf.Mote_ShotFlash, this.verbProps.muzzleFlashScale); } if (this.verbProps.soundCast != null) { this.verbProps.soundCast.PlayOneShot(new TargetInfo(this.caster.Position, this.caster.Map, false)); } if (this.verbProps.soundCastTail != null) { this.verbProps.soundCastTail.PlayOneShotOnCamera(this.caster.Map); } if (this.CasterIsPawn) { if (this.CasterPawn.thinker != null) { Notify_EngagedTarget(); } if (this.CasterPawn.mindState != null) { Notify_AttackedTarget(localTargetInfo); } if (this.CasterPawn.MentalState != null) { this.CasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo); } if (this.TerrainDefSource != null) { this.CasterPawn.meleeVerbs.Notify_UsedTerrainBasedVerb(); } if (this.CasterPawn.health != null) { this.CasterPawn.health.Notify_UsedVerb(this, localTargetInfo); } if (this.EquipmentSource != null) { this.EquipmentSource.Notify_UsedWeapon(this.CasterPawn); } if (!this.CasterPawn.Spawned) { this.Reset(); return; } } if (this.verbProps.consumeFuelPerShot > 0f) { CompRefuelable compRefuelable = this.caster.TryGetCompFast <CompRefuelable>(); if (compRefuelable != null) { compRefuelable.ConsumeFuel(this.verbProps.consumeFuelPerShot); } } this.burstShotsLeft--; } else { this.burstShotsLeft = 0; } if (this.burstShotsLeft > 0) { this.ticksToNextBurstShot = this.verbProps.ticksBetweenBurstShots; if (this.CasterIsPawn && !this.verbProps.nonInterruptingSelfCast) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.ticksBetweenBurstShots + 1, this.currentTarget, this)); return; } } else { this.state = VerbState.Idle; if (this.CasterIsPawn && !this.verbProps.nonInterruptingSelfCast) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.AdjustedCooldownTicks(this, this.CasterPawn), this.currentTarget, this)); } if (this.castCompleteCallback != null) { castCompleteCallback(); } } }
// Decompiled code is painful to read... Continue at your own risk public static List <FloatMenuOption> ChoicesForThing(Thing thing, Pawn pawn) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); Thing t = thing; // Copied from FloatMenuMakerMap.AddHumanlikeOrders if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { string text; if (t.def.ingestible.ingestCommandString.NullOrEmpty()) { text = "ConsumeThing".Translate(new NamedArgument[] { t.LabelShort }); } else { text = string.Format(t.def.ingestible.ingestCommandString, t.LabelShort); } if (!t.IsSociallyProper(pawn)) { text = text + " (" + "ReservedForPrisoners".Translate() + ")"; } FloatMenuOption item7; if (t.def.IsNonMedicalDrug && pawn.IsTeetotaler()) { item7 = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item7 = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { MenuOptionPriority priority2 = (!(t is Corpse)) ? MenuOptionPriority.Default : MenuOptionPriority.Low; item7 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate() { t.SetForbidden(false, true); Job job = new Job(JobDefOf.Ingest, t); job.count = FoodUtility.WillIngestStackCountOf(pawn, t.def, t.GetStatValue(StatDefOf.Nutrition, true)); pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, priority2, null, null, 0f, null, null), pawn, t, "ReservedBy"); } opts.Add(item7); } // Add equipment commands // Copied from FloatMenuMakerMap.AddHumanlikeOrders if (thing is ThingWithComps equipment && equipment.GetComp <CompEquippable>() != null) { string labelShort = equipment.LabelShort; FloatMenuOption item4; if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { item4 = new FloatMenuOption("CannotEquip".Translate(new NamedArgument[] { labelShort }) + " (" + "IsIncapableOfViolenceLower".Translate(new NamedArgument[] { pawn.LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item4 = new FloatMenuOption("CannotEquip".Translate(new NamedArgument[] { labelShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item4 = new FloatMenuOption("CannotEquip".Translate(new NamedArgument[] { labelShort }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { string text5 = "Equip".Translate(new NamedArgument[] { labelShort }); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text5 = text5 + " " + "EquipWarningBrawler".Translate(); } item4 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text5, delegate() { equipment.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Equip, equipment), JobTag.Misc); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy"); } opts.Add(item4); } // Add clothing commands Apparel apparel = thing as Apparel; if (apparel != null) { FloatMenuOption item5; if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item5 = new FloatMenuOption("CannotWear".Translate(new NamedArgument[] { apparel.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) { item5 = new FloatMenuOption("CannotWear".Translate(new NamedArgument[] { apparel.Label }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { item5 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("ForceWear".Translate(new NamedArgument[] { apparel.LabelShort }), delegate() { apparel.SetForbidden(false, true); Job job = new Job(JobDefOf.Wear, apparel); pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, apparel, "ReservedBy"); } opts.Add(item5); } // Add caravan commands if (pawn.IsFormingCaravan()) { if (thing != null && thing.def.EverHaulable) { Pawn packTarget = GiveToPackAnimalUtility.UsablePackAnimalWithTheMostFreeSpace(pawn) ?? pawn; JobDef jobDef = (packTarget != pawn) ? JobDefOf.GiveToPackAnimal : JobDefOf.TakeInventory; if (!pawn.CanReach(thing, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(new NamedArgument[] { thing.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, thing, 1)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(new NamedArgument[] { thing.Label }) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { LordJob_FormAndSendCaravan lordJob = (LordJob_FormAndSendCaravan)pawn.GetLord().LordJob; float capacityLeft = CaravanFormingUtility.CapacityLeft(lordJob); if (thing.stackCount == 1) { float capacityLeft4 = capacityLeft - thing.GetStatValue(StatDefOf.Mass, true); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravan".Translate(new NamedArgument[] { thing.Label }), capacityLeft4), delegate() { thing.SetForbidden(false, false); Job job = new Job(jobDef, thing); job.count = 1; job.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, thing, "ReservedBy")); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, thing, thing.stackCount)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravanAll".Translate(new NamedArgument[] { thing.Label }) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { float capacityLeft2 = capacityLeft - (float)thing.stackCount * thing.GetStatValue(StatDefOf.Mass, true); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravanAll".Translate(new NamedArgument[] { thing.Label }), capacityLeft2), delegate() { thing.SetForbidden(false, false); Job job = new Job(jobDef, thing); job.count = thing.stackCount; job.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, thing, "ReservedBy")); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("LoadIntoCaravanSome".Translate(new NamedArgument[] { thing.LabelNoCount }), delegate() { int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(packTarget, thing), thing.stackCount); Dialog_Slider window = new Dialog_Slider(delegate(int val) { float capacityLeft3 = capacityLeft - (float)val * thing.GetStatValue(StatDefOf.Mass, true); return(CaravanFormingUtility.AppendOverweightInfo(string.Format("LoadIntoCaravanCount".Translate(new NamedArgument[] { thing.LabelNoCount }), val), capacityLeft3)); }, 1, to, delegate(int count) { thing.SetForbidden(false, false); Job job = new Job(jobDef, thing); job.count = count; job.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, int.MinValue); Find.WindowStack.Add(window); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, thing, "ReservedBy")); } } } } if (opts.Count == 0) { opts.Add(new FloatMenuOption("NoneBrackets".Translate(), null) { Disabled = true }); } return(opts); }
private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (SimpleSidearms.CEOverride) { return; } IntVec3 c = IntVec3.FromVector3(clickPos); if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null) { string labelShort = equipment.LabelShort; string errStr; FloatMenuOption item3; if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { } else if (!equipment.def.IsWeapon) { } else if (!StatCalculator.canCarrySidearm(equipment.def, pawn, out errStr)) { "CannotEquip".Translate(); item3 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + errStr + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); opts.Add(item3); } else { string text2 = "Equip".Translate(labelShort) + "AsSidearm".Translate(); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text2 = text2 + " " + "EquipWarningBrawler".Translate(); } item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, delegate { equipment.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(SidearmsDefOf.EquipSecondary, equipment), JobTag.Misc); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f); PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy"); opts.Add(item3); } } } }
protected void TryCastNextBurstShot() { LocalTargetInfo localTargetInfo = this.currentTarget; if (this.Available() && this.TryCastShot()) { if (this.verbProps.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(this.caster.Position, this.caster.Map, ThingDefOf.Mote_ShotFlash, this.verbProps.muzzleFlashScale); } if (this.verbProps.soundCast != null) { this.verbProps.soundCast.PlayOneShot(new TargetInfo(this.caster.Position, this.caster.Map, false)); } if (this.verbProps.soundCastTail != null) { this.verbProps.soundCastTail.PlayOneShotOnCamera(this.caster.Map); } if (this.CasterIsPawn) { if (this.CasterPawn.thinker != null) { this.CasterPawn.mindState.Notify_EngagedTarget(); } if (this.CasterPawn.mindState != null) { this.CasterPawn.mindState.Notify_AttackedTarget(localTargetInfo); } if (this.CasterPawn.MentalState != null) { this.CasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo); } if (this.TerrainDefSource != null) { this.CasterPawn.meleeVerbs.Notify_UsedTerrainBasedVerb(); } if (!this.CasterPawn.Spawned) { return; } } if (this.verbProps.consumeFuelPerShot > 0f) { CompRefuelable compRefuelable = this.caster.TryGetComp <CompRefuelable>(); if (compRefuelable != null) { compRefuelable.ConsumeFuel(this.verbProps.consumeFuelPerShot); } } this.burstShotsLeft--; } else { this.burstShotsLeft = 0; } if (this.burstShotsLeft > 0) { this.ticksToNextBurstShot = this.verbProps.ticksBetweenBurstShots; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.ticksBetweenBurstShots + 1, this.currentTarget, this)); } } else { this.state = VerbState.Idle; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.AdjustedCooldownTicks(this, this.CasterPawn), this.currentTarget, this)); } if (this.castCompleteCallback != null) { this.castCompleteCallback(); } } }
public override void Impact_Override(Thing hitThing) { Map map = base.Map; base.Impact_Override(hitThing); Pawn pawn = this.launcher as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningBolt.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningBolt_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningBolt.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningBolt_ver"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); pwrVal = pwr.level; verVal = ver.level; this.arcaneDmg = comp.arcaneDmg; if (settingsRef.AIHardMode && !pawn.IsColonistPlayerControlled) { pwrVal = 3; verVal = 3; } bool flag = hitThing != null; if (flag) { int damageAmountBase = Mathf.RoundToInt(this.def.projectile.damageAmountBase + (pwrVal * 9) * this.arcaneDmg); DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown); hitThing.TakeDamage(dinfo); bool flag2 = this.canStartFire && Rand.Range(0f, 1f) > this.startFireChance; if (flag2) { hitThing.TryAttachFire(0.05f); } Pawn hitTarget; bool flag3 = (hitTarget = (hitThing as Pawn)) != null; if (flag3) { this.PostImpactEffects(this.launcher as Pawn, hitTarget); MoteMaker.ThrowMicroSparks(this.destination, base.Map); MoteMaker.MakeStaticMote(this.destination, base.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f); } } else { MoteMaker.MakeStaticMote(this.ExactPosition, base.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f); MoteMaker.ThrowMicroSparks(this.ExactPosition, base.Map); } for (int i = 0; i <= verVal; i++) { SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None); SoundDefOf.Thunder_OnMap.PlayOneShot(info); } CellRect cellRect = CellRect.CenteredOn(hitThing.Position, 2); cellRect.ClipInsideMap(map); for (int i = 0; i < Rand.Range(verVal, verVal * 4); i++) { IntVec3 randomCell = cellRect.RandomCell; this.StaticExplosion(randomCell, map, 0.4f); } }
private static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts, bool drafted, FloatMenuOption[] ___equivalenceGroupTempStorage) { if (pawn.thinker.TryGetMainTreeThinkNode <JobGiver_Work>() != null) { IntVec3 clickCell = IntVec3.FromVector3(clickPos); TargetingParameters targetingParameters = new TargetingParameters(); targetingParameters.canTargetPawns = true; targetingParameters.canTargetBuildings = true; targetingParameters.canTargetItems = true; targetingParameters.mapObjectTargetsMustBeAutoAttackable = false; var ZTracker = ZUtils.ZTracker; foreach (Thing item in GenUI.ThingsUnderMouse(clickPos, 1f, targetingParameters)) { bool flag = false; foreach (WorkTypeDef item2 in DefDatabase <WorkTypeDef> .AllDefsListForReading) { for (int i = 0; i < item2.workGiversByPriority.Count; i++) { WorkGiverDef workGiver2 = item2.workGiversByPriority[i]; if (!drafted || workGiver2.canBeDoneWhileDrafted) { WorkGiver_Scanner workGiver_Scanner = workGiver2.Worker as WorkGiver_Scanner; if (workGiver_Scanner != null && workGiver_Scanner.def.directOrderable) { JobFailReason.Clear(); if ((workGiver_Scanner.PotentialWorkThingRequest.Accepts(item) || (workGiver_Scanner.PotentialWorkThingsGlobal(pawn) != null && workGiver_Scanner.PotentialWorkThingsGlobal(pawn).Contains(item))) && !workGiver_Scanner.ShouldSkip(pawn, forced: true)) { string text = null; Action action = null; PawnCapacityDef pawnCapacityDef = workGiver_Scanner.MissingRequiredCapacity(pawn); if (pawnCapacityDef != null) { text = "CannotMissingHealthActivities".Translate(pawnCapacityDef.label); } else { Map oldMap = pawn.Map; Job job = null; Map dest = null; foreach (var otherMap in ZTracker.GetAllMapsInClosestOrder(oldMap)) { if (workGiver_Scanner is WorkGiver_Refuel scanner1) { job = JobPatches.TryIssueJobPackagePatch.JobOnThing( scanner1, pawn, item, true); } else if (workGiver_Scanner.def.defName == "HaulGeneral" || workGiver_Scanner.def.defName == "HaulCorpses") { job = JobPatches.TryIssueJobPackagePatch.JobOnThing(pawn, item, ref dest); } else if (workGiver_Scanner is WorkGiver_DoBill scanner2) { job = JobPatches.TryIssueJobPackagePatch.JobOnThing( scanner2, pawn, item); } else if (workGiver_Scanner is WorkGiver_ConstructDeliverResourcesToBlueprints scanner3) { job = JobPatches.TryIssueJobPackagePatch.JobOnThing( scanner3, pawn, item); } else if (workGiver_Scanner is WorkGiver_ConstructDeliverResourcesToFrames scanner4) { job = JobPatches.TryIssueJobPackagePatch.JobOnThing( scanner4, pawn, item); } else { job = workGiver_Scanner.HasJobOnThing(pawn, item, forced: true) ? workGiver_Scanner.JobOnThing(pawn, item, forced: true) : null; } if (job != null) { break; } } if (job == null) { if (JobFailReason.HaveReason) { text = (JobFailReason.CustomJobString.NullOrEmpty() ? ((string)"CannotGenericWork".Translate(workGiver_Scanner.def.verb, item.LabelShort, item)) : ((string)"CannotGenericWorkCustom".Translate(JobFailReason.CustomJobString))); text = text + ": " + JobFailReason.Reason.CapitalizeFirst(); } else { if (!item.IsForbidden(pawn)) { continue; } text = (item.Position.InAllowedArea(pawn) ? ((string)"CannotPrioritizeForbidden".Translate(item.Label, item)) : ((string)("CannotPrioritizeForbiddenOutsideAllowedArea".Translate() + ": " + pawn.playerSettings.EffectiveAreaRestriction.Label))); } } else { WorkTypeDef workType = workGiver_Scanner.def.workType; if (pawn.WorkTagIsDisabled(workGiver_Scanner.def.workTags)) { text = "CannotPrioritizeWorkGiverDisabled".Translate(workGiver_Scanner.def.label); } else if (pawn.jobs.curJob != null && pawn.jobs.curJob.JobIsSameAs(job)) { text = "CannotGenericAlreadyAm".Translate(workGiver_Scanner.PostProcessedGerund(job), item.LabelShort, item); } else if (pawn.workSettings.GetPriority(workType) == 0) { text = (pawn.WorkTypeIsDisabled(workType) ? ((string)"CannotPrioritizeWorkTypeDisabled".Translate(workType.gerundLabel)) : ((!"CannotPrioritizeNotAssignedToWorkType".CanTranslate()) ? ((string)"CannotPrioritizeWorkTypeDisabled".Translate(workType.pawnLabel)) : ((string)"CannotPrioritizeNotAssignedToWorkType".Translate(workType.gerundLabel)))); } else if (job.def == JobDefOf.Research && item is Building_ResearchBench) { text = "CannotPrioritizeResearch".Translate(); } else if (item.IsForbidden(pawn)) { text = (item.Position.InAllowedArea(pawn) ? ((string)"CannotPrioritizeForbidden".Translate(item.Label, item)) : ((string)("CannotPrioritizeForbiddenOutsideAllowedArea".Translate() + ": " + pawn.playerSettings.EffectiveAreaRestriction.Label))); } else if (!pawn.CanReach(item, workGiver_Scanner.PathEndMode, Danger.Deadly)) { text = (item.Label + ": " + "NoPath".Translate().CapitalizeFirst()).CapitalizeFirst(); } else { text = "PrioritizeGeneric".Translate(workGiver_Scanner.PostProcessedGerund(job), item.Label); Job localJob2 = job; WorkGiver_Scanner localScanner2 = workGiver_Scanner; job.workGiverDef = workGiver_Scanner.def; action = delegate { if (!ZTracker.jobTracker.ContainsKey(pawn)) { ZTracker.jobTracker[pawn] = new JobTracker(); } if (dest != null) { ZTracker.BuildJobListFor(pawn, dest, job); } else { ZTracker.BuildJobListFor(pawn, oldMap, job); } pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); if (workGiver2.forceMote != null) { MoteMaker.MakeStaticMote(clickCell, pawn.Map, workGiver2.forceMote); } }; } } } if (DebugViewSettings.showFloatMenuWorkGivers) { text += $" (from {workGiver2.defName})"; } FloatMenuOption menuOption = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, action), pawn, item); if (drafted && workGiver2.autoTakeablePriorityDrafted != -1) { menuOption.autoTakeable = true; menuOption.autoTakeablePriority = workGiver2.autoTakeablePriorityDrafted; } if (!opts.Any((FloatMenuOption op) => op.Label == menuOption.Label)) { if (workGiver2.equivalenceGroup != null) { if (___equivalenceGroupTempStorage[workGiver2.equivalenceGroup.index] == null || (___equivalenceGroupTempStorage[workGiver2.equivalenceGroup.index].Disabled && !menuOption.Disabled)) { ___equivalenceGroupTempStorage[workGiver2.equivalenceGroup.index] = menuOption; flag = true; } } else { opts.Add(menuOption); } } } } } } } if (flag) { for (int j = 0; j < ___equivalenceGroupTempStorage.Length; j++) { if (___equivalenceGroupTempStorage[j] != null) { opts.Add(___equivalenceGroupTempStorage[j]); ___equivalenceGroupTempStorage[j] = null; } } } } foreach (WorkTypeDef item3 in DefDatabase <WorkTypeDef> .AllDefsListForReading) { for (int k = 0; k < item3.workGiversByPriority.Count; k++) { WorkGiverDef workGiver = item3.workGiversByPriority[k]; if (!drafted || workGiver.canBeDoneWhileDrafted) { WorkGiver_Scanner workGiver_Scanner2 = workGiver.Worker as WorkGiver_Scanner; if (workGiver_Scanner2 != null && workGiver_Scanner2.def.directOrderable) { JobFailReason.Clear(); if (workGiver_Scanner2.PotentialWorkCellsGlobal(pawn).Contains(clickCell) && !workGiver_Scanner2.ShouldSkip(pawn, forced: true)) { Action action2 = null; string label = null; PawnCapacityDef pawnCapacityDef2 = workGiver_Scanner2.MissingRequiredCapacity(pawn); if (pawnCapacityDef2 != null) { label = "CannotMissingHealthActivities".Translate(pawnCapacityDef2.label); } else { Job job2 = workGiver_Scanner2.HasJobOnCell(pawn, clickCell, forced: true) ? workGiver_Scanner2.JobOnCell(pawn, clickCell, forced: true) : null; if (job2 == null) { if (JobFailReason.HaveReason) { if (!JobFailReason.CustomJobString.NullOrEmpty()) { label = "CannotGenericWorkCustom".Translate(JobFailReason.CustomJobString); } else { label = "CannotGenericWork".Translate(workGiver_Scanner2.def.verb, "AreaLower".Translate()); } label = label + ": " + JobFailReason.Reason.CapitalizeFirst(); } else { if (!clickCell.IsForbidden(pawn)) { continue; } if (!clickCell.InAllowedArea(pawn)) { label = "CannotPrioritizeForbiddenOutsideAllowedArea".Translate() + ": " + pawn.playerSettings.EffectiveAreaRestriction.Label; } else { label = "CannotPrioritizeCellForbidden".Translate(); } } } else { WorkTypeDef workType2 = workGiver_Scanner2.def.workType; if (pawn.jobs.curJob != null && pawn.jobs.curJob.JobIsSameAs(job2)) { label = "CannotGenericAlreadyAmCustom".Translate(workGiver_Scanner2.PostProcessedGerund(job2)); } else if (pawn.workSettings.GetPriority(workType2) == 0) { if (pawn.WorkTypeIsDisabled(workType2)) { label = "CannotPrioritizeWorkTypeDisabled".Translate(workType2.gerundLabel); } else if ("CannotPrioritizeNotAssignedToWorkType".CanTranslate()) { label = "CannotPrioritizeNotAssignedToWorkType".Translate(workType2.gerundLabel); } else { label = "CannotPrioritizeWorkTypeDisabled".Translate(workType2.pawnLabel); } } else if (clickCell.IsForbidden(pawn)) { if (!clickCell.InAllowedArea(pawn)) { label = "CannotPrioritizeForbiddenOutsideAllowedArea".Translate() + ": " + pawn.playerSettings.EffectiveAreaRestriction.Label; } else { label = "CannotPrioritizeCellForbidden".Translate(); } } else if (!pawn.CanReach(clickCell, PathEndMode.Touch, Danger.Deadly)) { label = "AreaLower".Translate().CapitalizeFirst() + ": " + "NoPath".Translate().CapitalizeFirst(); } else { label = "PrioritizeGeneric".Translate(workGiver_Scanner2.PostProcessedGerund(job2), "AreaLower".Translate()); Job localJob = job2; WorkGiver_Scanner localScanner = workGiver_Scanner2; job2.workGiverDef = workGiver_Scanner2.def; action2 = delegate { if (pawn.jobs.TryTakeOrderedJobPrioritizedWork(localJob, localScanner, clickCell) && workGiver.forceMote != null) { MoteMaker.MakeStaticMote(clickCell, pawn.Map, workGiver.forceMote); } }; } } } if (!opts.Any((FloatMenuOption op) => op.Label == label.TrimEnd())) { FloatMenuOption floatMenuOption = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action2), pawn, clickCell); if (drafted && workGiver.autoTakeablePriorityDrafted != -1) { floatMenuOption.autoTakeable = true; floatMenuOption.autoTakeablePriority = workGiver.autoTakeablePriorityDrafted; } opts.Add(floatMenuOption); } } } } } } } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; try { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); //MightPowerSkill pwr = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_AntiArmor.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AntiArmor_pwr"); verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_AntiArmor, "TM_AntiArmor", "_ver", true); pwrVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_AntiArmor, "TM_AntiArmor", "_pwr", true); //MightPowerSkill ver = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_AntiArmor.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AntiArmor_ver"); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); //ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); //pwrVal = pwr.level; //verVal = ver.level; //if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // MightPowerSkill mpwr = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); // MightPowerSkill mver = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); // pwrVal = mpwr.level; // verVal = mver.level; //} //if (settingsRef.AIHardMode && !pawn.IsColonist) //{ // pwrVal = 3; // verVal = 3; //} this.Initialize(base.Position, pawn); if (victim != null && !victim.Dead && Rand.Chance(this.launcher.GetStatValue(StatDefOf.ShootingAccuracyPawn, true))) { int dmg = GetWeaponDmg(pawn); bool flagFleshType = victim.RaceProps.FleshType != FleshTypeDefOf.Normal; float num = TM_Calc.GetOverallArmor(victim, StatDefOf.ArmorRating_Sharp); bool flagArmorAmount = num > 1f; if (flagArmorAmount || flagFleshType) { MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), map); TM_Action.DamageEntities(victim, null, dmg, 1.5f, this.def.projectile.damageDef, pawn); MoteMaker.MakeStaticMote(victim.Position, pawn.Map, ThingDefOf.Mote_ExplosionFlash, 4f); TM_Action.DamageEntities(victim, null, GetWeaponDmgMech(pawn, dmg), 1.5f, this.def.projectile.damageDef, pawn); MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), map); for (int i = 0; i < 1 + verVal; i++) { GenExplosion.DoExplosion(newPos, map, Rand.Range(.1f * (1 + verVal), .3f * (1 + verVal)), DamageDefOf.Bomb, this.launcher, this.def.projectile.GetDamageAmount(1, null) / 4 * (1 + verVal), .4f, SoundDefOf.MetalHitImportant, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true); GenExplosion.DoExplosion(newPos, map, Rand.Range(.2f * (1 + verVal), .4f * (1 + verVal)), DamageDefOf.Stun, this.launcher, this.def.projectile.GetDamageAmount(1, null) / 2 * (1 + verVal), .4f, SoundDefOf.MetalHitImportant, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true); newPos = GetNewPos(newPos, pawn.Position.x <= victim.Position.x, pawn.Position.z <= victim.Position.z, false, 0, 0, xProb, 1 - xProb); MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), base.Map); MoteMaker.ThrowDustPuff(newPos, map, Rand.Range(1.2f, 2.4f)); } DestroyArmor(victim, 4, 100); } else { TM_Action.DamageEntities(victim, null, dmg, 1.5f, this.def.projectile.damageDef, pawn); } } else { Log.Message("No valid target for anti armor shot or missed"); } } catch (NullReferenceException) { // } }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn selPawn) { foreach (FloatMenuOption fmo in base.CompFloatMenuOptions(selPawn)) { yield return(fmo); } // Only show float menu for ThingDef-names 'Gun_xxxx' if (!(Props.allowedDefSubName.NullOrEmpty() || Props.allowedDefSubName == "*") && !parent.def.defName.Contains(Props.allowedDefSubName)) { yield break; } if (!InNeedOfRepairs) { //string debugstring = " => " + parent.HitPoints.ToString() + " / " + parent.MaxHitPoints.ToString(); //yield return FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("WeaponRepair_NoRepairNeeded".Translate(), null), selPawn, parent); yield break; } if (GetAvailableTwinThing(selPawn) == null) { //yield return FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("WeaponRepair_NoWeaponTwinFound".Translate(), null), selPawn, parent); yield break; } if (GetValidWorkTableCount(selPawn) == 0) { yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("WeaponRepair_NoRepairTableFound".Translate(), null), selPawn, parent)); yield break; } // Check if this is reservable by the pawn if (!selPawn.CanReserve(parent, 1)) { yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("CannotUseReserved".Translate(), null), selPawn, parent)); yield break; } // Check if this is reachable by the pawn if (!selPawn.CanReach(parent, PathEndMode.Touch, Danger.Deadly)) { yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("CannotUseNoPath".Translate(), null), selPawn, parent)); yield break; } if (selPawn.workSettings.GetPriority(Props.workTypeDef) == 0) { string label = "WeaponRepair_NotAssignedToWorkType".Translate(new object[] { Props.workTypeDef.gerundLabel }); yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, null), selPawn, parent)); yield break; } Action hoverAction = delegate { Thing twin = GetAvailableTwinThing(selPawn); MoteMaker.MakeStaticMote(twin.Position, parent.Map, ThingDefOf.Mote_FeedbackGoto); }; Action giveRepairJob = delegate { TryGiveWeaponRepairJobToPawn(selPawn); }; yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("WeaponRepair_RepairWeapon".Translate(), giveRepairJob, MenuOptionPriority.Default, hoverAction), selPawn, parent)); }
protected void TryCastNextBurstShot() { LocalTargetInfo localTargetInfo = this.currentTarget; //On successful firing of the beam if (this.TryCastShot()) { if (this.verbProps.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(this.caster.Position, this.caster.Map, ThingDefOf.Mote_ShotFlash, this.verbProps.muzzleFlashScale); } if (this.verbProps.soundCast != null) { this.verbProps.soundCast.PlayOneShot(new TargetInfo(this.caster.Position, this.caster.Map, false)); } if (this.verbProps.soundCastTail != null) { this.verbProps.soundCastTail.PlayOneShotOnCamera(this.caster.Map); } if (this.CasterIsPawn) { if (this.CasterPawn.thinker != null) { this.CasterPawn.mindState.lastEngageTargetTick = Find.TickManager.TicksGame; } if (this.CasterPawn.mindState != null) { this.CasterPawn.mindState.lastAttackTargetTick = Find.TickManager.TicksGame; this.CasterPawn.mindState.lastAttackedTarget = localTargetInfo; } if (this.CasterPawn.MentalState != null) { this.CasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo); } if (!this.CasterPawn.Spawned) { return; } } this.burstShotsLeft--; } else { this.burstShotsLeft = 0; } if (this.burstShotsLeft > 0) { this.ticksToNextBurstShot = this.verbProps.ticksBetweenBurstShots; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.ticksBetweenBurstShots + 1, this.currentTarget, this)); } } else { this.state = VerbState.Idle; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.AdjustedCooldownTicks(this, this.CasterPawn, this.ownerEquipment), this.currentTarget, this)); } if (this.castCompleteCallback != null) { this.castCompleteCallback(); } } }
public static void AddHumanlikeOrders_PostFix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); ThingWithComps slotLoadable = pawn.equipment.AllEquipmentListForReading.FirstOrDefault((ThingWithComps x) => x.TryGetComp <CompSlotLoadable>() != null); if (slotLoadable != null) { CompSlotLoadable compSlotLoadable = slotLoadable.GetComp <CompSlotLoadable>(); if (compSlotLoadable != null) { List <Thing> thingList = c.GetThingList(pawn.Map); foreach (SlotLoadable slot in compSlotLoadable.Slots) { Thing loadableThing = thingList.FirstOrDefault((Thing y) => slot.CanLoad(y.def)); if (loadableThing != null) { FloatMenuOption itemSlotLoadable; string labelShort = loadableThing.Label; if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { itemSlotLoadable = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(loadableThing, PathEndMode.ClosestTouch, Danger.Deadly)) { itemSlotLoadable = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReserve(loadableThing, 1)) { itemSlotLoadable = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "ReservedBy".Translate(new object[] { pawn.Map.physicalInteractionReservationManager.FirstReserverOf(loadableThing).LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { string text2 = "Equip".Translate(new object[] { labelShort }); itemSlotLoadable = new FloatMenuOption(text2, delegate { loadableThing.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(DefDatabase <JobDef> .GetNamed("GatherSlotItem"), loadableThing)); MoteMaker.MakeStaticMote(loadableThing.DrawPos, loadableThing.Map, ThingDefOf.Mote_FeedbackEquip, 1f); //PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null); } opts.Add(itemSlotLoadable); } } } } }
public static bool AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (Thing thing in c.GetThingList(pawn.Map)) { Pawn pawn2; if ((pawn2 = (thing as Pawn)) != null) { Lord lord = pawn2.GetLord(); if (lord != null && lord.CurLordToil != null) { IEnumerable <FloatMenuOption> enumerable = lord.CurLordToil.ExtraFloatMenuOptions(pawn2, pawn); if (enumerable != null) { foreach (FloatMenuOption item8 in enumerable) { opts.Add(item8); } } } } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo item9 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForArrest(pawn), thingsOnly: true)) { bool flag = item9.HasThing && item9.Thing is Pawn && ((Pawn)item9.Thing).IsWildMan(); if (pawn.Drafted || flag) { if (item9.Thing is Pawn && (pawn.InSameExtraFaction((Pawn)item9.Thing, ExtraFactionType.HomeFaction) || pawn.InSameExtraFaction((Pawn)item9.Thing, ExtraFactionType.MiniFaction))) { opts.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "SameFaction".Translate((Pawn)item9.Thing), null)); } else if (!pawn.CanReach(item9, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else { Pawn pTarg2 = (Pawn)item9.Thing; Action action = delegate { Building_Bed building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false); if (building_Bed3 == null) { building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed3 == null) { Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg2, MessageTypeDefOf.RejectInput, historical: false); } else { Job job19 = JobMaker.MakeJob(JobDefOf.Arrest, pTarg2, building_Bed3); job19.count = 1; pawn.jobs.TryTakeOrderedJob(job19); if (pTarg2.Faction != null && ((pTarg2.Faction != Faction.OfPlayer && !pTarg2.Faction.Hidden) || pTarg2.IsQuestLodger())) { TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies, pTarg2.GetAcceptArrestChance(pawn).ToStringPercent()); } } }; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("TryToArrest".Translate(item9.Thing.LabelCap, item9.Thing, pTarg2.GetAcceptArrestChance(pawn).ToStringPercent()), action, MenuOptionPriority.High, null, item9.Thing), pawn, pTarg2)); } } } } foreach (Thing thing2 in c.GetThingList(pawn.Map)) { Thing t = thing2; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { string text = (!t.def.ingestible.ingestCommandString.NullOrEmpty()) ? string.Format(t.def.ingestible.ingestCommandString, t.LabelShort) : ((string)"ConsumeThing".Translate(t.LabelShort, t)); if (!t.IsSociallyProper(pawn)) { text = text + ": " + "ReservedForPrisoners".Translate().CapitalizeFirst(); } FloatMenuOption floatMenuOption; if (t.def.IsNonMedicalDrug && pawn.IsTeetotaler()) { floatMenuOption = new FloatMenuOption(text + ": " + TraitDefOf.DrugDesire.DataAtDegree(-1).GetLabelCapFor(pawn), null); } else if (FoodUtility.InappropriateForTitle(t.def, pawn, allowIfStarving: true)) { floatMenuOption = new FloatMenuOption(text + ": " + "FoodBelowTitleRequirements".Translate(pawn.royalty.MostSeniorTitle.def.GetLabelFor(pawn)), null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly)) { floatMenuOption = new FloatMenuOption(text + ": " + "NoPath".Translate().CapitalizeFirst(), null); } else { MenuOptionPriority priority = (t is Corpse) ? MenuOptionPriority.Low : MenuOptionPriority.Default; int maxAmountToPickup = FoodUtility.GetMaxAmountToPickup(t, pawn, FoodUtility.WillIngestStackCountOf(pawn, t.def, t.GetStatValue(StatDefOf.Nutrition))); floatMenuOption = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate { int maxAmountToPickup2 = FoodUtility.GetMaxAmountToPickup(t, pawn, FoodUtility.WillIngestStackCountOf(pawn, t.def, t.GetStatValue(StatDefOf.Nutrition))); if (maxAmountToPickup2 != 0) { t.SetForbidden(value: false); Job job18 = JobMaker.MakeJob(JobDefOf.Ingest, t); job18.count = maxAmountToPickup2; pawn.jobs.TryTakeOrderedJob(job18); } }, priority), pawn, t); if (maxAmountToPickup == 0) { floatMenuOption.action = null; } } opts.Add(floatMenuOption); } } foreach (LocalTargetInfo item10 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForQuestPawnsWhoWillJoinColony(pawn), thingsOnly: true)) { Pawn toHelpPawn = (Pawn)item10.Thing; FloatMenuOption item4 = pawn.CanReach(item10, PathEndMode.Touch, Danger.Deadly) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(toHelpPawn.IsPrisoner ? "FreePrisoner".Translate() : "OfferHelp".Translate(), delegate { pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.OfferHelp, toHelpPawn)); }, MenuOptionPriority.RescueOrCapture, null, toHelpPawn), pawn, toHelpPawn) : new FloatMenuOption("CannotGoNoPath".Translate(), null); opts.Add(item4); } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (Thing thing3 in c.GetThingList(pawn.Map)) { Corpse corpse = thing3 as Corpse; if (corpse != null && corpse.IsInValidStorage()) { StoragePriority priority2 = StoreUtility.CurrentHaulDestinationOf(corpse).GetStoreSettings().Priority; if (StoreUtility.TryFindBestBetterNonSlotGroupStorageFor(corpse, pawn, pawn.Map, priority2, Faction.OfPlayer, out IHaulDestination haulDestination, acceptSamePriority: true) && haulDestination.GetStoreSettings().Priority == priority2 && haulDestination is Building_Grave) { Building_Grave grave = haulDestination as Building_Grave; string label = "PrioritizeGeneric".Translate("Burying".Translate(), corpse.Label); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, delegate { pawn.jobs.TryTakeOrderedJob(HaulAIUtility.HaulToContainerJob(pawn, corpse, grave)); }), pawn, new LocalTargetInfo(corpse))); } } } foreach (LocalTargetInfo item11 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true)) { Pawn victim3 = (Pawn)item11.Thing; if (!victim3.InBed() && pawn.CanReserveAndReach(victim3, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && !victim3.mindState.WillJoinColonyIfRescued) { if (!victim3.IsPrisonerOfColony && (!victim3.InMentalState || victim3.health.hediffSet.HasHediff(HediffDefOf.Scaria)) && (victim3.Faction == Faction.OfPlayer || victim3.Faction == null || !victim3.Faction.HostileTo(Faction.OfPlayer))) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Rescue".Translate(victim3.LabelCap, victim3), delegate { Building_Bed building_Bed2 = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false); if (building_Bed2 == null) { building_Bed2 = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed2 == null) { string t3 = (!victim3.RaceProps.Animal) ? ((string)"NoNonPrisonerBed".Translate()) : ((string)"NoAnimalBed".Translate()); Messages.Message("CannotRescue".Translate() + ": " + t3, victim3, MessageTypeDefOf.RejectInput, historical: false); } else { Job job17 = JobMaker.MakeJob(JobDefOf.Rescue, victim3, building_Bed2); job17.count = 1; pawn.jobs.TryTakeOrderedJob(job17); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); } }, MenuOptionPriority.RescueOrCapture, null, victim3), pawn, victim3)); } if (victim3.RaceProps.Humanlike && (victim3.InMentalState || victim3.Faction != Faction.OfPlayer || (victim3.Downed && (victim3.guilt.IsGuilty || victim3.IsPrisonerOfColony)))) { TaggedString taggedString = "Capture".Translate(victim3.LabelCap, victim3); if (victim3.Faction != null && victim3.Faction != Faction.OfPlayer && !victim3.Faction.Hidden && !victim3.Faction.HostileTo(Faction.OfPlayer) && !victim3.IsPrisonerOfColony) { taggedString += ": " + "AngersFaction".Translate().CapitalizeFirst(); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(taggedString, delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false); if (building_Bed == null) { building_Bed = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim3, MessageTypeDefOf.RejectInput, historical: false); } else { Job job16 = JobMaker.MakeJob(JobDefOf.Capture, victim3, building_Bed); job16.count = 1; pawn.jobs.TryTakeOrderedJob(job16); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); if (victim3.Faction != null && victim3.Faction != Faction.OfPlayer && !victim3.Faction.Hidden && !victim3.Faction.HostileTo(Faction.OfPlayer) && !victim3.IsPrisonerOfColony) { Messages.Message("MessageCapturingWillAngerFaction".Translate(victim3.Named("PAWN")).AdjustedFor(victim3), victim3, MessageTypeDefOf.CautionInput, historical: false); } } }, MenuOptionPriority.RescueOrCapture, null, victim3), pawn, victim3)); } } } foreach (LocalTargetInfo item12 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true)) { LocalTargetInfo localTargetInfo = item12; Pawn victim2 = (Pawn)localTargetInfo.Thing; if (victim2.Downed && pawn.CanReserveAndReach(victim2, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, ignoreOtherReservations: true) != null) { string text2 = "CarryToCryptosleepCasket".Translate(localTargetInfo.Thing.LabelCap, localTargetInfo.Thing); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action2 = delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn); if (building_CryptosleepCasket == null) { building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, ignoreOtherReservations: true); } if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim2, MessageTypeDefOf.RejectInput, historical: false); } else { Job job15 = JobMaker.MakeJob(jDef, victim2, building_CryptosleepCasket); job15.count = 1; pawn.jobs.TryTakeOrderedJob(job15); } }; if (victim2.IsQuestLodger()) { text2 += " (" + "CryptosleepCasketGuestsNotAllowed".Translate() + ")"; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, null, MenuOptionPriority.Default, null, victim2), pawn, victim2)); } else if (victim2.GetExtraHostFaction() != null) { text2 += " (" + "CryptosleepCasketGuestPrisonersNotAllowed".Translate() + ")"; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, null, MenuOptionPriority.Default, null, victim2), pawn, victim2)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, action2, MenuOptionPriority.Default, null, victim2), pawn, victim2)); } } } if (ModsConfig.RoyaltyActive) { foreach (LocalTargetInfo item13 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForShuttle(pawn), thingsOnly: true)) { LocalTargetInfo localTargetInfo2 = item13; Pawn victim = (Pawn)localTargetInfo2.Thing; Predicate <Thing> validator = (Thing thing) => thing.TryGetComp <CompShuttle>()?.IsAllowedNow(victim) ?? false; Thing shuttleThing = GenClosest.ClosestThingReachable(victim.Position, victim.Map, ThingRequest.ForDef(ThingDefOf.Shuttle), PathEndMode.ClosestTouch, TraverseParms.For(pawn), 9999f, validator); if (shuttleThing != null && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && !pawn.WorkTypeIsDisabled(WorkTypeDefOf.Hauling)) { string label2 = "CarryToShuttle".Translate(localTargetInfo2.Thing); Action action3 = delegate { CompShuttle compShuttle = shuttleThing.TryGetComp <CompShuttle>(); if (!compShuttle.LoadingInProgressOrReadyToLaunch) { TransporterUtility.InitiateLoading(Gen.YieldSingle(compShuttle.Transporter)); } Job job14 = JobMaker.MakeJob(JobDefOf.HaulToTransporter, victim, shuttleThing); job14.ignoreForbidden = true; job14.count = 1; pawn.jobs.TryTakeOrderedJob(job14); }; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label2, action3), pawn, victim)); } } } } foreach (LocalTargetInfo item14 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForStrip(pawn), thingsOnly: true)) { LocalTargetInfo stripTarg = item14; FloatMenuOption item5 = pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly) ? ((stripTarg.Pawn == null || !stripTarg.Pawn.HasExtraHomeFaction()) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Strip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing), delegate { stripTarg.Thing.SetForbidden(value: false, warnOnFail: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Strip, stripTarg)); StrippableUtility.CheckSendStrippingImpactsGoodwillMessage(stripTarg.Thing); }), pawn, stripTarg) : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null)) : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing) + ": " + "NoPath".Translate().CapitalizeFirst(), null); opts.Add(item5); } ThingWithComps equipment; if (pawn.equipment != null) { equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null) { string labelShort = equipment.LabelShort; FloatMenuOption item6; string cantReason; if (equipment.def.IsWeapon && pawn.WorkTagIsDisabled(WorkTags.Violent)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort, pawn), null); } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "NoPath".Translate().CapitalizeFirst(), null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "Incapable".Translate(), null); } else if (equipment.IsBurning()) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "BurningLower".Translate(), null); } else if (pawn.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(equipment, pawn)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null); } else if (!EquipmentUtility.CanEquip_NewTmp(equipment, pawn, out cantReason, checkBonded: false)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + cantReason.CapitalizeFirst(), null); } else { string text3 = "Equip".Translate(labelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text3 += " " + "EquipWarningBrawler".Translate(); } if (EquipmentUtility.AlreadyBondedToWeapon(equipment, pawn)) { text3 += " " + "BladelinkAlreadyBonded".Translate(); TaggedString dialogText = "BladelinkAlreadyBondedDialog".Translate(pawn.Named("PAWN"), equipment.Named("WEAPON"), pawn.equipment.bondedWeapon.Named("BONDEDWEAPON")); item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate { Find.WindowStack.Add(new Dialog_MessageBox(dialogText)); }, MenuOptionPriority.High), pawn, equipment); } else { item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate { string personaWeaponConfirmationText = EquipmentUtility.GetPersonaWeaponConfirmationText(equipment, pawn); if (!personaWeaponConfirmationText.NullOrEmpty()) { Find.WindowStack.Add(new Dialog_MessageBox(personaWeaponConfirmationText, "Yes".Translate(), delegate { Equip(); }, "No".Translate())); } else { Equip(); } }, MenuOptionPriority.High), pawn, equipment); } } opts.Add(item6); } } foreach (Pair <CompReloadable, Thing> item15 in ReloadableUtility.FindPotentiallyReloadableGear(pawn, c.GetThingList(pawn.Map))) { CompReloadable comp = item15.First; Thing second = item15.Second; string text4 = "Reload".Translate(comp.parent.Named("GEAR"), NamedArgumentUtility.Named(comp.AmmoDef, "AMMO")) + " (" + comp.LabelRemaining + ")"; List <Thing> chosenAmmo; if (!pawn.CanReach(second, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption(text4 + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (!comp.NeedsReload(allowForcedReload: true)) { opts.Add(new FloatMenuOption(text4 + ": " + "ReloadFull".Translate(), null)); } else if ((chosenAmmo = ReloadableUtility.FindEnoughAmmo(pawn, second.Position, comp, forceReload: true)) == null) { opts.Add(new FloatMenuOption(text4 + ": " + "ReloadNotEnough".Translate(), null)); } else { Action action4 = delegate { pawn.jobs.TryTakeOrderedJob(JobGiver_Reload.MakeReloadJob(comp, chosenAmmo)); }; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, action4), pawn, second)); } } if (pawn.apparel != null) { if (pawn.Map.thingGrid.ThingAt(c, ThingCategory.Item) is Apparel apparel) { string key = "CannotWear"; string key2 = "ForceWear"; if (apparel.def.apparel.LastLayer.IsUtilityLayer) { key = "CannotEquipApparel"; key2 = "ForceEquipApparel"; } string cantReason2; FloatMenuOption item7 = (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly)) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "NoPath".Translate().CapitalizeFirst(), null) : (apparel.IsBurning() ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "Burning".Translate(), null) : (pawn.apparel.WouldReplaceLockedApparel(apparel) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "WouldReplaceLockedApparel".Translate().CapitalizeFirst(), null) : ((!ApparelUtility.HasPartsToWear(pawn, apparel.def)) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "CannotWearBecauseOfMissingBodyParts".Translate(), null) : (EquipmentUtility.CanEquip_NewTmp(apparel, pawn, out cantReason2) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(key2.Translate(apparel.LabelShort, apparel), delegate { apparel.SetForbidden(value: false); Job job13 = JobMaker.MakeJob(JobDefOf.Wear, apparel); pawn.jobs.TryTakeOrderedJob(job13); }, MenuOptionPriority.High), pawn, apparel) : new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + cantReason2, null))))); opts.Add(item7); } } if (pawn.IsFormingCaravan()) { Thing item3 = c.GetFirstItem(pawn.Map); if (item3 != null && item3.def.EverHaulable && item3.def.canLoadIntoCaravan) { Pawn packTarget = GiveToPackAnimalUtility.UsablePackAnimalWithTheMostFreeSpace(pawn) ?? pawn; JobDef jobDef = (packTarget == pawn) ? JobDefOf.TakeInventory : JobDefOf.GiveToPackAnimal; if (!pawn.CanReach(item3, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(item3.Label, item3) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, item3, 1)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(item3.Label, item3) + ": " + "TooHeavy".Translate(), null)); } else { LordJob_FormAndSendCaravan lordJob = (LordJob_FormAndSendCaravan)pawn.GetLord().LordJob; float capacityLeft = CaravanFormingUtility.CapacityLeft(lordJob); if (item3.stackCount == 1) { float capacityLeft2 = capacityLeft - item3.GetStatValue(StatDefOf.Mass); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravan".Translate(item3.Label, item3), capacityLeft2), delegate { item3.SetForbidden(value: false, warnOnFail: false); Job job12 = JobMaker.MakeJob(jobDef, item3); job12.count = 1; job12.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job12); }, MenuOptionPriority.High), pawn, item3)); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, item3, item3.stackCount)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravanAll".Translate(item3.Label, item3) + ": " + "TooHeavy".Translate(), null)); } else { float capacityLeft3 = capacityLeft - (float)item3.stackCount * item3.GetStatValue(StatDefOf.Mass); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravanAll".Translate(item3.Label, item3), capacityLeft3), delegate { item3.SetForbidden(value: false, warnOnFail: false); Job job11 = JobMaker.MakeJob(jobDef, item3); job11.count = item3.stackCount; job11.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job11); }, MenuOptionPriority.High), pawn, item3)); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("LoadIntoCaravanSome".Translate(item3.LabelNoCount, item3), delegate { int to3 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(packTarget, item3), item3.stackCount); Dialog_Slider window3 = new Dialog_Slider(delegate(int val) { float capacityLeft4 = capacityLeft - (float)val * item3.GetStatValue(StatDefOf.Mass); return(CaravanFormingUtility.AppendOverweightInfo(string.Format("LoadIntoCaravanCount".Translate(item3.LabelNoCount, item3), val), capacityLeft4)); }, 1, to3, delegate(int count) { item3.SetForbidden(value: false, warnOnFail: false); Job job10 = JobMaker.MakeJob(jobDef, item3); job10.count = count; job10.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job10); }); Find.WindowStack.Add(window3); }, MenuOptionPriority.High), pawn, item3)); } } } } if (!pawn.Map.IsPlayerHome && !pawn.IsFormingCaravan()) { Thing item2 = c.GetFirstItem(pawn.Map); if (item2 != null && item2.def.EverHaulable) { if (!pawn.CanReach(item2, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(item2.Label, item2) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item2, 1)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(item2.Label, item2) + ": " + "TooHeavy".Translate(), null)); } else if (item2.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(item2.Label, item2), delegate { item2.SetForbidden(value: false, warnOnFail: false); Job job9 = JobMaker.MakeJob(JobDefOf.TakeInventory, item2); job9.count = 1; job9.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job9); }, MenuOptionPriority.High), pawn, item2)); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item2, item2.stackCount)) { opts.Add(new FloatMenuOption("CannotPickUpAll".Translate(item2.Label, item2) + ": " + "TooHeavy".Translate(), null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(item2.Label, item2), delegate { item2.SetForbidden(value: false, warnOnFail: false); Job job8 = JobMaker.MakeJob(JobDefOf.TakeInventory, item2); job8.count = item2.stackCount; job8.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job8); }, MenuOptionPriority.High), pawn, item2)); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpSome".Translate(item2.LabelNoCount, item2), delegate { int to2 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(pawn, item2), item2.stackCount); Dialog_Slider window2 = new Dialog_Slider("PickUpCount".Translate(item2.LabelNoCount, item2), 1, to2, delegate(int count) { item2.SetForbidden(value: false, warnOnFail: false); Job job7 = JobMaker.MakeJob(JobDefOf.TakeInventory, item2); job7.count = count; job7.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job7); }); Find.WindowStack.Add(window2); }, MenuOptionPriority.High), pawn, item2)); } } } if (!pawn.Map.IsPlayerHome && !pawn.IsFormingCaravan()) { Thing item = c.GetFirstItem(pawn.Map); if (item != null && item.def.EverHaulable) { Pawn bestPackAnimal = GiveToPackAnimalUtility.UsablePackAnimalWithTheMostFreeSpace(pawn); if (bestPackAnimal != null) { if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item.Label, item) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, 1)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item.Label, item) + ": " + "TooHeavy".Translate(), null)); } else if (item.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimal".Translate(item.Label, item), delegate { item.SetForbidden(value: false, warnOnFail: false); Job job6 = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item); job6.count = 1; pawn.jobs.TryTakeOrderedJob(job6); }, MenuOptionPriority.High), pawn, item)); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, item.stackCount)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimalAll".Translate(item.Label, item) + ": " + "TooHeavy".Translate(), null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalAll".Translate(item.Label, item), delegate { item.SetForbidden(value: false, warnOnFail: false); Job job5 = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item); job5.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job5); }, MenuOptionPriority.High), pawn, item)); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalSome".Translate(item.LabelNoCount, item), delegate { int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(bestPackAnimal, item), item.stackCount); Dialog_Slider window = new Dialog_Slider("GiveToPackAnimalCount".Translate(item.LabelNoCount, item), 1, to, delegate(int count) { item.SetForbidden(value: false, warnOnFail: false); Job job4 = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item); job4.count = count; pawn.jobs.TryTakeOrderedJob(job4); }); Find.WindowStack.Add(window); }, MenuOptionPriority.High), pawn, item)); } } } } if (!pawn.Map.IsPlayerHome && pawn.Map.exitMapGrid.MapUsesExitGrid) { foreach (LocalTargetInfo item16 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true)) { Pawn p = (Pawn)item16.Thing; if (p.Faction == Faction.OfPlayer || p.IsPrisonerOfColony || CaravanUtility.ShouldAutoCapture(p, Faction.OfPlayer)) { IntVec3 exitSpot; if (!pawn.CanReach(p, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label, p) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (!RCellFinder.TryFindBestExitSpot(pawn, out exitSpot)) { opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label, p) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else { TaggedString taggedString2 = (p.Faction == Faction.OfPlayer || p.IsPrisonerOfColony) ? "CarryToExit".Translate(p.Label, p) : "CarryToExitAndCapture".Translate(p.Label, p); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(taggedString2, delegate { Job job3 = JobMaker.MakeJob(JobDefOf.CarryDownedPawnToExit, p, exitSpot); job3.count = 1; job3.failIfCantJoinOrCreateCaravan = true; pawn.jobs.TryTakeOrderedJob(job3); }, MenuOptionPriority.High), pawn, item16)); } } } } if (pawn.equipment != null && pawn.equipment.Primary != null && GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForSelf(pawn), thingsOnly: true).Any()) { if (pawn.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanUnequip(pawn.equipment.Primary, pawn)) { opts.Add(new FloatMenuOption("CannotDrop".Translate(pawn.equipment.Primary.Label, pawn.equipment.Primary) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null)); } else { Action action5 = delegate { pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.DropEquipment, pawn.equipment.Primary)); }; opts.Add(new FloatMenuOption("Drop".Translate(pawn.equipment.Primary.Label, pawn.equipment.Primary), action5, MenuOptionPriority.Default, null, pawn)); } } foreach (LocalTargetInfo item17 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForTrade(), thingsOnly: true)) { if (!pawn.CanReach(item17, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled) { opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap), null)); } else if (!pawn.CanTradeWith(((Pawn)item17.Thing).Faction, ((Pawn)item17.Thing).TraderKind)) { opts.Add(new FloatMenuOption("CannotTradeMissingTitleAbility".Translate(), null)); } else { Pawn pTarg = (Pawn)item17.Thing; Action action6 = delegate { Job job2 = JobMaker.MakeJob(JobDefOf.TradeWithPawn, pTarg); job2.playerForced = true; pawn.jobs.TryTakeOrderedJob(job2); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }; string t2 = ""; if (pTarg.Faction != null) { t2 = " (" + pTarg.Faction.Name + ")"; } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("TradeWith".Translate(pTarg.LabelShort + ", " + pTarg.TraderKind.label) + t2, action6, MenuOptionPriority.InitiateSocial, null, item17.Thing), pawn, pTarg)); } } foreach (LocalTargetInfo casket in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForOpen(pawn), thingsOnly: true)) { if (!pawn.CanReach(casket, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotOpen".Translate(casket.Thing) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { opts.Add(new FloatMenuOption("CannotOpen".Translate(casket.Thing) + ": " + "Incapable".Translate(), null)); } else if (casket.Thing.Map.designationManager.DesignationOn(casket.Thing, DesignationDefOf.Open) == null) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Open".Translate(casket.Thing), delegate { Job job = JobMaker.MakeJob(JobDefOf.Open, casket.Thing); job.ignoreDesignations = true; pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.High), pawn, casket.Thing)); } } foreach (Thing item18 in pawn.Map.thingGrid.ThingsAt(c)) { foreach (FloatMenuOption floatMenuOption2 in item18.GetFloatMenuOptions(pawn)) { opts.Add(floatMenuOption2); } } void Equip() { equipment.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Equip, equipment)); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); } return(false); }
protected override void Impact(Thing hitThing) { Map map = base.Map; BattleLogEntry_RangedImpact logEntry = null; if (logMisses || (!logMisses && hitThing != null && (hitThing is Pawn || hitThing is Building_Turret) )) { LogImpact(hitThing, out logEntry); } if (hitThing != null) { int damageAmountBase = def.projectile.damageAmountBase; DamageDefExtensionCE damDefCE = def.projectile.damageDef.GetModExtension <DamageDefExtensionCE>() ?? new DamageDefExtensionCE(); DamageInfo dinfo = new DamageInfo( def.projectile.damageDef, damageAmountBase, ExactRotation.eulerAngles.y, launcher, null, def); // Set impact height BodyPartDepth partDepth = damDefCE != null && damDefCE.harmOnlyOutsideLayers ? BodyPartDepth.Outside : BodyPartDepth.Undefined; //NOTE: ExactPosition.y isn't always Height at the point of Impact! BodyPartHeight partHeight = new CollisionVertical(hitThing).GetCollisionBodyHeight(ExactPosition.y); dinfo.SetBodyRegion(partHeight, partDepth); if (damDefCE != null && damDefCE.harmOnlyOutsideLayers) { dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); } // Apply primary damage hitThing.TakeDamage(dinfo).InsertIntoLog(logEntry); // Apply secondary to non-pawns (pawn secondary damage is handled in the damage worker) var projectilePropsCE = def.projectile as ProjectilePropertiesCE; if (!(hitThing is Pawn) && projectilePropsCE != null && !projectilePropsCE.secondaryDamage.NullOrEmpty()) { foreach (SecondaryDamage cur in projectilePropsCE.secondaryDamage) { if (hitThing.Destroyed) { break; } var secDinfo = new DamageInfo( cur.def, cur.amount, ExactRotation.eulerAngles.y, launcher, null, def); hitThing.TakeDamage(secDinfo).InsertIntoLog(logEntry); } } } else { SoundDefOf.BulletImpactGround.PlayOneShot(new TargetInfo(base.Position, map, false)); //Only display a dirt hit for projectiles with a dropshadow if (base.castShadow) { MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); } } base.Impact(hitThing); }
private static FloatMenuOption GuardLocationOption(CompMeeseeksMemory compMeeseeksMemory, IntVec3 clickCell, Pawn pawn) { int num = GenRadial.NumCellsInRadius(2.9f); IntVec3 curLoc; for (int i = 0; i < num; i++) { curLoc = GenRadial.RadialPattern[i] + clickCell; if (!curLoc.Standable(pawn.Map)) { continue; } if (curLoc != pawn.Position) { if (!pawn.CanReach(curLoc, PathEndMode.OnCell, Danger.Deadly)) { return(new FloatMenuOption("CannotGoNoPath".Translate(), null)); } Action action = delegate { //IntVec3 guardPosition = RCellFinder.BestOrderedGotoDestNear(curLoc, pawn); compMeeseeksMemory.guardPosition = curLoc; Job job = JobMaker.MakeJob(JobDefOf.Goto, curLoc); job.playerForced = true; //if (pawn.Map.exitMapGrid.IsExitCell(UI.MouseCell())) //{ // job.exitMapOnArrival = true; //} //else if (!pawn.Map.IsPlayerHome && !pawn.Map.exitMapGrid.MapUsesExitGrid && CellRect.WholeMap(pawn.Map).IsOnEdge(UI.MouseCell(), 3) && pawn.Map.Parent.GetComponent<FormCaravanComp>() != null && MessagesRepeatAvoider.MessageShowAllowed("MessagePlayerTriedToLeaveMapViaExitGrid-" + pawn.Map.uniqueID, 60f)) //{ // if (pawn.Map.Parent.GetComponent<FormCaravanComp>().CanFormOrReformCaravanNow) // { // Messages.Message("MessagePlayerTriedToLeaveMapViaExitGrid_CanReform".Translate(), pawn.Map.Parent, MessageTypeDefOf.RejectInput, historical: false); // } // else // { // Messages.Message("MessagePlayerTriedToLeaveMapViaExitGrid_CantReform".Translate(), pawn.Map.Parent, MessageTypeDefOf.RejectInput, historical: false); // } //} pawn.drafter.Drafted = true; if (pawn.jobs.TryTakeOrderedJob(job)) { MoteMaker.MakeStaticMote(curLoc, pawn.Map, ThingDefOf.Mote_FeedbackGoto); } else { pawn.drafter.Drafted = false; } }; return(new FloatMenuOption("CM_Meeseeks_Box_GuardHere".Translate(), action, MenuOptionPriority.GoHere) { autoTakeable = false, autoTakeablePriority = 10f }); } return(null); } return(null); }