TinyLifeExampleMod/ExampleMod.cs

59 lines
2.5 KiB
C#
Raw Normal View History

2020-11-25 00:33:47 +01:00
using System.Collections.Generic;
using ExtremelySimpleLogger;
using Microsoft.Xna.Framework;
2020-11-28 17:05:46 +01:00
using Microsoft.Xna.Framework.Graphics;
2020-11-25 00:33:47 +01:00
using MLEM.Data;
using MLEM.Data.Content;
2020-11-28 17:05:46 +01:00
using MLEM.Textures;
2020-11-25 00:33:47 +01:00
using TinyLife;
using TinyLife.Mods;
using TinyLife.Objects;
using TinyLife.Utilities;
namespace ExampleMod {
public class ExampleMod : Mod {
// the logger that we can use to log info about this mod
public static Logger Logger { get; private set; }
// visual data about this mod
public override string Name => "Example Mod";
public override string Description => "This is the example mod for Tiny Life!";
private DataTextureAtlas customFurniture;
2020-11-28 17:05:46 +01:00
private UniformTextureAtlas customClothes;
private UniformTextureAtlas customClothesIcons;
2020-11-25 00:33:47 +01:00
public override void AddGameContent(GameImpl game) {
// adding a custom furniture item
FurnitureType.Register(new FurnitureType.TypeSettings("ExampleMod.CustomTable", new Point(1, 1), ObjectCategory.Table, 150, ColorScheme.SimpleWood) {
2020-11-25 00:33:47 +01:00
Construct = (i, t, c, m, p) => new CustomTable(i, t, c, m, p)
});
2020-11-28 17:05:46 +01:00
// adding custom clothing
Clothes.Register(new Clothes("ExampleMod.DarkShirt", ClothesLayer.Shirt,
this.customClothes[0, 0], // the top left in-world region (the rest will be auto-gathered from the atlas)
this.customClothesIcons[0, 0], // the region to use for the icon in the character editor
ColorScheme.WarmDark));
2020-11-25 00:33:47 +01:00
}
public override void Initialize(Logger logger, RawContentManager content) {
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");
2020-11-28 17:05:46 +01:00
// 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);
2020-11-25 00:33:47 +01:00
}
public override IEnumerable<DataTextureAtlas> GetCustomFurnitureTextures() {
// tell the game about our custom furniture texture
yield return this.customFurniture;
}
}
}