Beispiel #1
0
        public override void Initialize(WorldObjectCompProperties props)
        {
            base.Initialize(props);

            timer               = ticksBetweenUpdate;
            raidTimer           = ticksBetweenRaids;
            mortalShellingTimer = ticksBetweenMortalShelling;

            int count = 1;

            foreach (var pawnData in baseBlueprint.pawnLegend.Values)
            {
                if (pawnData.Count.max > 1)
                {
                    count = pawnData.Count.min;
                }
                else
                {
                    count = 1;
                }

                totalThreat += pawnData.Kind.combatPower * count;
            }

            totalThreat *= 0.7f;

            camp = (SiegeCampSite)parent;

            enable = true;
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Map map = (Map)parms.target;

            int spawnPoint = GetPlace(map);

            if (spawnPoint >= 0)
            {
                Tile tile = Find.WorldGrid[spawnPoint];
                if (Rand.Chance(0.25f))
                {
                    tile.hilliness = Hilliness.SmallHills;
                }
                else
                {
                    tile.hilliness = Hilliness.Flat;
                }

                SiegeCampSite site = (SiegeCampSite)WorldObjectMaker.MakeWorldObject(WorldObjectsDefOfLocal.SiegeCampSite);
                site.Tile = spawnPoint;
                site.SetFaction(GetEnemyFaction());
                site.SetMap(map);
                Find.WorldObjects.Add(site);

                CommunicationDialog dialog = QuestsManager.Communications.AddCommunication(QuestsManager.Communications.UniqueIdManager.GetNextDialogID(), "Comm_SiegeCampTitle".Translate(), "Comm_SiegeCampDesc".Translate(), incident: def);
                site.Dialog = dialog;

                SendStandardLetter(parms, site);

                return(true);
            }

            return(false);
        }