mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-12-22 07:29:24 +01:00
modding, part 1!
This commit is contained in:
parent
e35b60a2e7
commit
8db379cf51
6 changed files with 97 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
bin/
|
||||
obj/
|
||||
/packages/
|
||||
.idea
|
3
Content/ExampleMod/CustomFurniture.atlas
Normal file
3
Content/ExampleMod/CustomFurniture.atlas
Normal file
|
@ -0,0 +1,3 @@
|
|||
CustomTableUp
|
||||
loc 0 0 32 32
|
||||
piv 16 16
|
BIN
Content/ExampleMod/CustomFurniture.png
Normal file
BIN
Content/ExampleMod/CustomFurniture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 535 B |
23
CustomTable.cs
Normal file
23
CustomTable.cs
Normal file
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
47
ExampleMod.cs
Normal file
47
ExampleMod.cs
Normal file
|
@ -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<DataTextureAtlas> GetCustomFurnitureTextures() {
|
||||
// tell the game about our custom furniture texture
|
||||
yield return this.customFurniture;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
20
ExampleMod.csproj
Normal file
20
ExampleMod.csproj
Normal file
|
@ -0,0 +1,20 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ExtremelySimpleLogger" Version="1.1.0"/>
|
||||
<PackageReference Include="MLEM.Data" Version="4.3.0-7"/>
|
||||
<PackageReference Include="TinyLifeApi" Version="1.0.0"/>
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="./Content/**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in a new issue