Exemplo n.º 1
0
 private void CheckWonBattle()
 {
     if (!wonBattle && !GenHostility.AnyHostileActiveThreatToPlayer(base.Map))
     {
         TimedDetectionRaids component = GetComponent <TimedDetectionRaids>();
         component.SetNotifiedSilently();
         string detectionCountdownTimeLeftString = component.DetectionCountdownTimeLeftString;
         Find.LetterStack.ReceiveLetter("LetterLabelCaravansBattlefieldVictory".Translate(), "LetterCaravansBattlefieldVictory".Translate(detectionCountdownTimeLeftString), LetterDefOf.PositiveEvent, this);
         TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushDefeated, base.Map.mapPawns.FreeColonists.RandomElement());
         wonBattle = true;
     }
 }
        public static void CheckDefeated(Settlement factionBase)
        {
            if (factionBase.Faction == Faction.OfPlayer)
            {
                return;
            }
            Map map = factionBase.Map;

            if (map == null || !IsDefeated(map, factionBase.Faction))
            {
                return;
            }
            DestroyedSettlement destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement);

            destroyedSettlement.Tile = factionBase.Tile;
            destroyedSettlement.SetFaction(factionBase.Faction);
            Find.WorldObjects.Add(destroyedSettlement);
            TimedDetectionRaids component = destroyedSettlement.GetComponent <TimedDetectionRaids>();

            component.CopyFrom(factionBase.GetComponent <TimedDetectionRaids>());
            component.SetNotifiedSilently();
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("LetterFactionBaseDefeated".Translate(factionBase.Label, component.DetectionCountdownTimeLeftString));
            if (!HasAnyOtherBase(factionBase))
            {
                factionBase.Faction.defeated = true;
                stringBuilder.AppendLine();
                stringBuilder.AppendLine();
                stringBuilder.Append("LetterFactionBaseDefeated_FactionDestroyed".Translate(factionBase.Faction.Name));
            }
            foreach (Faction allFaction in Find.FactionManager.AllFactions)
            {
                if (!allFaction.Hidden && !allFaction.IsPlayer && allFaction != factionBase.Faction && allFaction.HostileTo(factionBase.Faction))
                {
                    FactionRelationKind playerRelationKind = allFaction.PlayerRelationKind;
                    if (allFaction.TryAffectGoodwillWith(Faction.OfPlayer, 20, canSendMessage: false, canSendHostilityLetter: false))
                    {
                        stringBuilder.AppendLine();
                        stringBuilder.AppendLine();
                        stringBuilder.Append("RelationsWith".Translate(allFaction.Name) + ": " + 20.ToStringWithSign());
                        allFaction.TryAppendRelationKindChangedInfo(stringBuilder, playerRelationKind, allFaction.PlayerRelationKind);
                    }
                }
            }
            Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(), stringBuilder.ToString(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(factionBase.Tile), factionBase.Faction);
            map.info.parent = destroyedSettlement;
            factionBase.Destroy();
            TaleRecorder.RecordTale(TaleDefOf.CaravanAssaultSuccessful, map.mapPawns.FreeColonists.RandomElement());
        }
 public void CopyFrom(TimedDetectionRaids other)
 {
     ticksLeftToSendRaid       = other.ticksLeftToSendRaid;
     ticksLeftTillNotifyPlayer = other.ticksLeftTillNotifyPlayer;
 }