private static void Prefix() { try { var timelineWidget = (TaskTimelineWidget)_getTimelineWidget.GetValue(WIIC.sim.RoomManager); var activeItems = (Dictionary <WorkOrderEntry, TaskManagementElement>)_getActiveItems.GetValue(timelineWidget); Utilities.slowDownFloaties(); ColourfulFlashPoints.Main.clearMapMarkers(); // ToList is used to make a copy because we may need to remove elements as we're iterating foreach (Flareup flareup in WIIC.flareups.Values.ToList()) { bool finished = flareup.passDay(); if (finished) { WIIC.cleanupSystem(flareup.location); } else { if (activeItems.TryGetValue(flareup.workOrder, out var taskManagementElement)) { taskManagementElement.UpdateItem(0); } } } WhoAndWhere.checkForNewFlareup(); if (Utilities.deferredToasts.Count > 0) { foreach (var toast in Utilities.deferredToasts) { WIIC.sim.RoomManager.ShipRoom.AddEventToast(new Text(toast)); } Utilities.deferredToasts.Clear(); } Utilities.redrawMap(); WIIC.sim.RoomManager.RefreshTimeline(false); } catch (Exception e) { WIIC.modLog.Error?.Write(e); } }
public static void Prefix(ref SimGameEventResult result) { Settings s = WIIC.settings; if (result.Scope == EventScope.Company && result.AddedTags != null) { foreach (string addedTag in result.AddedTags.ToList()) { try { MatchCollection matches = GIVE_SYSTEM.Matches(addedTag); if (matches.Count > 0) { string systemId = matches[0].Groups["system"].Value; string factionID = matches[0].Groups["faction"].Value; WIIC.modLog.Info?.Write($"ApplySimGameEventResult GIVE_SYSTEM: systemId {systemId}, factionID {factionID}"); StarSystem system = WIIC.sim.GetSystemById(systemId); FactionValue faction = Utilities.getFactionValueByFactionID(factionID); WIIC.cleanupSystem(system); Utilities.applyOwner(system, faction, true); result.AddedTags.Remove(addedTag); continue; } matches = ATTACK_SYSTEM.Matches(addedTag); if (matches.Count > 0) { string factionID = matches[0].Groups["faction"].Value; string systemId = matches[0].Groups["system"].Value; WIIC.modLog.Info?.Write($"ApplySimGameEventResult ATTACK_SYSTEM: factionID {factionID}, systemId {systemId}"); StarSystem system = WIIC.sim.GetSystemById(systemId); FactionValue faction = Utilities.getFactionValueByFactionID(factionID); if (system.OwnerValue.Name == faction.Name) { WIIC.modLog.Info?.Write($"Tagged system {system.Name} already owned by attacker {faction.Name}, ignoring"); continue; } WIIC.cleanupSystem(system); Flareup flareup = new Flareup(system, faction, "Attack", WIIC.sim); WIIC.flareups[system.ID] = flareup; Utilities.redrawMap(); result.AddedTags.Remove(addedTag); continue; } matches = RAID_SYSTEM.Matches(addedTag); if (matches.Count > 0) { string factionID = matches[0].Groups["faction"].Value; string systemId = matches[0].Groups["system"].Value; WIIC.modLog.Info?.Write($"ApplySimGameEventResult RAID_SYSTEM: factionID {factionID}, systemId {systemId}"); FactionValue faction = Utilities.getFactionValueByFactionID(factionID); StarSystem system = WIIC.sim.GetSystemById(systemId); WIIC.cleanupSystem(system); Flareup flareup = new Flareup(system, faction, "Raid", WIIC.sim); WIIC.flareups[system.ID] = flareup; Utilities.redrawMap(); result.AddedTags.Remove(addedTag); continue; } matches = ATTACKER_FORCES.Matches(addedTag); if (matches.Count > 0) { string systemId = matches[0].Groups["system"].Value; int strength = int.Parse(matches[0].Groups["strength"].Value); WIIC.modLog.Info?.Write($"ApplySimGameEventResult ATTACKER_FORCES: systemId {systemId}, strength {strength}"); StarSystem system = WIIC.sim.GetSystemById(systemId); if (WIIC.flareups.ContainsKey(system.ID)) { WIIC.flareups[system.ID].attackerStrength = strength; } else { WIIC.modLog.Error?.Write($"ApplySimGameEventResult: No flareup found at {systemId}"); } result.AddedTags.Remove(addedTag); continue; } matches = DEFENDER_FORCES.Matches(addedTag); if (matches.Count > 0) { string systemId = matches[0].Groups["system"].Value; int strength = int.Parse(matches[0].Groups["strength"].Value); WIIC.modLog.Info?.Write($"ApplySimGameEventResult DEFENDER_FORCES: systemId {systemId}, strength {strength}"); StarSystem system = WIIC.sim.GetSystemById(systemId); if (WIIC.flareups.ContainsKey(system.ID)) { WIIC.flareups[system.ID].attackerStrength = strength; } else { WIIC.modLog.Error?.Write($"ApplySimGameEventResult: No flareup found at {systemId}"); } result.AddedTags.Remove(addedTag); continue; } matches = ADD_SYSTEM_TAG.Matches(addedTag); if (matches.Count > 0) { string tag = matches[0].Groups["tag"].Value; string systemId = matches[0].Groups["system"].Value; WIIC.modLog.Info?.Write($"ApplySimGameEventResult ADD_SYSTEM_TAG: tag {tag}, systemId {systemId}"); StarSystem system = WIIC.sim.GetSystemById(systemId); system.Tags.Add(tag); result.AddedTags.Remove(addedTag); continue; } matches = REMOVE_SYSTEM_TAG.Matches(addedTag); if (matches.Count > 0) { string tag = matches[0].Groups["tag"].Value; string systemId = matches[0].Groups["system"].Value; WIIC.modLog.Info?.Write($"ApplySimGameEventResult REMOVE_SYSTEM_TAG: tag {tag}, systemId {systemId}"); StarSystem system = WIIC.sim.GetSystemById(systemId); system.Tags.Remove(tag); result.AddedTags.Remove(addedTag); continue; } } catch (Exception e) { WIIC.modLog.Error?.Write(e); } } } }