示例#1
0
        public static void LoadFlareups(GameInstanceSave gameInstanceSave, SimGameState __instance)
        {
            try {
                WIIC.sim = __instance;
                WIIC.modLog.Debug?.Write("Loading Flareups");
                WIIC.flareups.Clear();
                WIIC.sim.CompanyTags.Add("WIIC_enabled");

                WIIC.readFromJson("WIIC_ephemeralSystemControl.json", true);

                foreach (StarSystem system in __instance.StarSystems)
                {
                    string tag = system.Tags.ToList().Find(Flareup.isSerializedFlareup);
                    if (tag != null)
                    {
                        system.Tags.Remove(tag);

                        Flareup flareup = Flareup.Deserialize(tag);
                        WIIC.flareups[system.ID] = flareup;
                    }

                    tag = system.Tags.ToList().Find(Utilities.isControlTag);
                    if (tag != null)
                    {
                        system.Tags.Remove(tag);
                        WIIC.systemControl[system.ID] = tag;
                    }
                }

                WIIC.modLog.Debug?.Write($"Loaded {WIIC.flareups.Keys.Count} flareups and {WIIC.systemControl.Keys.Count} system control tags");
                Utilities.redrawMap();
            } catch (Exception e) {
                WIIC.modLog.Error?.Write(e);
            }
        }
示例#2
0
 public static void Postfix(SimGameState __instance)
 {
     try {
         WIIC.readFromJson("WIIC_systemControl.json", false);
     } catch (Exception e) {
         WIIC.modLog.Error?.Write(e);
     }
 }
示例#3
0
 public static void Postfix(SimGameState __instance)
 {
     try {
         WIIC.readFromJson();
     } catch (Exception e) {
         WIIC.modLog.Error?.Write(e);
     }
 }
示例#4
0
        public static void SaveFlareups()
        {
            WIIC.modLog.Debug?.Write($"Saving {WIIC.flareups.Keys.Count} flareups and {WIIC.systemControl.Keys.Count} system control tags");

            try {
                foreach (Flareup flareup in WIIC.flareups.Values)
                {
                    flareup.location.Tags.Add(flareup.Serialize());
                }
                foreach (KeyValuePair <string, string> control in WIIC.systemControl)
                {
                    WIIC.sim.GetSystemById(control.Key).Tags.Add(control.Value);
                }
                WIIC.serializeToJson();
            } catch (Exception e) {
                WIIC.modLog.Error?.Write(e);
            }
        }
示例#5
0
        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);
            }
        }
示例#6
0
        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);
                    }
                }
            }
        }