Exemplo n.º 1
0
 internal void DumpData()
 {
     try { lock ( Data ) {
               if (Data.Count == 0)
               {
                   ZyMod.Verbo("Skipping {0} because it is empty", Name);
                   return;
               }
               ZyMod.Info("Dumping {0} ({1})", Name, Data.Count);
               SortData();
               var path = DeleteOldDumps();
               using (var fstream = new FileStream(path, FileMode.Create)) {
                   if (Mod.Config.GZip)
                   {
                       var buffer = new GZipStream(fstream, CompressionLevel.Optimal);
                       using (var writer = new StreamWriter(buffer)) DumpToWriter(writer);
                   }
                   else
                   {
                       using (var writer = new StreamWriter(fstream)) DumpToWriter(writer);
                   }
               }
               ZyMod.Verbo("Finished {0}, {1} bytes written", Name, new FileInfo(path).Length);
               Data.Clear();
           } } catch (Exception ex) { ZyMod.Error(ex); }
 }
Exemplo n.º 2
0
 internal void Update()
 {
     if (Config_Version < 20200422)  // Keep 0422 which has Optimise_Log_File
     {
         Config_Version = 20200503;
         ZyMod.Api("config_save", this);
     }
 }
Exemplo n.º 3
0
        public static void GeoscapeMod(Func <string, object, object> api = null)
        {
            ZyMod.SetApi(api);
            var module = new UncapAug();

            module.UncapMutate();
            module.UncapBionic();
        }
Exemplo n.º 4
0
 private static float SyncDamage(this WeaponDef weapon, DamageKeywordDef damageType, Func <float, float> handler)
 {
     lock ( weapon ) {
         if (weapon == null)
         {
             throw new ArgumentNullException(nameof(weapon));
         }
         if (damageType == null)
         {
             throw new ArgumentNullException(nameof(damageType));
         }
         var list = weapon.DamagePayload.DamageKeywords;
         var pair = list.FirstOrDefault(e => e.DamageKeywordDef == damageType);
         var orig = pair?.Value ?? 0;
         if (handler == null)
         {
             return(orig);
         }
         var value = handler(orig);
         if (value == orig)
         {
             return(orig);
         }
         object[] logArg = new object[] { weapon.name, damageType.name, orig, value };
         if (value > 0)
         {
             if (pair == null)
             {
                 ZyMod.ApiLog(TraceEventType.Start, "Adding {1} {3} to {0}", logArg);
                 list.Add(pair = new DamageKeywordPair {
                     DamageKeywordDef = damageType, Value = value
                 });
             }
             else
             {
                 ZyMod.ApiLog(TraceEventType.Start, "Update {0} {1} {2} to {3}", logArg);
                 pair.Value = value;
             }
         }
         else if (pair != null)
         {
             ZyMod.ApiLog(TraceEventType.Start, "Removing {1} {2} from {0}", logArg);
             list.Remove(pair);
         }
         return(orig);
     }
 }
Exemplo n.º 5
0
        internal void Upgrade()
        {
            if (Config_Version >= 20201128)
            {
                return;
            }

            if (Config_Version < 20200630)
            {
                ;                           // Do nothing; Added Auto_Dump field
            }
            if (Config_Version < 20201128)
            {
                if (Dump_Defs?.Length == 23 && Dump_Defs[0] == "VehicleItemDef" && Dump_Defs[22] == "AbilityDef")
                {
                    Dump_Defs = new ModConfig().Dump_Defs; // Add EntitlementDef
                }
            }
            ZyMod.Api("config save", this); // Add Auto_Dump
        }
Exemplo n.º 6
0
        }                                                 // Replaced by Auto_Unpause_Multiple on ver 20200603

        internal void Upgrade()
        {
            if (Config_Version < 20200603 && No_Auto_Unpause == false)
            {
                Auto_Unpause_Multiple = true;
            }
            if (Config_Version < 20201027)
            {
                Config_Version = 20201027;
                if (Haven_Icons?.Always_Show_Soldier == true)
                {
                    Haven_Icons.Always_Show_Action = true;
                }
                ZyMod.Api("config save", this);
            }
            if (Haven_Icons == null)
            {
                Haven_Icons = new HavenIconConfig();
            }
        }
Exemplo n.º 7
0
        protected KeyValuePair <string, string> Stringify(ViewElementDef view)
        {
            string title = view.DisplayName1.Localize(), desc = view.Description.Localize(), key = view.DisplayName1.LocalizationKey;

            if (desc.Contains("{") && desc.Contains("}") && FindInterpol(view) is IInterpolatableObject ipol)
            {
                desc = view.GetInterpolatedDescription(ipol);
            }
            if (view is MutationViewElementDef mut)  // Mutations
            {
                title = view.DisplayName2.Localize();
                desc  = mut.MutationDescription.Localize();
            }
            else if (key.IndexOf("_PERSONALTRACK_", StringComparison.Ordinal) >= 0 || key.IndexOf("KEY_CLASS_", StringComparison.Ordinal) == 0)        // Class & Skills
            {
                title = ZyMod.TitleCase(title);
            }
            else if (RegexBodyParts.IsMatch(key))    // Armours
            {
                title = view.DisplayName2.Localize();
            }
            return(new KeyValuePair <string, string>(title, desc));
        }
Exemplo n.º 8
0
     internal void Upgrade()
     {
         if (Config_Version < 20200604)
         {
             if (Grafts != null)
             {
                 Augments = Grafts;
             }
         }
         if (Config_Version < 20201102)
         {
             Config_Version = 20201102;
             ZyMod.Api("config save", this);
         }
         if (Skills == null)
         {
             Skills = new ListConfig {
                 Enabled = false
             }
         }
         ;
         if (Augments == null)
         {
             Augments = new ListConfig {
                 Enabled = false
             }
         }
         ;
         if (Equipments == null)
         {
             Equipments = new ListConfig {
                 Enabled = false
             }
         }
         ;
     }
 }
Exemplo n.º 9
0
 public static object Api(string action, object param) => ZyMod.Api(action, param);
Exemplo n.º 10
0
 public void OnManufacture(GeoFaction faction) => ZyMod.Warn("Attempting to manufacture {0}", GetName());