-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMod.cs
More file actions
131 lines (107 loc) · 4.69 KB
/
Copy pathMod.cs
File metadata and controls
131 lines (107 loc) · 4.69 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using Reloaded.Hooks.ReloadedII.Interfaces;
using Reloaded.Mod.Interfaces;
using Reloaded.Mod.Interfaces.Internal;
using Unhardcoded_P5R.Configuration;
using Unhardcoded_P5R.Template;
namespace Unhardcoded_P5R
{
/// <summary>
/// Your mod logic goes here.
/// </summary>
public class Mod : ModBase // <= Do not Remove.
{
/// <summary>
/// Provides access to the mod loader API.
/// </summary>
private readonly IModLoader _modLoader;
/// <summary>
/// Provides access to the Reloaded.Hooks API.
/// </summary>
/// <remarks>This is null if you remove dependency on Reloaded.SharedLib.Hooks in your mod.</remarks>
private readonly IReloadedHooks? _hooks;
/// <summary>
/// Provides access to the Reloaded logger.
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Entry point into the mod, instance that created this class.
/// </summary>
private readonly IMod _owner;
/// <summary>
/// Provides access to this mod's configuration.
/// </summary>
private Config _configuration;
/// <summary>
/// The configuration of the currently executing mod.
/// </summary>
private readonly IModConfig _modConfig;
private Utils _utils = null!;
private ChatHooks _chatHooks = null!;
private LmapHooks _lmapHooks = null!;
private ShopHooks _shopHooks = null!;
private SelCutinHooks _selCutinHooks = null!;
private FieldModelNumHooks _fieldModelNumHooks = null!;
public Mod(ModContext context)
{
//Debugger.Launch();
_modLoader = context.ModLoader;
_hooks = context.Hooks;
_logger = context.Logger;
_owner = context.Owner;
_configuration = context.Configuration;
_modConfig = context.ModConfig;
// For more information about this template, please see
// https://reloaded-project.github.io/Reloaded-II/ModTemplate/
// If you want to implement e.g. unload support in your mod,
// and some other neat features, override the methods in ModBase.
// TODO: Implement some mod logic
_utils = new Utils(_hooks, _logger, _modLoader, _configuration);
if (_configuration.ChatHooks)
_chatHooks = new ChatHooks(_modLoader, _hooks, _utils);
if (_configuration.LmapHooks)
_lmapHooks = new LmapHooks(_hooks, _utils);
if (_configuration.ShopHooks)
_shopHooks = new ShopHooks(_hooks, _utils);
if (_configuration.SelCutinHooks)
_selCutinHooks = new SelCutinHooks(_utils);
if (_configuration.FieldModelNumHooks)
_fieldModelNumHooks = new FieldModelNumHooks(_hooks, _utils);
_modLoader.ModLoading += OnModLoading;
_modLoader.OnModLoaderInitialized += OnModLoaderInitialized;
}
private void OnModLoading(IModV1 mod, IModConfigV1 modConfig)
{
if (_configuration.ChatHooks)
{
var chatIconParamFilePath = Path.Join(_modLoader.GetDirectoryForModId(modConfig.ModId), "UnhardcodedP5R", "ChatIconParams.json");
_chatHooks.ReadChatIconParamFile(chatIconParamFilePath);
}
if (_configuration.LmapHooks)
{
var lmapSpriteParamFilePath = Path.Join(_modLoader.GetDirectoryForModId(modConfig.ModId), "UnhardcodedP5R", "LmapSpriteParams.json");
_lmapHooks.ReadLmapSpriteParamFile(lmapSpriteParamFilePath);
var lmapSilhouetteFieldsFilePath = Path.Join(_modLoader.GetDirectoryForModId(modConfig.ModId), "UnhardcodedP5R", "LmapSilhouetteFields.json");
_lmapHooks.ReadLmapSilhouetteFieldFile(lmapSilhouetteFieldsFilePath);
}
}
private void OnModLoaderInitialized()
{
if (_configuration.LmapHooks)
_lmapHooks.WriteNewLmapParamTable();
}
#region Standard Overrides
public override void ConfigurationUpdated(Config configuration)
{
// Apply settings from configuration.
// ... your code here.
_configuration = configuration;
_logger.WriteLine($"[{_modConfig.ModId}] Config Updated: Applying");
}
#endregion
#region For Exports, Serialization etc.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public Mod() { }
#pragma warning restore CS8618
#endregion
}
}