public static Thing GetAttacker(Pawn pawn, Thing target, bool attackingHive) { Pawn pawnTarget = target as Pawn; Insect enemyBug = target as Insect; Building_Turret turretTarget = target as Building_Turret; bool recentAttack = false; if (pawnTarget != null) { recentAttack = pawnTarget.mindState.lastAttackTargetTick <= Find.TickManager.TicksGame && pawnTarget.mindState.lastAttackTargetTick > Find.TickManager.TicksGame - ticksInAttackMode; } else if (turretTarget != null) { recentAttack = turretTarget.LastAttackTargetTick <= Find.TickManager.TicksGame && turretTarget.LastAttackTargetTick > Find.TickManager.TicksGame - ticksInAttackMode; } int dist = IntVec3Utility.ManhattanDistanceFlat(pawn.PositionHeld, target.PositionHeld); bool withinHiveAndInVisual = JobGiver_InsectGather.WithinHive(pawn, target, false) && GenSight.LineOfSight(pawn.Position, target.Position, pawn.Map, true, null, 0, 0); bool enemyPawnThreat = (withinHiveAndInVisual || (attackingHive && recentAttack)) && dist < maxAttackDistance; bool enemyInsectThreat = enemyBug != null && enemyBug.Faction != pawn.Faction && GenSight.LineOfSight(pawn.Position, enemyBug.Position, pawn.Map, true, null, 0, 0) && dist < 30; if (enemyPawnThreat || enemyInsectThreat) { if (pawn.CanReach(target, PathEndMode.Touch, Danger.Deadly, true, TraverseMode.PassDoors)) { return(target); } } return(null); }
protected override Job TryGiveJob(Pawn pawn) { var thing = ThingToDo(pawn); if (thing != null) { if (!thing.Position.IsValid) { return(null); } if (!pawn.CanReach(thing.Position, PathEndMode.ClosestTouch, maxDanger)) { return(null); } if (IntVec3Utility.DistanceTo(thing.Position, pawn.Position) < 10f) { return(null); } var job = JobMaker.MakeJob(JobDefOf.Goto, thing.Position); job.locomotionUrgency = LocomotionUrgency.Sprint; return(job); } else { return(null); } }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.OnCell)); yield return(new Toil { initAction = delegate() { var selectedStack = pawn.Map.listerThings.ThingsOfDef(AlteredCarbonDefOf .AC_EmptyCorticalStack) .Where(x => pawn.CanReserveAndReach(x, PathEndMode.ClosestTouch, Danger.Deadly)) .MinBy(x => IntVec3Utility.DistanceTo(pawn.Position, x.Position)); //var selectedStack = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, // ThingRequest.ForDef(AlteredCarbonDefOf.AC_EmptyCorticalStack), PathEndMode // .ClosestTouch, TraverseParms.For(TraverseMode.ByPawn, Danger.Deadly, false)); pawn.CurJob.targetB = selectedStack; } }); yield return(Toils_Haul.StartCarryThing(TargetIndex.A).FailOnDespawnedNullOrForbidden(TargetIndex.B)); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch)); yield return(new Toil { initAction = delegate() { pawn.carryTracker.TryDropCarriedThing(pawn.Position, ThingPlaceMode.Near, out Thing resultingThing); if (resultingThing != TargetThingA) { pawn.CurJob.targetA = resultingThing; } } });
public static void PushEffect(Thing Caster, Thing target, int distance, bool damageOnCollision = false) { if (target is Building) { return; } LongEventHandler.QueueLongEvent(delegate() { Pawn pawn; if (target != null && (pawn = (target as Pawn)) != null && pawn.Spawned && !pawn.Downed && !pawn.Dead && (pawn?.MapHeld) != null) { bool drafted = pawn.Drafted; Vector3 vector = Main.PushResult(Caster, target, distance, out bool flag2); RRY_FlyingObject flyingObject = (RRY_FlyingObject)GenSpawn.Spawn(ThingDef.Named("JT_FlyingObject"), pawn.PositionHeld, pawn.MapHeld, 0); bool flag3 = flag2 & damageOnCollision; if (flag3) { flyingObject.Launch(Caster, new LocalTargetInfo(IntVec3Utility.ToIntVec3(vector)), target, new DamageInfo?(new DamageInfo(DamageDefOf.Blunt, (float)Rand.Range(8, 10), 0f, -1f, null, null, null, 0, null))); } else { flyingObject.Launch(Caster, new LocalTargetInfo(IntVec3Utility.ToIntVec3(vector)), target); } } }, "PushingCharacter", false, null); }
public static IntVec3 GetCellToTeleportFrom(Map oldMap, IntVec3 originPosition, Map newMap) { IntVec3 position = originPosition; var oldMapZIndex = ZTracker.GetZIndexFor(oldMap); var newMapZIndex = ZTracker.GetZIndexFor(newMap); var maps = oldMapZIndex > newMapZIndex?ZTracker.GetAllMapsFromToBelow(oldMap, newMap) : ZTracker.GetAllMapsFromToUpper(oldMap, newMap); foreach (var otherMap in maps) { var stairs = new List <Building_Stairs>(); var otherMapZIndex = ZTracker.GetZIndexFor(otherMap); if (otherMap == oldMap) { if (oldMapZIndex > newMapZIndex) { Map lowerMap = ZTracker.GetLowerLevel(otherMap.Tile, otherMap); if (lowerMap != null) { stairs = ZTracker.stairsUp[lowerMap]; } } else if (oldMapZIndex < newMapZIndex) { Map upperMap = ZTracker.GetUpperLevel(otherMap.Tile, otherMap); if (upperMap != null) { stairs = ZTracker.stairsDown[upperMap]; } } } else if (otherMapZIndex > oldMapZIndex) { Map lowerMap = ZTracker.GetLowerLevel(otherMap.Tile, otherMap); if (lowerMap != null) { stairs = ZTracker.stairsUp[lowerMap]; } } else if (otherMapZIndex < oldMapZIndex) { Map upperMap = ZTracker.GetUpperLevel(otherMap.Tile, otherMap); if (upperMap != null) { stairs = ZTracker.stairsDown[upperMap]; } } if (stairs != null && stairs.Any()) { var selectedStairs = stairs.MinBy(x => IntVec3Utility.DistanceTo(position, x.Position)); position = selectedStairs.Position; } else { return(IntVec3.Invalid); } } return(position); }
private static MinifiedThing GetClosestCandidate(BuildableDef sourceDef, IntVec3 center, Map map, Faction faction, ThingDef stuff) { var settings = UseMinifiedBuildings.Settings; var matches = map.listerThings.ThingsOfDef(ThingDefOf.MinifiedThing).OfType <MinifiedThing>() .Where(m => m.InnerThing.def == sourceDef && m.InnerThing.Stuff == stuff && !m.IsForbidden(faction) && InstallBlueprintUtility.ExistingBlueprintFor(m) == null && (!m.TryGetQuality(out QualityCategory qc) || (settings.EnableForQualityBuildings && qc >= settings.GetMinQuality(sourceDef.frameDef, map)))) .ToList(); var minDist = int.MaxValue; MinifiedThing closest = null; foreach (var t in matches) { var dist = IntVec3Utility.ManhattanDistanceFlat(center, t.Position); if (dist < minDist) { minDist = dist; closest = t; } } return(settings.IsTooFar(minDist) ? null : closest); }
protected override Job TryGiveJob(Pawn pawn) { var thing = ThingToDo(pawn); if (thing != null) { if (!thing.Position.IsValid) { return((Job)null); } if (!pawn.CanReach((LocalTargetInfo)thing.Position, PathEndMode.ClosestTouch, maxDanger)) { return((Job)null); } if (IntVec3Utility.DistanceTo(thing.Position, pawn.Position) < 10f) { return(null); } return(new Job(JobDefOf.Goto, (LocalTargetInfo)thing.Position) { locomotionUrgency = LocomotionUrgency.Sprint }); } else { return(null); } }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { if (!(t is Fire fire)) { return(false); } if (fire.parent is Pawn pawn2) { if (pawn2 == pawn) { return(false); } if ((pawn2.Faction == pawn.Faction || pawn2.HostFaction == pawn.Faction || pawn2.HostFaction == pawn.HostFaction) && !pawn.Map.areaManager.Home[fire.Position] && IntVec3Utility.ManhattanDistanceFlat(pawn.Position, pawn2.Position) > MaxReservationCheckDistance) { return(false); } if (!pawn.CanReach(pawn2, PathEndMode.Touch, Danger.Deadly)) { return(false); } } else { if (pawn.story.DisabledWorkTagsBackstoryAndTraits.OverlapsWithOnAnyWorkType(WorkTags.Firefighting)) { return(false); } if (!pawn.Map.areaManager.Home[fire.Position]) { JobFailReason.Is(WorkGiver_FixBrokenDownBuilding.NotInHomeAreaTrans); return(false); } } if (Designator_AreaNoFireFighting.NoFireFightingArea(pawn.Map.areaManager)[fire.Position]) { return(false); } if ((pawn.Position - fire.Position).LengthHorizontalSquared <= MaxReservationCheckDistance * NearbyPawnRadius) { return(!FireIsBeingHandled(fire, pawn)); } LocalTargetInfo target = fire; if (!pawn.CanReserve(target, 1, -1, null, forced)) { return(false); } return(!FireIsBeingHandled(fire, pawn)); }
private void AffectCell(IntVec3 c) { bool flag2 = !GenGrid.InBounds(c, base.Map); if (!flag2) { bool flag = this.ShouldCellBeAffectedOnlyByDamage(c); bool flag3 = !flag && Rand.Chance(this.preExplosionSpawnChance) && GenGrid.Walkable(c, base.Map); if (flag3) { this.TrySpawnExplosionThing(this.preExplosionSpawnThingDef, c, this.preExplosionSpawnThingCount); } this.damType.Worker.ExplosionAffectCell(this, c, this.damagedThings, this.ignoredThings, !flag); bool flag4 = !flag && Rand.Chance(this.postExplosionSpawnChance) && GenGrid.Walkable(c, base.Map); if (flag4) { this.TrySpawnExplosionThing(this.postExplosionSpawnThingDef, c, this.postExplosionSpawnThingCount); } float num = this.chanceToStartFire; bool damageFalloff = this.damageFalloff; if (damageFalloff) { num *= Mathf.Lerp(1f, 0.2f, IntVec3Utility.DistanceTo(c, base.Position) / this.radius); } bool flag5 = Rand.Chance(num); if (flag5) { FireUtility.TryStartFireIn(c, base.Map, Rand.Range(0.1f, 0.925f)); } } }
public override void CompTick() { base.CompTick(); if (this.IsMounted) { if (driver.Dead || driver.Downed || driver.health.InPainShock || driver.InMentalState || //Abnormal (!driver.RaceProps.Animal && driver.Faction != Faction.OfPlayer) || ForbidUtility.IsForbidden(parent, Faction.OfPlayer)) { Dismount(); } else { if (Find.TickManager.TicksGame - tickLastDoorCheck >= TickCooldownDoorCheck && (driver.Position.GetEdifice() is Building_Door || parent.Position.GetEdifice() is Building_Door)) { lastPassedDoor = ((driver.Position.GetEdifice() is Building_Door) ? driver.Position.GetEdifice() : parent.Position.GetEdifice()) as Building_Door; lastPassedDoor.StartManualOpenBy(driver); tickLastDoorCheck = Find.TickManager.TicksGame; } else if (Find.TickManager.TicksGame - tickLastDoorCheck >= TickCooldownDoorCheck && lastPassedDoor != null) { lastPassedDoor.StartManualCloseBy(driver); lastPassedDoor = null; } parent.Position = IntVec3Utility.ToIntVec3(Position); parent.Rotation = driver.Rotation; } } }
public void DropTeam() { // Find exit spot. IntVec3 exitSpot = IntVec3.Invalid; bool exitSpotIsValid = Expedition.TryFindRandomExitSpot(this.Map, this.Position, out exitSpot); if (exitSpotIsValid) { // Spawn expedition pawns. List <Pawn> stayingAboardPawns = new List <Pawn>(); List <Pawn> droppedPawns = new List <Pawn>(); foreach (Pawn pawn in this.pawnsAboard) { if (pawn.kindDef == Util_PawnKindDefOf.Pilot) { stayingAboardPawns.Add(pawn); } else { droppedPawns.Add(pawn); GenSpawn.Spawn(pawn, this.Position + IntVec3Utility.RandomHorizontalOffset(3f), this.Map); } } this.pawnsAboard = stayingAboardPawns; // Make lord. LordMaker.MakeNewLord(Util_Faction.MiningCoFaction, new LordJob_ExitMap(exitSpot), this.Map, droppedPawns); // Spawn payment. SpawnPayment(droppedPawns.Count); Util_Faction.AffectGoodwillWith(Util_Faction.MiningCoFaction, Faction.OfPlayer, droppedPawns.Count); } }
static void Prefix(Thing __instance, ref DamageInfo dinfo) { try { if (__instance?.Position == null || dinfo.Def == null || dinfo.Instigator?.Faction == null || dinfo.Instigator?.Position == null || dinfo.Weapon?.Verbs?[0] == null || dinfo.Weapon.Verbs.Count == 0) { return; } if (Settings.usingRubberBullets && dinfo.Instigator.Faction.IsPlayer && dinfo.Def == DamageDefOf.Bullet) { float distance = IntVec3Utility.DistanceTo(dinfo.Instigator.Position, __instance.Position); float range = dinfo.Weapon.Verbs[0].range; float damageScalingByDistance = 0.5f * distance / range; dinfo = new DamageInfo(DamageDefOf.Blunt, dinfo.Amount, 0, dinfo.Angle, dinfo.Instigator, dinfo.HitPart, dinfo.Weapon, dinfo.Category, dinfo.IntendedTarget); dinfo.SetAmount((float)Math.Round(dinfo.Amount - dinfo.Amount * damageScalingByDistance)); } } catch (Exception e) { } //catch melee NullReference exceptions }
// Token: 0x060000F0 RID: 240 RVA: 0x00008BAC File Offset: 0x00006DAC protected virtual void Explode(Thing hitThing, bool destroy = false) { Map map = base.Map; IntVec3 intVec = (hitThing != null) ? hitThing.PositionHeld : IntVec3Utility.ToIntVec3(this.destinationInt); if (destroy) { this.Destroy(0); } bool flag = this.def.projectile.explosionEffect != null; if (flag) { Effecter effecter = this.def.projectile.explosionEffect.Spawn(); effecter.Trigger(new TargetInfo(intVec, map, false), new TargetInfo(intVec, map, false)); effecter.Cleanup(); } IntVec3 intVec2 = intVec; Map map2 = map; float explosionRadius = this.def.projectile.explosionRadius; DamageDef damageDef = this.def.projectile.damageDef; Thing launcher = this.launcher; int damageAmount = this.def.projectile.GetDamageAmount(1f, null); SoundDef soundExplode = this.def.projectile.soundExplode; ThingDef equipmentDef = this.equipmentDef; ThingDef def = this.def; ThingDef postExplosionSpawnThingDef = this.def.projectile.postExplosionSpawnThingDef; float postExplosionSpawnChance = this.def.projectile.postExplosionSpawnChance; int postExplosionSpawnThingCount = this.def.projectile.postExplosionSpawnThingCount; ThingDef preExplosionSpawnThingDef = this.def.projectile.preExplosionSpawnThingDef; GenExplosion.DoExplosion(intVec2, map2, explosionRadius, damageDef, launcher, damageAmount, 0f, soundExplode, equipmentDef, def, null, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff); }
public override bool HasJobOnThing(Pawn pawn, Thing t) { Fire fire = t as Fire; if (fire == null) { return(false); } Area outpostArea = OG_Util.FindOutpostArea(); Pawn pawn2 = fire.parent as Pawn; if (pawn2 != null) { if (pawn2 == pawn) { return(false); } if ((pawn2.Faction == pawn.Faction || pawn2.HostFaction == pawn.Faction || pawn2.HostFaction == pawn.HostFaction) && ((outpostArea == null) || (outpostArea.ActiveCells.Contains(t.Position) == false)) && IntVec3Utility.ManhattanDistanceFlat(pawn.Position, pawn2.Position) > 15) { return(false); } } else if ((outpostArea == null) || (outpostArea.ActiveCells.Contains(t.Position) == false)) { return(false); } return(((pawn.Position - fire.Position).LengthHorizontalSquared <= 225f || pawn.CanReserve(fire, 1)) && !WorkGiver_FightFiresOutpost.FireIsBeingHandled(fire, pawn)); }
public void ScareAnimals() { //Select a from animals where a.bodySize <= human && a.intelligence < toolUser && !a.WouldHuntHumans IEnumerable <Pawn> pawns = base.parent.Map.mapPawns.AllPawns.Where(x => x.def.race.intelligence == Intelligence.Animal // x has animal intelligence. I could use RaceProps but this has the potential for // more flavor, e.g. Ferals mutants fleeing and intelligent animals not && SmallEnoughToScare(x) && // x is small enough to scare IsAffectedPredator(x) && // x wouldn't prey upon colonists ShouldAffectColonyAnimal(x)); // if set for colony animals to ignore it, they will if (pawns == null || pawns.Count() <= 0) { return; } //for all animals foreach (Pawn animal in pawns) { //if animal is nearby and not already fleeing if (animal != null && animal.jobs?.curJob?.def != JobDefOf.Flee && IntVec3Utility.DistanceTo(animal.Position, base.parent.Position) < Radius) { //give the animal the flee job with parent as the thing they're fleeing Job job = new Job(JobDefOf.Flee, // Note that the below thing only treats things of the parent's def as dangerous. Done for performance reasons. // Not an issue with the mod as written, since VFE_Scarecrow is a single def, but could cause minor issues if the design changes. CellFinderLoose.GetFleeDest(animal, base.parent.Map.listerThings.ThingsOfDef(base.parent.def), Props.minFleeDistance), base.parent.Position); animal.jobs.StartJob(job, JobCondition.InterruptOptional); } } }
public void DoCatapult(Pawn pawn) { MLB_ThrownObject flyingObject = (MLB_ThrownObject)GenSpawn.Spawn(ThingDef.Named("BETA_GrapplerClassThrown"), pawn.PositionHeld, pawn.MapHeld, 0); var cellToCatapult = pawn.Map.AllCells.Where(x => IntVec3Utility.DistanceTo(pawn.Position, x) == 20).FirstOrDefault(); flyingObject.Launch(null, new LocalTargetInfo(cellToCatapult), pawn); }
// Token: 0x06000065 RID: 101 RVA: 0x00004254 File Offset: 0x00002454 public override void Draw() { bool flag = this.flyingThing != null; if (flag) { bool flag2 = this.flyingThing is Pawn; if (flag2) { Vector3 drawPos = this.DrawPos; bool flag3 = false; if (flag3) { return; } bool flag4 = !IntVec3Utility.ToIntVec3(this.DrawPos).IsValid; if (flag4) { return; } Pawn pawn = this.flyingThing as Pawn; pawn.Drawer.DrawAt(this.DrawPos); } else { Graphics.DrawMesh(MeshPool.plane10, this.DrawPos, this.ExactRotation, this.flyingThing.def.DrawMatSingle, 0); } base.Comps_PostDraw(); } }
// Token: 0x06000064 RID: 100 RVA: 0x00004198 File Offset: 0x00002398 public override void Tick() { base.Tick(); Vector3 exactPosition = this.ExactPosition; this.ticksToImpact--; bool flag = !GenGrid.InBounds(this.ExactPosition, base.Map); if (flag) { this.ticksToImpact++; base.Position = IntVec3Utility.ToIntVec3(this.ExactPosition); this.Destroy(0); } else { base.Position = IntVec3Utility.ToIntVec3(this.ExactPosition); bool flag2 = this.ticksToImpact <= 0; if (flag2) { bool flag3 = GenGrid.InBounds(this.DestinationCell, base.Map); if (flag3) { base.Position = this.DestinationCell; } this.ImpactSomething(); } } }
public void SpawnExplosions() { for (int explosionIndex = 0; explosionIndex < 5; explosionIndex++) { GenExplosion.DoExplosion(this.Position + IntVec3Utility.RandomHorizontalOffset(5f), this.Map, Rand.Range(3f, 7f), DamageDefOf.Bomb, this, Rand.Range(8, 45)); } }
// Token: 0x06000008 RID: 8 RVA: 0x00002298 File Offset: 0x00000498 private static IntVec3 GetNearestBaseItem(Pawn pawn) { IntVec3 position = pawn.Position; float num = 99999f; List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial); if (list.Count > 0) { Thing thing = null; foreach (Thing thing2 in list) { LocalTargetInfo localTargetInfo = thing2; if (ReachabilityUtility.CanReach(pawn, localTargetInfo, PathEndMode.Touch, Danger.Deadly, false, 0)) { float num2 = IntVec3Utility.DistanceTo(pawn.Position, thing2.Position); if (num2 < num) { thing = thing2; num = num2; } } } if (thing != null) { position = thing.Position; } } return(position); }
public override void TickRare() { if (this.power.PowerOn) { IntVec3 loc1 = this.Position + IntVec3Utility.RotatedBy(IntVec3.South, this.Rotation); IntVec3 loc2 = this.Position + IntVec3Utility.RotatedBy(IntVec3.North, this.Rotation); Room room1 = GridsUtility.GetRoom(loc1); if (room1 == null) { return; } Room room2 = GridsUtility.GetRoom(loc2); if (room2 == null || room1 == room2 || room1.UsesOutdoorTemperature && room2.UsesOutdoorTemperature) { return; } float targetTemp = !room1.UsesOutdoorTemperature ? (!room2.UsesOutdoorTemperature ? (float)((double)room1.Temperature * (double)room1.CellCount + (double)room2.Temperature * (double)room2.CellCount) / (float)(room1.CellCount + room2.CellCount) : room2.Temperature) : room1.Temperature; if (!room1.UsesOutdoorTemperature) { this.Equalize(room1, targetTemp); } if (room2.UsesOutdoorTemperature) { return; } this.Equalize(room2, targetTemp); } }
protected override Job TryGiveJob(Pawn pawn) { if (HiveUtility.JobGivenRecentTick(pawn, "Mine")) { return(null); } Region region = pawn.GetRegion(RegionType.Set_Passable); if (region == null) { return(null); } Queen queen = HiveUtility.FindQueen(pawn); if (queen == null) { return(null); } IntVec3 pos = IntVec3.Invalid; List <Egg> eggs = queen.spawnedEggs; if (eggs != null && eggs.Any()) { pos = eggs.RandomElement().Position; } else { pos = queen.hiveLocation; } for (int i = 0; i < 40; i++) { IntVec3 randomCell = region.RandomCell; for (int j = 0; j < 4; j++) { IntVec3 c = randomCell + GenAdj.CardinalDirections[j]; int dist = IntVec3Utility.ManhattanDistanceFlat(c, pos); if (dist > 3) { continue; } if (!c.InBounds(pawn.Map)) { continue; } Building edifice = c.GetEdifice(pawn.Map); if (edifice != null && (edifice.def.passability == Traversability.Impassable || edifice.def.IsDoor) && edifice.def.size == IntVec2.One && edifice.def != ThingDefOf.CollapsedRocks && pawn.CanReserve(edifice, 1, -1, null, false)) { return(new Job(JobDefOf.Mine, edifice) { ignoreDesignations = true }); } } } return(null); }
public void SpawnFuelPuddleAndFire() { for (int fireIndex = 0; fireIndex < 150; fireIndex++) { IntVec3 spawnCell = this.Position + IntVec3Utility.RandomHorizontalOffset(12f); GenSpawn.Spawn(ThingDefOf.Filth_Fuel, spawnCell, this.Map); Fire fire = GenSpawn.Spawn(ThingDefOf.Fire, spawnCell, this.Map) as Fire; fire.fireSize = Rand.Range(0.25f, 1.25f); } }
// Token: 0x0600000B RID: 11 RVA: 0x000024A4 File Offset: 0x000006A4 public override void TickRare() { base.TickRare(); bool shouldSendAlert = this.shouldSendAlert; if (shouldSendAlert) { MoteMaker.ThrowMetaIcon(IntVec3Utility.ToIntVec3(GenThing.TrueCenter(this)), base.Map, ThingDefOf.Mote_IncapIcon); } }
private void SpawnBeam() { ChronoBeam cb = ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("ChronoBeam", true), null) as ChronoBeam; bool flag = cb == null; if (!flag) { cb.Setup(this.caster, this.currentTarget); GenSpawn.Spawn(cb, IntVec3Utility.ToIntVec3(this.caster.Position.ToVector3()), this.caster.Map, 0); } }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); Building_CPRdummy.Ui_Change = ContentFinder <Texture2D> .Get("UI/UI_Change Button", true); if (this.MyCustomJob == null) { this.MyCustomJob = new Job(DefDatabase <JobDef> .GetNamed("GoToAndWaitForeverCPR", true), (LocalTargetInfo)((Thing)this), (LocalTargetInfo)InteractionCell); } this.ShotShield = this.Position + IntVec3Utility.RotatedBy(new Vector3(0.0f, 0.0f, 3f).ToIntVec3(), this.Rotation); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Fire fire = t as Fire; bool result; if (fire == null) { result = false; } else { Pawn pawn2 = fire.parent as Pawn; if (pawn2 != null) { if (pawn2 == pawn) { return(false); } if (pawn2.Faction == pawn.Faction || pawn2.HostFaction == pawn.Faction || pawn2.HostFaction == pawn.HostFaction) { if (!pawn.Map.areaManager.Home[fire.Position] && IntVec3Utility.ManhattanDistanceFlat(pawn.Position, pawn2.Position) > 15) { return(false); } } if (!pawn.CanReach(pawn2, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { return(false); } } else { if (pawn.story.WorkTagIsDisabled(WorkTags.Firefighting)) { return(false); } if (!pawn.Map.areaManager.Home[fire.Position]) { JobFailReason.Is(WorkGiver_FixBrokenDownBuilding.NotInHomeAreaTrans, null); return(false); } } if ((pawn.Position - fire.Position).LengthHorizontalSquared > 225) { LocalTargetInfo target = fire; if (!pawn.CanReserve(target, 1, -1, null, forced)) { return(false); } } result = !WorkGiver_FightFires.FireIsBeingHandled(fire, pawn); } return(result); }
public static void ThrowSmokeTrail(Vector3 loc, float size, Map map, string defName) { if (GenView.ShouldSpawnMotesAt(loc, map) && !map.moteCounter.Saturated) { MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named(defName), null); moteThrown.Scale = Rand.Range(2f, 3f) * size; moteThrown.exactPosition = loc; moteThrown.rotationRate = Rand.Range(-0.5f, 0.5f); moteThrown.SetVelocity((float)Rand.Range(30, 40), Rand.Range(0.008f, 0.012f)); GenSpawn.Spawn(moteThrown, IntVec3Utility.ToIntVec3(loc), map, WipeMode.Vanish); } }
// Token: 0x0600004A RID: 74 RVA: 0x0000417C File Offset: 0x0000237C public override void Tick() { this.innerContainer.ThingOwnerTick(true); this.ticksToImpact--; this.ticksToHeadAche++; Vector3 drawLoc = base.DrawPos; if (this.ticksToImpact % 3 == 0) { int numMotes = Math.Min(2, this.def.skyfaller.motesPerCell); for (int i = 0; i < numMotes; i++) { MoteMaker.ThrowSmoke(drawLoc, base.Map, 2f); } } if (this.ticksToImpact % 25 == 0 && this.JumpSound != null) { IntVec3 SoundPos = IntVec3Utility.ToIntVec3(drawLoc); SoundStarter.PlayOneShot(this.JumpSound, new TargetInfo(SoundPos, base.Map, false)); } if (this.ticksToHeadAche == 3 && Settings.AllowFire) { this.JPIgnite(IntVec3Utility.ToIntVec3(drawLoc), base.Map); } if (this.ticksToHeadAche == 10) { this.JPHitRoof(true); } if (this.ticksToImpact == 15) { this.JPHitRoof(false); } if (!this.anticipationSoundPlayed && this.def.skyfaller.anticipationSound != null && this.ticksToImpact < this.def.skyfaller.anticipationSoundTicks) { this.anticipationSoundPlayed = true; SoundStarter.PlayOneShot(this.def.skyfaller.anticipationSound, new TargetInfo(base.Position, base.Map, false)); } if (this.ticksToImpact == 3) { this.EjectPilot(); } if (this.ticksToImpact == 0) { this.JPImpact(); return; } if (this.ticksToImpact < 0) { Log.Error("ticksToImpact < 0. Was there an exception? Destroying skyfaller.", false); this.EjectPilot(); this.Destroy(0); } }
private Toil Toils_Training(TargetIndex targetIndex) { Toil toil = new Toil(); toil.initAction = (Action)(() => { toil.actor.pather.StopDead(); Building_Trainable X = (Building_Trainable)this.TargetA; switch (X.def.defName) { case "ShootingRange": this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain); IntVec3 shooter = TargetA.Cell + IntVec3Utility.RotatedBy(new Vector3(0.0f, 0.0f, 3f).ToIntVec3(), X.Rotation); Projectile projectile = (Projectile)ThingMaker.MakeThing(ThingDef.Named("TrainingBullet"), (ThingDef)null); GenSpawn.Spawn((Thing)projectile, pawn.Position, Map); projectile.Launch((Thing)pawn, pawn.DrawPos, shooter, (Thing)null); SoundDef Sound_shoot = SoundDef.Named("ShotRevolver"); Sound_shoot.PlayOneShot(SoundInfo.InMap(X, MaintenanceType.None)); break; case "CPRdummy": this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain); MoteMaker.ThrowMetaIcon(this.TargetA.Cell, this.Map, ThingDef.Named("Mote_HealingCross")); break; case "Holodeck": this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain); IntVec3 bubble_pos = new IntVec3(TargetA.Cell.x + 1, TargetA.Cell.y, TargetA.Cell.z); MoteMaker.MakeStaticMote(bubble_pos, Map, DefDatabase <ThingDef> .GetNamed("Mote_Speech"), 1f); break; case "PunchingBag": this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain); MoteMaker.ThrowDustPuff(TargetA.Cell, Map, 1.0f); SoundDef Sound_PBAG = SoundDef.Named("Pawn_Melee_Punch_HitPawn"); Sound_PBAG.PlayOneShot(SoundInfo.InMap(X, MaintenanceType.None)); break; default: return; } }); toil.defaultCompleteMode = ToilCompleteMode.Instant; return(toil); }