Compare commits

...

3 commits

2 changed files with 18 additions and 10 deletions

View file

@ -49,10 +49,17 @@ public class ExampleMod : Mod {
// adding custom clothing // adding custom clothing
var darkShirt = new Clothes("ExampleMod.DarkShirt", ClothesLayer.Shirt, var darkShirt = new Clothes("ExampleMod.DarkShirt", ClothesLayer.Shirt,
this.customTops, new Point(0, 0), // the top left in-world region (the rest will be auto-gathered from the atlas) // the top left in-world region
100, // the price // additional regions will be auto-gathered from the atlas according to the rules described in https://docs.tinylifegame.com/articles/creating_textures.html
ClothesIntention.Everyday | ClothesIntention.Workout, // the clothes item's use cases this.customTops, new Point(0, 0),
ColorScheme.WarmDark) {Icon = this.Icon}; // the price
100,
// the clothes item's use cases
ClothesIntention.Everyday | ClothesIntention.Workout,
// the clothes item's color scheme
// if the item should have multiple layers, multiple color schemes can be supplied here (see docs above)
ColorScheme.WarmDark
) {Icon = this.Icon};
Clothes.Register(darkShirt); Clothes.Register(darkShirt);
// adding some more custom clothing // adding some more custom clothing
Clothes.Register(new Clothes("ExampleMod.PastelPants", ClothesLayer.Pants, this.customBottoms, new Point(4, 0), 100, ClothesIntention.Everyday, ColorScheme.Pastel) {Icon = this.Icon}); Clothes.Register(new Clothes("ExampleMod.PastelPants", ClothesLayer.Pants, this.customBottoms, new Point(4, 0), 100, ClothesIntention.Everyday, ColorScheme.Pastel) {Icon = this.Icon});
@ -106,10 +113,11 @@ public class ExampleMod : Mod {
// loads a texture atlas with the given amount of separate texture regions in the x and y axes // 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 // we submit it to the texture packer to increase rendering performance. The callback is invoked once packing is completed
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomTops"), 4, 11), r => this.customTops = r); // 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<Texture2D>("CustomHairs"), 4, 5), r => this.customHairs = r); texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomTops"), 4, 11), r => this.customTops = r, 1, true);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomBottomsShoes"), 8, 6), r => this.customBottoms = r); texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomHairs"), 4, 5), r => this.customHairs = r, 1, true);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("UiTextures"), 8, 8), r => this.uiTextures = r); texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomBottomsShoes"), 8, 6), r => this.customBottoms = r, 1, true);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("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 // wallpaper textures require special treatment to work with openings, the x and y values are passed to the UniformTextureAtlas constructor
WallMode.ApplyMasks(content.Load<Texture2D>("Wallpapers"), 4, 5, texturePacker, r => this.wallpaperTextures = r); WallMode.ApplyMasks(content.Load<Texture2D>("Wallpapers"), 4, 5, texturePacker, r => this.wallpaperTextures = r);
} }

View file

@ -43,7 +43,7 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
using (var stream = new FileStream(log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (var stream = new FileStream(log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
using (var reader = new StreamReader(stream)) { using (var reader = new StreamReader(stream)) {
var lastPos = 0L; var lastPos = 0L;
while (!process.HasExited) { do {
if (reader.BaseStream.Length > lastPos) { if (reader.BaseStream.Length > lastPos) {
reader.BaseStream.Seek(lastPos, SeekOrigin.Begin); reader.BaseStream.Seek(lastPos, SeekOrigin.Begin);
string line; string line;
@ -52,7 +52,7 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
lastPos = reader.BaseStream.Position; lastPos = reader.BaseStream.Position;
} }
Thread.Sleep(10); Thread.Sleep(10);
} } while (!process.HasExited);
} }
} }
} }