// Token: 0x0600139E RID: 5022 RVA: 0x00096118 File Offset: 0x00094518 public void FireEvent(Map map, IntVec3 strikeLoc) { if (!strikeLoc.IsValid) { strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(map) && !map.roofGrid.Roofed(sq), map, 1000); } Mesh boltMesh = LightningBoltMeshPool.RandomBoltMesh; Material boltMat = null; if (!strikeLoc.Fogged(map)) { Vector3 loc = strikeLoc.ToVector3Shifted(); for (int i = 0; i < 4; i++) { MoteMaker.ThrowSmoke(loc, map, 1.5f); MoteMaker.ThrowMicroSparks(loc, map); MoteMaker.ThrowLightningGlow(loc, map, 1.5f); } } if (extFaction != null) { Graphic g = GraphicDatabase.Get <Graphic_Single>(extFaction.TeleportBoltTexPath, ShaderTypeDefOf.Transparent.Shader); boltMat = g.MatSingle; } SoundInfo info = SoundInfo.InMap(new TargetInfo(strikeLoc, map, false), MaintenanceType.None); SoundDefOf.Thunder_OnMap.PlayOneShot(info); EventDraw(map, strikeLoc, boltMesh, boltMat); }
public static bool Prefix(Map map, IntVec3 __result) { ///Predicate<IntVec3> validator, Map map, float roadChance, out IntVec3 result // don't drop on deep water __result = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(map) && !c.GetTerrain(map).HasTag("TKKN_Swim") && !c.Roofed(map) && !c.Fogged(map), map, 1000); return(true); }
// Token: 0x0600137A RID: 4986 RVA: 0x00094788 File Offset: 0x00092B88 public override void FireEvent() { base.FireEvent(); if (!strikeLoc.IsValid) { strikeLoc = CellFinderLoose.RandomCellWith(sq => sq.Standable(map) && !map.roofGrid.Roofed(sq), map); } boltMesh = LightningBoltMeshPool.RandomBoltMesh; if (!strikeLoc.Fogged(map)) { GenExplosion.DoExplosion(strikeLoc, map, 8f, DefDatabase <DamageDef> .GetNamed("ApoDamage"), null, 1000); var loc = strikeLoc.ToVector3Shifted(); for (var i = 0; i < 4; i++) { FleckMaker.ThrowSmoke(loc, map, 1.5f); FleckMaker.ThrowMicroSparks(loc, map); FleckMaker.ThrowLightningGlow(loc, map, 1.5f); } } var info = SoundInfo.InMap(new TargetInfo(strikeLoc, map)); SoundDef.Named("ra2_StormAtk").PlayOneShot(info); }
public override void FireEvent() { base.FireEvent(); if (!this.strikeLoc.IsValid) { this.strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(this.map) && !this.map.roofGrid.Roofed(sq), this.map, 1000); } this.boltMesh = LightningBoltMeshPool.RandomBoltMesh; if (!this.strikeLoc.Fogged(this.map)) { List <Thing> ignoredThings = new List <Thing>(); List <Building> allBuildings = this.map.listerBuildings.allBuildingsColonist; for (int k = 0; k < allBuildings.Count; k++) { if (allBuildings[k] != null && allBuildings[k].def.defName == "VPE_LightningRod") { ignoredThings.Add(allBuildings[k]); } } GenExplosion.DoExplosion(this.strikeLoc, this.map, 1.9f, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, ignoredThings); Vector3 loc = this.strikeLoc.ToVector3Shifted(); for (int i = 0; i < 4; i++) { MoteMaker.ThrowSmoke(loc, this.map, 1.5f); MoteMaker.ThrowMicroSparks(loc, this.map); MoteMaker.ThrowLightningGlow(loc, this.map, 1.5f); } } SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikeLoc, this.map, false), MaintenanceType.None); SoundDefOf.Thunder_OnMap.PlayOneShot(info); }
private void DoPawnReleased() { // A pawn is released and joins the colony? IntVec3 startPos; string str; str = txtArtefactActivatedPawnReleasedJoinsColony.Translate(); // Find a valid spawn position startPos = CellFinderLoose.RandomCellWith((IntVec3 c) => { if (Map.fogGrid.IsFogged(c)) { return(false); } if (!Map.reachability.CanReachColony(c)) { return(false); } if (Map.roofGrid.Roofed(c)) { return(false); } return(true); }, Map); Faction faction = Faction.OfPlayer; Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDefs.RandomElement(), faction); float value = UnityEngine.Random.Range(0.0f, 100.0f); if (value < 25.0f) // 25% chance: The pawn remains with weapon and clothes { // Do nothing... } else if (value < 60.0f) // 35% chance: The pawn has no weapon { pawn.equipment = new Pawn_EquipmentTracker(pawn); } else // 40% chance: The pawn has no weapon and is naked { pawn.apparel = new Pawn_ApparelTracker(pawn); pawn.equipment = new Pawn_EquipmentTracker(pawn); } // Spawn the pawn GenPlace.TryPlaceThing(pawn, startPos, Map, ThingPlaceMode.Direct); // Notify the Storyteller Find.StoryWatcher.watcherPopAdaptation.Notify_PawnEvent(pawn, PopAdaptationEvent.GainedColonist); string label = labelLetterArtefact.Translate(); // add game event Find.LetterStack.ReceiveLetter(label, str, LetterDefOf.PositiveEvent, pawn, null); }
private void DoSpawnResources() { IntVec3 startPos; string str = txtArtefactActivatedResources.Translate(); startPos = CellFinderLoose.RandomCellWith((IntVec3 c) => { // only allow standable, not fogged positions, not home region if (!c.Standable(Map) || Map.fogGrid.IsFogged(c) || Map.areaManager.Home[c]) { return(false); } else { return(true); } }, Map); // Get random resource ThingDef thingDef = resourceDefs.RandomElement(); List <Thing> things = new List <Thing>(); while (true) { int maxValuePerStack = UnityEngine.Random.Range(200, 2000); // max value per stack Thing thing = ThingMaker.MakeThing(thingDef); thing.stackCount = UnityEngine.Random.Range(15, 75); // random stack count if (thing.stackCount > thing.def.stackLimit) { thing.stackCount = thing.def.stackLimit; } if ((float)thing.stackCount * thing.def.BaseMarketValue > (float)maxValuePerStack) // check if stack is more worth than max value { thing.stackCount = Mathf.CeilToInt((float)maxValuePerStack / thing.def.BaseMarketValue); } things.Add(thing); if (things.Count < UnityEngine.Random.Range(6, 13)) // create 6-12 stacks { continue; } break; } //DropPodUtility.DropThingsNear(startPos, things, 0, true, false); foreach (Thing thing2 in things) { IntVec3 spawnPos = CellFinder.RandomClosewalkCellNear(startPos, Map, 5); GenPlace.TryPlaceThing(thing2, spawnPos, Map, ThingPlaceMode.Near); } string label = labelLetterArtefact.Translate(); // add game event Find.LetterStack.ReceiveLetter(label, str, LetterDefOf.PositiveEvent, new GlobalTargetInfo(startPos, Map), null); }
// Token: 0x06002764 RID: 10084 RVA: 0x0012C518 File Offset: 0x0012A918 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true) { foreach (List <Thing> list in thingsGroups) { IntVec3 intVec; if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch)) { Log.Warning(string.Concat(new object[] { "DropThingsNear failed to find a place to drop ", list.FirstOrDefault <Thing>(), " near ", dropCenter, ". Dropping on random square instead." })); intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map) && (c.Roofed(map) && c.GetRoof(map) != RoofDefOf.RoofRockThick), map, 1000); } for (int i = 0; i < list.Count; i++) { list[i].SetForbidden(true, false); } foreach (Thing thing in list) { // Log.Message(string.Format("revealing infiltrator: {0}, @: {1}, {2}", thing, intVec, map)); GenPlace.TryPlaceThing(thing, intVec, map, ThingPlaceMode.Near, null, null); } } }
public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true) { foreach (List <Thing> thingsGroup in thingsGroups) { if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out IntVec3 result, allowFogged: true, canRoofPunch)) { Log.Warning("DropThingsNear failed to find a place to drop " + thingsGroup.FirstOrDefault() + " near " + dropCenter + ". Dropping on random square instead."); result = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map); } for (int i = 0; i < thingsGroup.Count; i++) { thingsGroup[i].SetForbidden(value: true, warnOnFail: false); } if (instaDrop) { foreach (Thing item in thingsGroup) { GenPlace.TryPlaceThing(item, result, map, ThingPlaceMode.Near); } } else { ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); foreach (Thing item2 in thingsGroup) { activeDropPodInfo.innerContainer.TryAdd(item2); } activeDropPodInfo.openDelay = openDelay; activeDropPodInfo.leaveSlag = leaveSlag; MakeDropPodAt(result, map, activeDropPodInfo); } } }
public override void FireEvent() { //SoundDefOf.Thunder_OffMap.PlayOneShotOnCamera(this.map); if (!this.strikeLoc.IsValid) { this.strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(this.map) && !this.map.roofGrid.Roofed(sq), this.map, 1000); } this.boltMesh = RandomBoltMesh; if (!this.strikeLoc.Fogged(this.map)) { SoundDef exp = TorannMagicDefOf.TM_FireBombSD; GenExplosion.DoExplosion(this.strikeLoc, this.map, (Rand.Range(.8f, 1.2f) * this.averageRadius), this.damageType, instigator, this.damageAmount, -1f, exp, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); Vector3 loc = this.strikeLoc.ToVector3Shifted(); for (int i = 0; i < 4; i++) { MoteMaker.ThrowSmoke(loc, this.map, 1.3f); MoteMaker.ThrowMicroSparks(loc, this.map); MoteMaker.ThrowLightningGlow(loc, this.map, 1.2f); } } SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikeLoc, this.map, false), MaintenanceType.None); info.volumeFactor = this.soundVolume; info.pitchFactor = this.soundPitch; TorannMagicDefOf.TM_Thunder_OnMap.PlayOneShot(info); }
public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true, bool explode = false) { foreach (List <Thing> thingsGroup in thingsGroups) { IntVec3 intVec = default(IntVec3); if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch)) { Log.Warning("DropThingsNear failed to find a place to drop " + thingsGroup.FirstOrDefault() + " near " + dropCenter + ". Dropping on random square instead."); intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000); } for (int i = 0; i < thingsGroup.Count; i++) { thingsGroup[i].SetForbidden(true, false); } if (instaDrop) { foreach (Thing item in thingsGroup) { GenPlace.TryPlaceThing(item, intVec, map, ThingPlaceMode.Near, null); } } else { ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); foreach (Thing item2 in thingsGroup) { activeDropPodInfo.innerContainer.TryAdd(item2, true); } activeDropPodInfo.openDelay = openDelay; activeDropPodInfo.leaveSlag = leaveSlag; DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, explode); } } }
public override bool TryExecute(IncidentParms parms) { Map map = (Map)parms.target; string[] array = new string[] { "SandstoneBoulder", "LimestoneBoulder", "GraniteBoulder", "SlateBoulder", "MarbleBoulder", "MineralBoulder", "SilverBoulder", "GoldBoulder", "UraniumBoulder", "JadeBoulder" }; Random random = new Random(); int num = random.Next(array.Length); ThingDef thingDef = ThingDef.Named(array[num]); Thing singleContainedThing = ThingMaker.MakeThing(thingDef); IntVec3 dropCenter = CellFinderLoose.RandomCellWith((IntVec3 c) => GenGrid.Standable(c, map) && !map.roofGrid.Roofed(c) && !map.fogGrid.IsFogged(c), map, 1000); MeteorUtility.MakeMeteorAt(dropCenter, map, new MeteorInfo { SingleContainedThing = singleContainedThing, openDelay = 1, leaveSlag = false }); Find.LetterStack.ReceiveLetter("Meteor Incoming", "A meteoroid has entered the planets gravity well and come crashing down in a fiery explosion! weeee", LetterType.BadNonUrgent, new TargetInfo(dropCenter, map, false), null); return(true); }
public static IntVec3 TradeDropSpot(Map map) { IEnumerable <Building> collection = from b in map.listerBuildings.allBuildingsColonist where b.def.IsCommsConsole select b; IEnumerable <Building> enumerable = from b in map.listerBuildings.allBuildingsColonist where b.def.IsOrbitalTradeBeacon select b; Building building = enumerable.FirstOrDefault((Building b) => !map.roofGrid.Roofed(b.Position) && AnyAdjacentGoodDropSpot(b.Position, map, allowFogged: false, canRoofPunch: false)); IntVec3 result; if (building == null) { List <Building> list = new List <Building>(); list.AddRange(enumerable); list.AddRange(collection); list.RemoveAll(delegate(Building b) { CompPowerTrader compPowerTrader = b.TryGetComp <CompPowerTrader>(); return(compPowerTrader != null && !compPowerTrader.PowerOn); }); Predicate <IntVec3> validator = (IntVec3 c) => IsGoodDropSpot(c, map, allowFogged: false, canRoofPunch: false); if (!list.Any()) { list.AddRange(map.listerBuildings.allBuildingsColonist); list.Shuffle(); if (!list.Any()) { return(CellFinderLoose.RandomCellWith(validator, map)); } } int num = 8; int num2; IntVec3 size; do { for (int i = 0; i < list.Count; i++) { IntVec3 position = list[i].Position; if (CellFinder.TryFindRandomCellNear(position, map, num, validator, out result)) { return(result); } } num = Mathf.RoundToInt((float)num * 1.1f); num2 = num; size = map.Size; }while (num2 <= size.x); Log.Error("Failed to generate trade drop center. Giving random."); return(CellFinderLoose.RandomCellWith(validator, map)); } result = building.Position; if (!TryFindDropSpotNear(result, map, out IntVec3 result2, allowFogged: false, canRoofPunch: false)) { Log.Error("Could find no good TradeDropSpot near dropCenter " + result + ". Using a random standable unfogged cell."); return(CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(map) && !c.Fogged(map), map)); } return(result2); }
// Token: 0x06002764 RID: 10084 RVA: 0x0012C518 File Offset: 0x0012A918 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true, DeepStrikeType strikeType = DeepStrikeType.Drop) { foreach (List <Thing> list in thingsGroups) { List <Thing> list2 = list.Where(x => x.def.thingClass == typeof(Pawn) && (x.Faction != null && x.Faction.def.HasModExtension <FactionDefExtension>())).ToList(); FactionDefExtension extension = list2.RandomElement().Faction.def.GetModExtension <FactionDefExtension>(); IntVec3 intVec; if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch)) { Log.Warning(string.Concat(new object[] { "DropThingsNear failed to find a place to drop ", list.FirstOrDefault <Thing>(), " near ", dropCenter, ". Dropping on random square instead." }), false); intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map) && (c.Roofed(map) && c.GetRoof(map) != RoofDefOf.RoofRockThick), map, 1000); } for (int i = 0; i < list.Count; i++) { list[i].SetForbidden(true, false); } if (instaDrop) { foreach (Thing thing in list) { GenPlace.TryPlaceThing(thing, intVec, map, ThingPlaceMode.Near, null, null); } } else { ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); foreach (Thing item in list) { activeDropPodInfo.innerContainer.TryAddOrTransfer(item, true); } activeDropPodInfo.openDelay = openDelay; activeDropPodInfo.leaveSlag = leaveSlag; if (strikeType == DeepStrikeType.Fly) { DeepStrikeUtility.MakeFlyerLandAt(intVec, map, activeDropPodInfo, extension); } else if (strikeType == DeepStrikeType.Tunnel) { DeepStrikeUtility.MakeTunnelAt(intVec, map, activeDropPodInfo, extension); } else if (strikeType == DeepStrikeType.Teleport) { DeepStrikeUtility.MakeTeleportAt(intVec, map, activeDropPodInfo, extension); } else { DeepStrikeUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, extension); } } } }
public override void GameConditionTick() { base.GameConditionTick(); IntVec3 newFilthLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(AffectedMaps[0]) && !AffectedMaps[0].roofGrid.Roofed(sq), AffectedMaps[0], 1000); FilthMaker.TryMakeFilth(newFilthLoc, AffectedMaps[0], ThingDefOf.Filth_Vomit); }
public override void FireEvent() { if (!this.strikeLoc.IsValid) { this.strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(map) && !sq.Roofed(map), map); } this.boltMesh = Skydriller_PLasmaBeam_MeshMaker.NewBoltMesh(); }
public override bool TryExecute(IncidentParms parms) { IntVec3 dropCenter = CellFinderLoose.RandomCellWith((IntVec3 c) => GenGrid.Standable(c) && !Find.RoofGrid.Roofed(c) && !Find.FogGrid.IsFogged(c), 1000); GenSpawn.Spawn(ThingDef.Named("Thing_RazorSpawner"), dropCenter); Find.LetterStack.ReceiveLetter("Razor rain imminent", "Some debris in orbit around the planet has started to fall in the area, brace yourselves.", LetterType.BadUrgent); return(true); }
public static bool TryFindRaidDropCenterClose(out IntVec3 spot, Map map) { Faction faction = map.ParentFaction ?? Faction.OfPlayer; int num = 0; while (true) { IntVec3 root = IntVec3.Invalid; if (map.mapPawns.FreeHumanlikesSpawnedOfFaction(faction).Count <Pawn>() > 0) { root = map.mapPawns.FreeHumanlikesSpawnedOfFaction(faction).RandomElement <Pawn>().Position; } else { if (faction == Faction.OfPlayer) { List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist; for (int i = 0; i < allBuildingsColonist.Count; i++) { if (DropCellFinder.TryFindDropSpotNear(allBuildingsColonist[i].Position, map, out root, true, true)) { break; } } } else { List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial); for (int j = 0; j < list.Count; j++) { if (list[j].Faction == faction && DropCellFinder.TryFindDropSpotNear(list[j].Position, map, out root, true, true)) { break; } } } if (!root.IsValid) { root = DropCellFinder.RandomDropSpot(map); } } spot = CellFinder.RandomClosewalkCellNear(root, map, 10, null); if (DropCellFinder.CanPhysicallyDropInto(spot, map, true)) { break; } num++; if (num > 300) { goto Block_9; } } return(true); Block_9: spot = CellFinderLoose.RandomCellWith((IntVec3 c) => DropCellFinder.CanPhysicallyDropInto(c, map, true), map, 1000); return(false); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec = CellFinderLoose.RandomCellWith((IntVec3 sq) => GenGrid.Standable(sq, map) && !map.fogGrid.IsFogged(sq), map, 1000); Thing thing = ThingMaker.MakeThing(ThingDef.Named("MO_RTWorker"), null); GenSpawn.Spawn(thing, intVec, map); return(true); }
public override bool TryExecute(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 dropCenter = CellFinderLoose.RandomCellWith((IntVec3 c) => GenGrid.Standable(c, map) && !map.roofGrid.Roofed(c) && !map.fogGrid.IsFogged(c), map, 1000); GenSpawn.Spawn(ThingDef.Named("Thing_MeteorSpawner"), dropCenter, map); Find.LetterStack.ReceiveLetter("Meteor Shower Incoming", "A shower of meteoroids have entered the planets gravity well and come crashing down in a fiery explosion! weeee", LetterType.BadUrgent); return(true); }
private static bool SpawnAnimalPrefix(WildAnimalSpawner __instance, ref IntVec3 loc, ref bool __result, Map ___map) { if (ZLevelsMod.settings.allowZLevelsInfestation) { try { bool result = false; var comp = ZUtils.GetMapComponentZLevel(___map); var ZTracker = ZUtils.ZTracker; if (___map.Parent is MapParent_ZLevel && comp != null && ZTracker.GetUpperLevel(___map.Tile, ___map) != null && !ZUtils.GetMapComponentZLevel(ZTracker.GetUpperLevel(___map.Tile, ___map)) .hasCavesBelow.GetValueOrDefault(false)) { result = false; } else { PawnKindDef pawnKindDef = (from a in ___map.Biome.AllWildAnimals where ___map.mapTemperature.SeasonAcceptableFor(a.race) select a) .RandomElementByWeight((PawnKindDef def) => ___map.Biome.CommonalityOfAnimal(def) / def.wildGroupSize.Average); if (pawnKindDef == null) { Log.Error("No spawnable animals right now."); result = false; } else { ZLogger.Message("Spawning animal: " + pawnKindDef + " in biome: " + ___map.Biome); int randomInRange = pawnKindDef.wildGroupSize.RandomInRange; int radius = Mathf.CeilToInt(Mathf.Sqrt((float)pawnKindDef.wildGroupSize.max)); if (___map.Parent is MapParent_ZLevel && !loc.Walkable(___map)) { loc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Walkable(___map), ___map); } for (int i = 0; i < randomInRange; i++) { IntVec3 loc2 = CellFinder.RandomClosewalkCellNear(loc, ___map, radius, null); GenSpawn.Spawn(PawnGenerator.GeneratePawn(pawnKindDef, null), loc2, ___map, WipeMode.Vanish); } result = true; } } __result = result; } catch (Exception ex) { Log.Error("[Z-Levels] SpawnAnimalPrefix patch produced an error. That should not happen and will break things. Send a Hugslib log to the Z-Levels developers. Error message: " + ex); } return(false); } return(true); }
public static bool TryFindRaidDropCenterClose(out IntVec3 spot, Map map, bool canRoofPunch = true, bool allowIndoors = true, bool closeWalk = true, int maxRadius = -1) { Faction parentFaction = map.ParentFaction; if (parentFaction == null) { return(RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => CanPhysicallyDropInto(x, map, canRoofPunch, allowIndoors) && !x.Fogged(map) && x.Standable(map), map, out spot)); } int num = 0; do { IntVec3 result = IntVec3.Invalid; if (map.mapPawns.FreeHumanlikesSpawnedOfFaction(parentFaction).Count() > 0) { result = map.mapPawns.FreeHumanlikesSpawnedOfFaction(parentFaction).RandomElement().Position; } else { if (parentFaction == Faction.OfPlayer) { List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist; for (int i = 0; i < allBuildingsColonist.Count && !TryFindDropSpotNear(allBuildingsColonist[i].Position, map, out result, allowFogged: true, canRoofPunch, allowIndoors); i++) { } } else { List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial); for (int j = 0; j < list.Count && (list[j].Faction != parentFaction || !TryFindDropSpotNear(list[j].Position, map, out result, allowFogged: true, canRoofPunch, allowIndoors)); j++) { } } if (!result.IsValid) { RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => CanPhysicallyDropInto(x, map, canRoofPunch, allowIndoors) && !x.Fogged(map) && x.Standable(map), map, out result); } } int num2 = ((maxRadius >= 0) ? maxRadius : 10); if (!closeWalk) { CellFinder.TryFindRandomCellNear(result, map, num2 * num2, null, out spot, 50); } else { spot = CellFinder.RandomClosewalkCellNear(result, map, num2); } if (CanPhysicallyDropInto(spot, map, canRoofPunch, allowIndoors) && !spot.Fogged(map)) { return(true); } num++; }while (num <= 300); spot = CellFinderLoose.RandomCellWith((IntVec3 c) => CanPhysicallyDropInto(c, map, canRoofPunch, allowIndoors), map); return(false); }
public void PerformChannelingTreatment() { this.channelingTicksCounter++; if (this.channelingTicksCounter == 1) { Find.WeatherManager.TransitionTo(Util_MechanoidTerraformer.TerraformingThunderstormDef); } else if ((this.channelingTicksCounter >= channelingWithoutStrikesTicks) && (this.channelingTicksCounter < channelingWithoutStrikesTicks + channelingWithStrikesTicks)) { if (Rand.Value < chanceToStrikePerTick) { IntVec3 strikePosition = new IntVec3(); if (Rand.Value < 0.5f) { // Strike on a nearby pawn. List <Pawn> nearbyPawns = new List <Pawn>(); foreach (Pawn pawn in Find.ListerPawns.AllPawns) { if (pawn.Position.InHorDistOf(base.forcedTarget.Cell, this.areaOfEffectRadius)) { nearbyPawns.Add(pawn); } } if (nearbyPawns.Count > 0) { strikePosition = nearbyPawns.RandomElement <Pawn>().Position; WeatherEvent_LightningStrike lightningStrike = new WeatherEvent_LightningStrike(strikePosition); Find.WeatherManager.eventHandler.AddEvent(lightningStrike); } } else { Predicate <IntVec3> validator = (IntVec3 cell) => cell.Walkable() && (Find.RoofGrid.Roofed(cell) == false) && cell.InHorDistOf(base.forcedTarget.Cell, this.def.building.turretGunDef.Verbs[0].projectileDef.projectile.explosionRadius); strikePosition = CellFinderLoose.RandomCellWith(validator); WeatherEvent_LightningStrike lightningStrike = new WeatherEvent_LightningStrike(strikePosition); Find.WeatherManager.eventHandler.AddEvent(lightningStrike); } } } else if (this.channelingTicksCounter == channelingWithoutStrikesTicks + channelingWithStrikesTicks) { Find.WeatherManager.TransitionTo(WeatherDef.Named("Clear")); } else if (this.channelingTicksCounter == 2 * channelingWithoutStrikesTicks + channelingWithStrikesTicks) { this.charge = 0; this.channelingTicksCounter = 0; this.skywrathState = SkywrathState.Charging; } }
// Token: 0x06000004 RID: 4 RVA: 0x0000257C File Offset: 0x0000077C private static void Postfix(Map map) { if (!Settings.RainWaterPuddles) { return; } if (map.weatherManager.curWeather.rainRate >= 1f && map.weatherManager.curWeather.snowRate <= 0f && Rand.Range(1, 100) <= Settings.PuddleChance) { FilthMaker.TryMakeFilth(CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(map) && !map.roofGrid.Roofed(sq), map, 1000), map, ThingDef.Named("FilthWater"), 1); } }
public static IntVec3 FindClusterPosition(Map map, MechClusterSketch sketch, int maxTries = 100, float spawnCloseToColonyChance = 0f) { IntVec3 result = IntVec3.Invalid; float num = float.MinValue; if (Rand.Chance(spawnCloseToColonyChance)) { for (int i = 0; i < 20; i++) { if (!DropCellFinder.TryFindRaidDropCenterClose(out IntVec3 spot, map, canRoofPunch: true, allowIndoors: true, closeWalk: false, 40)) { break; } float clusterPositionScore = GetClusterPositionScore(spot, map, sketch); if (clusterPositionScore >= 100f || Mathf.Approximately(clusterPositionScore, 100f)) { return(spot); } if (clusterPositionScore > num) { result = spot; num = clusterPositionScore; } } } for (int j = 0; j < maxTries; j++) { IntVec3 intVec = CellFinderLoose.RandomCellWith((IntVec3 x) => x.Standable(map), map); if (!intVec.IsValid) { continue; } IntVec3 intVec2 = RCellFinder.FindSiegePositionFrom_NewTemp(intVec, map); if (intVec2.IsValid) { float clusterPositionScore2 = GetClusterPositionScore(intVec2, map, sketch); if (clusterPositionScore2 >= 100f || Mathf.Approximately(clusterPositionScore2, 100f)) { return(intVec2); } if (clusterPositionScore2 > num) { result = intVec; num = clusterPositionScore2; } } } if (!result.IsValid) { return(CellFinder.RandomCell(map)); } return(result); }
internal static IntVec3 _TradeDropSpot() { IEnumerable <Building> beacons = Find.ListerBuildings.allBuildingsColonist.Where(b => ( ( (b.def.thingClass == typeof(Building_OrbitalTradeBeacon)) || (b.def.thingClass.IsSubclassOf(typeof(Building_OrbitalTradeBeacon))) ) && (b.PoweredAndOn()) )); Building building = Enumerable.FirstOrDefault <Building>(beacons, ValidAdjacentCell); if (building != null) { IntVec3 position = building.Position; IntVec3 result; if (!DropCellFinder.TryFindDropSpotNear(position, out result, false, false)) { Log.Error("Could find no good TradeDropSpot near dropCenter " + (object)position + ". Using a random standable unfogged cell."); result = CellFinderLoose.RandomCellWith(c => (c.Standable() && !c.Fogged())); } return(result); } List <Building> beaconAndComms = beacons.ToList(); beaconAndComms.AddRange( Find.ListerBuildings.allBuildingsColonist.Where(b => ( ( (b.def.thingClass == typeof(Building_CommsConsole)) || (b.def.thingClass.IsSubclassOf(typeof(Building_CommsConsole))) ) && (PoweredAndOn(b)) ))); int squareRadius = 8; do { for (int index = 0; index < beaconAndComms.Count; ++index) { IntVec3 result; if (CellFinder.TryFindRandomCellNear( beaconAndComms[index].Position, squareRadius, IsGoodDropSpot, out result)) { return(result); } } squareRadius = Mathf.RoundToInt((float)squareRadius * 1.1f); }while(squareRadius <= Find.Map.Size.x); Log.Error("Failed to generate trade drop center. Giving random."); return(CellFinderLoose.RandomCellWith(IsGoodDropSpot)); }
static bool Prefix(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true) { IntVec3 intVec3; foreach (List <Thing> thingsGroup in thingsGroups) { if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec3, true, canRoofPunch)) { Log.Warning(string.Concat(new object[] { "DropThingsNear failed to find a place to drop ", thingsGroup.FirstOrDefault <Thing>(), " near ", dropCenter, ". Dropping on random square instead." })); intVec3 = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000); } for (int i = 0; i < thingsGroup.Count; i++) { thingsGroup[i].SetForbidden(true, false); } if (!instaDrop) { ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); foreach (Thing thing in thingsGroup) { activeDropPodInfo.innerContainer.TryAdd(thing, true); } if (Controller.Settings.podTrees.Equals(true)) { float woodCheck = map.Biome.plantDensity; if (woodCheck > 1) { woodCheck = 1; } if (Rand.Value < (woodCheck * 4)) { Thing wood = ThingMaker.MakeThing(ThingDefOf.WoodLog, null); float count = Rand.Gaussian(80, 10); count = count * woodCheck; wood.stackCount = (int)count; activeDropPodInfo.innerContainer.TryAdd(wood, true); } } activeDropPodInfo.openDelay = openDelay; activeDropPodInfo.leaveSlag = leaveSlag; DropPodUtility.MakeDropPodAt(intVec3, map, activeDropPodInfo); } else { foreach (Thing thing1 in thingsGroup) { GenPlace.TryPlaceThing(thing1, intVec3, map, ThingPlaceMode.Near, null); } } } return(false); }
public override void CompTick() { base.CompTick(); if (GetPawn == null || GetPawn.Dead || GetPawn.Map == null) { return; } if (GetPawn.IsHashIntervalTick(GenTicks.SecondsToTicks(Props.secondsBetweenLightning)) && (GetPawn.IsFighting() || GetPawn.InAggroMentalState)) { IntVec3 strikeLocation = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(GetPawn.Map) && !GetPawn.Map.roofGrid.Roofed(sq) && GetPawn.Position.DistanceTo(sq) <= Props.lightningRadius, GetPawn.Map, 1000); Find.CurrentMap.weatherManager.eventHandler.AddEvent(new WeatherEvent_LightningStrike(GetPawn.Map, strikeLocation)); } }
private void MakeTradeCaravans(Map map) { IntVec3 spot; if (RCellFinder.TryFindRandomSpotJustOutsideColony(CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(map), map, 1000), map, out spot)) { foreach (Faction faction in this.Factions) { this.MakeTradeCaravan(faction, spot, map); } this.MakeTradeCaravan(this.hostFaction, spot, map); } }
public static void UnfogFromRandomEdge(Map map) { MapGenUtility.FogAll(map); MapGenerator.rootsToUnfog.Clear(); foreach (Pawn current in map.mapPawns.FreeColonists) { MapGenerator.rootsToUnfog.Add(current.Position); } MapGenerator.rootsToUnfog.Add(CellFinderLoose.RandomCellWith((IntVec3 loc) => GenGrid.Standable(loc, map) && (loc.x <4 || loc.z <4 || loc.x> map.Size.x - 5 || loc.z> map.Size.z - 5), map, 1000)); foreach (IntVec3 current2 in MapGenerator.rootsToUnfog) { FloodFillerFog.FloodUnfog(current2, map); } }
public void IncreaseZombiePopulation() { if (populationSpawnCounter-- < 0) { populationSpawnCounter = (int)GenMath.LerpDouble(0, 1000, 300, 20, Math.Max(100, Math.Min(1000, currentColonyPoints))); if (GenDate.DaysPassedFloat < ZombieSettings.Values.daysBeforeZombiesCome) { return; } if (ZombieSettings.Values.spawnWhenType == SpawnWhenType.InEventsOnly) { return; } var numberOfZombies = ZombieCount() + Tools.generator.ZombiesQueued(map); if (numberOfZombies < GetMaxZombieCount()) { switch (ZombieSettings.Values.spawnHowType) { case SpawnHowType.AllOverTheMap: { var cell = CellFinderLoose.RandomCellWith(Tools.ZombieSpawnLocator(map), map, 4); if (cell.IsValid) { Tools.generator.SpawnZombieAt(map, cell, false); } return; } case SpawnHowType.FromTheEdges: { IntVec3 cell; if (CellFinder.TryFindRandomEdgeCellWith(Tools.ZombieSpawnLocator(map), map, CellFinder.EdgeRoadChance_Neutral, out cell)) { Tools.generator.SpawnZombieAt(map, cell, false); } return; } default: { Log.Error("Unknown spawn type " + ZombieSettings.Values.spawnHowType); return; } } } } }