public static void Prefix(SGCharacterCreationCareerBackgroundSelectionPanel __instance) { var traverse = Traverse.Create(__instance); var results = new List <SimGameEventResult>(); var playerBackground = traverse.Property("playerBackground").GetValue <List <BackgroundDef> >(); foreach (BackgroundDef backgroundDef in playerBackground) { results.Add(backgroundDef.Results); } SimGameState.ApplySimGameEventResult(results); return; }
public void conclude() { Settings s = WIIC.settings; removeParticipationContracts(); string text = Strings.T(completionText(), attacker.FactionDef.Name, location.OwnerValue.FactionDef.Name, location.Name); // Because shortnames can start with a lowercase 'the' ("the Aurigan Coalition", for example), we have to fix the capitalization or the result can look weird. text = text.Replace(". the ", ". The "); text = char.ToUpper(text[0]) + text.Substring(1); // At the current location, a flareup gets a popup - whether or not the player was involved, it's important. if (WIIC.sim.CurSystem == location) { SimGameInterruptManager queue = WIIC.sim.GetInterruptQueue(); string title = Strings.T($"{type} Complete"); string primaryButtonText = Strings.T("Acknowledged"); string itemCollection = reward(); WIIC.modLog.Info?.Write(text); WIIC.modLog.Info?.Write($"Reward: {itemCollection} for {employer.Name}"); Sprite sprite = attackerStrength > 0 ? attacker.FactionDef.GetSprite() : location.OwnerValue.FactionDef.GetSprite(); queue.QueuePauseNotification(title, text, sprite, string.Empty, delegate { try { if (itemCollection != null) { queue.QueueRewardsPopup(itemCollection); } } catch (Exception e) { WIIC.modLog.Error?.Write(e); } }, primaryButtonText); if (!queue.IsOpen) { queue.DisplayIfAvailable(); } // Things happening elsewhere in the galaxy just get an event toast. } else { WIIC.sim.RoomManager.ShipRoom.AddEventToast(new Text(text)); } // Now apply the owner or stat changes if (type == "Attack" && defenderStrength <= 0 && attackerStrength > 0) { Utilities.applyOwner(location, attacker, true); } else if (type == "Raid") { SimGameEventResult result = new SimGameEventResult(); result.Scope = EventScope.Company; result.TemporaryResult = true; result.ResultDuration = s.raidResultDuration; if (attackerStrength <= 0) { SimGameStat attackStat = new SimGameStat($"WIIC_{attacker.Name}_attack_strength", 1, false); SimGameStat defenseStat = new SimGameStat($"WIIC_{location.OwnerValue.Name}_defense_strength", -1, false); result.Stats = new SimGameStat[] { attackStat, defenseStat }; } else if (defenderStrength <= 0) { SimGameStat attackStat = new SimGameStat($"WIIC_{attacker.Name}_attack_strength", -1, false); SimGameStat defenseStat = new SimGameStat($"WIIC_{location.OwnerValue.Name}_defense_strength", 1, false); result.Stats = new SimGameStat[] { attackStat, defenseStat }; } SimGameEventResult[] results = { result }; SimGameState.ApplySimGameEventResult(new List <SimGameEventResult>(results)); } }
public void conclude() { WIIC.modLog.Info?.Write($"{type} finished at {location.Name}."); removeParticipationContracts(); string text = ""; if (type == "Attack") { if (attackerStrength <= 0) { text = Strings.T("Battle for {0} concludes - {1} holds off the {2} attack", location.Name, location.OwnerValue.FactionDef.ShortName, attacker.FactionDef.ShortName); } else if (defenderStrength <= 0) { text = Strings.T("Battle for {0} concludes - {1} takes the system from {2}", location.Name, attacker.FactionDef.ShortName, location.OwnerValue.FactionDef.ShortName); Utilities.applyOwner(location, attacker, true); } } else if (type == "Raid") { SimGameEventResult result = new SimGameEventResult(); result.Scope = EventScope.Company; result.TemporaryResult = true; result.ResultDuration = WIIC.settings.raidResultDuration; if (attackerStrength <= 0) { text = Strings.T("Raid on {0} concludes - {1} drives off the {2} forces", location.Name, location.OwnerValue.FactionDef.ShortName, attacker.FactionDef.ShortName); SimGameStat attackStat = new SimGameStat($"WIIC_{attacker.Name}_attack_strength", 1, false); SimGameStat defenseStat = new SimGameStat($"WIIC_{location.OwnerValue.Name}_defense_strength", -1, false); result.Stats = new SimGameStat[] { attackStat, defenseStat }; } else if (defenderStrength <= 0) { text = Strings.T("Raid on {0} concludes - {1} weakens {2} control", location.Name, attacker.FactionDef.ShortName, location.OwnerValue.FactionDef.ShortName); SimGameStat attackStat = new SimGameStat($"WIIC_{attacker.Name}_attack_strength", -1, false); SimGameStat defenseStat = new SimGameStat($"WIIC_{location.OwnerValue.Name}_defense_strength", 1, false); result.Stats = new SimGameStat[] { attackStat, defenseStat }; } SimGameEventResult[] results = { result }; SimGameState.ApplySimGameEventResult(new List <SimGameEventResult>(results)); } // At the current location, a flareup gets a popup - whether or not the player was involved, it's important. if (WIIC.sim.CurSystem == location) { SimGameInterruptManager queue = WIIC.sim.GetInterruptQueue(); string title = Strings.T($"{type} Complete"); string primaryButtonText = Strings.T("Acknowledged"); queue.QueuePauseNotification(title, text, WIIC.sim.GetCrewPortrait(SimGameCrew.Crew_Sumire), string.Empty, null, primaryButtonText); if (!queue.IsOpen) { queue.DisplayIfAvailable(); } // Things happening elsewhere in the galaxy just get an event toast. } else { sim.RoomManager.ShipRoom.AddEventToast(new Text(text)); } }