private void ImpactSomething() { if (this.def.projectile.flyOverhead) { RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position); if (roofDef != null) { if (roofDef.isThickRoof) { SoundStarter.PlayOneShot(this.def.projectile.soundHitThickRoof, new TargetInfo(base.Position, base.Map, false)); this.Destroy(0); return; } if (GridsUtility.GetEdifice(base.Position, base.Map) == null || GridsUtility.GetEdifice(base.Position, base.Map).def.Fillage != FillCategory.Full) { RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map, null); } } } if (!this.usedTarget.HasThing || !base.CanHit(this.usedTarget.Thing)) { List <Thing> list = new List <Thing>(); list.Clear(); List <Thing> thingList = GridsUtility.GetThingList(base.Position, base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if ((thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) && base.CanHit(thing)) { list.Add(thing); } } GenList.Shuffle <Thing>(list); for (int j = 0; j < list.Count; j++) { Thing thing2 = list[j]; Pawn pawn = thing2 as Pawn; float num; if (pawn != null) { num = 0.5f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (PawnUtility.GetPosture(pawn) != null && GenGeo.MagnitudeHorizontalSquared(this.origin - this.destination) >= 20.25f) { num *= 0.2f; } if (this.launcher != null && pawn.Faction != null && this.launcher.Faction != null && !FactionUtility.HostileTo(pawn.Faction, this.launcher.Faction)) { num *= VerbUtility.InterceptChanceFactorFromDistance(this.origin, base.Position); } } else { num = 1.5f * thing2.def.fillPercent; } if (Rand.Chance(num)) { this.Impact(GenCollection.RandomElement <Thing>(list)); return; } } this.Impact(null); return; } Pawn pawn2 = this.usedTarget.Thing as Pawn; if (pawn2 != null && PawnUtility.GetPosture(pawn2) != null && GenGeo.MagnitudeHorizontalSquared(this.origin - this.destination) >= 20.25f && !Rand.Chance(0.2f)) { this.Impact(null); return; } this.Impact(this.usedTarget.Thing); }
// Token: 0x0600002F RID: 47 RVA: 0x00002870 File Offset: 0x00000A70 public static void DoTend(Pawn doctor, Pawn patient, Cloakgen medkit) { bool flag = patient.health.HasHediffsNeedingTend(false); if (flag) { bool flag2 = medkit != null && medkit.Destroyed; if (flag2) { Log.Warning("Tried to use destroyed medkit.", false); medkit = null; } float num = HealthShardTendUtility.CalculateBaseTendQuality(doctor, patient, medkit.kitComp.Props.medicine ?? null); HealthShardTendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medkit.kitComp.Props.medicine != null, HealthShardTendUtility.tmpHediffsToTend, null); for (int i = 0; i < HealthShardTendUtility.tmpHediffsToTend.Count; i++) { HealthShardTendUtility.tmpHediffsToTend[i].Tended(num, i); } bool flag3 = doctor != null && doctor.Faction == Faction.OfPlayer && patient.Faction != doctor.Faction && !patient.IsPrisoner && patient.Faction != null; if (flag3) { patient.mindState.timesGuestTendedToByPlayer++; } bool flag4 = doctor != null && doctor.IsColonistPlayerControlled; if (flag4) { patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer); } bool flag5 = doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal; if (flag5) { bool flag6 = RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f); if (flag6) { bool flag7 = doctor.Faction != null && doctor.Faction != patient.Faction; if (flag7) { InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false); } } } patient.records.Increment(RecordDefOf.TimesTendedTo); bool flag8 = doctor != null; if (flag8) { doctor.records.Increment(RecordDefOf.TimesTendedOther); } bool flag9 = doctor == patient && !doctor.Dead; if (flag9) { doctor.mindState.Notify_SelfTended(); } bool flag10 = medkit.kitComp.Props.medicine != null; if (flag10) { bool flag11 = patient.Spawned || (doctor != null && doctor.Spawned); if (flag11) { bool flag12 = medkit.kitComp.Props.medicine != null && StatExtension.GetStatValueAbstract(medkit.kitComp.Props.medicine, StatDefOf.MedicalPotency, null) > StatExtension.GetStatValueAbstract(ThingDefOf.MedicineIndustrial, StatDefOf.MedicalPotency, null); if (flag12) { SoundStarter.PlayOneShot(SoundDefOf.TechMedicineUsed, new TargetInfo(patient.Position, patient.Map, false)); } } } } }
public void OnGUI(Rect rect) { float curY = 0f; float repeatModeButX = 0f; float adjustButHeight = 30f; try { GUI.BeginGroup(rect); //Do the top buttons. If the parent is not null, then do the suspend button. if (!setupStage) { float suspendButRightEdge = rect.width / 2f - 5f; Rect suspendButRect = new Rect(0f, 0f, suspendButRightEdge, buttonSize.y); if (Suspended) { if (Widgets.TextButton(suspendButRect, "Suspended".Translate())) { Suspended = false; } } else { if (Widgets.TextButton(suspendButRect, "NotSuspended".Translate())) { Suspended = true; } } repeatModeButX = rect.width / 2f + 5f; } string label = "But"; if (repeatMode == BillRepeatMode.RepeatCount) { label = "DoXTimes".Translate(); } if (repeatMode == BillRepeatMode.TargetCount) { label = "DoUntilYouHaveX".Translate(); } if (repeatMode == BillRepeatMode.Forever) { label = "DoForever".Translate(); } Vector2 repeatButSize = new Vector2(rect.width - repeatModeButX, buttonSize.y); Rect repeatButRect = new Rect(repeatModeButX, curY, repeatButSize.x, repeatButSize.y); if (Widgets.TextButton(repeatButRect, label)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("DoXTimes".Translate(), delegate { this.repeatMode = BillRepeatMode.RepeatCount; })); list.Add(new FloatMenuOption("DoUntilYouHaveX".Translate(), delegate { this.repeatMode = BillRepeatMode.TargetCount; })); list.Add(new FloatMenuOption("DoForever".Translate(), delegate { this.repeatMode = BillRepeatMode.Forever; })); Find.WindowStack.Add(new FloatMenu(list)); } curY += repeatButSize.y + margin; //Do the target count label Rect countRect = new Rect(0, curY, rect.width, 30f); curY += countRect.height + margin; string text = string.Empty; if (this.repeatMode == BillRepeatMode.RepeatCount) { text = "RepeatCount".Translate(new object[] { Cycles.ToString() }); float butPadding = 2f; float butWidth = (rect.width - 8 * butPadding) / 5f; float xPos = 0f; Rect but1Rect = new Rect(xPos, curY, butWidth, adjustButHeight); if (Widgets.TextButton(but1Rect, "-25")) { if (Cycles == 0) { SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera()); } else { Cycles -= 25; } } xPos += butWidth + butPadding * 2; Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but2Rect, "-1")) { if (Cycles == 0) { SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera()); } else { Cycles -= 1; } } xPos += butWidth + butPadding * 2; Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but3Rect, "1")) { Cycles = 1; } xPos += butWidth + butPadding * 2; Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but4Rect, "+1")) { Cycles += 1; } xPos += butWidth + butPadding * 2; Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but5Rect, "+25")) { Cycles += 25; } } else if (repeatMode == BillRepeatMode.TargetCount) { text = "TargetCount".Translate(new object[] { (TargetCount >= 999999)?"Infinite".Translate() : TargetCount.ToString() }); float butPadding = 2f; float butWidth = (rect.width - 12 * butPadding) / 7f; float xPos = 0f; Rect but1Rect = new Rect(xPos, curY, butWidth, adjustButHeight); if (Widgets.TextButton(but1Rect, "-250")) { if (TargetCount == 0) { SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera()); } else { TargetCount -= 250; } } xPos += butWidth + butPadding * 2; Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but2Rect, "-25")) { if (TargetCount == 0) { SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera()); } else { TargetCount -= 25; } } xPos += butWidth + butPadding * 2; Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but3Rect, "-1")) { if (TargetCount == 0) { SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera()); } else { TargetCount -= 1; } } xPos += butWidth + butPadding * 2; Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but4Rect, "1")) { TargetCount = 1; } xPos += butWidth + butPadding * 2; Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but5Rect, "+1")) { TargetCount += 1; } xPos += butWidth + butPadding * 2; Rect but6Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but6Rect, "+25")) { TargetCount += 25; } xPos += butWidth + butPadding * 2; Rect but7Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight); if (Widgets.TextButton(but7Rect, "+250")) { TargetCount += 250; } } else if (repeatMode == BillRepeatMode.Forever) { text = "Do Forever"; } else { throw new InvalidOperationException(); } curY += adjustButHeight + margin + 6f; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(countRect, text); //Now for the ThingFilter box (shiver) Rect thingFilterLabelRect = new Rect(0f, curY, rect.width, 20f); curY += thingFilterLabelRect.height + margin; Widgets.Label(thingFilterLabelRect, "PermittedIngredients".Translate()); Text.Anchor = TextAnchor.UpperLeft; float tfheight = rect.height - curY - adjustButHeight - margin; Rect thingFilterRect = new Rect(0f, curY, rect.width, tfheight); curY += tfheight + margin; ThingFilterUI.DoThingFilterConfigWindow(thingFilterRect, ref this.scrollPosition, this.ingredientsFilter, this.recipe.fixedIngredientFilter); //Well that wasn't so hard after all float checkWidth = rect.width / 2 - 30f; float checkXPos = rect.width / 2 - (checkWidth / 2); Rect checkRect = new Rect(checkXPos, curY, checkWidth, adjustButHeight); Widgets.LabelCheckbox(checkRect, "Complete all", ref this.completeAll); string s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 15 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick."; if (RepeatMode == BillRepeatMode.TargetCount) { s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 5 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick."; } TipSignal tip = new TipSignal(s); TooltipHandler.TipRegion(checkRect, tip); } finally { GUI.EndGroup(); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } }
public override void CompTick() { base.CompTick(); if (this.ticks > 0) { this.ticks--; } if (this.ticks < 0) { this.ticks = 0; } if (this.ticks < 1) { lastHitBuild = null; hitTime = 0; } if (this.ticks > 0 && this.ticks % 5 == 0 && lastHitBuild != null) { ChronoMoteMaker.ThrowCell(lastHitBuild.TrueCenter().ToIntVec3(), lastHitBuild.Map, DefDatabase <ThingDef> .GetNamed("Mote_BlastEMP", true), new UnityEngine.Color(1, 1, 1), (lastHitBuild is Pawn)?new IntVec2((int)((Pawn)lastHitBuild).RaceProps.baseBodySize, (int)((Pawn)lastHitBuild).RaceProps.baseBodySize) :lastHitBuild.def.size); } if (lastHitBuild != null) { if (lastHitBuild.Destroyed) { lastHitBuild = null; hitTime = 0; return; } int HP = 1000; if (lastHitBuild.def.useHitPoints) { HP = this.lastHitBuild.MaxHitPoints; } if (lastHitBuild is Pawn) { HP = 400; } if (this.hitTime > (int)(HP / (20 * this.hitTime))) { SoundStarter.PlayOneShot(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_kill", true), lastHitBuild); MoteMaker.ThrowExplosionCell(lastHitBuild.Position, lastHitBuild.Map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1, 1, 1)); if (lastHitBuild.def == ThingDefOf.SteamGeyser) { lastHitBuild.DeSpawn(DestroyMode.Vanish); } else { lastHitBuild.Destroy(DestroyMode.Vanish); } lastHitBuild = null; hitTime = 0; ticks = 0; } } else { // Log.Warning("null"); } }
public override void WarmupComplete() { if (isJammed) { System.Random random = new System.Random(); int num = random.Next(0, 2); if (num == 1) { isJammed = false; Vector3 loc = new Vector3((float)this.caster.Position.x + 1f, (float)this.caster.Position.y, (float)this.caster.Position.z + 1f); MoteMaker.ThrowText(loc, caster.Map, "Jam Cleared", Color.white); this.ownerEquipment.def.soundInteract.PlayOneShot( new TargetInfo(caster.Position, caster.Map, false)); return; } else { return; } } int jamChance = 0; QualityCategory qual; this.caster.TryGetQuality(out qual); switch (qual) { case QualityCategory.Awful: jamChance = 30; break; case QualityCategory.Poor: jamChance = 40; break; case QualityCategory.Shoddy: jamChance = 50; break; case QualityCategory.Normal: jamChance = 60; break; case QualityCategory.Good: jamChance = 70; break; case QualityCategory.Excellent: jamChance = 80; break; case QualityCategory.Superior: jamChance = 90; break; case QualityCategory.Masterwork: jamChance = 100; break; case QualityCategory.Legendary: jamChance = 10000; break; default: jamChance = 60; break; } if (Rand.Range(1, jamChance) == 1) { Vector3 loc = new Vector3((float)this.caster.Position.x + 1f, (float)this.caster.Position.y, (float)this.caster.Position.z + 1f); MoteMaker.ThrowText(loc, caster.Map, "Jammed", Color.white); SoundStarter.PlayOneShot(jamSound, new TargetInfo(caster.Position, caster.Map, false)); isJammed = true; return; } base.WarmupComplete(); if (base.CasterIsPawn && base.CasterPawn.skills != null) { float xp = 10f; if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn) { if (this.currentTarget.Thing.HostileTo(this.caster)) { xp = 240f; } else { xp = 50f; } } base.CasterPawn.skills.Learn(SkillDefOf.Shooting, xp); } }
// Token: 0x0600001D RID: 29 RVA: 0x00002781 File Offset: 0x00000981 public void Spring(Pawn p) { SoundStarter.PlayOneShot(SoundDef.Named("DeadfallSpring"), new TargetInfo(base.Position, base.Map, false)); this.SpringSub(p); }
public override IEnumerable <Gizmo> GetWornGizmos() { // base.GetWornGizmos(); if (Find.Selector.SingleSelectedThing != base.Wearer) { yield break; } //tanya if (base.Wearer.kindDef.defName == "ra2_AlliedTanya") { yield return new Command_Action { icon = ContentFinder <Texture2D> .Get(!tanyaHandWeapon()?DefDatabase <ThingDef> .GetNamed("ra2_Gun_Tanya", true).graphicData.texPath : DefDatabase <ThingDef> .GetNamed("ra2_TanyaC4Bomb", true).graphicData.texPath, true), defaultLabel = "TanyaChangeWeapon".Translate(), activateSound = DefDatabase <SoundDef> .GetNamed("ra2_tanya_select", true), action = delegate { Pawn_EquipmentTracker pe = base.Wearer.equipment; ThingDef tempDef = DefDatabase <ThingDef> .GetNamed(tanyaHandWeapon()? "ra2_TanyaC4Bomb" : "ra2_Gun_Tanya", true); pe.Remove(pe.Primary); pe.AddEquipment((ThingWithComps)ThingMaker.MakeThing(tempDef)); } } } ; //chrono TargetingParameters tp = new TargetingParameters(); tp.canTargetBuildings = false; tp.canTargetFires = false; tp.canTargetLocations = true; tp.canTargetPawns = false; tp.canTargetSelf = false; if (base.Wearer.kindDef.defName == "ra2_AlliedChrono") { yield return new Command_TargetPlus { icon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport", true), defaultLabel = "ChronoTeleport".Translate(), activateSound = DefDatabase <SoundDef> .GetNamed("ra2_Chrono_select", true), targetingParams = tp, hotKey = KeyBindingDefOf.Misc4, disabled = !base.Wearer.drafter.Drafted || base.Wearer.stances.stunner.Stunned, aimIcon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport", true), action = delegate(LocalTargetInfo target) { Pawn casterPawn = base.Wearer; Map map = base.Wearer.Map; IEnumerable <Thing> thi = map.thingGrid.ThingsAt(target.Cell); foreach (Thing th in thi) { if (th is Building) { Messages.Message("ChronoNotToBuild".Translate(), MessageTypeDefOf.RejectInput); return; } } MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1, 1, 1)); // MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1,1,1)); for (int asd = 0; asd < 60; asd++) { MoteMaker.ThrowExplosionCell(casterPawn.Position, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1f - asd * 0.1f, asd * 0.1f, 1f - asd * 0.05f)); } double dist = Math.Sqrt(Math.Pow(casterPawn.Position.x - target.Cell.x, 2) + Math.Pow(casterPawn.Position.z - target.Cell.z, 2)); if (dist < 20) { dist = 20; } ThingSelectionUtility.SelectNextColonist(); base.Wearer.DeSpawn(DestroyMode.Vanish); GenSpawn.Spawn(casterPawn, target.Cell, map, WipeMode.Vanish); casterPawn.drafter.Drafted = true; ThingSelectionUtility.SelectPreviousColonist(); SoundStarter.PlayOneShot(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_move", true), casterPawn); SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_movesay", true)); DamageInfo dinfo = new DamageInfo(DamageDefOf.Stun, (int)(dist * 0.1), -1, 1, null, null, base.Wearer.equipment.Primary.def, DamageInfo.SourceCategory.ThingOrUnknown, casterPawn); casterPawn.TakeDamage(dinfo); // Log.Warning(target+"VV"); } } } ; //yuri bool isYuri = false; if (this.Wearer != null) { Pawn pawn = this.Wearer; if (pawn.kindDef.defName.EqualsIgnoreCase("ra2_yuriyuri")) { isYuri = true; } } if (isYuri) { bool canCast = this.ticks <= 0 && this.Wearer.drafter.Drafted && !this.Wearer.stances.stunner.Stunned; yield return(new Command_YuriAction { defaultLabel = "YuriExpTitle".Translate(), icon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/yuriExpIcon", true), disabled = !canCast, caster = this.Wearer, hotKey = KeyBindingDefOf.Misc4, action = delegate { Pawn pawn = this.Wearer; DamageDef df = DefDatabase <DamageDef> .GetNamed("YuriExp", true); foreach (IntVec3 cell in CellsAround(pawn.Position, pawn.Map, 7)) { // if (!cell.IsValid) continue; List <Thing> list = (pawn.Map.thingGrid.ThingsListAt(cell)); try { if (list.Count < 1) { continue; } for (int i = 0; i < list.Count; i++) { Pawn p; if ((p = (list[i] as Pawn)) != null) { if (p.kindDef.defName.EqualsIgnoreCase("ra2_yuriyuri")) { continue; } if (p.RaceProps.IsFlesh) { { p.Kill(new DamageInfo(df, 0, 0, -1, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null), null); } if (!(p.Faction == Faction.OfPlayer && p.kindDef.defName.StartsWith("ra2_"))) { p.Corpse.Kill(null); } } } } } catch (Exception e) { Log.Warning(e + "233"); } } pawn.stances.stunner.StunFor(120, null); this.ticks = 300; GenExplosion.DoExplosion(pawn.Position, pawn.Map, 7f, df, pawn, 0, -1, null, null, null, null, null, 0, 1, false, null, 0, 1, 0, false); } }); } yield break; } } }
public void DraggingUpdate(float mouseOffX, float rateFactor) { Update(); int amount = 0; int direction = 1; if (mouseOffX != 0) { float delta = Math.Abs(mouseOffX); if (delta > maxDelta) { delta = maxDelta; } delta = delta * stretch; delta = scale / (delta * delta); if (lastUpdateTime > delta) { amount = 0; while (lastUpdateTime > delta) { lastUpdateTime -= delta; amount++; } } } if (mouseOffX < 0) { direction = -1; } AcceptanceReport acceptanceReport = null; if (amount != 0) { if (Event.current.shift) { amount = amount * multiplier; } if (direction > 0) { if (value < maxValue) { if (maxValue - value < amount) { value = maxValue; } else { value += amount; } acceptanceReport = true; } else { acceptanceReport = false; } } else { if (value > minValue) { if (minValue + amount > value) { value = minValue; } else { value -= amount; } acceptanceReport = true; } else { acceptanceReport = false; } } if (acceptanceReport.Accepted) { SoundStarter.PlayOneShot(DragAmountChangedSound, SoundInfo.OnCamera(MaintenanceType.None)); lastDragRealTime = Time.realtimeSinceStartup; } } if (valueUpdateCallback != null) { valueUpdateCallback(value); } }
public void DraggingCompleted(float mouseOffX, float rateFactor) { SoundStarter.PlayOneShot(DragEndSound, SoundInfo.OnCamera(MaintenanceType.None)); valueUpdateCallback = null; }
public void DraggingStart(float mouseOffX, float rateFactor) { SoundStarter.PlayOneShot(DragStartSound, SoundInfo.OnCamera(MaintenanceType.None)); }
private void ProtectSquare(IntVec3 square, bool flag_direct, bool flag_indirect, bool IFFcheck) { if (!GenGrid.InBounds(square) || (!this.shieldBlockIndirect || !flag_indirect) && (!this.shieldBlockDirect || !flag_direct)) { return; } List <Thing> thingList1 = Find.get_ThingGrid().ThingsListAt(square); List <Thing> thingList2 = new List <Thing>(); int index1 = 0; for (int index2 = ((IEnumerable <Thing>)thingList1).Count <Thing>(); index1 < index2; ++index1) { if (thingList1[index1] != null && thingList1[index1] is Projectile) { Projectile projectile = (Projectile)thingList1[index1]; if (!((Thing)projectile).get_Destroyed() && (this.shieldBlockIndirect && flag_indirect && ((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).flyOverhead != null || this.shieldBlockDirect && flag_direct && ((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).flyOverhead == null)) { bool flag = true; if (IFFcheck) { Thing instanceField = ReflectionHelper.GetInstanceField(typeof(Projectile), (object)projectile, "launcher") as Thing; if (instanceField != null && instanceField.get_Faction() != null && (instanceField.get_Faction().def != null && instanceField.get_Faction().def == FactionDefOf.Colony)) { flag = false; } } if (((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).flyOverhead != null && !this.WillTargetLandInRange(projectile)) { flag = false; } if (flag) { Quaternion exactRotation = projectile.get_ExactRotation(); Vector3 exactPosition = projectile.get_ExactPosition(); exactPosition.y = (__Null)0.0; Vector3 vec = Vectors.IntVecToVec(this.position); vec.y = (__Null)0.0; Quaternion quaternion = Quaternion.LookRotation(Vector3.op_Subtraction(exactPosition, vec)); if ((double)Quaternion.Angle(exactRotation, quaternion) > 90.0 || IFFcheck) { MoteThrower.ThrowLightningGlow(projectile.get_ExactPosition(), 0.5f); SoundStarter.PlayOneShot(ShieldField.HitSoundDef, SoundInfo.op_Implicit(((Thing)projectile).get_Position())); this.ProcessDamage((int)((ProjectileProperties)((ThingDef)((Thing)projectile).def).projectile).damageAmountBase); thingList2.Add((Thing)projectile); if (!this.isOnline()) { break; } } } } } } using (List <Thing> .Enumerator enumerator = thingList2.GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.Destroy((DestroyMode)0); } } }
protected override IEnumerable <Toil> MakeNewToils() { var followAndAttack = new Toil(); followAndAttack.initAction = delegate() { var actor = followAndAttack.actor; var curJob = actor.jobs.curJob; var thing = curJob.GetTarget(this.a).Thing; var pawn1 = thing as Pawn; if (thing != actor.pather.Destination.Thing || (!this.pawn.pather.Moving && !this.pawn.Position.AdjacentTo8WayOrInside(thing))) { RoofDef roofDef = actor.Map.roofGrid.RoofAt(actor.Position); if (roofDef != null) { if (roofDef != RoofDefOf.RoofConstructed) { return; } if (!SoundDefHelper.NullOrUndefined(roofDef.soundPunchThrough)) { SoundStarter.PlayOneShot(roofDef.soundPunchThrough, new TargetInfo(actor.Position, actor.Map, false)); CellRect.CellRectIterator iterator = CellRect.CenteredOn(actor.Position, 1).GetIterator(); while (!iterator.Done()) { Find.CurrentMap.roofGrid.SetRoof(iterator.Current, null); iterator.MoveNext(); } } } RoofDef roofDef2 = actor.Map.roofGrid.RoofAt(thing.Position); if (roofDef2 != null) { if (roofDef2 != RoofDefOf.RoofConstructed) { return; } if (!SoundDefHelper.NullOrUndefined(roofDef2.soundPunchThrough)) { SoundStarter.PlayOneShot(roofDef2.soundPunchThrough, new TargetInfo(actor.Position, actor.Map, false)); CellRect.CellRectIterator iterator2 = CellRect.CenteredOn(thing.Position, 1).GetIterator(); while (!iterator2.Done()) { Find.CurrentMap.roofGrid.SetRoof(iterator2.Current, null); iterator2.MoveNext(); } } } } actor.pather.StartPath(thing, PathEndMode.OnCell); actor.Position = thing.Position; actor.pather.StopDead(); pawn1.pather.StopDead(); pawn1.TakeDamage(new DamageInfo(PurpleIvyDefOf.AlienToxicSting, 3, 0f, -1f, actor, null, null)); if (actor.jobs.curJob != null) { actor.jobs.curDriver.Notify_PatherArrived(); } actor.jobs.TryTakeOrderedJob(PurpleIvyUtils.MeleeAttackJob(actor, pawn1)); }; followAndAttack.defaultCompleteMode = ToilCompleteMode.Never; followAndAttack.EndOnDespawnedOrNull <Toil>(this.a, JobCondition.Succeeded); followAndAttack.FailOn <Toil>(new Func <bool>(this.hunterIsKilled)); yield return(followAndAttack); yield break; }