Compare commits

...

76 commits
0.28.0 ... main

Author SHA1 Message Date
Ell 339411aed6 0.41.2 2024-05-01 17:59:47 +02:00
Ell ef04313a7a 0.41.1 2024-04-21 10:33:56 +02:00
Ell 17e0f6dbfb 0.41.0 2024-04-14 17:59:01 +02:00
Ell 728553e329 0.40.1 2024-03-10 16:38:23 +01:00
Ell 6d6e95727b 0.40.0 2024-03-09 19:54:31 +01:00
Ell 0c2057801e 0.39.1 2024-02-04 12:36:01 +01:00
Ell 7676e8e294 0.39.0 2024-02-02 18:15:15 +01:00
jpiolho a07d8ba5c7
Custom tile example (#2)
* Added custom tile example

* Fixed whitespace
2024-01-27 13:50:18 +01:00
Ell f20a1dc1ae 0.38.4 2024-01-07 16:53:45 +01:00
Ell 9f2694178d use collection expressions in whole project 2023-12-21 17:34:40 +01:00
Ell 25d51baafb 0.38.3 2023-12-19 16:55:34 +01:00
Ell 855feece79 don't include various ide settings by default 2023-12-16 20:22:50 +01:00
Ell 3a4f8d5413 added some more base game dependencies to example mod for ease of use 2023-12-16 17:15:12 +01:00
Ell cefa4b4f13 0.38.2 2023-12-14 11:04:47 +01:00
Ell f911f01ce9 0.38.1 2023-12-13 14:46:38 +01:00
Ell 80309a73a5 small cake cleanup 2023-12-10 17:25:20 +01:00
Ell 4a7a3e8e44 fixed running on *nix causing log output to appear twice 2023-12-10 15:46:33 +01:00
Ell eb4bebe12a added the ability to pass arguments to the cake script 2023-12-08 13:37:12 +01:00
Ell 4a1a06ac94 0.38.0 2023-12-06 13:30:16 +01:00
Ell 89b120e61c rider what 2023-12-01 13:45:52 +01:00
Ell cd1445af8a allow including ansi code in logs for modders 2023-12-01 13:44:56 +01:00
Ell 1620b0f462 0.37.5 2023-11-18 12:57:03 +01:00
Ell 41e2b9ad10 0.37.4 2023-11-06 14:08:50 +01:00
Ell 27dcdb7b00 0.37.3 2023-11-05 20:57:08 +01:00
Ell aac7975b29 0.37.2 2023-11-04 19:27:37 +01:00
Ell dcbe2af6cf 0.37.1 2023-10-30 11:03:04 +01:00
Ell 3bb4161937 0.37.0 2023-10-25 14:35:53 +02:00
Ell a6c4173e4d 0.37.0-pre.3 2023-10-18 17:54:31 +02:00
Ell aa62777102 0.37.0-pre.2 2023-10-12 21:19:35 +02:00
Ell ae5196eef5 0.37.0-pre.1 2023-10-11 16:05:30 +02:00
Ell 715b11dbd9 0.36.2 2023-09-17 15:04:12 +02:00
Ell 1885b79dd7 0.36.1 2023-08-25 12:01:31 +02:00
Ell 682c713961 0.36.0 2023-08-15 13:17:18 +02:00
Ell 24e330553b 0.35.4 2023-08-02 09:26:23 +02:00
Ell d36bcb69bc 0.35.3 2023-08-01 14:10:36 +02:00
Ell 472e5b2b3d 0.35.2 2023-07-28 12:27:46 +02:00
Ell e1e14b3e2f 0.35.1 2023-07-22 12:03:52 +02:00
Ell c4a68727af 0.35.0 2023-07-20 14:34:15 +02:00
Ell ee6be0821a 0.34.0 2023-06-25 15:43:59 +02:00
Ell 5a96eecf96 dep update 2023-05-29 22:59:36 +02:00
Ell faa96c9406 0.33.2 2023-05-29 13:04:24 +02:00
Ell 473fef5f3d added issue tracker URL to example mod 2023-05-29 11:26:33 +02:00
Ell 2fab5e57af 0.33.1 2023-05-27 10:02:32 +02:00
Ell df2e0266d6 0.33.0 2023-05-26 15:16:14 +02:00
Ell 70f98b24cf 0.32.4 2023-05-11 14:56:06 +02:00
Ell 0e6af45024 swap initialize and addgamecontent for clarity 2023-05-10 23:50:26 +02:00
Ell 9c78aabbda (maybe??) condense the example mod into a single file 2023-05-10 23:45:59 +02:00
Ell 22e2dd39a2 0.32.3 2023-05-08 12:13:56 +02:00
Ell 5985b3948a reduced steam thumbnail sizes 2023-05-08 11:17:49 +02:00
Ell 2012b517b8 0.32.2 2023-05-04 13:26:40 +02:00
Ell 3516871064 0.32.1 2023-05-03 23:00:35 +02:00
Ell 51b4d9e2e7 0.32.0 2023-05-02 17:28:57 +02:00
Ell ea73c23d7f 0.31.4 2023-04-27 18:53:11 +02:00
Ell 6aecdffd2e 0.31.3 2023-04-26 21:12:38 +02:00
Ell e282328f28 0.31.2 2023-04-26 14:51:12 +02:00
Ell 0a018706e4 pad textures by default 2023-04-24 23:07:49 +02:00
Ell c068b255a5 print the log at least once even if the game exits early 2023-04-24 21:38:11 +02:00
Ell ffa44436d6 improved clothing color scheme docs 2023-04-24 20:19:46 +02:00
Ell 485e86342d updated example mod and docs for new clothing texture layouts 2023-04-24 11:44:11 +02:00
Ell 150a8eae24 allow mods to have a steam workshop thumbnail 2023-04-23 14:19:23 +02:00
Ell f6c82cefd3 0.31.1 2023-04-17 12:49:49 +02:00
Ell 661b7e5b7a 0.31.0 2023-04-14 13:00:32 +02:00
Ell 7493d4b896 debug saves in example mod build script 2023-04-09 15:43:43 +02:00
Ell bd006fed3a 0.30.1 2023-04-02 22:44:10 +02:00
Ell d2d234a274 0.30.0 2023-03-31 13:26:11 +02:00
Ell b45f9565eb 0.29.5 2023-02-20 12:52:23 +01:00
Ell 724e4ec478 0.29.4 2023-02-14 15:06:54 +01:00
Ell 0d6a0fad1a 0.29.3 2023-01-26 14:16:20 +01:00
Ell b79bf56474 0.29.2 2023-01-19 11:28:10 +01:00
Ell 9aad424ae7 0.29.1 2023-01-17 11:27:33 +01:00
Ell 63c8f836c6 0.29.0 2023-01-16 12:23:53 +01:00
Ell 2c8205eebb removed MG.Extended dependency 2023-01-07 20:50:08 +01:00
Ell fe33c07209 0.28.3 2022-12-28 18:09:02 +01:00
Ell f0f4f17bb7 improved mod options 2022-12-23 23:40:21 +01:00
Ell 4865bd81a7 0.28.2 2022-12-23 11:26:47 +01:00
Ell 17f55129c2 well this is embarrassing (0.28.1) 2022-12-20 14:00:14 +01:00
13 changed files with 142 additions and 148 deletions

4
.gitignore vendored
View file

@ -1,4 +1,6 @@
bin/
obj/
/packages/
.idea
.idea/
.vs/
.vscode/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -1,7 +1,8 @@
{
"BuildMode": {
"ExampleMod.CustomTable": "Custom Table",
"ExampleMod.CrossedWallpaper": "Crossed Wallpaper"
"ExampleMod.CrossedWallpaper": "Crossed Wallpaper",
"ExampleMod.CustomTile": "Custom Tile"
},
"Clothes": {
"ExampleMod.DarkShirt": "Dark Shirt",

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

View file

@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using ExtremelySimpleLogger;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MLEM.Data;
using MLEM.Data.Content;
using MLEM.Textures;
@ -13,6 +17,7 @@ using TinyLife.Mods;
using TinyLife.Objects;
using TinyLife.Utilities;
using TinyLife.World;
using Action = TinyLife.Actions.Action;
namespace ExampleMod;
@ -20,7 +25,7 @@ public class ExampleMod : Mod {
// the logger that we can use to log info about this mod
public static Logger Logger { get; private set; }
public static ExampleModOptions Options { get; private set; }
public static ExampleOptions Options { get; private set; }
public static EmotionModifier GrassSittingModifier { get; private set; }
@ -28,19 +33,38 @@ public class ExampleMod : 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[new Point(0, 0)];
public override string IssueTrackerUrl => "https://github.com/Ellpeck/TinyLifeExampleMod/issues";
public override string TestedVersionRange => "[0.41.0,0.41.2]";
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;
private Dictionary<Point, TextureRegion> tileTextures;
public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) {
ExampleMod.Logger = logger;
ExampleMod.Options = info.LoadOptions(() => new ExampleOptions());
// 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
// 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>("CustomTops"), 4, 11), r => this.customTops = r, 1, true);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("CustomHairs"), 4, 5), r => this.customHairs = r, 1, true);
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);
texturePacker.Add(new UniformTextureAtlas(content.Load<Texture2D>("Tiles"), 4, 2), r => this.tileTextures = r, 1, true);
// 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);
}
public override void AddGameContent(GameImpl game, ModInfo info) {
// adding a custom furniture item
FurnitureType.Register(new FurnitureType.TypeSettings("ExampleMod.CustomTable", new Point(1, 1), ObjectCategory.Table, 150, ColorScheme.SimpleWood) {
// specify the type that should be constructed when this furniture type is placed
// if this is not specified, the Furniture class is used, which is used for furniture without special animations or data
ConstructedType = typeof(ExampleModTable),
ConstructedType = typeof(ExampleTable),
// specifying icons for custom clothes and furniture is optional, but using the mod's icon helps users recognize a mod's features
Icon = this.Icon,
// allow chairs and plates to be slotted into and onto the table
@ -49,15 +73,25 @@ public class ExampleMod : Mod {
// adding custom clothing
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)
100, // the price
ClothesIntention.Everyday | ClothesIntention.Workout, // the clothes item's use cases
ColorScheme.WarmDark) {Icon = this.Icon};
// the top left in-world region
// additional regions will be auto-gathered from the atlas according to the rules described in https://docs.tinylifegame.com/articles/creating_textures.html
this.customTops, new Point(0, 0),
// the price
100,
// the clothes item's use cases
ClothesIntention.Everyday | ClothesIntention.Workout,
// the clothes item's style preferences, which influence randomly generated tinies slightly
// neutral style preferences have the same chance to be picked for all tinies, others have a 25% chance for mismatched preferences
StylePreference.Neutral,
// 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);
// 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.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});
Clothes.Register(new Clothes("ExampleMod.PastelPants", ClothesLayer.Pants, this.customBottoms, new Point(4, 0), 100, ClothesIntention.Everyday, StylePreference.Neutral, ColorScheme.Pastel) {Icon = this.Icon});
Clothes.Register(new Clothes("ExampleMod.PastelShoes", ClothesLayer.Shoes, this.customBottoms, new Point(0, 0), 100, ClothesIntention.Everyday, StylePreference.Neutral, ColorScheme.Pastel) {Icon = this.Icon});
Clothes.Register(new Clothes("ExampleMod.WeirdHair", ClothesLayer.Hair, this.customHairs, new Point(0, 0), 0, ClothesIntention.None, StylePreference.Neutral, ColorScheme.Modern) {Icon = this.Icon});
// adding an event subscription to people
MapObject.OnEventsAttachable += o => {
@ -71,12 +105,12 @@ public class ExampleMod : Mod {
};
// adding a simple action: sitting down in the grass, which also gives us a nice emotion modifier
ActionType.Register(new ActionType.TypeSettings("ExampleMod.SitOnGrass", ObjectCategory.Ground, typeof(ExampleModGrassSitAction)) {
ActionType.Register(new ActionType.TypeSettings("ExampleMod.SitOnGrass", ObjectCategory.Ground, typeof(ExampleGrassSitAction)) {
// we set this action to be executable only on grass tiles, not on other ground
CanExecute = (actionInfo, _) => {
if (!actionInfo.Map.IsInBounds(actionInfo.ActionLocation.ToPoint()))
if (!actionInfo.GoalMap.IsInBounds(actionInfo.ActionLocation.ToPoint()))
return CanExecuteResult.Hidden;
var tile = actionInfo.Map.GetTile(actionInfo.ActionLocation.ToPoint());
var tile = actionInfo.GoalMap.GetTile(actionInfo.ActionLocation.ToPoint(), (int) actionInfo.ActionFloor);
// hidden means the action won't be displayed in the ring menu, Valid means the player (or AI) is able to enqueue and execute it
return tile.Name.StartsWith("Grass") ? CanExecuteResult.Valid : CanExecuteResult.Hidden;
},
@ -84,7 +118,7 @@ public class ExampleMod : Mod {
// we allow the action to be done even if the solved needs aren't low enough on a person
CanDoRandomly = true,
// the solved needs indicate when the AI should mark this action as important, they don't actually have to match the action's behavior
SolvedNeeds = new[] {NeedType.Energy},
SolvedNeeds = [NeedType.Energy],
// make people more likely to sit down in the grass if they're uncomfortable
PassivePriority = p => p.Emotion == EmotionType.Uncomfortable ? 150 : 25
},
@ -98,20 +132,9 @@ public class ExampleMod : Mod {
// 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);
}
public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) {
ExampleMod.Logger = logger;
ExampleMod.Options = info.LoadOptions(() => new ExampleModOptions());
// 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(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);
// adding a custom tile
Tile.Register("ExampleMod.CustomTile", 8, this.tileTextures, new Point(0, 0), ColorScheme.Bricks, icon: this.Icon);
}
public override IEnumerable<string> GetCustomFurnitureTextures(ModInfo info) {
@ -127,7 +150,7 @@ public class ExampleMod : Mod {
// in general, options should be stored in the ModInfo.OptionsFile file that is given to the mod by the game
public override void PopulateOptions(Group group, ModInfo info) {
group.AddChild(new Paragraph(Anchor.AutoLeft, 1, _ => $"{Localization.Get(LnCategory.Ui, "ExampleMod.DarkShirtSpeedOption")}: {ExampleMod.Options.DarkShirtSpeedIncrease}"));
group.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 12), 5, 5) {
group.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 10), 5, 5) {
CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease,
OnValueChanged = (_, v) => {
ExampleMod.Options.DarkShirtSpeedIncrease = v;
@ -137,3 +160,62 @@ public class ExampleMod : Mod {
}
}
// these options are saved and loaded in ExampleMod
public class ExampleOptions {
public float DarkShirtSpeedIncrease = 2;
}
// we use a multi action because we want to walk to the location, and then execute the main sitting part
// see ExampleTable for information on how to store custom action-specific information to disk as well
public class ExampleGrassSitAction : MultiAction {
public ExampleGrassSitAction(ActionType type, ActionInfo info) : base(type, info) {}
protected override IEnumerable<Action> CreateFirstActions() {
// we want to walk to the location clicked, so we use the current action info
yield return ActionType.GoHere.Construct<Action>(this.Info);
}
protected override void AndThenUpdate(GameTime time, TimeSpan passedInGame, float speedMultiplier) {
base.AndThenUpdate(time, passedInGame, speedMultiplier);
// set our person to look like they're sitting on the ground
this.Person.CurrentPose = Pose.SittingGround;
// restore need and lower emotions
this.Person.RestoreNeed(NeedType.Energy, 0.5F, this.Info, speedMultiplier);
this.Person.LowerEmotion(EmotionType.Uncomfortable, 0.0001F, speedMultiplier);
}
protected override CompletionType AndThenIsCompleted() {
// we want to complete our action once 10 minutes of sitting time have passed
return this.CompleteIfTimeUp(TimeSpan.FromMinutes(10));
}
protected override void AndThenOnCompleted(CompletionType type) {
base.AndThenOnCompleted(type);
// this method is called when the action completes in any way, even if it fails
if (type == CompletionType.Completed) {
// once we're finished sitting, we want to get a nice emotion modifier for it
this.Person.AddEmotion(ExampleMod.GrassSittingModifier, 2, TimeSpan.FromHours(1), this.Type);
}
}
}
// note that having a custom class for a furniture item like this is entirely optional
// but it allows for additional functionalities as displayed in this example
public class ExampleTable : Furniture {
// anything whose base classes have the DataContract attribute automatically gets saved and loaded to and from disk
// this means that you can add custom DataMember members to have them saved and loaded
[DataMember]
public float TestValue;
public ExampleTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos, float floor) : base(id, type, colors, map, pos, floor) {
this.TestValue = Furniture.Random.NextSingle();
}
}

View file

@ -1,25 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TinyLifeApi" Version="0.28.0" />
<PackageReference Include="TinyLifeApi" Version="0.41.2" />
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.5" />
<PackageReference Include="Lib.Harmony" Version="2.2.1" />
<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" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
<PackageReference Include="ExtremelySimpleLogger" Version="1.4.1" />
<PackageReference Include="MLEM.Data" Version="6.3.0" />
<PackageReference Include="MLEM.Extended" Version="6.3.0" />
<PackageReference Include="MLEM.Startup" Version="6.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="DynamicEnums" Version="1.2.0" />
<PackageReference Include="Coroutine" Version="2.1.5" />
</ItemGroup>
<ItemGroup>
<Content Include="./Content/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SteamThumbnail.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View file

@ -1,55 +0,0 @@
using System;
using System.Collections.Generic;
using TinyLife;
using TinyLife.Actions;
using TinyLife.Emotions;
using TinyLife.Objects;
using Action = TinyLife.Actions.Action;
namespace ExampleMod;
// we use a multi action because we want to walk to the location, and then execute the main sitting part
// see CustomTable for information on how to store custom action-specific information to disk as well
public class ExampleModGrassSitAction : MultiAction {
public ExampleModGrassSitAction(ActionType type, ActionInfo info) : base(type, info) {}
protected override IEnumerable<Action> CreateFirstActions() {
// we want to walk to the location clicked, so we use the current action info
yield return ActionType.GoHere.Construct(this.Info);
// if multiple things should be done before starting this action, they can all be returned here
}
protected override void AndThenInitialize() {
// this is called when the main action starts (after going to the location, in our case)
// but we don't need to do anything here for our action
}
protected override void AndThenUpdate(GameTime time, TimeSpan passedInGame, float speedMultiplier) {
base.AndThenUpdate(time, passedInGame, speedMultiplier);
// this method gets called every update frame while the action is active
// set our person to look like they're sitting on the ground
this.Person.CurrentPose = Person.Pose.SittingGround;
// restore need and lower emotions
this.Person.RestoreNeed(NeedType.Energy, 0.5F, this.Info, speedMultiplier);
this.Person.LowerEmotion(EmotionType.Uncomfortable, 0.0001F, speedMultiplier);
}
protected override CompletionType AndThenIsCompleted() {
// we want to complete our action once 10 minutes of sitting time have passed
return this.CompleteIfTimeUp(TimeSpan.FromMinutes(10));
}
protected override void AndThenOnCompleted(CompletionType type) {
base.AndThenOnCompleted(type);
// this method is called when the action completes in any way, even if it fails
if (type == CompletionType.Completed) {
// once we're finished sitting, we want to get a nice emotion modifier for it
this.Person.AddEmotion(ExampleMod.GrassSittingModifier, 2, TimeSpan.FromHours(1), this.Type);
}
}
}

View file

@ -1,8 +0,0 @@
namespace ExampleMod;
// these options are saved and loaded in ExampleMod
public class ExampleModOptions {
public float DarkShirtSpeedIncrease = 2;
}

View file

@ -1,37 +0,0 @@
using System;
using System.Runtime.Serialization;
using TinyLife.Objects;
using TinyLife.World;
namespace ExampleMod;
// note that having a custom class for a furniture item like this is entirely optional
// but it allows for additional functionalities as displayed in this example
public class ExampleModTable : Furniture {
// anything whose base classes have the DataContract attribute automatically gets saved and loaded to and from disk
// this means that you can add custom DataMember members to have them saved and loaded
[DataMember]
public float TestValue;
public ExampleModTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
this.TestValue = Furniture.Random.NextSingle();
}
public override void OnAdded() {
base.OnAdded();
ExampleMod.Logger.Info("The custom table was added at " + this.Position);
}
public override void OnRemoved() {
base.OnRemoved();
ExampleMod.Logger.Info("The custom table was removed from " + this.Position);
}
// validate is called when this object is loaded from disk
// returning false causes the object to be marked as invalid and removed
public override bool Validate() {
return base.Validate() && this.TestValue <= 1;
}
}

BIN
SteamThumbnail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

View file

@ -4,6 +4,7 @@ using System.Threading;
var target = Argument("target", "Run");
var config = Argument("configuration", "Release");
var args = Argument("args", "");
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
@ -29,12 +30,16 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
// start the tiny life process
var exeDir = System.IO.File.ReadAllText($"{tinyLifeDir}/GameDir");
var process = Process.Start(new ProcessStartInfo($"{exeDir}/Tiny Life") {
Arguments = "-v --skip-splash --skip-preloads",
CreateNoWindow = true
Arguments = $"-v --skip-splash --skip-preloads --debug-saves --ansi {args}",
RedirectStandardOutput = true,
RedirectStandardError = true
});
// make sure the output buffers (which we ignore) don't fill up
process.BeginOutputReadLine();
process.BeginErrorReadLine();
// we wait a bit to make sure the process has generated a new log file, bleh
Thread.Sleep(3000);
// we wait a bit to make sure the process has generated a new log file
Thread.Sleep(1000);
// attach to the newest log file
var logsDir = $"{tinyLifeDir}/Logs";
@ -43,16 +48,16 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
using (var stream = new FileStream(log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
using (var reader = new StreamReader(stream)) {
var lastPos = 0L;
while (!process.HasExited) {
if (reader.BaseStream.Length > lastPos) {
reader.BaseStream.Seek(lastPos, SeekOrigin.Begin);
do {
if (stream.Length > lastPos) {
stream.Seek(lastPos, SeekOrigin.Begin);
string line;
while ((line = reader.ReadLine()) != null)
Information(line);
lastPos = reader.BaseStream.Position;
lastPos = stream.Position;
}
Thread.Sleep(10);
}
} while (!process.HasExited);
}
}
}