Esempio n. 1
0
        public static void MakeMeteorAt(IntVec3 loc, Map map, MeteorInfo info)
        {
            MeteorIncoming meteorIncoming = (MeteorIncoming)ThingMaker.MakeThing(ThingDef.Named("MeteorIncoming"));

            meteorIncoming.contents = info;
            GenSpawn.Spawn(meteorIncoming, loc, map);
        }
Esempio n. 2
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);
         }
     }
 }
Esempio n. 3
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);
         }
     }
 }
Esempio n. 4
0
 public static void DropThingGroupsNear(IntVec3 dropCenter, 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, 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(), 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, 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, dropPodInfo);
         }
     }
 }
        public static void DropThingGroupsNear( IntVec3 dropCenter, List<List<Thing>> thingsGroups, int openDelay = MeteorInfo.DefaultOpenDelay, bool canInstaDropDuringInit = true, bool leaveSlag = false )
        {
            IntVec3 dropSpot;
            foreach( var group in thingsGroups )
            {
            if( !RCellFinder.TryFindDropPodSpotNear( dropCenter, out dropSpot ) )
            {
                Log.Warning("DropThingsNear failed to find a place to drop " + group.FirstOrDefault() + " near " + dropCenter + ". Dropping on random square instead." );
                dropSpot = GenCellFinder.RandomCellWith( sq=>sq.Walkable() );
            }

            //Forbid all the things if possible
            foreach( Thing t in group )
            {
                ThingWithComponents tComp = t as ThingWithComponents;
                if( tComp != null && tComp.GetComp<CompForbiddable>() != null )
                    tComp.GetComp<CompForbiddable>().forbidden = true;
            }

            if( canInstaDropDuringInit && Find.TickManager.tickCount < 2 )
            {
                //Dropping before game start: just insta-spawn
                foreach( Thing t in group )
                {
                    GenPlace.TryPlaceThing(t, dropSpot, ThingPlaceMode.Near);
                }
            }
            else
            {
                MeteorInfo podInfo = new MeteorInfo();

                foreach( Thing t in group )
                {
                    podInfo.containedThings.Add(t);
                }

                podInfo.openDelay = openDelay;
                podInfo.leaveSlag = leaveSlag;
                dropSpot = GenCellFinder.RandomCellWith(sq => sq.Walkable());
                MeteorUtility.MakeMeteorAt( dropSpot, podInfo );
            }
            }
        }
 public static void MakeMeteorAt( IntVec3 loc, MeteorInfo info )
 {
     MeteorIncoming inc = (MeteorIncoming)ThingMaker.MakeThing( ThingDef.Named("MeteorIncoming") );
     inc.contents = info;
     GenSpawn.Spawn(inc, loc );
 }