BIG BOI FORMATTING

This commit is contained in:
CWX
2025-02-07 19:36:17 +00:00
parent 7916ae1156
commit 5c6fa9242f
644 changed files with 41578 additions and 10914 deletions
@@ -1,4 +1,3 @@
using Core.Callbacks;
using Core.DI;
using Core.Helpers;
using Core.Models.Eft.Common.Tables;
@@ -24,9 +23,6 @@ public class HideoutCraftQuestIdGenerator(
IEnumerable<OnLoad> _onLoadComponents
)
{
private readonly List<QuestProductionOutput> _questProductionOutputList = [];
private readonly Dictionary<string, string> _questProductionMap = new();
private readonly HashSet<string> _blacklistedProductions =
[
"6617cdb6b24b0ea24505f618", // Old event quest production "Radio Repeater" alt recipe
@@ -42,6 +38,9 @@ public class HideoutCraftQuestIdGenerator(
{ "63a571802116d261d2336cd1", "625d6ffaf7308432be1d44c5" } // Network Provider - Part 2
};
private readonly Dictionary<string, string> _questProductionMap = new();
private readonly List<QuestProductionOutput> _questProductionOutputList = [];
public async Task Run()
{
// We only need the DB for this, other OnLoad events alter the data
@@ -129,7 +128,8 @@ public class HideoutCraftQuestIdGenerator(
if (_forcedQuestToProductionAssociations.TryGetValue(production.Id, out var associatedQuestIdToComplete))
{
// Found one, move to next production
_logger.Success($"FORCED - Updated: {production.Id} {production.EndProduct} ({_itemHelper.GetItemName(production.EndProduct)}) with quantity: {production.Count} to target quest: {associatedQuestIdToComplete}"
_logger.Success(
$"FORCED - Updated: {production.Id} {production.EndProduct} ({_itemHelper.GetItemName(production.EndProduct)}) with quantity: {production.Count} to target quest: {associatedQuestIdToComplete}"
);
questCompleteRequirements[0].QuestId = associatedQuestIdToComplete;
@@ -214,7 +214,21 @@ public class HideoutCraftQuestIdGenerator(
public class QuestProductionOutput
{
public string QuestId { get; set; }
public string ItemTemplate { get; set; }
public double Quantity { get; set; }
public string QuestId
{
get;
set;
}
public string ItemTemplate
{
get;
set;
}
public double Quantity
{
get;
set;
}
}
@@ -10,10 +10,10 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\Core\Core.csproj" />
<ProjectReference Include="..\..\Libraries\SptAssets\SptAssets.csproj" />
<ProjectReference Include="..\..\Libraries\SptDependencyInjection\SptDependencyInjection.csproj" />
<ProjectReference Include="..\..\SptCommon\SptCommon.csproj" />
<ProjectReference Include="..\..\Libraries\Core\Core.csproj"/>
<ProjectReference Include="..\..\Libraries\SptAssets\SptAssets.csproj"/>
<ProjectReference Include="..\..\Libraries\SptDependencyInjection\SptDependencyInjection.csproj"/>
<ProjectReference Include="..\..\SptCommon\SptCommon.csproj"/>
</ItemGroup>
</Project>
@@ -9,11 +9,12 @@ namespace HideoutCraftQuestIdGenerator;
public class SptBasicLogger<T> : ISptLogger<T>
{
private readonly string categoryName;
public SptBasicLogger()
{
categoryName = typeof(T).Name;
}
public void LogWithColor(string data, LogTextColor? textColor = null, LogBackgroundColor? backgroundColor = null,
Exception? ex = null)
{
+1 -1
View File
@@ -5,7 +5,7 @@ namespace ItemTplGenerator;
public class ItemOverrides
{
public static readonly ReadOnlyDictionary<string, string> ItemOverridesDictionary = new(
new Dictionary<string, string>()
new Dictionary<string, string>
{
// Stashes
{ "5963866b86f7747bfa1c4462", "QuestOffline" },
+157 -35
View File
@@ -23,10 +23,10 @@ public class ItemTplGenerator(
IEnumerable<OnLoad> _onLoadComponents
)
{
private readonly HashSet<string> collidedEnumKeys = [];
private string enumDir;
private Dictionary<string, TemplateItem> items;
private IDictionary<string, string> itemOverrides;
private HashSet<string> collidedEnumKeys = [];
private Dictionary<string, TemplateItem> items;
public async Task Run()
{
@@ -35,7 +35,10 @@ public class ItemTplGenerator(
foreach (var onLoad in _onLoadComponents)
{
if (onLoad is HttpCallbacks)
{
continue;
}
await onLoad.OnLoad();
}
@@ -52,7 +55,10 @@ public class ItemTplGenerator(
var itemTplOutPath = Path.Combine(enumDir, "ItemTpl.cs");
WriteEnumsToFile(
itemTplOutPath,
new Dictionary<string, Dictionary<string, string>>() { { nameof(ItemTpl), orderedItemsObject } }
new Dictionary<string, Dictionary<string, string>>
{
{ nameof(ItemTpl), orderedItemsObject }
}
);
// Handle the weapon type enums
@@ -61,7 +67,10 @@ public class ItemTplGenerator(
var weaponTypeOutPath = Path.Combine(enumDir, "Weapons.cs");
WriteEnumsToFile(
weaponTypeOutPath,
new Dictionary<string, Dictionary<string, string>>() { { nameof(Weapons), weaponsObject } }
new Dictionary<string, Dictionary<string, string>>
{
{ nameof(Weapons), weaponsObject }
}
);
_logger.Info("Generating items finished");
@@ -77,7 +86,10 @@ public class ItemTplGenerator(
foreach (var item in items.Values)
{
// Skip invalid items (Non-Item types, and shrapnel)
if (!IsValidItem(item)) continue;
if (!IsValidItem(item))
{
continue;
}
var itemParentName = GetParentName(item);
var itemPrefix = GetItemPrefix(item);
@@ -90,7 +102,10 @@ public class ItemTplGenerator(
itemPrefix == "")
{
itemName = itemName.Substring(itemParentName.Length + 1);
if (itemName.Length > 0 && itemName[0] != '_') itemName = $"_{itemName}";
if (itemName.Length > 0 && itemName[0] != '_')
{
itemName = $"_{itemName}";
}
}
// Handle the case where the item ends with the parent category name. Avoids things like 'KEY_DORM_ROOM_103_KEY'
@@ -99,7 +114,10 @@ public class ItemTplGenerator(
{
itemName = itemName.Substring(0, itemName.Length - itemParentName.Length);
if (itemName.Substring(itemName.Length - 1) == "_") itemName = itemName.Substring(0, itemName.Length - 1);
if (itemName.Substring(itemName.Length - 1) == "_")
{
itemName = itemName.Substring(0, itemName.Length - 1);
}
}
var itemKey = $"{itemParentName}{itemPrefix}{itemName}{itemSuffix}";
@@ -133,9 +151,11 @@ public class ItemTplGenerator(
// If we still collide, log an error
if (itemsObject.ContainsKey(itemKey))
{
_logger.Error(
$"After rename, itemsObject already contains {itemKey} {itemsObject[itemKey]} => {item.Id}"
);
}
}
else
{
@@ -156,7 +176,6 @@ public class ItemTplGenerator(
}
/**
*
* @param orderedItemsObject The previously generated object of item name to item ID associations
* @returns
*/
@@ -165,19 +184,27 @@ public class ItemTplGenerator(
var weaponsObject = new Dictionary<string, string>();
foreach (var kv /*[itemId, item]*/ in items)
{
if (!_itemHelper.IsOfBaseclass(kv.Key, BaseClasses.WEAPON)) continue;
if (!_itemHelper.IsOfBaseclass(kv.Key, BaseClasses.WEAPON))
{
continue;
}
var caliber = CleanCaliber(kv.Value.Properties.AmmoCaliber.ToUpper());
var weaponShortName = _localeService.GetLocaleDb()[$"{kv.Key} ShortName"]?.ToUpper();
// Special case for the weird duplicated grenade launcher
if (kv.Key == "639c3fbbd0446708ee622ee9") weaponShortName = "FN40GL_2";
if (kv.Key == "639c3fbbd0446708ee622ee9")
{
weaponShortName = "FN40GL_2";
}
// Include any bracketed suffixes that exist, handles the case of colored gun variants
var weaponFullName = _localeService.GetLocaleDb()[$"{kv.Key} Name"]?.ToUpper();
if (weaponFullName.RegexMatch(@"\((.+?)\)$", out var itemNameBracketSuffix) &&
!weaponShortName.EndsWith(itemNameBracketSuffix.Groups[1].Value))
{
weaponShortName += $"_{itemNameBracketSuffix.Groups[1].Value}";
}
var parentName = GetParentName(kv.Value);
@@ -218,29 +245,62 @@ public class ItemTplGenerator(
private string GetParentName(TemplateItem item)
{
if (item.Properties?.QuestItem is true) return "QUEST";
if (item.Properties?.QuestItem is true)
{
return "QUEST";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.BARTER_ITEM)) return "BARTER";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.BARTER_ITEM))
{
return "BARTER";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.THROW_WEAPON)) return "GRENADE";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.THROW_WEAPON))
{
return "GRENADE";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.STIMULATOR)) return "STIM";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.STIMULATOR))
{
return "STIM";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.MAGAZINE)) return "MAGAZINE";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.MAGAZINE))
{
return "MAGAZINE";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.KEY_MECHANICAL)) return "KEY";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.KEY_MECHANICAL))
{
return "KEY";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.MOB_CONTAINER)) return "SECURE";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.MOB_CONTAINER))
{
return "SECURE";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.SIMPLE_CONTAINER)) return "CONTAINER";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.SIMPLE_CONTAINER))
{
return "CONTAINER";
}
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.PORTABLE_RANGE_FINDER)) return "RANGEFINDER";
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.PORTABLE_RANGE_FINDER))
{
return "RANGEFINDER";
}
// Why are flares grenade launcher...?
if (item.Name.StartsWith("weapon_rsp30")) return "FLARE";
if (item.Name.StartsWith("weapon_rsp30"))
{
return "FLARE";
}
// This is a special case for the signal pistol, I'm not adding it as a Grenade Launcher
if (item.Id == "620109578d82e67e7911abf2") return "SIGNALPISTOL";
if (item.Id == "620109578d82e67e7911abf2")
{
return "SIGNALPISTOL";
}
var parentId = item.Parent;
return items[parentId].Name.ToUpper();
@@ -250,9 +310,15 @@ public class ItemTplGenerator(
{
var shrapnelId = "5943d9c186f7745a13413ac9";
if (item.Type != "Item") return false;
if (item.Type != "Item")
{
return false;
}
if (item.Prototype == shrapnelId) return false;
if (item.Prototype == shrapnelId)
{
return false;
}
return true;
}
@@ -268,15 +334,25 @@ public class ItemTplGenerator(
// Prefix ammo with its caliber
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.AMMO))
{
prefix = GetAmmoPrefix(item);
}
// Prefix ammo boxes with their caliber
else if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.AMMO_BOX))
{
prefix = GetAmmoBoxPrefix(item);
}
// Prefix magazines with their caliber
else if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.MAGAZINE)) prefix = GetMagazinePrefix(item);
else if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.MAGAZINE))
{
prefix = GetMagazinePrefix(item);
}
// Make sure there's an underscore separator
if (prefix.Length > 0 && prefix[0] != '_') prefix = $"_{prefix}";
if (prefix.Length > 0 && prefix[0] != '_')
{
prefix = $"_{prefix}";
}
return prefix;
}
@@ -287,15 +363,26 @@ public class ItemTplGenerator(
// Add mag size for magazines
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.MAGAZINE))
{
suffix = $"{item.Properties?.Cartridges?[0].MaxCount?.ToString()}RND";
}
// Add pack size for ammo boxes
else if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.AMMO_BOX)) suffix = $"{item.Properties.StackSlots[0]?.MaxCount.ToString()}RND";
else if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.AMMO_BOX))
{
suffix = $"{item.Properties.StackSlots[0]?.MaxCount.ToString()}RND";
}
// Add "DAMAGED" for damaged items
if (item.Name.ToLower().Contains("damaged")) suffix += "_DAMAGED";
if (item.Name.ToLower().Contains("damaged"))
{
suffix += "_DAMAGED";
}
// Make sure there's an underscore separator
if (suffix.Length > 0 && suffix[0] != '_') suffix = $"_{suffix}";
if (suffix.Length > 0 && suffix[0] != '_')
{
suffix = $"_{suffix}";
}
return suffix;
}
@@ -368,21 +455,32 @@ public class ItemTplGenerator(
else if (_itemHelper.IsOfBaseclasses(item.Id, [BaseClasses.AMMO, BaseClasses.AMMO_BOX, BaseClasses.MAGAZINE]))
{
if (localeDb.TryGetValue($"{item.Id} ShortName", out itemName))
{
itemName = itemName.ToUpper();
}
}
// For everything else, use the full name
else
{
if (localeDb.TryGetValue($"{item.Id} Name", out itemName))
{
itemName = itemName.ToUpper();
}
}
// Fall back in the event we couldn't find a name
if (string.IsNullOrEmpty(itemName))
{
if (localeDb.TryGetValue($"{item.Id} Name", out itemName))
{
itemName = itemName.ToUpper();
}
}
if (string.IsNullOrEmpty(itemName)) itemName = item.Name?.ToUpper() ?? null;
if (string.IsNullOrEmpty(itemName))
{
itemName = item.Name?.ToUpper() ?? null;
}
if (string.IsNullOrEmpty(itemName))
{
@@ -403,7 +501,9 @@ public class ItemTplGenerator(
// Add grid size for lootable containers
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.LOOT_CONTAINER))
{
return $"{item.Properties.Grids[0]?.Props.CellsH}X{item.Properties.Grids[0]?.Props.CellsV}";
}
// Add ammo caliber to conflicting weapons
if (_itemHelper.IsOfBaseclass(item.Id, BaseClasses.WEAPON))
@@ -411,19 +511,31 @@ public class ItemTplGenerator(
var caliber = CleanCaliber(item.Properties.AmmoCaliber.ToUpper());
// If the item has a bracketed section at the end of its name, include that
if (itemName?.RegexMatch(@"\((.+?)\)$", out var itemNameBracketSuffix) ?? false) return $"{caliber}_{itemNameBracketSuffix.Groups[1].Value}";
if (itemName?.RegexMatch(@"\((.+?)\)$", out var itemNameBracketSuffix) ?? false)
{
return $"{caliber}_{itemNameBracketSuffix.Groups[1].Value}";
}
return caliber;
}
// Make sure we have a full name
if (string.IsNullOrEmpty(itemName)) return "";
if (string.IsNullOrEmpty(itemName))
{
return "";
}
// If the item has a bracketed section at the end of its name, use that
if (itemName.RegexMatch(@"\((.+?)\)$", out var itemNameBracker)) return itemNameBracker.Groups[1].Value;
if (itemName.RegexMatch(@"\((.+?)\)$", out var itemNameBracker))
{
return itemNameBracker.Groups[1].Value;
}
// If the item has a number at the end of its name, use that
if (itemName.RegexMatch("#([0-9]+)$", out var itemNameNumberSuffix)) return itemNameNumberSuffix.Groups[1].Value;
if (itemName.RegexMatch("#([0-9]+)$", out var itemNameNumberSuffix))
{
return itemNameNumberSuffix.Groups[1].Value;
}
return "";
}
@@ -432,14 +544,21 @@ public class ItemTplGenerator(
{
// First generate a mapping of the original enum values to names
var originalEnumValues = new Dictionary<string, string>();
foreach (var field in originalEnum.GetFields()) originalEnumValues.Add(field.GetValue(null)!.ToString()!, field.Name);
foreach (var field in originalEnum.GetFields())
{
originalEnumValues.Add(field.GetValue(null)!.ToString()!, field.Name);
}
// Loop through our new data, and find any where the given ID's name doesn't match the original enum
foreach (var kv in data)
{
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}"
);
}
}
}
private void WriteEnumsToFile(string outputPath, Dictionary<string, Dictionary<string, string>> enumEntries)
@@ -451,7 +570,10 @@ public class ItemTplGenerator(
{
enumFileData += $"\npublic static class {enumName}\n{{\n";
foreach (var (key, value) in data) enumFileData += $" public const string {key} = \"{value}\";\n";
foreach (var (key, value) in data)
{
enumFileData += $" public const string {key} = \"{value}\";\n";
}
enumFileData += "}\n";
}
+14 -14
View File
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\Core\Core.csproj" />
<ProjectReference Include="..\..\Libraries\SptAssets\SptAssets.csproj" />
<ProjectReference Include="..\..\Libraries\SptDependencyInjection\SptDependencyInjection.csproj" />
<ProjectReference Include="..\..\SptCommon\SptCommon.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\Core\Core.csproj"/>
<ProjectReference Include="..\..\Libraries\SptAssets\SptAssets.csproj"/>
<ProjectReference Include="..\..\Libraries\SptDependencyInjection\SptDependencyInjection.csproj"/>
<ProjectReference Include="..\..\SptCommon\SptCommon.csproj"/>
</ItemGroup>
</Project>