This commit is contained in:
Ell 2020-12-20 13:33:38 +01:00
parent a30e7b59dc
commit fa047e021f
3 changed files with 21 additions and 22 deletions

View file

@ -20,7 +20,6 @@ namespace ExampleMod {
public override string Name => "Example Mod"; public override string Name => "Example Mod";
public override string Description => "This is the example mod for Tiny Life!"; public override string Description => "This is the example mod for Tiny Life!";
private DataTextureAtlas customFurniture;
private UniformTextureAtlas customClothes; private UniformTextureAtlas customClothes;
private UniformTextureAtlas customClothesIcons; private UniformTextureAtlas customClothesIcons;
@ -37,22 +36,21 @@ namespace ExampleMod {
ColorScheme.WarmDark)); ColorScheme.WarmDark));
} }
public override void Initialize(Logger logger, RawContentManager content) { public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker) {
Logger = logger; Logger = logger;
// loads the custom furniture texture atlas // 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
texturePacker.Add(content.Load<Texture2D>("CustomClothes"), r => this.customClothes = new UniformTextureAtlas(r, 4, 6));
texturePacker.Add(content.Load<Texture2D>("CustomClothesIcons"), r => this.customClothesIcons = new UniformTextureAtlas(r, 16, 16));
}
public override IEnumerable<string> GetCustomFurnitureTextures() {
// tell the game about our custom furniture texture
// 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 // the texture atlas combines the png texture and the .atlas information
// see https://mlem.ellpeck.de/api/MLEM.Data.DataTextureAtlas.html for more info // see https://mlem.ellpeck.de/api/MLEM.Data.DataTextureAtlas.html for more info
this.customFurniture = content.LoadTextureAtlas("CustomFurniture"); yield return "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<Texture2D>("CustomClothes"), 4, 6);
this.customClothesIcons = new UniformTextureAtlas(content.Load<Texture2D>("CustomClothesIcons"), 16, 16);
}
public override IEnumerable<DataTextureAtlas> GetCustomFurnitureTextures() {
// tell the game about our custom furniture texture
yield return this.customFurniture;
} }
} }

View file

@ -5,12 +5,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="TinyLifeApi" Version="0.3.0" /> <PackageReference Include="TinyLifeApi" Version="0.3.1" />
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.1" /> <PackageReference Include="ExtremelySimpleLogger" Version="1.2.1" />
<PackageReference Include="MLEM.Data" Version="4.3.0-8" /> <PackageReference Include="MLEM.Data" Version="4.3.0-20" />
<PackageReference Include="MLEM.Extended" Version="4.3.0-8" /> <PackageReference Include="MLEM.Extended" Version="4.3.0-20" />
<PackageReference Include="MLEM.Startup" Version="4.3.0-8" /> <PackageReference Include="MLEM.Startup" Version="4.3.0-20" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" /> <PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" /> <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
</ItemGroup> </ItemGroup>

View file

@ -36,6 +36,14 @@ Technically, you can download the game [from itch](https://ellpeck.itch.io/tiny-
## Dependency version history ## 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). 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 ```xml
<!-- Tiny Life 0.3.1+ -->
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.1" />
<PackageReference Include="MLEM.Data" Version="4.3.0-20" />
<PackageReference Include="MLEM.Extended" Version="4.3.0-20" />
<PackageReference Include="MLEM.Startup" Version="4.3.0-20" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
<!-- Tiny Life 0.2.2+ --> <!-- Tiny Life 0.2.2+ -->
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.1" /> <PackageReference Include="ExtremelySimpleLogger" Version="1.2.1" />
<PackageReference Include="MLEM.Data" Version="4.3.0-8" /> <PackageReference Include="MLEM.Data" Version="4.3.0-8" />
@ -43,11 +51,4 @@ Since the mod is compiled against the same dependencies as Tiny Life, it also ne
<PackageReference Include="MLEM.Startup" Version="4.3.0-8" /> <PackageReference Include="MLEM.Startup" Version="4.3.0-8" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" /> <PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" /> <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
<!-- Tiny Life 0.2.1 -->
<PackageReference Include="ExtremelySimpleLogger" Version="1.1.0" />
<PackageReference Include="MLEM.Data" Version="4.3.0-7" />
<PackageReference Include="MLEM.Extended" Version="4.0.0" />
<PackageReference Include="MLEM.Startup" Version="4.2.0-298" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
``` ```