Пример #1
0
        public static void MakeShipWreckCrashingAt(IntVec3 dropCenter, List<List<Thing>> thingsGroups, int openDelay = 120, bool canInstaDropDuringInit = true, bool leaveSlag = false, bool canRoofPunch = false)
        {
            // Set a var to store drop cell
            IntVec3 intVec;
            // If we cant find a dropspot
            if (!DropCellFinder.TryFindDropSpotNear(dropCenter, out intVec, true, canRoofPunch))
            {
                // Log an error
                Log.Warning(string.Concat("DropThingsNear in RA failed to find a place to drop ", " near ", dropCenter, ". Dropping on random square instead."));
                // Try another way to get a drop spot
                CellFinderLoose.RandomCellWith(cell => cell.Walkable());
            }

            // Setup a new container for contents and config
            var cargo = new DropPodInfo();
            // Loop over things passed in params
            foreach (var group in thingsGroups)
            {
                // Foreach thing we find
                foreach (var thing in group)
                {
                    // Add it to the info container
                    cargo.containedThings.Add(thing);
                }
            }
            // Set the open delay on the info container
            cargo.openDelay = openDelay;

            // Call the main method to create the ship
            var wreck = (ShipWreckFlying)ThingMaker.MakeThing(ThingDef.Named("ShipWreckFlying"));
            // Set its content to what was passed in params
            wreck.cargo = cargo;
            // Spawn the falling ship part
            GenSpawn.Spawn(wreck, dropCenter);
        }
Пример #2
0
        public static void DropThingGroupsNear( IntVec3 dropCenter, List<List<Thing>> thingsGroups, int openDelay = DropPodInfo.DefaultOpenDelay, bool canInstaDropDuringInit = true, bool leaveSlag = false )
        {
            IntVec3 dropSpot;
            foreach( var group in thingsGroups )
            {
            if( !CellFinder.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
            {
                DropPodInfo podInfo = new DropPodInfo();

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

                podInfo.openDelay = openDelay;
                podInfo.leaveSlag = leaveSlag;
                DropPodUtility.MakeDropPodAt( dropSpot, podInfo );
            }
            }
        }
Пример #3
0
 public static void MakeDropPodCrashingAt(IntVec3 loc, DropPodInfo cargo)
 {
     // Create a new falling drop pod
     var dropPodCrashing = (DropPodFlying)ThingMaker.MakeThing(ThingDef.Named("DropPodFlying"));
     // Set its content to what was passed in params
     dropPodCrashing.cargo = cargo;
     // Spawn the falling drop pod
     GenSpawn.Spawn(dropPodCrashing, loc);
 }
Пример #4
0
 public static void MakeDropPodAt( IntVec3 loc, DropPodInfo info )
 {
     DropPodIncoming inc = (DropPodIncoming)ThingMaker.MakeThing( ThingDef.Named("DropPodIncoming") );
     inc.contents = info;
     GenSpawn.Spawn(inc, loc );
 }