This commit is contained in:
Ell 2022-12-20 13:24:55 +01:00
parent c8c7d3c528
commit 66987d3838
3 changed files with 20 additions and 20 deletions

View file

@ -27,12 +27,12 @@ public class ExampleMod : Mod {
// visual data about this mod
public override string Name => "Example Mod";
public override string Description => "This is the example mod for Tiny Life!";
public override TextureRegion Icon => this.uiTextures[0, 0];
public override TextureRegion Icon => this.uiTextures[new Point(0, 0)];
private UniformTextureAtlas customTops;
private UniformTextureAtlas customHairs;
private UniformTextureAtlas customBottoms;
private UniformTextureAtlas uiTextures;
private Dictionary<Point, TextureRegion> customTops;
private Dictionary<Point, TextureRegion> customHairs;
private Dictionary<Point, TextureRegion> customBottoms;
private Dictionary<Point, TextureRegion> uiTextures;
private Dictionary<Point, TextureRegion> wallpaperTextures;
public override void AddGameContent(GameImpl game, ModInfo info) {
@ -49,15 +49,15 @@ public class ExampleMod : Mod {
// adding custom clothing
var darkShirt = new Clothes("ExampleMod.DarkShirt", ClothesLayer.Shirt,
this.customTops[0, 0], // the top left in-world region (the rest will be auto-gathered from the atlas)
this.customTops, new Point(0, 0), // the top left in-world region (the rest will be auto-gathered from the atlas)
100, // the price
ClothesIntention.Everyday | ClothesIntention.Workout, // the clothes item's use cases
ColorScheme.WarmDark) {Icon = this.Icon};
Clothes.Register(darkShirt);
// adding some more custom clothing
Clothes.Register(new Clothes("ExampleMod.PastelPants", ClothesLayer.Pants, this.customBottoms[4, 0], 100, ClothesIntention.Everyday, ColorScheme.Pastel) {Icon = this.Icon});
Clothes.Register(new Clothes("ExampleMod.PastelShoes", ClothesLayer.Shoes, this.customBottoms[0, 0], 100, ClothesIntention.Everyday, ColorScheme.Pastel) {Icon = this.Icon});
Clothes.Register(new Clothes("ExampleMod.WeirdHair", ClothesLayer.Hair, this.customHairs[0, 0], 0, ClothesIntention.None, ColorScheme.Modern) {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});
Clothes.Register(new Clothes("ExampleMod.PastelShoes", ClothesLayer.Shoes, this.customBottoms, new Point(0, 0), 100, ClothesIntention.Everyday, ColorScheme.Pastel) {Icon = this.Icon});
Clothes.Register(new Clothes("ExampleMod.WeirdHair", ClothesLayer.Hair, this.customHairs, new Point(0, 0), 0, ClothesIntention.None, ColorScheme.Modern) {Icon = this.Icon});
// adding an event subscription to people
MapObject.OnEventsAttachable += o => {
@ -89,12 +89,12 @@ public class ExampleMod : Mod {
PassivePriority = p => p.Emotion == EmotionType.Uncomfortable ? 150 : 25
},
// since this action doesn't use objects (like chairs etc.), we set a texture to display instead
Texture = this.uiTextures[1, 0]
Texture = this.uiTextures[new Point(1, 0)]
});
// we use this emotion modifier in SitDownOnGrassAction
ExampleMod.GrassSittingModifier = EmotionModifier.Register(
new EmotionModifier("ExampleMod.GrassSitting", this.uiTextures[1, 0], EmotionType.Happy));
new EmotionModifier("ExampleMod.GrassSitting", this.uiTextures[new Point(1, 0)], EmotionType.Happy));
// adding a custom wallpaper (we're using the top left texture region, which is why we pass 0, 0 as the texture coordinate)
Wallpaper.Register("ExampleMod.CrossedWallpaper", 15, this.wallpaperTextures, new Point(0, 0), ColorScheme.Modern, this.Icon);
@ -106,10 +106,10 @@ public class ExampleMod : Mod {
// 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>("CustomTops"), r => this.customTops = new UniformTextureAtlas(r, 4, 8));
texturePacker.Add(content.Load<Texture2D>("CustomHairs"), r => this.customHairs = new UniformTextureAtlas(r, 4, 6));
texturePacker.Add(content.Load<Texture2D>("CustomBottomsShoes"), r => this.customBottoms = new UniformTextureAtlas(r, 8, 6));
texturePacker.Add(content.Load<Texture2D>("UiTextures"), r => this.uiTextures = new UniformTextureAtlas(r, 8, 8));
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomTops"), 4, 8), r => this.customTops = r);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomHairs"), 4, 6), r => this.customHairs = r);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomBottomsShoes"), 8, 6), r => this.customBottoms = r);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("UiTextures"), 8, 8), r => this.uiTextures = r);
// 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);
}

View file

@ -5,13 +5,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TinyLifeApi" Version="0.27.0" />
<PackageReference Include="TinyLifeApi" Version="0.28.0" />
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.5" />
<PackageReference Include="Lib.Harmony" Version="2.2.1" />
<PackageReference Include="MLEM.Data" Version="6.0.0" />
<PackageReference Include="MLEM.Extended" Version="6.0.0" />
<PackageReference Include="MLEM.Startup" Version="6.0.0" />
<PackageReference Include="MLEM.Data" Version="6.1.0-629" />
<PackageReference Include="MLEM.Extended" Version="6.1.0-629" />
<PackageReference Include="MLEM.Startup" Version="6.1.0-629" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.263" />

View file

@ -40,7 +40,7 @@ public class ExampleModGrassSitAction : MultiAction {
protected override CompletionType AndThenIsCompleted() {
// we want to complete our action once 10 minutes of sitting time have passed
return this.CompleteInTime(TimeSpan.FromMinutes(10));
return this.CompleteIfTimeUp(TimeSpan.FromMinutes(10));
}
protected override void AndThenOnCompleted(CompletionType type) {