Exemplo n.º 1
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            List <int> tiles = new List <int>();

            for (int i = 0; i < Find.WorldGrid.TilesCount; i++)
            {
                Tile tile = Find.WorldGrid[i];
                if (tile.biome != BiomeDefOf.Ocean && tile.biome != BiomeDefOf.Lake && tile.hilliness != Hilliness.Impassable)
                {
                    tiles.Add(i);
                }
            }

            if (tiles.Count == 0)
            {
                return(false);
            }

            int partsCount = Rand.Range(minParts, maxParts);

            for (int i = 0; i < partsCount; i++)
            {
                int tileID = tiles.RandomElement();

                if (Find.WorldObjects.AnyMapParentAt(tileID))
                {
                    continue;
                }

                Faction f = RandomEnemyFaction();
                if (f == null)
                {
                    return(false);
                }

                ShipMapGenerator generator = GetGenerator();
                ShipCrash_Controller.MakeShipPart(generator, tileID, f);
            }

            SendStandardLetter(parms, null);

            CommunicationDialog dialog = QuestsManager.Communications.AddCommunication(QuestsManager.Communications.UniqueIdManager.GetNextDialogID(), "Comm_ShipCrashTitle".Translate(), "Comm_ShipCrashDesc".Translate(), incident: def);

            TimeComp timeComp = new TimeComp(dialog, 7000);

            timeComp.id = QuestsManager.Communications.UniqueIdManager.GetNextComponentID();
            QuestsManager.Communications.RegisterComponent(timeComp);

            ShipCrash_Controller.ShipCount++;

            return(true);
        }
Exemplo n.º 2
0
        private void DoShipFall()
        {
            ShipMapGenerator generator = ships[Rand.Range(0, ships.Length)];

            int tile = TileFinder.RandomStartingTile();

            ShipCrash_Controller.MakeShipPart(generator, tile, Find.FactionManager.AllFactionsVisible.Where(x => x != Faction.OfPlayer).RandomElement());

            Messages.Message("GameCondition_SpaceBattleTitle".Translate(), MessageTypeDefOf.NeutralEvent, false);
        }
Exemplo n.º 3
0
        public static ShipSite MakeShipPart(ShipMapGenerator gen, int tileID, Faction faction)
        {
            ShipSite site = (ShipSite)WorldObjectMaker.MakeWorldObject(ShipWorldObjectDefOf.ShipCrashSite);

            site.SetGenerator(gen);
            site.Tile = tileID;
            site.SetFaction(faction);

            Find.WorldObjects.Add(site);

            return(site);
        }
Exemplo n.º 4
0
 public void SetGenerator(ShipMapGenerator generator)
 {
     this.generator = generator;
     GeneratorType  = $"MoreEvents.Events.ShipCrash.Map.MapGenerator.{generator.GetType().Name}";
 }
Exemplo n.º 5
0
 public CaravanArrivalAction_EnterToShipCrash(MapParent mapParent, ShipMapGenerator generator)
 {
     this.mapParent = mapParent;
     this.generator = generator;
 }