From b1465643ca2f915e7dbc8386701e9c85c051d4e1 Mon Sep 17 00:00:00 2001 From: Bradley Burcar Date: Sun, 15 Sep 2019 14:16:05 -0400 Subject: [PATCH] Bug fix for local faction. --- Galaxy at War/Core.cs | 11 ++++++++--- Galaxy at War/HotSpots.cs | 20 +++++++++++++------- Galaxy at War/SaveHandling.cs | 13 +++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Galaxy at War/Core.cs b/Galaxy at War/Core.cs index 49a6f2d..16704ed 100644 --- a/Galaxy at War/Core.cs +++ b/Galaxy at War/Core.cs @@ -162,7 +162,6 @@ public static void Postfix(SimGameState __instance) //} while (i < 100); //__instance.StopPlayMode(); //return; - if (__instance.DayRemainingInQuarter % Settings.WarFrequency == 0) { //LogDebug(">>> PROC"); @@ -187,7 +186,6 @@ public static void Postfix(SimGameState __instance) NeedsProcessing = false; } } - SaveHandling.SerializeWar(); LogDebug(">>> DONE PROC"); } @@ -1150,7 +1148,13 @@ public static void Postfix(SimGameState __instance) if (contractType == ContractType.AttackDefend || contractType == ContractType.FireMission) { if (Settings.IncludedFactions.Contains(teamfaction)) - WarStatus.warFactionTracker.Find(x => x.faction == teamfaction).AttackResources += difficulty; + { + if (!Settings.DefensiveFactions.Contains(teamfaction)) + WarStatus.warFactionTracker.Find(x => x.faction == teamfaction).AttackResources += difficulty; + else + WarStatus.warFactionTracker.Find(x => x.faction == teamfaction).DefensiveResources += difficulty; + } + if (Settings.IncludedFactions.Contains(enemyfaction)) { WarStatus.warFactionTracker.Find(x => x.faction == enemyfaction).DefensiveResources -= difficulty; @@ -1233,6 +1237,7 @@ public static void Postfix(SimGameState __instance) } } } + public static void SystemDifficulty() { bool GetPirateFlex = true; diff --git a/Galaxy at War/HotSpots.cs b/Galaxy at War/HotSpots.cs index 2f82e8b..78e6e33 100644 --- a/Galaxy at War/HotSpots.cs +++ b/Galaxy at War/HotSpots.cs @@ -131,12 +131,13 @@ static void Postfix(StarSystem __instance) if (Core.NeedsProcessing) ProcessHotSpots(); - + isBreadcrumb = true; sim.CurSystem.SystemBreadcrumbs.Clear(); Traverse.Create(sim.CurSystem).Property("MissionsCompleted").SetValue(20); Traverse.Create(sim.CurSystem).Property("CurBreadcrumbOverride").SetValue(1); Traverse.Create(sim.CurSystem).Property("CurMaxBreadcrumbs").SetValue(1); + if (HomeContendedSystems.Count != 0) { int i = 0; @@ -150,23 +151,30 @@ static void Postfix(StarSystem __instance) RandomSystem = rand.Next(HomeContendedSystems.Count / 2, HomeContendedSystems.Count); if (twiddle == -1) RandomSystem = rand.Next(0, HomeContendedSystems.Count / 2); - + var MainBCTarget = HomeContendedSystems[RandomSystem]; - if (MainBCTarget == sim.CurSystem) + + if (MainBCTarget == sim.CurSystem || (sim.CurSystem.Owner == Faction.Locals && MainBCTarget.Owner != Faction.Locals)) { HomeContendedSystems.Remove(MainBCTarget); continue; } TemporaryFlip(MainBCTarget, sim.CurSystem.Owner); if (sim.CurSystem.SystemBreadcrumbs.Count == 0) + { sim.GeneratePotentialContracts(true, null, MainBCTarget, false); + } else + { sim.GeneratePotentialContracts(false, null, MainBCTarget, false); - SystemBonuses(MainBCTarget); + SystemBonuses(MainBCTarget); + } + Core.RefreshContracts(MainBCTarget); HomeContendedSystems.Remove(MainBCTarget); if (sim.CurSystem.SystemBreadcrumbs.Count == Core.Settings.InternalHotSpots) break; + i = sim.CurSystem.SystemBreadcrumbs.Count; twiddle *= -1; } @@ -280,14 +288,12 @@ public static void TemporaryFlip(StarSystem starSystem, Faction faction) break; } } - - if (starSystem.Def.ContractTargets.Count == 0) + if (starSystem.Def.ContractTargets.Count <= 1) { starSystem.Def.ContractTargets.Add(Faction.AuriganPirates); if (!Core.WarStatus.AbandonedSystems.Contains(starSystem.Name)) starSystem.Def.ContractTargets.Add(Faction.Locals); } - } //Deployments area. diff --git a/Galaxy at War/SaveHandling.cs b/Galaxy at War/SaveHandling.cs index f12593b..5dbb2ef 100644 --- a/Galaxy at War/SaveHandling.cs +++ b/Galaxy at War/SaveHandling.cs @@ -138,6 +138,19 @@ public static void RebuildState() { Core.AdjustDeathList(deathListTracker, sim, true); } + foreach (var defensivefaction in Core.Settings.DefensiveFactions) + { + if (Core.WarStatus.warFactionTracker.Find(x => x.faction == defensivefaction) == null) + continue; + + var targetfaction = Core.WarStatus.warFactionTracker.Find(x => x.faction == defensivefaction); + + if (targetfaction.AttackResources != 0) + { + targetfaction.DefensiveResources += targetfaction.AttackResources; + targetfaction.AttackResources = 0; + } + } } public static void ConvertToSave()