Esempio n. 1
0
        protected virtual void Impact()
        {
            if (this.def.skyfaller.CausesExplosion)
            {
                GenExplosion.DoExplosion(base.Position, base.Map, this.def.skyfaller.explosionRadius, this.def.skyfaller.explosionDamage, null, GenMath.RoundRandom((float)this.def.skyfaller.explosionDamage.defaultDamage * this.def.skyfaller.explosionDamageFactor), -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
            }
            for (int i = this.innerContainer.Count - 1; i >= 0; i--)
            {
                GenPlace.TryPlaceThing(this.innerContainer[i], base.Position, base.Map, ThingPlaceMode.Near, delegate(Thing thing, int count)
                {
                    PawnUtility.RecoverFromUnwalkablePositionOrKill(thing.Position, thing.Map);
                }, null);
            }
            this.innerContainer.ClearAndDestroyContents(DestroyMode.Vanish);
            CellRect cellRect = this.OccupiedRect();

            for (int j = 0; j < cellRect.Area * this.def.skyfaller.motesPerCell; j++)
            {
                MoteMaker.ThrowDustPuff(cellRect.RandomVector3, base.Map, 2f);
            }
            if (this.def.skyfaller.MakesShrapnel)
            {
                SkyfallerShrapnelUtility.MakeShrapnel(base.Position, base.Map, this.shrapnelDirection, this.def.skyfaller.shrapnelDistanceFactor, this.def.skyfaller.metalShrapnelCountRange.RandomInRange, this.def.skyfaller.rubbleShrapnelCountRange.RandomInRange, true);
            }
            if (this.def.skyfaller.cameraShake > 0f && base.Map == Find.CurrentMap)
            {
                Find.CameraDriver.shaker.DoShake(this.def.skyfaller.cameraShake);
            }
            if (this.def.skyfaller.impactSound != null)
            {
                this.def.skyfaller.impactSound.PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None));
            }
            this.Destroy(DestroyMode.Vanish);
        }
 private void <Impact> m__0(Thing thing, int count)
 {
     PawnUtility.RecoverFromUnwalkablePositionOrKill(thing.Position, thing.Map);
     if (thing.def.Fillage == FillCategory.Full && this.def.skyfaller.CausesExplosion && thing.Position.InHorDistOf(base.Position, this.def.skyfaller.explosionRadius))
     {
         base.Map.terrainGrid.Notify_TerrainDestroyed(thing.Position);
     }
 }
Esempio n. 3
0
 protected virtual void SpawnThings()
 {
     for (int num = innerContainer.Count - 1; num >= 0; num--)
     {
         GenPlace.TryPlaceThing(innerContainer[num], base.Position, base.Map, ThingPlaceMode.Near, delegate(Thing thing, int count)
         {
             PawnUtility.RecoverFromUnwalkablePositionOrKill(thing.Position, thing.Map);
             if (thing.def.Fillage == FillCategory.Full && def.skyfaller.CausesExplosion && def.skyfaller.explosionDamage.isExplosive && thing.Position.InHorDistOf(base.Position, def.skyfaller.explosionRadius))
             {
                 base.Map.terrainGrid.Notify_TerrainDestroyed(thing.Position);
             }
         }, null, innerContainer[num].def.defaultPlacingRot);
     }
 }
Esempio n. 4
0
        protected virtual void Impact()
        {
            if (def.skyfaller.CausesExplosion)
            {
                GenExplosion.DoExplosion(base.Position, base.Map, def.skyfaller.explosionRadius, def.skyfaller.explosionDamage, null, GenMath.RoundRandom((float)def.skyfaller.explosionDamage.defaultDamage * def.skyfaller.explosionDamageFactor));
            }
            for (int num = innerContainer.Count - 1; num >= 0; num--)
            {
                GenPlace.TryPlaceThing(innerContainer[num], base.Position, base.Map, ThingPlaceMode.Near, delegate(Thing thing, int count)
                {
                    PawnUtility.RecoverFromUnwalkablePositionOrKill(thing.Position, thing.Map);
                    if (thing.def.Fillage == FillCategory.Full && def.skyfaller.CausesExplosion && thing.Position.InHorDistOf(base.Position, def.skyfaller.explosionRadius))
                    {
                        base.Map.terrainGrid.Notify_TerrainDestroyed(thing.Position);
                    }
                });
            }
            innerContainer.ClearAndDestroyContents();
            CellRect cellRect = this.OccupiedRect();

            for (int i = 0; i < cellRect.Area * def.skyfaller.motesPerCell; i++)
            {
                MoteMaker.ThrowDustPuff(cellRect.RandomVector3, base.Map, 2f);
            }
            if (def.skyfaller.MakesShrapnel)
            {
                SkyfallerShrapnelUtility.MakeShrapnel(base.Position, base.Map, shrapnelDirection, def.skyfaller.shrapnelDistanceFactor, def.skyfaller.metalShrapnelCountRange.RandomInRange, def.skyfaller.rubbleShrapnelCountRange.RandomInRange, spawnMotes: true);
            }
            if (def.skyfaller.cameraShake > 0f && base.Map == Find.CurrentMap)
            {
                Find.CameraDriver.shaker.DoShake(def.skyfaller.cameraShake);
            }
            if (def.skyfaller.impactSound != null)
            {
                def.skyfaller.impactSound.PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map)));
            }
            Destroy();
        }
Esempio n. 5
0
 private static void <Impact> m__0(Thing thing, int count)
 {
     PawnUtility.RecoverFromUnwalkablePositionOrKill(thing.Position, thing.Map);
 }
        private void TryOrbit()
        {
            //move ship there
            Map newMap = null;
            Map oldMap = parent.Map;

            ShipInteriorMod.Log("Adding world object...");
            Planet.MapParent obj = Planet.WorldObjectMaker.MakeWorldObject(GenDefDatabase.GetDef(typeof(WorldObjectDef), "OrbitShip") as WorldObjectDef) as Planet.MapParent;
            obj.Tile = oldMap.Tile;

            Find.World.worldObjects.Add(obj);

            //create world map pawn for ship
            LongEventHandler.QueueLongEvent(() =>
            {
                ShipInteriorMod.Log("Generating map...");
                //generate orbit map
                var generatorDef = GenDefDatabase.GetDef(typeof(MapGeneratorDef), "Orbit") as MapGeneratorDef;
                ShipInteriorMod.noSpaceWeather = true;
                newMap = MapGenerator.GenerateMap(oldMap.Size, obj, generatorDef, obj.ExtraGenStepDefs, null);
                ShipInteriorMod.noSpaceWeather = false;
            }, "Orbit_Generate", doAsynchronously: true, exceptionHandler: GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap);

            oldMap
            .GetSpaceAtmosphereMapComponent()
            .DefinitionAt(parent.Position)
            .Move(oldMap, () => newMap, "Orbit", true, Handler, (AirShipWorldObject)obj)
            .Then(() =>
            {
                HashSet <RoomGroup> processedGroups = new HashSet <RoomGroup>();
                foreach (var room in newMap.regionGrid.allRooms)
                {
                    var group = room.Group;
                    if (!processedGroups.Contains(group))
                    {
                        processedGroups.Add(group);
                        group.Temperature = 21f;     // initialize life support
                    }
                }
            }, "Orbit_Temperature", Handler)
            .Then(() =>
            {
                //generate some meteors
                ShipInteriorMod.Log("Generating meteors...");
                int numMeteors = Rand.Range(ShipInteriorMod.instance.meteorMinCount.Value, ShipInteriorMod.instance.meteorMaxCount.Value);
                for (int i = 0; i < numMeteors; i++)
                {
                    if (!TryFindCell(out IntVec3 cell, newMap))
                    {
                        ShipInteriorMod.Log("Nowhere for meteor!?!");
                        continue;
                    }

                    ShipInteriorMod.Log("Found cell for meteor!");

                    List <Thing> list = new List <Thing>();
                    for (int m = 0; m < ShipInteriorMod.instance.meteorSizeMultiplier.Value; m++)
                    {
                        list.AddRange(ThingSetMakerDefOf.Meteorite.root.Generate());
                    }
                    ShipInteriorMod.Log("Meteor has " + list.Count + " chunks!");
                    for (int num = list.Count - 1; num >= 0; num--)
                    {
                        ShipInteriorMod.Log("Placing chunk!");
                        GenPlace.TryPlaceThing(list[num], cell, newMap, ThingPlaceMode.Near, (Thing thing, int count) =>
                        {
                            PawnUtility.RecoverFromUnwalkablePositionOrKill(thing.Position, thing.Map);
                        });
                    }
                }
            }, "Orbit_Meteors", Handler)
            .Then(() => { Current.Game.CurrentMap = newMap; }, "Orbit_Swap", Handler)
            .Then(() => {
                foreach (var cell in Find.CurrentMap.areaManager.Home.ActiveCells.ToList())
                {
                    if (!Find.CurrentMap.thingGrid.ThingsAt(cell).Any(x => (x.def.building?.shipPart).GetValueOrDefault(false)))
                    {
                        Find.CurrentMap.areaManager.Home[cell] = false;
                    }
                }
                foreach (var pawn in Find.CurrentMap.mapPawns.AllPawns.Where(p => p.Faction == Faction.OfPlayer))
                {
                    pawn.playerSettings.AreaRestriction = Find.CurrentMap.areaManager.Home;
                }
            }, "Orbit_Swap", Handler);


            //do cool graphic?
        }