Beispiel #1
0
 public static void Init(Db db)
 {
     if (INITIALIZED)
     {
         return;
     }
     lock (INITIALIZE_LOCK) {
         if (INITIALIZED)
         {
             return;
         }
         INITIALIZED = true;
         foreach (var assembly in ASSEMBLIES)
         {
             VLogger.Log($"Initializing for {assembly}");
             VUtils.RegisterAllBuildings(assembly, db);
             VUtils.BindAllLocStrings(assembly);
         }
     }
 }
Beispiel #2
0
        public static void RegisterAllBuildings(Assembly assembly, Db db)
        {
            var buildingConfigs = ListBuildingConfigs(assembly);

            foreach (var buildingConfig in buildingConfigs)
            {
                try {
                    VLogger.Log($"Registering building {buildingConfig.id} in Plan '{buildingConfig.planName}'");
                    ModUtil.AddBuildingToPlanScreen(buildingConfig.planName, buildingConfig.id);

                    VLogger.Log($"Registering building {buildingConfig.id} in Tech '{buildingConfig.techId}'");
                    BuildingUtils.AddTech(db, buildingConfig.techId, buildingConfig.id);

                    VLogger.Log($"Registering building {buildingConfig.id} in Strings");
                    var id     = buildingConfig.id;
                    var name   = buildingConfig.name;
                    var desc   = buildingConfig.desc;
                    var effect = buildingConfig.effect;
                    var prefix = $"STRINGS.BUILDINGS.PREFABS.{id.ToUpperInvariant()}.";
                    if (name != null)
                    {
                        Strings.Add($"{prefix}NAME", name);
                    }
                    if (desc != null)
                    {
                        Strings.Add($"{prefix}DESC", desc);
                    }
                    if (effect != null)
                    {
                        Strings.Add($"{prefix}EFFECT", effect);
                    }
                }
                catch (Exception ex) {
                    DebugUtil.LogException(null, $"Exception while registering building {buildingConfig.id}", ex);
                }
            }
        }