Format Style Fixes
This commit is contained in:
@@ -30,12 +30,11 @@ public class HideoutCraftQuestIdGenerator(
|
||||
"67093210d514d26f8408612b", // Old event quest production "TG-Vi-24 true vaccine"
|
||||
];
|
||||
|
||||
private static readonly Dictionary<MongoId, MongoId> _forcedQuestToProductionAssociations =
|
||||
new()
|
||||
{
|
||||
// KEY = PRODUCTION, VALUE = QUEST
|
||||
{ new MongoId("63a571802116d261d2336cd1"), new MongoId("625d6ffaf7308432be1d44c5") }, // Network Provider - Part 2)
|
||||
};
|
||||
private static readonly Dictionary<MongoId, MongoId> _forcedQuestToProductionAssociations = new()
|
||||
{
|
||||
// KEY = PRODUCTION, VALUE = QUEST
|
||||
{ new MongoId("63a571802116d261d2336cd1"), new MongoId("625d6ffaf7308432be1d44c5") }, // Network Provider - Part 2)
|
||||
};
|
||||
|
||||
private readonly Dictionary<MongoId, MongoId> _questProductionMap = new();
|
||||
private readonly List<QuestProductionOutput> _questProductionOutputList = [];
|
||||
@@ -50,14 +49,10 @@ public class HideoutCraftQuestIdGenerator(
|
||||
|
||||
// Figure out our source and target directories
|
||||
var projectDir = Directory.GetParent("./").Parent.Parent.Parent.Parent.Parent;
|
||||
const string productionPath =
|
||||
"Libraries\\SPTarkov.Server.Assets\\SPT_Data\\database\\hideout\\production.json";
|
||||
const string productionPath = "Libraries\\SPTarkov.Server.Assets\\SPT_Data\\database\\hideout\\production.json";
|
||||
var productionFilePath = Path.Combine(projectDir.FullName, productionPath);
|
||||
|
||||
var updatedProductionJson = _jsonUtil.Serialize(
|
||||
_databaseServer.GetTables().Hideout.Production,
|
||||
true
|
||||
);
|
||||
var updatedProductionJson = _jsonUtil.Serialize(_databaseServer.GetTables().Hideout.Production, true);
|
||||
await _fileUtil.WriteFileAsync(productionFilePath, updatedProductionJson);
|
||||
}
|
||||
|
||||
@@ -66,9 +61,7 @@ public class HideoutCraftQuestIdGenerator(
|
||||
{
|
||||
foreach (var (questId, quest) in _databaseServer.GetTables().Templates.Quests)
|
||||
{
|
||||
var combinedRewards = CombineRewards(quest.Rewards)
|
||||
.Where(x => x.Type == RewardType.ProductionScheme)
|
||||
.ToList();
|
||||
var combinedRewards = CombineRewards(quest.Rewards).Where(x => x.Type == RewardType.ProductionScheme).ToList();
|
||||
foreach (var reward in combinedRewards)
|
||||
{
|
||||
// Assume all productions only output a single item template
|
||||
@@ -85,10 +78,7 @@ public class HideoutCraftQuestIdGenerator(
|
||||
{
|
||||
if (item.Template != output.ItemTemplate)
|
||||
{
|
||||
_logger.Error(
|
||||
$"Production scheme has multiple output items. "
|
||||
+ $"{output.ItemTemplate} != {item.Template}"
|
||||
);
|
||||
_logger.Error($"Production scheme has multiple output items. " + $"{output.ItemTemplate} != {item.Template}");
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -114,9 +104,7 @@ public class HideoutCraftQuestIdGenerator(
|
||||
}
|
||||
|
||||
// Look for a 'quest completion' requirement
|
||||
var questCompleteRequirements = production
|
||||
.Requirements.Where(req => req.Type == "QuestComplete")
|
||||
.ToList();
|
||||
var questCompleteRequirements = production.Requirements.Where(req => req.Type == "QuestComplete").ToList();
|
||||
if (questCompleteRequirements.Count == 0)
|
||||
{
|
||||
// Production has no quest requirement
|
||||
@@ -125,21 +113,14 @@ public class HideoutCraftQuestIdGenerator(
|
||||
|
||||
if (questCompleteRequirements.Count > 1)
|
||||
{
|
||||
_logger.Error(
|
||||
$"Error, prodId: {production.Id} contains multiple QuestComplete requirements"
|
||||
);
|
||||
_logger.Error($"Error, prodId: {production.Id} contains multiple QuestComplete requirements");
|
||||
|
||||
// Production has no multiple quest requirements
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for forced ids
|
||||
if (
|
||||
_forcedQuestToProductionAssociations.TryGetValue(
|
||||
production.Id,
|
||||
out var associatedQuestIdToComplete
|
||||
)
|
||||
)
|
||||
if (_forcedQuestToProductionAssociations.TryGetValue(production.Id, out var associatedQuestIdToComplete))
|
||||
{
|
||||
var enLocale = _databaseServer.GetTables().Locales.Global["en"].Value;
|
||||
var questName = enLocale[$"{associatedQuestIdToComplete} name"];
|
||||
@@ -154,20 +135,11 @@ public class HideoutCraftQuestIdGenerator(
|
||||
|
||||
// Try to find the quest that matches this production
|
||||
var questProductionOutputs = _questProductionOutputList
|
||||
.Where(output =>
|
||||
output.ItemTemplate == production.EndProduct
|
||||
&& output.Quantity == production.Count
|
||||
)
|
||||
.Where(output => output.ItemTemplate == production.EndProduct && output.Quantity == production.Count)
|
||||
.ToList();
|
||||
|
||||
// Make sure we found valid data
|
||||
if (
|
||||
!IsValidQuestProduction(
|
||||
production,
|
||||
questProductionOutputs,
|
||||
questCompleteRequirements[0]
|
||||
)
|
||||
)
|
||||
if (!IsValidQuestProduction(production, questProductionOutputs, questCompleteRequirements[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -205,10 +177,7 @@ public class HideoutCraftQuestIdGenerator(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
questComplete.QuestId is not null
|
||||
&& questComplete.QuestId != questProductionOutputs[0].QuestId
|
||||
)
|
||||
if (questComplete.QuestId is not null && questComplete.QuestId != questProductionOutputs[0].QuestId)
|
||||
{
|
||||
_logger.Error(
|
||||
$"Error: Multiple productions match quest. EndProduct: {production.EndProduct} with quantity {production.Count}, existing quest: {questComplete.QuestId} {questProductionOutputs[0].QuestName}"
|
||||
|
||||
@@ -18,9 +18,7 @@ public class HideoutCraftQuestIdGeneratorLauncher
|
||||
serviceCollection.AddSingleton(WebApplication.CreateBuilder());
|
||||
serviceCollection.AddSingleton<IReadOnlyList<SptMod>>([]);
|
||||
var diHandler = new DependencyInjectionHandler(serviceCollection);
|
||||
diHandler.AddInjectableTypesFromTypeAssembly(
|
||||
typeof(HideoutCraftQuestIdGeneratorLauncher)
|
||||
);
|
||||
diHandler.AddInjectableTypesFromTypeAssembly(typeof(HideoutCraftQuestIdGeneratorLauncher));
|
||||
diHandler.AddInjectableTypesFromTypeAssembly(typeof(App));
|
||||
diHandler.InjectAll();
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
@@ -15,12 +15,7 @@ public class SptBasicLogger<T> : ISptLogger<T>
|
||||
categoryName = typeof(T).Name;
|
||||
}
|
||||
|
||||
public void LogWithColor(
|
||||
string data,
|
||||
LogTextColor? textColor = null,
|
||||
LogBackgroundColor? backgroundColor = null,
|
||||
Exception? ex = null
|
||||
)
|
||||
public void LogWithColor(string data, LogTextColor? textColor = null, LogBackgroundColor? backgroundColor = null, Exception? ex = null)
|
||||
{
|
||||
Console.WriteLine($"{categoryName}: {data}");
|
||||
}
|
||||
|
||||
@@ -4,10 +4,7 @@ namespace JsonExtensionDataGenerator;
|
||||
|
||||
public class JsonExtensionDataGeneratorLauncher
|
||||
{
|
||||
private static readonly Regex _recordAndClassRegex = new(
|
||||
"^(public record |public class )",
|
||||
RegexOptions.Multiline
|
||||
);
|
||||
private static readonly Regex _recordAndClassRegex = new("^(public record |public class )", RegexOptions.Multiline);
|
||||
private static readonly Regex _endRecordClassRegex = new("^}", RegexOptions.Multiline);
|
||||
private static readonly Regex _startRecordClassRegex = new("^{", RegexOptions.Multiline);
|
||||
private const int StartRecordClassOffset = 3;
|
||||
@@ -41,17 +38,13 @@ public class JsonExtensionDataGeneratorLauncher
|
||||
var content = File.ReadAllText(modelFile);
|
||||
if (!content.Contains("public record ") && !content.Contains("public class "))
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"File {fileName} doesn't contain any records or classes, skipping..."
|
||||
);
|
||||
Console.WriteLine($"File {fileName} doesn't contain any records or classes, skipping...");
|
||||
// Probably an enum or interface
|
||||
return;
|
||||
}
|
||||
|
||||
var classesAndRecordsToProcessCount = _recordAndClassRegex.Matches(content).Count;
|
||||
Console.WriteLine(
|
||||
$"Found {classesAndRecordsToProcessCount} records or classes for {fileName}"
|
||||
);
|
||||
Console.WriteLine($"Found {classesAndRecordsToProcessCount} records or classes for {fileName}");
|
||||
var firstTimeFlag = false;
|
||||
var currentIndex = 0;
|
||||
try
|
||||
@@ -62,15 +55,9 @@ public class JsonExtensionDataGeneratorLauncher
|
||||
var endIndex = FindEndClassIndex(content, startIndex);
|
||||
currentIndex = endIndex;
|
||||
// Check if this class already has the tag anywhere
|
||||
if (
|
||||
content
|
||||
.Substring(startIndex, endIndex - startIndex)
|
||||
.Contains("[JsonExtensionData]")
|
||||
)
|
||||
if (content.Substring(startIndex, endIndex - startIndex).Contains("[JsonExtensionData]"))
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"Class index {i} for {fileName} already contains [JsonExtensionData], skipping class..."
|
||||
);
|
||||
Console.WriteLine($"Class index {i} for {fileName} already contains [JsonExtensionData], skipping class...");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -78,9 +65,7 @@ public class JsonExtensionDataGeneratorLauncher
|
||||
{
|
||||
if (extensions.Any(e => !e.StartsWith("I")))
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"Class index {i} for {fileName} extends a parent class, skipping..."
|
||||
);
|
||||
Console.WriteLine($"Class index {i} for {fileName} extends a parent class, skipping...");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -90,9 +75,7 @@ public class JsonExtensionDataGeneratorLauncher
|
||||
{
|
||||
if (!content.Contains("using System.Text.Json.Serialization;"))
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"Class index {i} for {fileName} doesn't contain using for Json.Serialization. Adding."
|
||||
);
|
||||
Console.WriteLine($"Class index {i} for {fileName} doesn't contain using for Json.Serialization. Adding.");
|
||||
// insert the using and adjust the indexes
|
||||
content = Using + content;
|
||||
startIndex += Using.Length;
|
||||
@@ -105,8 +88,7 @@ public class JsonExtensionDataGeneratorLauncher
|
||||
|
||||
// We need to add StartRecordClassOffset to offset the EOL
|
||||
var insertionIndex =
|
||||
_startRecordClassRegex.Match(content, startIndex, endIndex - startIndex).Index
|
||||
+ StartRecordClassOffset;
|
||||
_startRecordClassRegex.Match(content, startIndex, endIndex - startIndex).Index + StartRecordClassOffset;
|
||||
content = content.Insert(insertionIndex, Insertion);
|
||||
Console.WriteLine($"Class index {i} for {fileName} processed.");
|
||||
currentIndex += Insertion.Length;
|
||||
@@ -122,21 +104,14 @@ public class JsonExtensionDataGeneratorLauncher
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetExtensions(
|
||||
string content,
|
||||
int startIndex,
|
||||
int endIndex,
|
||||
out IEnumerable<string> extensions
|
||||
)
|
||||
private static bool TryGetExtensions(string content, int startIndex, int endIndex, out IEnumerable<string> extensions)
|
||||
{
|
||||
extensions = null;
|
||||
var match = _extensionFinding.Match(content, startIndex, endIndex - startIndex);
|
||||
if (match.Success)
|
||||
{
|
||||
var extensionsGroup = match.Groups[8];
|
||||
extensions = extensionsGroup.Captures.Select(c =>
|
||||
_extensionCleanup.Replace(c.Value, "")
|
||||
);
|
||||
extensions = extensionsGroup.Captures.Select(c => _extensionCleanup.Replace(c.Value, ""));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -157,12 +132,7 @@ public class JsonExtensionDataGeneratorLauncher
|
||||
private static IEnumerable<string> LoadModelFiles()
|
||||
{
|
||||
var projectDir = Directory.GetParent("./").Parent.Parent.Parent.Parent.Parent;
|
||||
var modelsDir = Path.Combine(
|
||||
projectDir.FullName,
|
||||
"Libraries",
|
||||
"SPTarkov.Server.Core",
|
||||
"Models"
|
||||
);
|
||||
var modelsDir = Path.Combine(projectDir.FullName, "Libraries", "SPTarkov.Server.Core", "Models");
|
||||
return Directory.GetFiles(modelsDir, "*.cs", SearchOption.AllDirectories);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,7 @@ using SPTarkov.Server.Core.Models.Utils;
|
||||
namespace MongoIdTplGenerator;
|
||||
|
||||
[Injectable(InjectionType.Singleton)]
|
||||
public class Application(
|
||||
ISptLogger<Application> logger,
|
||||
IEnumerable<IOnLoad> onloadComponents,
|
||||
IEnumerable<IMongoIdGenerator> generators
|
||||
)
|
||||
public class Application(ISptLogger<Application> logger, IEnumerable<IOnLoad> onloadComponents, IEnumerable<IMongoIdGenerator> generators)
|
||||
{
|
||||
public async Task Run()
|
||||
{
|
||||
|
||||
@@ -26,13 +26,7 @@ public class BaseClassesIdGenerator(
|
||||
{
|
||||
// Figure out our source and target directories
|
||||
var projectDir = Directory.GetParent("./").Parent.Parent.Parent.Parent.Parent;
|
||||
_enumDir = Path.Combine(
|
||||
projectDir.FullName,
|
||||
"Libraries",
|
||||
"SPTarkov.Server.Core",
|
||||
"Models",
|
||||
"Enums"
|
||||
);
|
||||
_enumDir = Path.Combine(projectDir.FullName, "Libraries", "SPTarkov.Server.Core", "Models", "Enums");
|
||||
_items = databaseServer.GetTables().Templates.Items;
|
||||
|
||||
// Generate an object containing all item name to ID associations
|
||||
@@ -43,10 +37,7 @@ public class BaseClassesIdGenerator(
|
||||
var itemTplOutPath = Path.Combine(_enumDir, "BaseClasses.cs");
|
||||
WriteEnumsToFile(
|
||||
itemTplOutPath,
|
||||
new Dictionary<string, Dictionary<string, MongoId>>
|
||||
{
|
||||
{ nameof(BaseClasses), orderedItemsObject },
|
||||
}
|
||||
new Dictionary<string, Dictionary<string, MongoId>> { { nameof(BaseClasses), orderedItemsObject } }
|
||||
);
|
||||
|
||||
logger.Info("Generating items finished");
|
||||
@@ -86,11 +77,7 @@ public class BaseClassesIdGenerator(
|
||||
return orderedItemsObject;
|
||||
}
|
||||
|
||||
private void LogEnumValueChanges(
|
||||
Dictionary<string, MongoId> data,
|
||||
string enumName,
|
||||
Type originalEnum
|
||||
)
|
||||
private void LogEnumValueChanges(Dictionary<string, MongoId> data, string enumName, Type originalEnum)
|
||||
{
|
||||
// First generate a mapping of the original enum values to names
|
||||
var originalEnumValues = new Dictionary<string, string>();
|
||||
@@ -104,17 +91,12 @@ public class BaseClassesIdGenerator(
|
||||
{
|
||||
if (originalEnumValues.ContainsKey(kv.Value) && originalEnumValues[kv.Value] != kv.Key)
|
||||
{
|
||||
logger.Warning(
|
||||
$"Enum {enumName} key has changed for {kv.Value}, {originalEnumValues[kv.Value]} => {kv.Key}"
|
||||
);
|
||||
logger.Warning($"Enum {enumName} key has changed for {kv.Value}, {originalEnumValues[kv.Value]} => {kv.Key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteEnumsToFile(
|
||||
string outputPath,
|
||||
Dictionary<string, Dictionary<string, MongoId>> enumEntries
|
||||
)
|
||||
private void WriteEnumsToFile(string outputPath, Dictionary<string, Dictionary<string, MongoId>> enumEntries)
|
||||
{
|
||||
var enumFileData =
|
||||
"using SPTarkov.Server.Core.Models.Common;\n\n"
|
||||
@@ -126,8 +108,7 @@ public class BaseClassesIdGenerator(
|
||||
|
||||
foreach (var (key, value) in data)
|
||||
{
|
||||
enumFileData +=
|
||||
$" public static readonly MongoId {key} = new MongoId(\"{value}\");\n";
|
||||
enumFileData += $" public static readonly MongoId {key} = new MongoId(\"{value}\");\n";
|
||||
}
|
||||
|
||||
enumFileData += "}\n";
|
||||
|
||||
@@ -33,13 +33,7 @@ public class ItemTplMongoIdGenerator(
|
||||
|
||||
// Figure out our source and target directories
|
||||
var projectDir = Directory.GetParent("./").Parent.Parent.Parent.Parent.Parent;
|
||||
_enumDir = Path.Combine(
|
||||
projectDir.FullName,
|
||||
"Libraries",
|
||||
"SPTarkov.Server.Core",
|
||||
"Models",
|
||||
"Enums"
|
||||
);
|
||||
_enumDir = Path.Combine(projectDir.FullName, "Libraries", "SPTarkov.Server.Core", "Models", "Enums");
|
||||
_items = databaseServer.GetTables().Templates.Items;
|
||||
|
||||
// Generate an object containing all item name to ID associations
|
||||
@@ -48,25 +42,13 @@ public class ItemTplMongoIdGenerator(
|
||||
// Log any changes to enum values, so the source can be updated as required
|
||||
LogEnumValueChanges(orderedItemsObject, "ItemTpl", typeof(ItemTpl));
|
||||
var itemTplOutPath = Path.Combine(_enumDir, "ItemTpl.cs");
|
||||
WriteEnumsToFile(
|
||||
itemTplOutPath,
|
||||
new Dictionary<string, Dictionary<string, string>>
|
||||
{
|
||||
{ nameof(ItemTpl), orderedItemsObject },
|
||||
}
|
||||
);
|
||||
WriteEnumsToFile(itemTplOutPath, new Dictionary<string, Dictionary<string, string>> { { nameof(ItemTpl), orderedItemsObject } });
|
||||
|
||||
// Handle the weapon type enums
|
||||
var weaponsObject = GenerateWeaponsObject();
|
||||
LogEnumValueChanges(weaponsObject, "Weapons", typeof(Weapons));
|
||||
var weaponTypeOutPath = Path.Combine(_enumDir, "Weapons.cs");
|
||||
WriteEnumsToFile(
|
||||
weaponTypeOutPath,
|
||||
new Dictionary<string, Dictionary<string, string>>
|
||||
{
|
||||
{ nameof(Weapons), weaponsObject },
|
||||
}
|
||||
);
|
||||
WriteEnumsToFile(weaponTypeOutPath, new Dictionary<string, Dictionary<string, string>> { { nameof(Weapons), weaponsObject } });
|
||||
|
||||
logger.Info("Generating items finished");
|
||||
|
||||
@@ -108,10 +90,7 @@ public class ItemTplMongoIdGenerator(
|
||||
}
|
||||
|
||||
// Handle the case where the item ends with the parent category name. Avoids things like 'KEY_DORM_ROOM_103_KEY'
|
||||
if (
|
||||
itemName.Length >= itemParentName.Length
|
||||
&& itemParentName == itemName.Substring(itemName.Length - itemParentName.Length)
|
||||
)
|
||||
if (itemName.Length >= itemParentName.Length && itemParentName == itemName.Substring(itemName.Length - itemParentName.Length))
|
||||
{
|
||||
itemName = itemName.Substring(0, itemName.Length - itemParentName.Length);
|
||||
|
||||
@@ -142,9 +121,7 @@ public class ItemTplMongoIdGenerator(
|
||||
var oldItemNameSuffix = GetItemNameSuffix(_items[oldItemId]);
|
||||
if (!string.IsNullOrEmpty(oldItemNameSuffix))
|
||||
{
|
||||
var oldItemNewKey = localeUtil.SanitizeEnumKey(
|
||||
$"{itemKey}_{oldItemNameSuffix}"
|
||||
);
|
||||
var oldItemNewKey = localeUtil.SanitizeEnumKey($"{itemKey}_{oldItemNameSuffix}");
|
||||
itemsObject.Remove(itemKey);
|
||||
itemsObject[oldItemNewKey] = oldItemId;
|
||||
}
|
||||
@@ -155,17 +132,13 @@ public class ItemTplMongoIdGenerator(
|
||||
// If we still collide, log an error
|
||||
if (itemsObject.TryGetValue(itemKey, out var value))
|
||||
{
|
||||
logger.Error(
|
||||
$"After rename, itemsObject already contains {itemKey} {value} => {item.Id}"
|
||||
);
|
||||
logger.Error($"After rename, itemsObject already contains {itemKey} {value} => {item.Id}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var val = itemsObject.GetValueOrDefault(itemKey, itemKey);
|
||||
logger.Error(
|
||||
$"New itemOverride entry required: itemsObject already contains {itemKey} {val} => {item.Id}"
|
||||
);
|
||||
logger.Error($"New itemOverride entry required: itemsObject already contains {itemKey} {val} => {item.Id}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -403,20 +376,14 @@ public class ItemTplMongoIdGenerator(
|
||||
|
||||
private string GetAmmoBoxPrefix(TemplateItem item)
|
||||
{
|
||||
var ammoTpl = item
|
||||
.Properties?.StackSlots?.First()
|
||||
?.Props?.Filters?.First()
|
||||
?.Filter?.FirstOrDefault();
|
||||
var ammoTpl = item.Properties?.StackSlots?.First()?.Props?.Filters?.First()?.Filter?.FirstOrDefault();
|
||||
|
||||
return GetAmmoPrefix(_items[ammoTpl.Value]);
|
||||
}
|
||||
|
||||
private string GetMagazinePrefix(TemplateItem item)
|
||||
{
|
||||
var ammoTpl = item
|
||||
.Properties?.Cartridges?.First()
|
||||
?.Props?.Filters?.First()
|
||||
?.Filter?.FirstOrDefault();
|
||||
var ammoTpl = item.Properties?.Cartridges?.First()?.Props?.Filters?.First()?.Filter?.FirstOrDefault();
|
||||
|
||||
return GetAmmoPrefix(_items[ammoTpl.Value]);
|
||||
}
|
||||
@@ -437,22 +404,12 @@ public class ItemTplMongoIdGenerator(
|
||||
itemName = itemNameOverride.ToUpper();
|
||||
}
|
||||
// For the listed types, user the item's _name property
|
||||
else if (
|
||||
itemHelper.IsOfBaseclasses(
|
||||
item.Id,
|
||||
[BaseClasses.RANDOM_LOOT_CONTAINER, BaseClasses.BUILT_IN_INSERTS, BaseClasses.STASH]
|
||||
)
|
||||
)
|
||||
else if (itemHelper.IsOfBaseclasses(item.Id, [BaseClasses.RANDOM_LOOT_CONTAINER, BaseClasses.BUILT_IN_INSERTS, BaseClasses.STASH]))
|
||||
{
|
||||
itemName = item.Name.ToUpper();
|
||||
}
|
||||
// For the listed types, use the short name
|
||||
else if (
|
||||
itemHelper.IsOfBaseclasses(
|
||||
item.Id,
|
||||
[BaseClasses.AMMO, BaseClasses.AMMO_BOX, BaseClasses.MAGAZINE]
|
||||
)
|
||||
)
|
||||
else if (itemHelper.IsOfBaseclasses(item.Id, [BaseClasses.AMMO, BaseClasses.AMMO_BOX, BaseClasses.MAGAZINE]))
|
||||
{
|
||||
if (localeDb.TryGetValue($"{item.Id} ShortName", out itemName))
|
||||
{
|
||||
@@ -540,11 +497,7 @@ public class ItemTplMongoIdGenerator(
|
||||
return "";
|
||||
}
|
||||
|
||||
private void LogEnumValueChanges(
|
||||
Dictionary<string, string> data,
|
||||
string enumName,
|
||||
Type originalEnum
|
||||
)
|
||||
private void LogEnumValueChanges(Dictionary<string, string> data, string enumName, Type originalEnum)
|
||||
{
|
||||
// First generate a mapping of the original enum values to names
|
||||
var originalEnumValues = new Dictionary<string, string>();
|
||||
@@ -558,17 +511,12 @@ public class ItemTplMongoIdGenerator(
|
||||
{
|
||||
if (originalEnumValues.ContainsKey(kv.Value) && originalEnumValues[kv.Value] != kv.Key)
|
||||
{
|
||||
logger.Warning(
|
||||
$"Enum {enumName} key has changed for {kv.Value}, {originalEnumValues[kv.Value]} => {kv.Key}"
|
||||
);
|
||||
logger.Warning($"Enum {enumName} key has changed for {kv.Value}, {originalEnumValues[kv.Value]} => {kv.Key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteEnumsToFile(
|
||||
string outputPath,
|
||||
Dictionary<string, Dictionary<string, string>> enumEntries
|
||||
)
|
||||
private void WriteEnumsToFile(string outputPath, Dictionary<string, Dictionary<string, string>> enumEntries)
|
||||
{
|
||||
var enumFileData =
|
||||
"using SPTarkov.Server.Core.Models.Common;\n\n"
|
||||
@@ -580,8 +528,7 @@ public class ItemTplMongoIdGenerator(
|
||||
|
||||
foreach (var (key, value) in data)
|
||||
{
|
||||
enumFileData +=
|
||||
$" public static readonly MongoId {key} = new MongoId(\"{value}\");\n";
|
||||
enumFileData += $" public static readonly MongoId {key} = new MongoId(\"{value}\");\n";
|
||||
}
|
||||
|
||||
enumFileData += "}\n";
|
||||
|
||||
@@ -25,13 +25,7 @@ public class QuestTplMongoIdGenerator(
|
||||
{
|
||||
// Figure out our source and target directories
|
||||
var projectDir = Directory.GetParent("./").Parent.Parent.Parent.Parent.Parent;
|
||||
_enumDir = Path.Combine(
|
||||
projectDir.FullName,
|
||||
"Libraries",
|
||||
"SPTarkov.Server.Core",
|
||||
"Models",
|
||||
"Enums"
|
||||
);
|
||||
_enumDir = Path.Combine(projectDir.FullName, "Libraries", "SPTarkov.Server.Core", "Models", "Enums");
|
||||
|
||||
_quests = databaseServer.GetTables().Templates.Quests;
|
||||
var questTplObject = GenerateQuestTplObject();
|
||||
@@ -54,18 +48,13 @@ public class QuestTplMongoIdGenerator(
|
||||
{
|
||||
if (!result.TryAdd(nameOverride, id))
|
||||
{
|
||||
logger.Warning(
|
||||
$"Duplicate locale name: {nameOverride} with id: {id} in quest list"
|
||||
);
|
||||
logger.Warning($"Duplicate locale name: {nameOverride} with id: {id} in quest list");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var locale = localeService
|
||||
.GetLocaleDb()[$"{id} name"]
|
||||
.Replace(" ", "_")
|
||||
.Replace("-", "_");
|
||||
var locale = localeService.GetLocaleDb()[$"{id} name"].Replace(" ", "_").Replace("-", "_");
|
||||
|
||||
locale = localeUtil.SanitizeEnumKey(locale);
|
||||
|
||||
@@ -88,8 +77,7 @@ public class QuestTplMongoIdGenerator(
|
||||
|
||||
foreach (var (enumName, data) in enumEntries)
|
||||
{
|
||||
enumFileData +=
|
||||
$" public static readonly MongoId {enumName} = new MongoId(\"{data}\");\n";
|
||||
enumFileData += $" public static readonly MongoId {enumName} = new MongoId(\"{data}\");\n";
|
||||
}
|
||||
|
||||
enumFileData += "}\n";
|
||||
|
||||
@@ -15,12 +15,7 @@ public class SptBasicLogger<T> : ISptLogger<T>
|
||||
categoryName = typeof(T).Name;
|
||||
}
|
||||
|
||||
public void LogWithColor(
|
||||
string data,
|
||||
LogTextColor? textColor = null,
|
||||
LogBackgroundColor? backgroundColor = null,
|
||||
Exception? ex = null
|
||||
)
|
||||
public void LogWithColor(string data, LogTextColor? textColor = null, LogBackgroundColor? backgroundColor = null, Exception? ex = null)
|
||||
{
|
||||
Console.WriteLine($"{categoryName}: {data}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user