generated from Ellpeck/TinyLifeExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleObjectLoader.cs
76 lines (60 loc) · 2.35 KB
/
SimpleObjectLoader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using ExtremelySimpleLogger;
using MLEM.Data;
using MLEM.Data.Content;
using SimpleObjectLoader.Builder;
using SimpleObjectLoader.Config;
using SimpleObjectLoader.Utils;
using System.Collections.Generic;
using System.Linq;
using TinyLife;
using TinyLife.Mods;
namespace SimpleObjectLoader;
public class SimpleObjectLoader : 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 => "Simple Object Loader";
public override string Description => "A way to add custom objects without programming";
public override string IssueTrackerUrl => "https://github.com/Sir-Fenrir/simple-object-loader/issues";
public override string TestedVersionRange => "[0.44.1]";
private List<ModConfig> modConfigs;
public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info)
{
SimpleObjectLoader.Logger = logger;
modConfigs = new ModConfigLoader().GetMods();
LocalizationUtils.ReadLocalizationFiles(modConfigs);
TextureUtils.LoadTextures(texturePacker, content, modConfigs.SelectMany(m => m.Clothes).ToArray());
TextureUtils.LoadTextures(texturePacker, content, modConfigs.SelectMany(m => m.Tiles).ToArray());
TextureUtils.LoadWallPaperTextures(texturePacker, content, modConfigs.SelectMany(m => m.Wallpapers).ToArray());
}
public override void AddGameContent(GameImpl game, ModInfo info)
{
Logger.Info("Adding game content");
foreach (var mod in modConfigs)
{
foreach (var furniture in mod.Furniture)
{
new FurnitureBuilder(furniture).Build();
}
foreach (var clothes in mod.Clothes)
{
new ClothingBuilder(clothes).Build();
}
foreach (var wallpaper in mod.Wallpapers)
{
new WallpaperBuilder(wallpaper).Build();
}
foreach (var tile in mod.Tiles)
{
new TileBuilder(tile).Build();
}
}
}
public override IEnumerable<string> GetCustomFurnitureTextures(ModInfo info)
{
return modConfigs
.SelectMany(config => config.Furniture)
.Select(f => f.Atlas);
}
}