From 0e6af45024cc6a1538d7fcece2e5c0bc162ad8e0 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 10 May 2023 23:50:26 +0200 Subject: [PATCH] swap initialize and addgamecontent for clarity --- ExampleMod.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ExampleMod.cs b/ExampleMod.cs index f0a5408..d2b8980 100644 --- a/ExampleMod.cs +++ b/ExampleMod.cs @@ -38,6 +38,21 @@ public class ExampleMod : Mod { private Dictionary uiTextures; private Dictionary wallpaperTextures; + public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) { + ExampleMod.Logger = logger; + ExampleMod.Options = info.LoadOptions(() => new ExampleOptions()); + + // loads a texture atlas with the given amount of separate texture regions in the x and y axes + // we submit it to the texture packer to increase rendering performance. The callback is invoked once packing is completed + // additionally, we pad all texture regions by 1 pixel, so that rounding errors during rendering don't cause visual artifacts + texturePacker.Add(new UniformTextureAtlas(content.Load("CustomTops"), 4, 11), r => this.customTops = r, 1, true); + texturePacker.Add(new UniformTextureAtlas(content.Load("CustomHairs"), 4, 5), r => this.customHairs = r, 1, true); + texturePacker.Add(new UniformTextureAtlas(content.Load("CustomBottomsShoes"), 8, 6), r => this.customBottoms = r, 1, true); + texturePacker.Add(new UniformTextureAtlas(content.Load("UiTextures"), 8, 8), r => this.uiTextures = r, 1, true); + // wallpaper textures require special treatment to work with openings, the x and y values are passed to the UniformTextureAtlas constructor + WallMode.ApplyMasks(content.Load("Wallpapers"), 4, 5, texturePacker, r => this.wallpaperTextures = r); + } + public override void AddGameContent(GameImpl game, ModInfo info) { // adding a custom furniture item FurnitureType.Register(new FurnitureType.TypeSettings("ExampleMod.CustomTable", new Point(1, 1), ObjectCategory.Table, 150, ColorScheme.SimpleWood) { @@ -110,21 +125,6 @@ public class ExampleMod : Mod { Wallpaper.Register("ExampleMod.CrossedWallpaper", 15, this.wallpaperTextures, new Point(0, 0), ColorScheme.Modern, this.Icon); } - public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) { - ExampleMod.Logger = logger; - ExampleMod.Options = info.LoadOptions(() => new ExampleOptions()); - - // loads a texture atlas with the given amount of separate texture regions in the x and y axes - // we submit it to the texture packer to increase rendering performance. The callback is invoked once packing is completed - // additionally, we pad all texture regions by 1 pixel, so that rounding errors during rendering don't cause visual artifacts - texturePacker.Add(new UniformTextureAtlas(content.Load("CustomTops"), 4, 11), r => this.customTops = r, 1, true); - texturePacker.Add(new UniformTextureAtlas(content.Load("CustomHairs"), 4, 5), r => this.customHairs = r, 1, true); - texturePacker.Add(new UniformTextureAtlas(content.Load("CustomBottomsShoes"), 8, 6), r => this.customBottoms = r, 1, true); - texturePacker.Add(new UniformTextureAtlas(content.Load("UiTextures"), 8, 8), r => this.uiTextures = r, 1, true); - // wallpaper textures require special treatment to work with openings, the x and y values are passed to the UniformTextureAtlas constructor - WallMode.ApplyMasks(content.Load("Wallpapers"), 4, 5, texturePacker, r => this.wallpaperTextures = r); - } - public override IEnumerable GetCustomFurnitureTextures(ModInfo info) { // tell the game about our custom furniture texture // this needs to be a path to a data texture atlas, relative to our "Content" directory