From 8db379cf510fdaf473193bd4360cd2c3431bee61 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 25 Nov 2020 00:33:47 +0100 Subject: [PATCH] modding, part 1! --- .gitignore | 4 ++ Content/ExampleMod/CustomFurniture.atlas | 3 ++ Content/ExampleMod/CustomFurniture.png | Bin 0 -> 535 bytes CustomTable.cs | 23 +++++++++++ ExampleMod.cs | 47 +++++++++++++++++++++++ ExampleMod.csproj | 20 ++++++++++ 6 files changed, 97 insertions(+) create mode 100644 .gitignore create mode 100644 Content/ExampleMod/CustomFurniture.atlas create mode 100644 Content/ExampleMod/CustomFurniture.png create mode 100644 CustomTable.cs create mode 100644 ExampleMod.cs create mode 100644 ExampleMod.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..634ecdc --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/ +obj/ +/packages/ +.idea \ No newline at end of file diff --git a/Content/ExampleMod/CustomFurniture.atlas b/Content/ExampleMod/CustomFurniture.atlas new file mode 100644 index 0000000..34fae15 --- /dev/null +++ b/Content/ExampleMod/CustomFurniture.atlas @@ -0,0 +1,3 @@ +CustomTableUp +loc 0 0 32 32 +piv 16 16 \ No newline at end of file diff --git a/Content/ExampleMod/CustomFurniture.png b/Content/ExampleMod/CustomFurniture.png new file mode 100644 index 0000000000000000000000000000000000000000..31dd5d4017ef2e08e45f350edefe67046de2f383 GIT binary patch literal 535 zcmV+y0_gpTP)Px$(Md!>R9J=Wl}nDoFbsx&CnJy|&e5HZK`+pA<^sbpvdcA!B6X2=Hsg$23grzW z@k@xRaqKUCqy#1JJ(k4G0{~cS0RTB?06++V7B|o6>s&(}*cgMp@1a3t{Zf!cfa!_l z-xvb`H-j7n(1ESB7={7BU&=KI5tTKupMo?^a~{C-#M-e0)FAquwqLDQ$T=5(0A@2X zdKqIJbRbEumaI!gw9T|EQz!tas%jK-gx+->QcA^%F{U`xU7vFX5rK$C>qK<0PuAoY zV;pqMgAzFB3WRg6biI^8mqV99KT8It<D@d6}e(50}}mY~c`F~*}KdDcZF4yvje0ARD(jIyG~ zv~61e05jiq59qm-D|!mzoGTELA+eD?$L3!&q6{Gn&N<|q7jH6w5S>c1*o$vHiYI$u zNzS>_u-E#y3E&=jF92q)Q%dN%4o%Z+pAO)?-!XH|%(eG^ch5ljZ~)5T4#x1_ft7a5 zT+8!OfCuZ~aPQTGuh7LMP*-amLiqlDx5Z3)9|E8>+f>g4xGAvc|MbApXZ2dWJOdwn Z^aFr64th*e+~oiO002ovPDHLkV1ho7>(T%K literal 0 HcmV?d00001 diff --git a/CustomTable.cs b/CustomTable.cs new file mode 100644 index 0000000..78a3032 --- /dev/null +++ b/CustomTable.cs @@ -0,0 +1,23 @@ +using System; +using Microsoft.Xna.Framework; +using TinyLife.Objects; +using TinyLife.World; + +namespace ExampleMod { + public class CustomTable : Furniture { + + public CustomTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) { + } + + public override void OnAdded() { + base.OnAdded(); + ExampleMod.Logger.Info("We were added at " + this.Position); + } + + public override void OnRemoved() { + base.OnRemoved(); + ExampleMod.Logger.Info("We were removed from " + this.Position); + } + + } +} \ No newline at end of file diff --git a/ExampleMod.cs b/ExampleMod.cs new file mode 100644 index 0000000..35caf27 --- /dev/null +++ b/ExampleMod.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using ExtremelySimpleLogger; +using Microsoft.Xna.Framework; +using MLEM.Data; +using MLEM.Data.Content; +using MLEM.Misc; +using TinyLife; +using TinyLife.Mods; +using TinyLife.Objects; +using TinyLife.Utilities; + +namespace ExampleMod { + public class ExampleMod : Mod { + + // the logger that we can use to log info about this mod + public static Logger Logger { get; private set; } + + // visual data about this mod + public override string Name => "Example Mod"; + public override string Description => "This is the example mod for Tiny Life!"; + + private DataTextureAtlas customFurniture; + + public override void AddGameContent(GameImpl game) { + // adding a custom furniture item + FurnitureType.Register(new FurnitureType.TypeSettings("CustomTable", new Point(1, 1), ObjectCategory.Table, 150, ColorScheme.SimpleWood) { + Construct = (i, t, c, m, p) => new CustomTable(i, t, c, m, p) + }); + } + + public override void Initialize(Logger logger, RawContentManager content) { + Logger = logger; + + // loads the custom furniture texture atlas + // the texture atlas combines the png texture and the .atlas information + // see https://mlem.ellpeck.de/api/MLEM.Data.DataTextureAtlas.html for more info + this.customFurniture = content.LoadTextureAtlas("CustomFurniture"); + } + + public override IEnumerable GetCustomFurnitureTextures() { + // tell the game about our custom furniture texture + yield return this.customFurniture; + } + + } +} \ No newline at end of file diff --git a/ExampleMod.csproj b/ExampleMod.csproj new file mode 100644 index 0000000..ef6328c --- /dev/null +++ b/ExampleMod.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp3.0 + + + + + + + + + + + + PreserveNewest + + + +