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);
        }
Ejemplo n.º 2
0
 public static void DropThingsNear(IntVec3 dropCenter, Map map, IEnumerable <Thing> things, int openDelay = 110, bool canInstaDropDuringInit = true, bool leaveSlag = false)
 {
     foreach (Thing current in things)
     {
         List <Thing> list = new List <Thing>();
         list.Add(current);
         MeteorUtility.tempList.Add(list);
     }
     MeteorUtility.DropThingGroupsNear(dropCenter, map, MeteorUtility.tempList, openDelay, canInstaDropDuringInit, leaveSlag);
     MeteorUtility.tempList.Clear();
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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);
         }
     }
 }
Ejemplo n.º 5
0
 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);
         }
     }
 }
Ejemplo n.º 6
0
        private void DoMeteorEvent()
        {
            Map map = base.Map;

            this.numMeteorEventCount--;
            if (this.numMeteorEventCount < 0)
            {
                Find.LetterStack.ReceiveLetter("Meteor Shower Stopped", "No further meteors detected.", LetterType.Good);
                this.Destroy(0);
                return;
            }
            int     num        = this.random.Next(numMinMeteors, numMaxMeteors);
            IntVec3 dropCenter = CellFinderLoose.RandomCellWith((IntVec3 c) => GenGrid.Standable(c, map) && !map.roofGrid.Roofed(c) && !map.fogGrid.IsFogged(c), map, 1000);

            string[] array = new string[]
            {
                "SandstoneBoulder",
                "LimestoneBoulder",
                "GraniteBoulder",
                "SlateBoulder",
                "MarbleBoulder",
                "MineralBoulder",
                "SilverBoulder",
                "GoldBoulder",
                "UraniumBoulder",
                "JadeBoulder"
            };
            ThingDef     thingDef = ThingDef.Named(array[this.random.Next(array.Length)]);
            List <Thing> list     = new List <Thing>();

            while (list.Count < num)
            {
                Thing item = ThingMaker.MakeThing(thingDef);
                list.Add(item);
            }
            MeteorUtility.DropThingsNear(dropCenter, map, list, 1, true, false);
        }