mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-11-26 05:28:34 +01:00
Compare commits
2 commits
260d3437ab
...
0ba898838a
Author | SHA1 | Date | |
---|---|---|---|
0ba898838a | |||
438d203bc9 |
5 changed files with 22 additions and 19 deletions
|
@ -20,7 +20,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 ModOptions Options { get; private set; }
|
||||
public static ExampleModOptions Options { get; private set; }
|
||||
|
||||
public static EmotionModifier GrassSittingModifier { get; private set; }
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ExampleMod : Mod {
|
|||
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(CustomTable),
|
||||
ConstructedType = typeof(ExampleModTable),
|
||||
// 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
|
||||
|
@ -71,7 +71,7 @@ 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(SitDownOnGrassAction)) {
|
||||
ActionType.Register(new ActionType.TypeSettings("ExampleMod.SitOnGrass", ObjectCategory.Ground, typeof(ExampleModGrassSitAction)) {
|
||||
// we set this action to be executable only on grass tiles, not on other ground
|
||||
CanExecute = (actionInfo, _) => {
|
||||
if (!actionInfo.Map.IsInBounds(actionInfo.ActionLocation.ToPoint()))
|
||||
|
@ -102,7 +102,7 @@ public class ExampleMod : Mod {
|
|||
|
||||
public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) {
|
||||
ExampleMod.Logger = logger;
|
||||
ExampleMod.Options = info.LoadOptions(() => new ModOptions());
|
||||
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
|
||||
|
|
|
@ -10,9 +10,9 @@ 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 SitDownOnGrassAction : MultiAction {
|
||||
public class ExampleModGrassSitAction : MultiAction {
|
||||
|
||||
public SitDownOnGrassAction(ActionType type, ActionInfo info) : base(type, info) {}
|
||||
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
|
|
@ -1,7 +1,7 @@
|
|||
namespace ExampleMod;
|
||||
|
||||
// these options are saved and loaded in ExampleMod
|
||||
public class ModOptions {
|
||||
public class ExampleModOptions {
|
||||
|
||||
public float DarkShirtSpeedIncrease = 2;
|
||||
|
|
@ -6,15 +6,15 @@ 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 CustomTable : Furniture {
|
||||
// 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 CustomTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
|
||||
public ExampleModTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
|
||||
this.TestValue = Furniture.Random.NextSingle();
|
||||
}
|
||||
|
21
build.cake
21
build.cake
|
@ -7,25 +7,28 @@ var config = Argument("configuration", "Release");
|
|||
|
||||
var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life";
|
||||
|
||||
Task("Clean").Does(() => {
|
||||
EnsureDirectoryDoesNotExist($"bin/{config}");
|
||||
EnsureDirectoryDoesNotExist($"{tinyLifeDir}/Mods/_Dev");
|
||||
});
|
||||
|
||||
Task("Build").DoesForEach(GetFiles("**/*.csproj"), p => {
|
||||
DeleteFiles($"bin/{config}/**/*");
|
||||
DotNetBuild(p.FullPath, new DotNetBuildSettings { Configuration = config });
|
||||
DotNetBuild(p.FullPath, new DotNetBuildSettings {
|
||||
Configuration = config
|
||||
});
|
||||
});
|
||||
|
||||
Task("CopyToMods").IsDependentOn("Build").Does(() => {
|
||||
var dir = $"{tinyLifeDir}/Mods";
|
||||
CreateDirectory(dir);
|
||||
var dir = $"{tinyLifeDir}/Mods/_Dev";
|
||||
EnsureDirectoryExists(dir);
|
||||
var files = GetFiles($"bin/{config}/net*/**/*");
|
||||
CopyFiles(files, dir, true);
|
||||
});
|
||||
|
||||
Task("Run").IsDependentOn("CopyToMods").Does(() => {
|
||||
// start the tiny life process
|
||||
var exeDir = $"{tinyLifeDir}/GameDir";
|
||||
if (!FileExists(exeDir))
|
||||
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 process = Process.Start(new ProcessStartInfo(exe) {
|
||||
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
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue