mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-09-28 17:11:05 +02:00
Compare commits
41 commits
Author | SHA1 | Date | |
---|---|---|---|
c9977fd7e3 | |||
52a625f38b | |||
be5ca71661 | |||
4e8e306195 | |||
bf63a03e46 | |||
38d2ab6719 | |||
e6c5beea29 | |||
b26e7a6c5f | |||
bd7f3e51d2 | |||
9d9b6a381d | |||
6345a8c422 | |||
28b8aadc7f | |||
c0cc18b0a0 | |||
3da4807b57 | |||
eb19f848e0 | |||
0922ecefc5 | |||
977ad2d401 | |||
c963a9781c | |||
339411aed6 | |||
ef04313a7a | |||
17e0f6dbfb | |||
728553e329 | |||
6d6e95727b | |||
0c2057801e | |||
7676e8e294 | |||
|
a07d8ba5c7 | ||
f20a1dc1ae | |||
9f2694178d | |||
25d51baafb | |||
855feece79 | |||
3a4f8d5413 | |||
cefa4b4f13 | |||
f911f01ce9 | |||
80309a73a5 | |||
4a7a3e8e44 | |||
eb4bebe12a | |||
4a1a06ac94 | |||
89b120e61c | |||
cd1445af8a | |||
1620b0f462 | |||
41e2b9ad10 |
6 changed files with 36 additions and 22 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
/packages/
|
/packages/
|
||||||
.idea
|
.idea/
|
||||||
|
.vs/
|
||||||
|
.vscode/
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"BuildMode": {
|
"BuildMode": {
|
||||||
"ExampleMod.CustomTable": "Custom Table",
|
"ExampleMod.CustomTable": "Custom Table",
|
||||||
"ExampleMod.CrossedWallpaper": "Crossed Wallpaper"
|
"ExampleMod.CrossedWallpaper": "Crossed Wallpaper",
|
||||||
|
"ExampleMod.CustomTile": "Custom Tile"
|
||||||
},
|
},
|
||||||
"Clothes": {
|
"Clothes": {
|
||||||
"ExampleMod.DarkShirt": "Dark Shirt",
|
"ExampleMod.DarkShirt": "Dark Shirt",
|
||||||
|
|
BIN
Content/ExampleMod/Tiles.png
Normal file
BIN
Content/ExampleMod/Tiles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 535 B |
|
@ -34,12 +34,14 @@ public class ExampleMod : Mod {
|
||||||
public override string Description => "This is the example mod for Tiny Life!";
|
public override string Description => "This is the example mod for Tiny Life!";
|
||||||
public override TextureRegion Icon => this.uiTextures[new Point(0, 0)];
|
public override TextureRegion Icon => this.uiTextures[new Point(0, 0)];
|
||||||
public override string IssueTrackerUrl => "https://github.com/Ellpeck/TinyLifeExampleMod/issues";
|
public override string IssueTrackerUrl => "https://github.com/Ellpeck/TinyLifeExampleMod/issues";
|
||||||
|
public override string TestedVersionRange => "[0.43.0,0.43.11]";
|
||||||
|
|
||||||
private Dictionary<Point, TextureRegion> customTops;
|
private Dictionary<Point, TextureRegion> customTops;
|
||||||
private Dictionary<Point, TextureRegion> customHairs;
|
private Dictionary<Point, TextureRegion> customHairs;
|
||||||
private Dictionary<Point, TextureRegion> customBottoms;
|
private Dictionary<Point, TextureRegion> customBottoms;
|
||||||
private Dictionary<Point, TextureRegion> uiTextures;
|
private Dictionary<Point, TextureRegion> uiTextures;
|
||||||
private Dictionary<Point, TextureRegion> wallpaperTextures;
|
private Dictionary<Point, TextureRegion> wallpaperTextures;
|
||||||
|
private Dictionary<Point, TextureRegion> tileTextures;
|
||||||
|
|
||||||
public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) {
|
public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) {
|
||||||
ExampleMod.Logger = logger;
|
ExampleMod.Logger = logger;
|
||||||
|
@ -52,6 +54,7 @@ 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>("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>("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>("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
|
// 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);
|
||||||
}
|
}
|
||||||
|
@ -115,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
|
// we allow the action to be done even if the solved needs aren't low enough on a person
|
||||||
CanDoRandomly = true,
|
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
|
// 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
|
// make people more likely to sit down in the grass if they're uncomfortable
|
||||||
PassivePriority = p => p.Emotion == EmotionType.Uncomfortable ? 150 : 25
|
PassivePriority = p => p.Emotion == EmotionType.Uncomfortable ? 150 : 25
|
||||||
},
|
},
|
||||||
|
@ -129,6 +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)
|
// 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);
|
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) {
|
public override IEnumerable<string> GetCustomFurnitureTextures(ModInfo info) {
|
||||||
|
@ -146,11 +152,9 @@ public class ExampleMod : Mod {
|
||||||
group.AddChild(new Paragraph(Anchor.AutoLeft, 1, _ => $"{Localization.Get(LnCategory.Ui, "ExampleMod.DarkShirtSpeedOption")}: {ExampleMod.Options.DarkShirtSpeedIncrease}"));
|
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) {
|
group.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 10), 5, 5) {
|
||||||
CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease,
|
CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease,
|
||||||
OnValueChanged = (_, v) => {
|
OnValueChanged = (_, v) => ExampleMod.Options.DarkShirtSpeedIncrease = v
|
||||||
ExampleMod.Options.DarkShirtSpeedIncrease = v;
|
|
||||||
info.SaveOptions(ExampleMod.Options);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
group.OnRemovedFromUi += _ => info.SaveOptions(ExampleMod.Options);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TinyLifeApi" Version="0.37.3" />
|
<PackageReference Include="TinyLife.ApiReference" Version="0.43.11" />
|
||||||
|
|
||||||
<PackageReference Include="ExtremelySimpleLogger" Version="1.3.1" />
|
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105" />
|
||||||
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
|
<PackageReference Include="Lib.Harmony" Version="2.3.3" />
|
||||||
<PackageReference Include="MLEM.Data" Version="6.1.0" />
|
<PackageReference Include="ExtremelySimpleLogger" Version="1.4.1" />
|
||||||
<PackageReference Include="MLEM.Extended" Version="6.1.0" />
|
<PackageReference Include="MLEM.Data" Version="7.1.1" />
|
||||||
<PackageReference Include="MLEM.Startup" Version="6.1.0" />
|
<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="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
|
<PackageReference Include="DynamicEnums" Version="2.0.0" />
|
||||||
|
<PackageReference Include="Coroutine" Version="2.1.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
19
build.cake
19
build.cake
|
@ -4,6 +4,7 @@ using System.Threading;
|
||||||
|
|
||||||
var target = Argument("target", "Run");
|
var target = Argument("target", "Run");
|
||||||
var config = Argument("configuration", "Release");
|
var config = Argument("configuration", "Release");
|
||||||
|
var args = Argument("args", "");
|
||||||
|
|
||||||
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
|
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
|
||||||
|
|
||||||
|
@ -29,12 +30,16 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
|
||||||
// start the tiny life process
|
// start the tiny life process
|
||||||
var exeDir = System.IO.File.ReadAllText($"{tinyLifeDir}/GameDir");
|
var exeDir = System.IO.File.ReadAllText($"{tinyLifeDir}/GameDir");
|
||||||
var process = Process.Start(new ProcessStartInfo($"{exeDir}/Tiny Life") {
|
var process = Process.Start(new ProcessStartInfo($"{exeDir}/Tiny Life") {
|
||||||
Arguments = "-v --skip-splash --skip-preloads --debug-saves",
|
Arguments = $"-v --skip-splash --skip-preloads --debug-saves --ansi {args}",
|
||||||
CreateNoWindow = true
|
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
|
// we wait a bit to make sure the process has generated a new log file
|
||||||
Thread.Sleep(3000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
// attach to the newest log file
|
// attach to the newest log file
|
||||||
var logsDir = $"{tinyLifeDir}/Logs";
|
var logsDir = $"{tinyLifeDir}/Logs";
|
||||||
|
@ -44,12 +49,12 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
|
||||||
using (var reader = new StreamReader(stream)) {
|
using (var reader = new StreamReader(stream)) {
|
||||||
var lastPos = 0L;
|
var lastPos = 0L;
|
||||||
do {
|
do {
|
||||||
if (reader.BaseStream.Length > lastPos) {
|
if (stream.Length > lastPos) {
|
||||||
reader.BaseStream.Seek(lastPos, SeekOrigin.Begin);
|
stream.Seek(lastPos, SeekOrigin.Begin);
|
||||||
string line;
|
string line;
|
||||||
while ((line = reader.ReadLine()) != null)
|
while ((line = reader.ReadLine()) != null)
|
||||||
Information(line);
|
Information(line);
|
||||||
lastPos = reader.BaseStream.Position;
|
lastPos = stream.Position;
|
||||||
}
|
}
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
} while (!process.HasExited);
|
} while (!process.HasExited);
|
||||||
|
|
Loading…
Reference in a new issue