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 override bool TryExecute(IncidentParms parms) { // Don't execute, when the colonist-count is too low if (Find.ListerPawns.ColonistCount <= 4) { return(false); } // Find a random square thats standable and not hidden by fog IntVec3 intVec3 = GenCellFinder.RandomCellWith((IntVec3 sq) => (!sq.Standable() ? false : !sq.IsFogged())); // Make the crash explosion Explosion.DoExplosion(intVec3, 3f, DamageTypeDefOf.Flame, null); string letter = "A part of the engine of your spaceship has crashed nearby./n/n" + "Caution: It's radiation may cause changes in the behavior of nearby animals!/n" + "I recomend to destroy it as soon as possible."; // Get the letter data from xml if possible string xmlLetter = ((ThingDef_AnimalInsaniator)ThingDef.Named(defNameCrashedObject)).incidentLetter; if (xmlLetter != null) { letter = xmlLetter; } // Make Letter letter = letter.Replace("/n", Environment.NewLine); Find.LetterStack.ReceiveLetter(new Letter(letter, LetterType.BadNonUrgent, intVec3)); // Spawn the Animal Insaniator ThingDef thingDef = ThingDef.Named(defNameCrashedObject); Thing thing = GenSpawn.Spawn(thingDef, intVec3); thing.SetFactionDirect(Find.FactionManager.AllFactions.Where(f => f.IsHostileToward(Faction.OfColony)).RandomElement <Faction>()); return(true); }