refactor(mod): changed hardcode items and locale to JSON controlled one
This commit is contained in:
29
moe.yuyui.weebsights-port/Services/WeebLocaleService.cs
Normal file
29
moe.yuyui.weebsights-port/Services/WeebLocaleService.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using moe.yuyui.weebsights_port.Models;
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.DI;
|
||||
using SPTarkov.Server.Core.Models.Common;
|
||||
using SPTarkov.Server.Core.Utils;
|
||||
|
||||
namespace moe.yuyui.weebsights_port.Services;
|
||||
|
||||
[Injectable(TypePriority = OnLoadOrder.PostDBModLoader + 4)]
|
||||
public class WeebLocaleService(JsonUtil jsonUtil)
|
||||
{
|
||||
public bool TryLoadLocales(string filePath, out Dictionary<MongoId, WeebLocaleConfig> outputObject)
|
||||
{
|
||||
var json = LoadLocales(filePath);
|
||||
if (json == null)
|
||||
{
|
||||
outputObject = new Dictionary<MongoId, WeebLocaleConfig>();
|
||||
return false;
|
||||
}
|
||||
|
||||
outputObject = json;
|
||||
return true;
|
||||
}
|
||||
|
||||
public Dictionary<MongoId, WeebLocaleConfig>? LoadLocales(string filePath)
|
||||
{
|
||||
return jsonUtil.DeserializeFromFile<Dictionary<MongoId, WeebLocaleConfig>>(filePath);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user