mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-11-22 12:03:28 +01:00
0.25.2
This commit is contained in:
parent
fa0514c7a2
commit
dcb31c9ed0
4 changed files with 6 additions and 32 deletions
|
@ -102,7 +102,7 @@ public class ExampleMod : Mod {
|
||||||
|
|
||||||
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;
|
||||||
ExampleMod.Options = ModOptions.Load(info);
|
ExampleMod.Options = info.LoadOptions(() => new ModOptions());
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -131,7 +131,7 @@ public class ExampleMod : Mod {
|
||||||
CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease,
|
CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease,
|
||||||
OnValueChanged = (_, v) => {
|
OnValueChanged = (_, v) => {
|
||||||
ExampleMod.Options.DarkShirtSpeedIncrease = v;
|
ExampleMod.Options.DarkShirtSpeedIncrease = v;
|
||||||
ExampleMod.Options.Save(info);
|
info.SaveOptions(ExampleMod.Options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TinyLifeApi" Version="0.25.1" />
|
<PackageReference Include="TinyLifeApi" Version="0.25.2" />
|
||||||
|
|
||||||
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.5" />
|
<PackageReference Include="ExtremelySimpleLogger" Version="1.2.5" />
|
||||||
<PackageReference Include="Lib.Harmony" Version="2.2.1" />
|
<PackageReference Include="Lib.Harmony" Version="2.2.1" />
|
||||||
|
|
|
@ -1,36 +1,8 @@
|
||||||
using System.IO;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using TinyLife;
|
|
||||||
using TinyLife.Mods;
|
|
||||||
|
|
||||||
namespace ExampleMod;
|
namespace ExampleMod;
|
||||||
|
|
||||||
// a simple implementation of custom options for the example mod
|
// these options are saved and loaded in ExampleMod
|
||||||
public class ModOptions {
|
public class ModOptions {
|
||||||
|
|
||||||
public float DarkShirtSpeedIncrease = 2;
|
public float DarkShirtSpeedIncrease = 2;
|
||||||
|
|
||||||
// a simple save method for the mod options, which saves the current instance to the designated options file
|
|
||||||
public void Save(ModInfo info) {
|
|
||||||
ExampleMod.Logger.Info($"Saving options to {info.OptionsFile}");
|
|
||||||
if (!info.OptionsFile.Directory.Exists)
|
|
||||||
info.OptionsFile.Directory.Create();
|
|
||||||
using var writer = new JsonTextWriter(info.OptionsFile.CreateText());
|
|
||||||
SaveHandler.CreateSerializer(null).Serialize(writer, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// a simple loader for the mod options, which uses the designated options file given to us by the game
|
|
||||||
// this method loads an instance of the options using a JSON loader and then returns it to be used in ExampleMod
|
|
||||||
public static ModOptions Load(ModInfo info) {
|
|
||||||
ExampleMod.Logger.Info($"Loading options from {info.OptionsFile}");
|
|
||||||
if (info.OptionsFile.Exists) {
|
|
||||||
using var reader = new JsonTextReader(info.OptionsFile.OpenText());
|
|
||||||
return SaveHandler.CreateSerializer(null).Deserialize<ModOptions>(reader);
|
|
||||||
} else {
|
|
||||||
var ret = new ModOptions();
|
|
||||||
ret.Save(info);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ var config = Argument("configuration", "Release");
|
||||||
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
|
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
|
||||||
|
|
||||||
Task("Build").DoesForEach(GetFiles("**/*.csproj"), p => {
|
Task("Build").DoesForEach(GetFiles("**/*.csproj"), p => {
|
||||||
|
DeleteFiles($"bin/{config}/**/*");
|
||||||
DotNetBuild(p.FullPath, new DotNetBuildSettings { Configuration = config });
|
DotNetBuild(p.FullPath, new DotNetBuildSettings { Configuration = config });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => {
|
||||||
throw new Exception("Didn't find game directory information. Run the game manually at least once to allow the Run task to be executed.");
|
throw new Exception("Didn't find game directory information. Run the game manually at least once to allow the Run task to be executed.");
|
||||||
var exe = $"{System.IO.File.ReadAllText(exeDir)}/Tiny Life";
|
var exe = $"{System.IO.File.ReadAllText(exeDir)}/Tiny Life";
|
||||||
var process = Process.Start(new ProcessStartInfo(exe) {
|
var process = Process.Start(new ProcessStartInfo(exe) {
|
||||||
|
Arguments = "-v --skip-splash --skip-preloads",
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue