mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-11-16 17:33:13 +01:00
Compare commits
No commits in common. "main" and "0.33.2" have entirely different histories.
6 changed files with 29 additions and 48 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,6 +1,4 @@
|
|||
bin/
|
||||
obj/
|
||||
/packages/
|
||||
.idea/
|
||||
.vs/
|
||||
.vscode/
|
||||
.idea
|
|
@ -1,8 +1,7 @@
|
|||
{
|
||||
"BuildMode": {
|
||||
"ExampleMod.CustomTable": "Custom Table",
|
||||
"ExampleMod.CrossedWallpaper": "Crossed Wallpaper",
|
||||
"ExampleMod.CustomTile": "Custom Tile"
|
||||
"ExampleMod.CrossedWallpaper": "Crossed Wallpaper"
|
||||
},
|
||||
"Clothes": {
|
||||
"ExampleMod.DarkShirt": "Dark Shirt",
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 535 B |
|
@ -3,8 +3,6 @@ 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;
|
||||
|
@ -34,14 +32,12 @@ public class ExampleMod : 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.44.0,0.44.1]";
|
||||
|
||||
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;
|
||||
|
@ -54,7 +50,6 @@ public class ExampleMod : Mod {
|
|||
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);
|
||||
}
|
||||
|
@ -80,18 +75,15 @@ public class ExampleMod : Mod {
|
|||
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, 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});
|
||||
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 => {
|
||||
|
@ -108,9 +100,9 @@ public class ExampleMod : Mod {
|
|||
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.GoalMap.IsInBounds(actionInfo.ActionLocation.ToPoint()))
|
||||
if (!actionInfo.Map.IsInBounds(actionInfo.ActionLocation.ToPoint()))
|
||||
return CanExecuteResult.Hidden;
|
||||
var tile = actionInfo.GoalMap.GetTile(actionInfo.ActionLocation.ToPoint(), (int) actionInfo.ActionFloor);
|
||||
var tile = actionInfo.Map.GetTile(actionInfo.ActionLocation.ToPoint());
|
||||
// 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;
|
||||
},
|
||||
|
@ -118,7 +110,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 = [NeedType.Energy],
|
||||
SolvedNeeds = new[] {NeedType.Energy},
|
||||
// make people more likely to sit down in the grass if they're uncomfortable
|
||||
PassivePriority = p => p.Emotion == EmotionType.Uncomfortable ? 150 : 25
|
||||
},
|
||||
|
@ -132,9 +124,6 @@ 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);
|
||||
|
||||
// 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) {
|
||||
|
@ -152,9 +141,11 @@ public class ExampleMod : Mod {
|
|||
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, 10), 5, 5) {
|
||||
CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease,
|
||||
OnValueChanged = (_, v) => ExampleMod.Options.DarkShirtSpeedIncrease = v
|
||||
OnValueChanged = (_, v) => {
|
||||
ExampleMod.Options.DarkShirtSpeedIncrease = v;
|
||||
info.SaveOptions(ExampleMod.Options);
|
||||
}
|
||||
});
|
||||
group.OnRemovedFromUi += _ => info.SaveOptions(ExampleMod.Options);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -212,7 +203,7 @@ public class ExampleTable : Furniture {
|
|||
[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) {
|
||||
public ExampleTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
|
||||
this.TestValue = Furniture.Random.NextSingle();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TinyLife.ApiReference" Version="0.44.1" />
|
||||
<PackageReference Include="TinyLifeApi" Version="0.33.2" />
|
||||
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105" />
|
||||
<PackageReference Include="Lib.Harmony" Version="2.3.3" />
|
||||
<PackageReference Include="ExtremelySimpleLogger" Version="1.4.1" />
|
||||
<PackageReference Include="MLEM.Data" Version="7.1.1" />
|
||||
<PackageReference Include="MLEM.Extended" Version="7.1.1" />
|
||||
<PackageReference Include="MLEM.Startup" Version="7.1.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="DynamicEnums" Version="2.0.0" />
|
||||
<PackageReference Include="Coroutine" Version="2.1.5" />
|
||||
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.5" />
|
||||
<PackageReference Include="Lib.Harmony" Version="2.2.1" />
|
||||
<PackageReference Include="MLEM.Data" Version="6.1.0" />
|
||||
<PackageReference Include="MLEM.Extended" Version="6.1.0" />
|
||||
<PackageReference Include="MLEM.Startup" Version="6.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.263" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
19
build.cake
19
build.cake
|
@ -4,7 +4,6 @@ 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";
|
||||
|
||||
|
@ -30,16 +29,12 @@ 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 --debug-saves --ansi {args}",
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true
|
||||
Arguments = "-v --skip-splash --skip-preloads --debug-saves",
|
||||
CreateNoWindow = 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
|
||||
Thread.Sleep(1000);
|
||||
// we wait a bit to make sure the process has generated a new log file, bleh
|
||||
Thread.Sleep(3000);
|
||||
|
||||
// attach to the newest log file
|
||||
var logsDir = $"{tinyLifeDir}/Logs";
|
||||
|
@ -49,12 +44,12 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
|
|||
using (var reader = new StreamReader(stream)) {
|
||||
var lastPos = 0L;
|
||||
do {
|
||||
if (stream.Length > lastPos) {
|
||||
stream.Seek(lastPos, SeekOrigin.Begin);
|
||||
if (reader.BaseStream.Length > lastPos) {
|
||||
reader.BaseStream.Seek(lastPos, SeekOrigin.Begin);
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
Information(line);
|
||||
lastPos = stream.Position;
|
||||
lastPos = reader.BaseStream.Position;
|
||||
}
|
||||
Thread.Sleep(10);
|
||||
} while (!process.HasExited);
|
||||
|
|
Loading…
Reference in a new issue