Exemple #1
0
        /// <summary>
        /// Adjusts Atmo and Jet suit decor.
        /// </summary>
        /// <param name="options">The options for the decor of those suits.</param>
        /// <param name="suit">The suit def to modify.</param>
        internal static void TuneSuits(DecorReimaginedOptions options, EquipmentDef suit)
        {
            var attr = Db.Get().BuildingAttributes;

            suit.AttributeModifiers.Add(new AttributeModifier(attr.Decor.Id, options.
                                                              AtmoSuitDecor, STRINGS.EQUIPMENT.PREFABS.ATMO_SUIT.NAME, false, false, true));
        }
 public static void OnLoad()
 {
     ImaginationLoader.Init(typeof(DecorReimaginedPatches));
     Options = new DecorReimaginedOptions();
     POptions.RegisterOptions(typeof(DecorReimaginedOptions));
     PUtil.RegisterPostload(DecorTuning.TuneBuildings);
     PatchParks();
     PatchRecBuildings();
 }
		public override void OnLoad(Harmony harmony) {
			base.OnLoad(harmony);
			PUtil.InitLibrary();
			Options = new DecorReimaginedOptions();
			ImaginationLoader.Instance.Register(typeof(DecorReimaginedPatches));
			new POptions().RegisterOptions(this, typeof(DecorReimaginedOptions));
			new PPatchManager(harmony).RegisterPatchClass(typeof(DecorReimaginedPatches));
			new PVersionCheck().Register(this, new SteamVersionChecker());
			PatchParks();
			PatchRecBuildings();
		}
Exemple #4
0
        /// <summary>
        /// Applies decor values from the database.
        /// </summary>
        internal static void ApplyDatabase(DecorReimaginedOptions options)
        {
            DecorDbEntry[] entries = null;
            try {
                // Read in database from the embedded config json
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                           "ReimaginationTeam.DecorRework.buildings.json")) {
                    var jr = new JsonTextReader(new StreamReader(stream));
                    entries = new JsonSerializer {
                        MaxDepth = 2
                    }.Deserialize <DecorDbEntry[]>(jr);
                    jr.Close();
                }
            } catch (JsonException e) {
                // Error when loading decor
                PUtil.LogExcWarn(e);
            } catch (IOException e) {
                // Error when loading decor
                PUtil.LogExcWarn(e);
            }
            if (entries != null)
            {
                var editDecor = DictionaryPool <string, DecorDbEntry, DecorDbEntry> .Allocate();

                string id;
                // Add to dictionary, way faster
                foreach (var entry in entries)
                {
                    if (!string.IsNullOrEmpty(id = entry.id) && !editDecor.ContainsKey(id))
                    {
                        editDecor.Add(id, entry);
                    }
                }
                foreach (var def in Assets.BuildingDefs)
                {
                    // If PreserveTileDecor is set to true, ignore foundation tile decor mods
                    if (editDecor.TryGetValue(id = def.PrefabID, out DecorDbEntry entry) &&
                        (def.TileLayer != ObjectLayer.FoundationTile || !options.
                         PreserveTileDecor))
                    {
                        float decor    = entry.decor;
                        int   radius   = entry.radius;
                        var   provider = def.BuildingComplete.GetComponent <DecorProvider>();
                        // For reference, these do not alter the BuildingComplete
                        def.BaseDecor       = decor;
                        def.BaseDecorRadius = radius;
                        // Actual decor provider
                        if (provider != null)
                        {
                            PUtil.LogDebug("Patched: {0} Decor: {1:F1} Radius: {2:D}".F(id,
                                                                                        decor, radius));
                            provider.baseDecor  = decor;
                            provider.baseRadius = radius;
                        }
                    }
                }
                editDecor.Recycle();
            }
            // Patch in the debris decor
            var baseOreTemplate = typeof(EntityTemplates).GetFieldSafe("baseOreTemplate",
                                                                       true)?.GetValue(null) as GameObject;
            DecorProvider component;

            if (baseOreTemplate != null && (component = baseOreTemplate.
                                                        GetComponent <DecorProvider>()) != null)
            {
                int radius = Math.Max(1, options.DebrisRadius);
                component.baseDecor  = options.DebrisDecor;
                component.baseRadius = radius;
                PUtil.LogDebug("Debris: {0:F1} radius {1:D}".F(options.DebrisDecor, radius));
            }
            // Patch the suits
            PUtil.LogDebug("Snazzy Suit: {0:D} Warm/Cool Vest: {1:D}".F(options.
                                                                        SnazzySuitDecor, options.VestDecor));
            ClothingWearer.ClothingInfo.FANCY_CLOTHING.decorMod = options.SnazzySuitDecor;
            ClothingWearer.ClothingInfo.COOL_CLOTHING.decorMod  = options.VestDecor;
            ClothingWearer.ClothingInfo.WARM_CLOTHING.decorMod  = options.VestDecor;
        }