Beispiel #1
0
        private static void BeforeAddEntry_AmendEntry(GeoscapeLogEntry entry, GeoscapeLogMessagesDef ____messagesDef, GeoFaction ____faction)
        {
            try {
                if (entry == null || entry.Text != ____messagesDef.AircraftCrewReadyMessage)
                {
                    return;
                }
                var name = (entry.Parameters[0] as LocalizedTextBind)?.Localize();
                Verbo("Checking rest message of {0}", name);

                Func <IGeoCharacterContainer, bool> foundEntry = (e) => e.Name == name;
                IGeoCharacterContainer container = ____faction.Vehicles.FirstOrDefault(foundEntry) ?? ____faction.Sites.FirstOrDefault(foundEntry);
                if (container == null)
                {
                    return;
                }

                string note;
                if (container.GetAllCharacters().Any(e => e.IsInjured))
                {
                    note = new LocalizedTextBind("KEY_GEOSCAPE_STAMINA").Localize();
                }
                else if (container.GetAllCharacters().Any(e => e.Fatigue?.IsFullyRested == false))
                {
                    note = new LocalizedTextBind("KEY_HEALTH").Localize();
                }
                else
                {
                    return;
                }
                Info("Updating rest message of {0}", name);
                entry.Text = new LocalizedTextBind(entry.GenerateMessage() + " (" + TitleCase(note) + ")", true);
            } catch (Exception ex) { Error(ex); }
        }
        /// <summary>
        /// Skip SetStat if stat is 0
        /// </summary>
        public static bool Prefix(
            UIItemTooltip __instance, MethodInfo __originalMethod,
            LocalizedTextBind statLocalization, bool secondObject, object statValue,
            object statCompareValue = null, UnityEngine.Sprite statIcon = null )
        {
            float svFloat,scvFloat;
            string svType, scvType = "";
            string svString = statValue as string ?? "null" ;
            string scvString = statCompareValue as string ?? "null";
            string zeroPercent = Base.UI.UIUtil.PercentageStat(0f, __instance.PercentageString.Localize(null));

            try {
                svFloat = (float)statValue;
            } catch (InvalidCastException) {
                svFloat = 12.34f;
            }
            try {
                scvFloat = (float)statValue;
            } catch (InvalidCastException) {
                scvFloat = 12.34f;
            }
            try {
                svType = statValue.GetType().ToString();
            } catch (NullReferenceException) {
                svType = "NULL";
            }
            try {
                scvType = statCompareValue.GetType().ToString();
            } catch (NullReferenceException) {
                scvType = "NULL";
            }

            bool svSkip = svString == "0" || svString == zeroPercent || svFloat == 0f;
            bool scvSkip = scvString == "0" || scvString == zeroPercent || scvFloat == 0f;
#if DEBUG
            BasicUtil.Log($"Injected into {__instance.GetType()}.{__originalMethod.Name}()", MyMod.storedAPI);
            BasicUtil.Log($"  {statLocalization.Localize()} [2nd: {secondObject}]", MyMod.storedAPI);
            BasicUtil.Log($"  SV: {statValue ?? 0,4} [{svType}]", MyMod.storedAPI);
            BasicUtil.Log($"  CV: {statCompareValue ?? 0,4} [{scvType}]", MyMod.storedAPI);
            BasicUtil.Log($"  SVSkip: {svSkip}", MyMod.storedAPI);
            BasicUtil.Log($"  CVSkip: {scvSkip}", MyMod.storedAPI);
#endif

            return !(scvSkip && svSkip) || MyMod.Config.show_zeros;
        }
Beispiel #3
0
 private static void AfterSiteMission_AmendLog(GeoSite site, GeoMission mission, List <GeoscapeLogEntry> ____entries)
 {
     try {
         if (!(mission is GeoHavenDefenseMission defense) || DefenseMission == null)
         {
             return;
         }
         var attacker = DefenseMission.GetEnemyFaction();
         if (!CauseZoneDamage(attacker))
         {
             return;
         }
         LocalizedTextBind zoneName = defense.AttackedZone?.Def?.ViewElementDef?.DisplayName1;
         if (zoneName == null || ____entries == null || ____entries.Count < 1)
         {
             return;
         }
         GeoscapeLogEntry entry = ____entries[____entries.Count - 1];
         Verbo("Converting {0} invasion message to zone invasion.", attacker.GetPPName());
         entry.Parameters[0] = new LocalizedTextBind(site.SiteName.Localize() + " " + TitleCase(zoneName.Localize()), true);
     } catch (Exception ex) { Error(ex); }
 }