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 override bool TryExecute(IncidentParms parms) { ThingDef thingDef = ThingDef.Named("Meteorite"); Thing singleContainedThing = ThingMaker.MakeThing(thingDef); IntVec3 intVec = GenCellFinder.RandomCellWith((IntVec3 sq) => GenGrid.Standable(sq) && !Find.RoofGrid.Roofed(sq) && !FogUtility.Fogged(sq)); MeteorUtility.MakeMeteorAt(intVec, new MeteorInfo { SingleContainedThing = singleContainedThing, openDelay = 1, leaveSlag = false }); Find.History.AddGameEvent("Look a giant flying purple rock....its purple it has to be something good...right?", GameEventType.BadNonUrgent, true, intVec, string.Empty); return(true); }
public static void DropThingGroupsNear(IntVec3 dropCenter, List <List <Thing> > thingsGroups, int openDelay = 110, bool canInstaDropDuringInit = true, bool leaveSlag = false) { foreach (List <Thing> current in thingsGroups) { IntVec3 intVec; if (!RCellFinder.TryFindDropPodSpotNear(dropCenter, out intVec)) { Log.Warning(string.Concat(new object[] { "DropThingsNear failed to find a place to drop ", current.FirstOrDefault <Thing>(), " near ", dropCenter, ". Dropping on random square instead." })); intVec = GenCellFinder.RandomCellWith((IntVec3 sq) => sq.Walkable()); } foreach (Thing current2 in current) { ThingWithComponents thingWithComponents = current2 as ThingWithComponents; if (thingWithComponents != null && thingWithComponents.GetComp <CompForbiddable>() != null) { thingWithComponents.GetComp <CompForbiddable>().forbidden = true; } } if (canInstaDropDuringInit && Find.TickManager.tickCount < 2) { foreach (Thing current3 in current) { GenPlace.TryPlaceThing(current3, intVec, ThingPlaceMode.Near); } } else { MeteorInfo meteorInfo = new MeteorInfo(); foreach (Thing current4 in current) { meteorInfo.containedThings.Add(current4); } meteorInfo.openDelay = openDelay; meteorInfo.leaveSlag = leaveSlag; MeteorUtility.MakeMeteorAt(intVec, meteorInfo); } } }
public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool canInstaDropDuringInit = true, bool leaveSlag = false, bool canRoofPunch = true) { foreach (List <Thing> current 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 ", current.FirstOrDefault <Thing>(), " near ", dropCenter, ". Dropping on random square instead." })); intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000); } for (int i = 0; i < current.Count; i++) { current[i].SetForbidden(true, false); } if (canInstaDropDuringInit && Find.TickManager.TicksGame < 2) { foreach (Thing current2 in current) { GenPlace.TryPlaceThing(current2, intVec, map, ThingPlaceMode.Near); } } else { MeteorInfo dropPodInfo = new MeteorInfo(); foreach (Thing current3 in current) { dropPodInfo.containedThings.Add(current3); } dropPodInfo.openDelay = openDelay; dropPodInfo.leaveSlag = leaveSlag; MeteorUtility.MakeMeteorAt(intVec, map, dropPodInfo); } } }