mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-11-29 15:08:35 +01:00
Compare commits
No commits in common. "0ba898838a306860580f0d24032986791905e8c4" and "260d3437ab7f31a8032d012bb55776bed0f9847d" have entirely different histories.
0ba898838a
...
260d3437ab
5 changed files with 19 additions and 22 deletions
|
@ -7,14 +7,14 @@ 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 {
|
||||
public class CustomTable : 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) {
|
||||
public CustomTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
|
||||
this.TestValue = Furniture.Random.NextSingle();
|
||||
}
|
||||
|
|
@ -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 ExampleModOptions Options { get; private set; }
|
||||
public static ModOptions 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(ExampleModTable),
|
||||
ConstructedType = typeof(CustomTable),
|
||||
// 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(ExampleModGrassSitAction)) {
|
||||
ActionType.Register(new ActionType.TypeSettings("ExampleMod.SitOnGrass", ObjectCategory.Ground, typeof(SitDownOnGrassAction)) {
|
||||
// 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 ExampleModOptions());
|
||||
ExampleMod.Options = info.LoadOptions(() => new ModOptions());
|
||||
|
||||
// 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace ExampleMod;
|
||||
|
||||
// these options are saved and loaded in ExampleMod
|
||||
public class ExampleModOptions {
|
||||
public class ModOptions {
|
||||
|
||||
public float DarkShirtSpeedIncrease = 2;
|
||||
|
|
@ -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 ExampleModGrassSitAction : MultiAction {
|
||||
public class SitDownOnGrassAction : MultiAction {
|
||||
|
||||
public ExampleModGrassSitAction(ActionType type, ActionInfo info) : base(type, info) {}
|
||||
public SitDownOnGrassAction(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
|
21
build.cake
21
build.cake
|
@ -7,28 +7,25 @@ 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 => {
|
||||
DotNetBuild(p.FullPath, new DotNetBuildSettings {
|
||||
Configuration = config
|
||||
});
|
||||
DeleteFiles($"bin/{config}/**/*");
|
||||
DotNetBuild(p.FullPath, new DotNetBuildSettings { Configuration = config });
|
||||
});
|
||||
|
||||
Task("CopyToMods").IsDependentOn("Build").Does(() => {
|
||||
var dir = $"{tinyLifeDir}/Mods/_Dev";
|
||||
EnsureDirectoryExists(dir);
|
||||
var dir = $"{tinyLifeDir}/Mods";
|
||||
CreateDirectory(dir);
|
||||
var files = GetFiles($"bin/{config}/net*/**/*");
|
||||
CopyFiles(files, dir, true);
|
||||
});
|
||||
|
||||
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") {
|
||||
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) {
|
||||
Arguments = "-v --skip-splash --skip-preloads",
|
||||
CreateNoWindow = true
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue