public override void Initialize(WorldObjectCompProperties props)
        {
            base.Initialize(props);

            settlement = (FriendlySettlement)parent;
            Enable     = true;
        }
示例#2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Faction    faction     = GetFriendlyFaction();
            Faction    faction2    = GetEnemyFaction(faction);
            Settlement factionBase = Find.WorldObjects.Settlements.Where(x => x.Faction == faction).RandomElement();

            if (factionBase == null)
            {
                return(false);
            }

            Quest_AttackFriendlySettlement quest = new Quest_AttackFriendlySettlement();

            quest.id      = QuestsManager.Communications.UniqueIdManager.GetNextQuestID();
            quest.Faction = faction;

            FriendlySettlement site = (FriendlySettlement)WorldObjectMaker.MakeWorldObject(WorldObjectsDefOfLocal.FriendlySettlementHelp);

            site.Tile  = factionBase.Tile;
            site.Quest = quest;
            site.SetFaction(faction);
            var comp = site.GetComponent <FriendlySettlementComp>();

            comp.TicksToAttack    = Rand.Range(8, 15) * 60000;
            quest.TicksToPass     = comp.TicksToAttack;
            comp.OffensiveFaction = faction2;
            comp.InitPoints();
            Find.WorldObjects.Add(site);

            string letterText;

            if (Rand.Chance(0.35f))
            {
                comp.ShowThreat = true;
                letterText      = "AttackFriendlySettlementLetter2".Translate(faction.Name, comp.Points);
            }
            else
            {
                letterText = "AttackFriendlySettlementLetter1".Translate(faction.Name);
            }

            quest.Target = site;
            QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: letterText, lookTarget: quest.Target));

            return(true);
        }