// Token: 0x06000031 RID: 49 RVA: 0x00003520 File Offset: 0x00001720 internal bool FlightChecksOK(Pawn pilot, Thing JP, out string checksReason) { checksReason = ""; if ((pilot?.Map) == null) { checksReason = Translator.Translate("JetPack.ChecksLocation"); return(false); } if (GridsUtility.Roofed(pilot.Position, pilot.Map)) { if (!Settings.RoofPunch) { checksReason = Translator.Translate("JetPack.ChecksRoofed"); return(false); } ThingDef chkSKF = DefDatabase <ThingDef> .GetNamed(this.JPSkyFallType, false); if (chkSKF == null || !chkSKF.skyfaller.hitRoof) { checksReason = TranslatorFormattedStringExtensions.Translate("JetPack.ChecksSFNotRPunch", (chkSKF != null) ? GenText.CapitalizeFirst(chkSKF.label) : null); return(false); } } if (this.JPFuelAmount < this.JPFuelMin) { checksReason = Translator.Translate("JetPack.ChecksRefuel") + GenText.CapitalizeFirst(JP.Label); return(false); } return(true); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); this.ticksToImpact = Rand.RangeInclusive(120, 200); if (GridsUtility.Roofed(base.Position, map)) { Log.Warning("Meteor dropped on roof at " + base.Position); } }
// Token: 0x06000051 RID: 81 RVA: 0x00004498 File Offset: 0x00002698 internal void JPHitRoof(bool up) { if (!this.def.skyfaller.hitRoof) { return; } CellRect cr; if (up) { IntVec3 hrpcell = IntVec3Utility.ToIntVec3(base.DrawPos); IntVec2 punchsize = new IntVec2(3, 3); cr = GenAdj.OccupiedRect(hrpcell, base.Rotation, punchsize); } else { cr = GenAdj.OccupiedRect(this); } if (cr.Cells.Any((IntVec3 x) => GridsUtility.Roofed(x, this.Map))) { RoofDef roof = GridsUtility.GetRoof(cr.Cells.First((IntVec3 x) => GridsUtility.Roofed(x, this.Map)), base.Map); if (!SoundDefHelper.NullOrUndefined(roof.soundPunchThrough)) { SoundStarter.PlayOneShot(roof.soundPunchThrough, new TargetInfo(base.Position, base.Map, false)); } RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(base.Map).Cells.Where(delegate(IntVec3 c) { if (!GenGrid.InBounds(c, this.Map)) { return(false); } if (cr.Contains(c)) { return(true); } if (GridsUtility.GetFirstPawn(c, this.Map) != null) { return(false); } Building edifice = GridsUtility.GetEdifice(c, this.Map); return(edifice == null || !edifice.def.holdsRoof); }), base.Map, null); if (up) { this.PilotRoofPunchUp = true; return; } this.PilotRoofPunchDown = true; } }
public bool ComputeLightState() { if (this.get_Wearer() == null || this.get_Wearer().get_Dead() || this.get_Wearer().get_Downed() || !RestUtility.Awake(this.get_Wearer())) { return(false); } if (lightMode == LightMode.ForcedOn) { return(true); } if (lightMode == LightMode.ForcedOff) { return(false); } if (this.get_Wearer().get_Map() != null && ((GridsUtility.Roofed(this.get_Wearer().get_Position(), this.get_Wearer().get_Map()) && (int)this.get_Wearer().get_Map().glowGrid.PsychGlowAt(this.get_Wearer().get_Position()) <= 1) || (!GridsUtility.Roofed(this.get_Wearer().get_Position(), this.get_Wearer().get_Map()) && (int)this.get_Wearer().get_Map().glowGrid.PsychGlowAt(this.get_Wearer().get_Position()) < 2))) { return(true); } return(false); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; //ThingDef skyfaller = DefDatabase<ThingDef>.GetNamed("PI_MeteorIncoming", true); IntVec3 intVec = CellFinderLoose.RandomCellWith( (IntVec3 sq) => GenGrid.Standable(sq, map) && !GridsUtility.Roofed(sq, map) && !GridsUtility.Fogged(sq, map) && GenGrid.InBounds(sq, map), map); //SkyfallerMaker.SpawnSkyfaller(skyfaller, meteor, intVec, map); Thing singleContainedThing = PawnGenerator.GeneratePawn(PurpleIvyDefOf.Genny_Queen, null); var meteorIncoming = (MeteorIncoming)ThingMaker.MakeThing(ThingDef.Named("PI_QueenIncoming"), null); MeteorUtility.MakeMeteorAt(map, intVec, meteorIncoming, new MeteorInfo { SingleContainedThing = singleContainedThing, openDelay = 1, leaveSlag = false }); Find.LetterStack.ReceiveLetter("MeteoritePurple".Translate(), "MeteoritePurpleDesc".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false)); //"Look a giant flying purple rock....its purple it has to be something good...right?" return(true); }
private void DoTickerWork(int tickerAmount) { bool flag = (this.powerComp == null || this.powerComp.PowerOn); if (flag && base.Spawned) { if (GridsUtility.Roofed(base.Position, this.Map)) { if (!BreakdownableUtility.IsBrokenDown(this)) { SetRoofInRange(); ResetRemovedRoof(); } } CompProperties_Power props = powerComp.Props; powerComp.PowerOutput = -props.basePowerConsumption; } else { // Set roofs that were changed back to being thickRoof ResetRoofInRange(); } }
public override void MapComponentTick() { base.MapComponentTick(); if (Find.TickManager.TicksGame % 250 == 0) { var plants = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy); //Log.Message("Checking orbital strike, " + this.OrbitalHelpActive + " - " + plants.Count); if (plants != null && ((this.OrbitalHelpActive == true && plants.Count > 0) || plants.Count > 2000)) // && Rand.Chance(PurpleIvyData.getFogProgress(plants.Count))) { if (this.OrbitalHelpActive == false) { this.OrbitalHelpActive = true; Find.LetterStack.ReceiveLetter("OrbitalHelpFromAncients".Translate(), "OrbitalHelpFromAncientsDesc".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(plants.RandomElement().Position, map, false)); } PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(PurpleIvyDefOf.PI_PowerBeam, plants.RandomElement().Position, this.map, 0); powerBeam.duration = 200; powerBeam.instigator = null; powerBeam.weaponDef = null; powerBeam.StartStrike(); } if ((plants.Count <= 0 || plants == null) && this.OrbitalHelpActive == true) { Log.Message("Orbital help"); this.OrbitalHelpActive = false; List <Pawn> list = new List <Pawn>(); var alpha = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha); var beta = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta); var gamma = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma); var omega = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega); var guard = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard); int pawnCount = alpha.Count; pawnCount += beta.Count; pawnCount += gamma.Count; pawnCount += omega.Count; pawnCount += guard.Count; Predicate <IntVec3> predicate = delegate(IntVec3 c) { return(!GridsUtility.Fogged(c, map) && !GridsUtility.Roofed(c, map) && GenGrid.InBounds(c, map) && GenRadial.RadialCellsAround(c, 10, true).Where(x => map.thingGrid.ThingsListAt(x).Where(y => y.Faction == PurpleIvyData.AlienFaction) != null) != null); }; IntVec3 position = CellFinder.RandomClosewalkCellNear(this.map.Center, this.map, 500, predicate); foreach (var num in Enumerable.Range(1, pawnCount / 2)) { Faction faction = FactionUtility.DefaultFactionFrom(PurpleIvyDefOf.KorsolianFaction); Pawn NewPawn = PawnGenerator.GeneratePawn(PurpleIvyDefOf.KorsolianSoldier, faction); if (faction != null && faction != Faction.OfPlayer) { Lord lord = null; if (this.map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) => p != NewPawn)) { lord = ((Pawn)GenClosest.ClosestThing_Global(NewPawn.Position, this.map.mapPawns.SpawnedPawnsInFaction(faction), 99999f, (Thing p) => p != NewPawn && ((Pawn)p).GetLord() != null, null)).GetLord(); } if (lord == null) { var lordJob = new LordJob_AssistColony(Faction.OfPlayer, position); //LordJob_DefendPoint lordJob = new LordJob_DefendPoint(position); lord = LordMaker.MakeNewLord(faction, lordJob, this.map, null); } lord.AddPawn(NewPawn); } Log.Message(NewPawn?.Faction?.def?.defName); list.Add(NewPawn); } DropPodUtility.DropThingsNear(position, this.map, list, 30, false, true, true, true); Find.LetterStack.ReceiveLetter("AncientsLandOnTheGround".Translate(), "AncientsLandOnTheGroundDesc".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(position, map, false)); } //Log.Message("Alpha limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName]); //Log.Message("Beta limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName]); //Log.Message("Gamma limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName]); //Log.Message("Omega limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName]); int count = plants.Count; bool comeFromOuterSource; var tempComp = new WorldObjectComp_InfectedTile(); tempComp.infectedTile = map.Tile; if (PurpleIvyUtils.getFogProgressWithOuterSources(count, tempComp, out comeFromOuterSource) > 0f && !map.gameConditionManager.ConditionIsActive(PurpleIvyDefOf.PurpleFogGameCondition)) { GameCondition_PurpleFog gameCondition = (GameCondition_PurpleFog)GameConditionMaker.MakeConditionPermanent (PurpleIvyDefOf.PurpleFogGameCondition); map.gameConditionManager.RegisterCondition(gameCondition); if (comeFromOuterSource == false) { Find.LetterStack.ReceiveLetter(gameCondition.LabelCap, gameCondition.LetterText, gameCondition.def.letterDef, new TargetInfo(map.Center, map, false)); } else { Find.LetterStack.ReceiveLetter("PurpleFogСomesFromInfectedSites".Translate(), "PurpleFogСomesFromInfectedSitesDesc".Translate(), LetterDefOf.ThreatBig, new TargetInfo(map.Center, map, false)); Log.Message("PurpleFogСomesFromInfectedSites: " + map.ToString() + " - " + Find.TickManager.TicksGame.ToString()); } if (map.Parent.GetComponent <WorldObjectComp_InfectedTile>() == null) { var comp = new WorldObjectComp_InfectedTile(); comp.parent = map.Parent; comp.StartInfection(); comp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition; comp.counter = count; comp.infectedTile = map.Tile; comp.radius = comp.GetRadius(); PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter); comp.fillRadius(); map.Parent.AllComps.Add(comp); Log.Message("Adding comp to: " + map.Parent.ToString()); } } } if (Find.TickManager.TicksGame % 60000 == 0) { int count = 0; var alphaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac); var betaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta); var gammaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma); var nestsEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard); var omegaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg); Log.Message("Total PurpleIvy count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName]) { foreach (var egg in alphaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in alphaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteAlpha count on the map: " + count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName]) { foreach (var egg in betaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in betaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteBeta count on the map: " + count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName]) { foreach (var egg in gammaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in gammaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteGamma count on the map: " + count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName]) { foreach (var egg in omegaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in omegaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteOmega count on the map: " + count.ToString(), true); Log.Message("Total Genny_ParasiteNestGuard count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard).Count.ToString(), true); Log.Message("Total EggSac count on the map: " + alphaEggs.Count.ToString(), true); Log.Message("Total EggSac beta count on the map: " + betaEggs.Count.ToString(), true); Log.Message("Total EggSac gamma count on the map: " + gammaEggs.Count.ToString(), true); Log.Message("Total EggSac NestGuard count on the map: " + nestsEggs.Count.ToString(), true); Log.Message("Total ParasiteEgg count on the map: " + omegaEggs.Count.ToString(), true); Log.Message("Total GasPump count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count.ToString(), true); Log.Message("Total GenTurretBase count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count.ToString(), true); Log.Message("Total Turret_GenMortarSeed count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count.ToString(), true); Log.Message("Total Nest count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count.ToString(), true); } }
public override void TickLong() { this.CheckTemperatureMakeLeafless(); if (!GenPlant.GrowthSeasonNow(this.Position, Find.VisibleMap)) { return; } if (!this.HasEnoughLightToGrow) { this.unlitTicks += 2000; } else { this.unlitTicks = 0; } bool flag = this.LifeStage == PlantLifeStage.Mature; this.growth += this.GrowthPerTick * 2000f; if (!flag && this.LifeStage == PlantLifeStage.Mature) { this.NewlyMatured(); } if (this.def.plant.LimitedLifespan) { this.age += 2000; if (this.get_Rotting()) { int num = Mathf.CeilToInt(10f); this.TakeDamage(new DamageInfo(DamageDefOf.Rotting, num, (Thing)null, new BodyPartDamageInfo?(), (ThingDef)null)); } } if (this.Destroyed || !this.def.plant.shootsSeeds || ((double)this.growth < 0.600000023841858 || !Rand.MTBEventOccurs(this.def.plant.seedEmitMTBDays, 30000f, 2000f)) || (!GenPlant.SnowAllowsPlanting(this.Position) || GridsUtility.Roofed(this.Position))) { return; } GenPlantReproduction.TrySpawnSeed(this.Position, this.def, SeedTargFindMode.MapGenCluster, (Thing)this); }
// Token: 0x0600002A RID: 42 RVA: 0x00002E28 File Offset: 0x00001028 internal bool FlightCellCheck(Pawn pilot, IntVec3 tCell, int fuel, float fRate, float minJump, float maxJump, out string cantReason) { cantReason = ""; if (!GenGrid.InBounds(tCell, pilot.Map)) { cantReason = Translator.Translate("JetPack.JumpReasonInvalid"); return(false); } if (this.JPOnCooldown) { cantReason = Translator.Translate("JetPack.JumpReasonOnCooldown"); return(false); } if (!ReservationUtility.CanReserve(pilot, tCell, 1, -1, null, false)) { cantReason = Translator.Translate("JetPack.JumpReasonReserved"); return(false); } if (GridsUtility.Roofed(tCell, pilot.Map)) { if (!Settings.RoofPunch) { cantReason = Translator.Translate("JetPack.JumpReasonRoofed"); return(false); } ThingDef chkSKF = DefDatabase <ThingDef> .GetNamed(this.JPSkyFallType, false); if (chkSKF == null || !chkSKF.skyfaller.hitRoof) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonSFNotRPunch", (chkSKF != null) ? GenText.CapitalizeFirst(chkSKF.label) : null); return(false); } } if (!GenGrid.Walkable(tCell, pilot.Map)) { cantReason = Translator.Translate("JetPack.JumpReasonNotWalk"); return(false); } if (DangerUtility.GetDangerFor(tCell, pilot, pilot.Map) == Danger.Deadly) { cantReason = Translator.Translate("JetPack.JumpReasonDeadly"); return(false); } float distance = IntVec3Utility.DistanceTo(pilot.Position, tCell); if (distance < minJump) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonMinRange", ((int)minJump).ToString()); return(false); } if (distance > maxJump) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonMaxRange", ((int)maxJump).ToString()); return(false); } if (fRate <= 0f) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpFuelRateInvalid", fRate.ToString()); return(false); } float distCanJump; if (Settings.UseCarry) { distCanJump = (float)fuel / fRate * JPWeightUtility.JPCarryFactor(pilot, this.def, this.JPFuelItem); } else { distCanJump = (float)fuel / fRate; } if (distCanJump > maxJump) { distCanJump = maxJump; } if (distCanJump < distance) { cantReason = Translator.Translate("JetPack.JumpNotEnoughfuel"); return(false); } return(true); }