public void Add(FactionInteraction faction) { if (!Factions.Contains(faction)) { factions.Add(faction); } }
public void RemoveFaction(FactionInteraction faction, AllianceRemoveReason reason) { Factions.Remove(faction); if (reason == AllianceRemoveReason.Kick) { faction.Faction.TrySetRelationKind(FactionOwner, FactionRelationKind.Hostile); faction.Trust -= KickTrustChange; foreach (var allianceFaction in Factions) { allianceFaction.Faction.TrySetRelationKind(faction.Faction, FactionRelationKind.Hostile); } } if (AllianceAgreements != null) { for (int i = 0; i < AllianceAgreements.Count; i++) { AllianceAgreementComp agreement = AllianceAgreements[i]; if (agreement.SignedFaction == faction) { EndAgreement(agreement, AgreementEndReason.FactionLeave); } } } RemoveFromWars(faction); Find.LetterStack.ReceiveLetter("AllianceRemoveFactionTitle".Translate(faction.Faction.Name), "Alliance_RemoveFactionDesc".Translate(faction.Faction.Name, reason.Translate()), LetterDefOf.NeutralEvent); }
private void DrawInteraction(Rect inRect) { Rect rect1 = inRect; Rect rect2 = inRect; rect1.xMax = 319; rect1.height = 556; GUI.color = MenuSectionBGBorderColor; Widgets.DrawBox(rect1); GUI.color = Color.white; Rect scrollVertRectFact = new Rect(0, 0, rect1.x, commFactionSliderLength); int y = 10; Widgets.BeginScrollView(rect1, ref factionListSlider, scrollVertRectFact, false); for (int i = 0; i < factions.Count; i++) { FactionInteraction faction = factions[i]; DrawFactionCard(rect1, ref y, faction); } Widgets.EndScrollView(); Rect rect3 = new Rect(328, rect2.yMin + 20, 610, rect2.yMax); DrawFactionCard(rect3); }
private void DrawFactionCard(Rect rect, ref int y, FactionInteraction faction) { Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; Rect r = new Rect(10, y, rect.width - 20, 70); Rect titleRect = new Rect(15, y, rect.width - 20, 50); Widgets.Label(titleRect, faction.Faction.Name); Text.Font = GameFont.Tiny; Rect rect2 = new Rect(15, y + 22, rect.width - 30, 20); Widgets.Label(rect2, "AllianceManager_TrustFactionLevel".Translate(faction.Trust)); Text.Anchor = TextAnchor.MiddleCenter; rect2.y += 20; if (GUIUtils.DrawCustomButton(rect2, "AllianceManager_KickButton".Translate(), Color.white)) { alliance.RemoveFaction(faction, AllianceRemoveReason.Kick); } Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; GUI.color = faction.Faction.Color; Widgets.DrawHighlight(r); GUI.color = Color.white; y += 80; }
public static void GiveScoutingComp(Faction faction, int delayDays, int totalDays, int scoutDays, int addDaysIfAlreadyHas = 5) { if (!ScoutingComp.ScoutAlready(faction, out ScoutingComp outComp)) { ScoutingComp comp = new ScoutingComp(faction, delayDays * 60000, totalDays * 60000, scoutDays); comp.id = QuestsManager.Communications.UniqueIdManager.GetNextComponentID(); QuestsManager.Communications.RegisterComponent(comp); FactionInteraction interaction = QuestsManager.Communications.FactionManager.GetInteraction(faction); foreach (var opt in interaction.Options) { if (opt is CommOption_SubscribeScout opt2) { opt2.Active = true; } } Find.LetterStack.ReceiveLetter("ScoutComp_GiveTitle".Translate(), "ScoutComp_Give".Translate(faction.Name, delayDays, totalDays), LetterDefOf.PositiveEvent); } else { outComp.AddDays(addDaysIfAlreadyHas); Find.LetterStack.ReceiveLetter("ScoutComp_AlreadyGiveTitle".Translate(), "ScoutComp_AlreadyGive".Translate(faction.Name, addDaysIfAlreadyHas), LetterDefOf.PositiveEvent); } }
public static bool WarWithPlayer(War war) { FactionInteraction player = QuestsManager.Communications.FactionManager.PlayerInteraction; var alliance = QuestsManager.Communications.FactionManager.PlayerAlliance; return(war.DeclaredWarFaction == player || war.DefendingFaction == player || war.AttackedAlliance == alliance || war.DefendAlliance == alliance); }
public static War MakeWar(string warName, WarGoalDef goal, FactionInteraction declaredWarFaction, FactionInteraction defendingFaction) { War war = new War(warName, goal, declaredWarFaction, defendingFaction); war.id = QuestsManager.Communications.UniqueIdManager.GetNextWarID(); return(war); }
public void Notify_FactionLeft(FactionInteraction factionInteraction) { Worker.FactionLeft(factionInteraction); RemoveArmy(factionInteraction); factionInteraction.Notify_WarIsOver(this); }
public FactionArmy CreateArmyFor(FactionInteraction factionInteraction, bool useForGenerator) { var army = new FactionArmy(factionInteraction, this, useForGenerator); army.DepletionFromWar = 0; return(army); }
public void AddFaction(FactionInteraction faction) { Factions.Add(faction); SynchonizeAllOwnerRelations(); AddIntoWars(faction); Find.LetterStack.ReceiveLetter("Alliance_AddFactionTitle".Translate(faction.Faction.Name), "Alliance_AddFactionDesc".Translate(faction.Faction.Name), LetterDefOf.PositiveEvent); }
public void AddDefendFaction(FactionInteraction factionInteraction) { if (DefendingFactions.Contains(factionInteraction)) { return; } DefendingFactions.Add(factionInteraction); Notify_NewFactionEntered(factionInteraction); }
private FactionInteraction InitNewFaction(Faction faction, List <InteractionOption> options) { FactionInteraction interaction = new FactionInteraction(); interaction.Faction = faction; interaction.id = QuestsManager.Communications.UniqueIdManager.GetNextFactionInteractionId(); interaction.Options = options; return(interaction); }
public void AddAssaultFaction(FactionInteraction factionInteraction) { if (AssaultFactions.Contains(factionInteraction)) { return; } AssaultFactions.Add(factionInteraction); Notify_NewFactionEntered(factionInteraction); }
public void RemoveDefendFaction(FactionInteraction factionInteraction) { if (!DefendingFactions.Contains(factionInteraction)) { return; } DefendingFactions.Remove(factionInteraction); Notify_FactionLeft(factionInteraction); }
public void RemoveAssaultFaction(FactionInteraction factionInteraction) { if (!AssaultFactions.Contains(factionInteraction)) { return; } AssaultFactions.Remove(factionInteraction); Notify_FactionLeft(factionInteraction); }
public override void DoAction(FactionInteraction interaction, Pawn speaker, Pawn defendant) { var alliance = interaction.Alliance; if (alliance != null && alliance.FactionOwner == speaker.Faction) { Messages.Message("CommOption_MakeWar_InAlliance".Translate(), MessageTypeDefOf.NeutralEvent); return; } Find.WindowStack.Add(new MakeWarWindow(interaction, speaker, defendant)); }
protected virtual void TryAffectOnWorld(FactionManager globalFactionManager, FactionInteraction interaction, int aggressiveLevel, int trustLevel) { if (globalFactionManager != null) { globalFactionManager.PlayerAggressiveLevel += aggressiveLevel; } if (interaction != null) { interaction.Trust += trustLevel; } }
public override void DoAction(FactionInteraction interaction, Pawn speaker, Pawn defendant) { if (WarUtility.FirstWarWithPlayer(interaction) != null) { Messages.Message("CommOption_InviteToAlliance_InWar".Translate(), MessageTypeDefOf.NeutralEvent); return; } if (interaction.Faction.RelationKindWith(Faction.OfPlayer) == FactionRelationKind.Hostile) { Messages.Message("CommOption_InviteToAlliance_NeedAAlly".Translate(), MessageTypeDefOf.NeutralEvent); return; } if (interaction.Trust < TrustMinNeed) { Messages.Message("CommOption_InviteToAlliance_NeedTrust".Translate(TrustMinNeed), MessageTypeDefOf.NeutralEvent); return; } if (blocked) { int waitTicks = (lastUseTicks - Find.TickManager.TicksGame) / 60000; Messages.Message("CommOption_InviteToAlliance_Wait".Translate(waitTicks.ToString("f2")), MessageTypeDefOf.NeutralEvent); return; } if (Alliance == null) { Messages.Message("CommOption_InviteToAlliance_NoAlliance".Translate(), MessageTypeDefOf.NeutralEvent); return; } if (interaction.InAnyAlliance()) { Messages.Message("CommOption_InviteToAlliance_AlreadyInAlliance".Translate(), MessageTypeDefOf.NeutralEvent); return; } if (Alliance.Factions.Any(x => x.Faction.HostileTo(interaction.Faction))) { Messages.Message("CommOption_InviteToAlliance_AnyHostileInAlliance".Translate(), MessageTypeDefOf.NeutralEvent); return; } defendantFaction = interaction; Dialog dia = new Dialog(DialogDef, speaker, defendantFaction.Faction.leader); dia.Init(); dia.CloseAction = CheckAnswer; Find.WindowStack.Add(dia); }
public static War FirstWarWith(this FactionInteraction interaction, FactionInteraction other) { var otherAlliance = other.Alliance; var firstAlliance = interaction.Alliance; if (firstAlliance == otherAlliance) { return(null); } return(interaction.InWars.FirstOrDefault(x => (x.DeclaredWarFaction == other && !x.AssaultFactions.Contains(interaction)) || (x.DefendingFaction == other && !x.DefendingFactions.Contains(interaction)) || (x.AttackedAlliance != null && x.AttackedAlliance == otherAlliance) || (x.DefendAlliance != null && x.DefendAlliance == otherAlliance))); }
private void DrawWarInfo(Rect rect) { float y = rect.y; Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Rect labelRect = new Rect(rect.x, y, rect.width, 35); Widgets.Label(labelRect, $"{currentWar.WarName} ({currentWar.WarGoalDef.LabelCap})"); Text.Font = GameFont.Small; GUIUtils.DrawLineHorizontal(rect.x, y + 30, rect.width, GUIUtils.CommBorderColor); labelRect.y += 50; y += 50; Widgets.Label(labelRect, "WarManager_DrawWarInfo_WarMembers".Translate(currentWar.DefendAlliance == null ? "WarManager_NoAlliance".Translate().ToString() : currentWar.DefendAlliance.Name)); y += 30; Rect defenderRect = new Rect(rect.x, y, rect.width, 250); Rect scrollVertRectFact = new Rect(0, 0, rect.x, currentWar.DefendingFactions.Count * 35); Widgets.BeginScrollView(defenderRect, ref defendersSlider, scrollVertRectFact, true); Rect factionRect = new Rect(0, 10, rect.width - 10, 30); for (int i = 0; i < currentWar.DefendingFactions.Count; i++) { FactionInteraction faction = currentWar.DefendingFactions[i]; GUI.color = faction.Faction.Color; Widgets.DrawHighlight(factionRect); GUI.color = Color.white; Widgets.Label(factionRect, faction.Faction.Name); factionRect.y += 35; } Widgets.EndScrollView(); y += 255; GUIUtils.DrawLineHorizontal(rect.x, y, rect.width, GUIUtils.CommBorderColor); y += 5; Rect statRect = new Rect(rect.x, y, rect.width, 200); Widgets.LabelScrollable(statRect, stat, ref statWorkerSlider); y += 205; GUIUtils.DrawLineHorizontal(rect.x, y, rect.width, GUIUtils.CommBorderColor); Text.Anchor = TextAnchor.UpperLeft; }
public static War FirstWarWithPlayer(this FactionInteraction interaction) { FactionInteraction player = QuestsManager.Communications.FactionManager.PlayerInteraction; var alliance = QuestsManager.Communications.FactionManager.PlayerAlliance; var secondAlliance = interaction.Alliance; if (alliance == secondAlliance) { return(null); } return(interaction.InWars.FirstOrDefault(x => (x.DeclaredWarFaction == player && !x.AssaultFactions.Contains(interaction)) || (x.DefendingFaction == player && !x.DefendingFactions.Contains(interaction)) || (x.AttackedAlliance != null && x.AttackedAlliance == alliance) || (x.DefendAlliance != null && x.DefendAlliance == alliance))); }
public void Remove(Faction faction) { if (Factions.Contains(faction)) { for (int i = 0; i < Factions.Count; i++) { FactionInteraction interaction = Factions[i]; if (interaction.Faction == faction) { factions.Remove(interaction); } } } }
public void RemoveArmy(FactionInteraction factionInteraction) { for (int i = 0; i < armys.Count; i++) { FactionArmy army = armys[i]; if (army.Faction == factionInteraction) { armys.Remove(army); break; } } }
public void EndComp() { FactionInteraction interaction = QuestsManager.Communications.FactionManager.GetInteraction(Faction); foreach (var opt in interaction.Options) { if (opt is CommOption_SubscribeScout opt2) { opt2.Active = false; } } QuestsManager.Communications.RemoveComponent(this); }
public override void DoAction(FactionInteraction interaction, Pawn speaker, Pawn defendant) { var war = interaction.FirstWarWithPlayer(); if (war != null) { Messages.Message("CommOption_SubscribeScout_CantSub".Translate(), MessageTypeDefOf.NeutralEvent); return; } bool subAlready = ScoutingComp.ScoutAlready(interaction.Faction, out ScoutingComp outComp); StringBuilder builder = new StringBuilder(); builder.Append("CommOption_SubscribeScout_SubTitle".Translate()); DiaOption diaOption = new DiaOption("CommOption_SubscribeScout_SubButton".Translate()); if (subAlready) { builder.Append("CommOption_SubscribeScout_SubAlready".Translate(outComp.GetDays())); diaOption.Disable("CommOption_SubscribeScout_SubAlreadyOption".Translate()); } else if (interaction.Faction.PlayerGoodwill < 80) { diaOption.Disable("CommOption_SubscribeScout_SubGoodWillOption".Translate()); } diaOption.action = delegate { if (!subAlready) { ScoutingComp.GiveScoutingComp(interaction.Faction, 2, 14, 5); } }; diaOption.resolveTree = true; DiaOption diaOption2 = new DiaOption("CommOption_ExitNode".Translate()); diaOption2.resolveTree = true; DiaNode diaNode = new DiaNode(builder.ToString()); diaNode.options.Add(diaOption); diaNode.options.Add(diaOption2); Dialog_NodeTree dialog_NodeTree = new Dialog_NodeTree(diaNode, delayInteractivity: true); Find.WindowStack.Add(dialog_NodeTree); }
public List <FactionInteraction> GetEnemyList(FactionInteraction factionInteraction) { if (factionInteraction == DeclaredWarFaction || AssaultFactions.Contains(factionInteraction)) { return(DefendingFactions); } if (factionInteraction == DefendingFaction || DefendingFactions.Contains(factionInteraction)) { return(AssaultFactions); } return(null); }
public void End() { FactionInteraction interaction = QuestsManager.Communications.FactionManager.GetInteraction(Faction); foreach (var opt in interaction.Options) { if (opt is CommOption_NonAgressionPact opt2) { opt2.Signed = false; } } Find.LetterStack.ReceiveLetter("NonAfressionPackCompTitle".Translate(), "NonAfressionPackComp".Translate(), LetterDefOf.NeutralEvent); QuestsManager.Communications.RemoveComponent(this); }
public void Notify_NewFactionEntered(FactionInteraction factionInteraction) { Worker.NewFactionEntered(factionInteraction); bool useForGenerator = true; if ((DeclaredWarFaction == PlayerInteraction && AssaultFactions.Contains(factionInteraction)) || DefendingFaction == PlayerInteraction && DefendingFactions.Contains(factionInteraction)) { useForGenerator = false; } AddArmy(CreateArmyFor(factionInteraction, useForGenerator)); factionInteraction.Notify_WarIsStarted(this); }
public War(string warName, WarGoalDef goal, FactionInteraction declaredWarFaction, FactionInteraction defendingFaction) { DeclaredWarFaction = declaredWarFaction; DefendingFaction = defendingFaction; WarGoalDef = goal; WarName = warName; AssaultFactions = new List <FactionInteraction>() { declaredWarFaction }; var attackedAlliance = AttackedAlliance; if (attackedAlliance != null) { foreach (var faction in attackedAlliance.Factions) { if (faction == DeclaredWarFaction) { continue; } AssaultFactions.Add(faction); } } DefendingFactions = new List <FactionInteraction> { defendingFaction }; var defendAlliance = DefendAlliance; if (defendAlliance != null) { foreach (var faction in defendAlliance.Factions) { if (faction == DefendingFaction) { continue; } DefendingFactions.Add(faction); } } StartTicks = Find.TickManager.TicksGame; }
public override void DoAction(FactionInteraction interaction, Pawn speaker, Pawn defendant) { var war = interaction.FirstWarWithPlayer(); if (war != null) { Messages.Message("CommOption_NonAgressionPact_CantSign".Translate(), MessageTypeDefOf.NeutralEvent); return; } if (Signed) { return; } Map map = speaker.Map; int playerSilver = map.resourceCounter.Silver; if (playerSilver >= SilverCost) { int remaining = SilverCost; List <Thing> silver = map.listerThings.ThingsOfDef(ThingDefOf.Silver); for (int i = 0; i < silver.Count; i++) { Thing item = silver[i]; int num = Mathf.Min(remaining, item.stackCount); item.SplitOff(num).Destroy(); remaining -= num; if (remaining == 0) { break; } } Success(interaction.Faction, speaker); } else { Messages.Message("CommOption_NonAgressionPact_NotEnoughSilver".Translate(SilverCost, playerSilver), MessageTypeDefOf.NeutralEvent, false); } }