From fa047e021f24b2a7edf730d8acb13a12a7dbb49e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 20 Dec 2020 13:33:38 +0100 Subject: [PATCH] update --- ExampleMod.cs | 20 +++++++++----------- ExampleMod.csproj | 8 ++++---- README.md | 15 ++++++++------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/ExampleMod.cs b/ExampleMod.cs index 41e8d80..9f738f7 100644 --- a/ExampleMod.cs +++ b/ExampleMod.cs @@ -20,7 +20,6 @@ namespace ExampleMod { public override string Name => "Example Mod"; public override string Description => "This is the example mod for Tiny Life!"; - private DataTextureAtlas customFurniture; private UniformTextureAtlas customClothes; private UniformTextureAtlas customClothesIcons; @@ -37,22 +36,21 @@ namespace ExampleMod { ColorScheme.WarmDark)); } - public override void Initialize(Logger logger, RawContentManager content) { + public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker) { Logger = logger; - // loads the custom furniture texture atlas - // the texture atlas combines the png texture and the .atlas information - // see https://mlem.ellpeck.de/api/MLEM.Data.DataTextureAtlas.html for more info - this.customFurniture = content.LoadTextureAtlas("CustomFurniture"); - // loads a texture atlas with the given amount of separate texture regions in the x and y axes - this.customClothes = new UniformTextureAtlas(content.Load("CustomClothes"), 4, 6); - this.customClothesIcons = new UniformTextureAtlas(content.Load("CustomClothesIcons"), 16, 16); + // we submit it to the texture packer to increase rendering performance. The callback is invoked once packing is completed + texturePacker.Add(content.Load("CustomClothes"), r => this.customClothes = new UniformTextureAtlas(r, 4, 6)); + texturePacker.Add(content.Load("CustomClothesIcons"), r => this.customClothesIcons = new UniformTextureAtlas(r, 16, 16)); } - public override IEnumerable GetCustomFurnitureTextures() { + public override IEnumerable GetCustomFurnitureTextures() { // tell the game about our custom furniture texture - yield return this.customFurniture; + // this needs to be a path to a data texture atlas, relative to our "Content" directory + // the texture atlas combines the png texture and the .atlas information + // see https://mlem.ellpeck.de/api/MLEM.Data.DataTextureAtlas.html for more info + yield return "CustomFurniture"; } } diff --git a/ExampleMod.csproj b/ExampleMod.csproj index 11f5e26..04f440f 100644 --- a/ExampleMod.csproj +++ b/ExampleMod.csproj @@ -5,12 +5,12 @@ - + - - - + + + diff --git a/README.md b/README.md index cafcbdd..6f815db 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,14 @@ Technically, you can download the game [from itch](https://ellpeck.itch.io/tiny- ## Dependency version history Since the mod is compiled against the same dependencies as Tiny Life, it also needs to have the same versions of those dependencies for mods to work correctly with the game. The following is a list of versions of Tiny Life and the appropriate dependency versions that the mod should be compiled against to work for that version. When updating your mod, you can just copy the appropriate part [into your project file](https://github.com/Ellpeck/TinyLifeExampleMod/blob/main/ExampleMod.csproj#L10-L15). ```xml + + + + + + + + @@ -43,11 +51,4 @@ Since the mod is compiled against the same dependencies as Tiny Life, it also ne - - - - - - - ``` \ No newline at end of file