This commit is contained in:
Liza 2024-11-19 16:32:37 +01:00
parent e93819da5b
commit 3eda727219
Signed by: liza
GPG Key ID: 7199F8D727D55F67
7 changed files with 77 additions and 62 deletions

2
LLib

@ -1 +1 @@
Subproject commit fde09c705b648f03c287814191a554f0a4b92cc4 Subproject commit e4bbc05ede6f6f01e7028b24614ed8cb333e909c

View File

@ -4,8 +4,8 @@ using System.Text.RegularExpressions;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using LLib; using LLib;
using Lumina.Excel; using Lumina.Excel;
using Lumina.Excel.CustomSheets; using Lumina.Excel.Sheets;
using Lumina.Excel.GeneratedSheets; using Lumina.Text.ReadOnly;
namespace Workshoppa.GameData; namespace Workshoppa.GameData;
@ -38,7 +38,16 @@ internal sealed class GameStrings
[Sheet("custom/001/CmnDefCompanyManufactory_00150")] [Sheet("custom/001/CmnDefCompanyManufactory_00150")]
[SuppressMessage("Performance", "CA1812")] [SuppressMessage("Performance", "CA1812")]
private sealed class WorkshopDialogue : QuestDialogueText private readonly struct WorkshopDialogue(ExcelPage page, uint offset, uint row)
: IQuestDialogueText, IExcelRow<WorkshopDialogue>
{ {
public uint RowId => row;
public ReadOnlySeString Key => page.ReadString(offset, offset);
public ReadOnlySeString Value => page.ReadString(offset + 4, offset);
static WorkshopDialogue IExcelRow<WorkshopDialogue>.Create(ExcelPage page, uint offset,
uint row) =>
new(page, offset, row);
} }
} }

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets2; using Lumina.Excel.Sheets;
namespace Workshoppa.GameData; namespace Workshoppa.GameData;
@ -31,9 +31,10 @@ internal sealed class RecipeTree
262211, // Z'ranmaia, upper decks 262211, // Z'ranmaia, upper decks
}; };
_shopItemsOnly = _dataManager.GetExcelSheet<GilShopItem>()! _shopItemsOnly = _dataManager.GetSubrowExcelSheet<GilShopItem>()
.Flatten()
.Where(x => shopVendorIds.Contains(x.RowId)) .Where(x => shopVendorIds.Contains(x.RowId))
.Select(x => x.Item.Row) .Select(x => x.Item.RowId)
.Where(x => x > 0) .Where(x => x > 0)
.Distinct() .Distinct()
.ToList() .ToList()
@ -121,32 +122,32 @@ internal sealed class RecipeTree
for (int i = 0; i < 8; ++ i) for (int i = 0; i < 8; ++ i)
{ {
var ingredient = recipe.Ingredient[i]; var ingredient = recipe.Value.Ingredient[i];
if (ingredient == null || ingredient.Row == 0) if (!ingredient.IsValid || ingredient.RowId == 0)
continue; continue;
Item? item = ingredient.Value; Item item = ingredient.Value;
if (item == null || !IsValidItem(item.RowId)) if (!IsValidItem(item.RowId))
continue; continue;
Recipe? ingredientRecipe = GetFirstRecipeForItem(ingredient.Row); Recipe? ingredientRecipe = GetFirstRecipeForItem(ingredient.RowId);
//_pluginLog.Information($"Adding {item.Name}"); //_pluginLog.Information($"Adding {item.Name}");
ingredients.Add(new RecipeInfo ingredients.Add(new RecipeInfo
{ {
ItemId = ingredient.Row, ItemId = ingredient.RowId,
Name = item.Name, Name = item.Name.ToString(),
TotalQuantity = material.TotalQuantity * recipe.AmountIngredient[i], TotalQuantity = material.TotalQuantity * recipe.Value.AmountIngredient[i],
Type = Type =
_shopItemsOnly.Contains(ingredient.Row) ? Ingredient.EType.ShopItem : _shopItemsOnly.Contains(ingredient.RowId) ? Ingredient.EType.ShopItem :
ingredientRecipe != null ? Ingredient.EType.Craftable : ingredientRecipe != null ? Ingredient.EType.Craftable :
GetGatheringItem(ingredient.Row) != null ? Ingredient.EType.Gatherable : GetGatheringItem(ingredient.RowId) != null ? Ingredient.EType.Gatherable :
GetVentureItem(ingredient.Row) != null ? Ingredient.EType.Gatherable : GetVentureItem(ingredient.RowId) != null ? Ingredient.EType.Gatherable :
Ingredient.EType.Other, Ingredient.EType.Other,
AmountCrafted = ingredientRecipe?.AmountResult ?? 1, AmountCrafted = ingredientRecipe?.AmountResult ?? 1,
DependsOn = ingredientRecipe?.Ingredient.Where(x => x != null && IsValidItem(x.Row)) DependsOn = ingredientRecipe?.Ingredient.Where(x => x.IsValid && IsValidItem(x.RowId))
.Select(x => x.Row) .Select(x => x.RowId)
.ToList() .ToList()
?? new(), ?? new(),
}); });
@ -170,9 +171,9 @@ internal sealed class RecipeTree
Name = x.Ingredient.Name, Name = x.Ingredient.Name,
TotalQuantity = x.Ingredient.TotalQuantity, TotalQuantity = x.Ingredient.TotalQuantity,
Type = _shopItemsOnly.Contains(x.Ingredient.ItemId) ? Ingredient.EType.ShopItem : x.Ingredient.Type, Type = _shopItemsOnly.Contains(x.Ingredient.ItemId) ? Ingredient.EType.ShopItem : x.Ingredient.Type,
AmountCrafted = x.Recipe!.AmountResult, AmountCrafted = x.Recipe!.Value.AmountResult,
DependsOn = x.Recipe.Ingredient.Where(y => y != null && IsValidItem(y.Row)) DependsOn = x.Recipe.Value.Ingredient.Where(y => y.IsValid && IsValidItem(y.RowId))
.Select(y => y.Row) .Select(y => y.RowId)
.ToList(), .ToList(),
}) })
.ToList(); .ToList();
@ -180,18 +181,18 @@ internal sealed class RecipeTree
private Recipe? GetFirstRecipeForItem(uint itemId) private Recipe? GetFirstRecipeForItem(uint itemId)
{ {
return _dataManager.GetExcelSheet<Recipe>()!.FirstOrDefault(x => x.RowId > 0 && x.ItemResult.Row == itemId); return _dataManager.GetExcelSheet<Recipe>().FirstOrDefault(x => x.RowId > 0 && x.ItemResult.RowId == itemId);
} }
private GatheringItem? GetGatheringItem(uint itemId) private GatheringItem? GetGatheringItem(uint itemId)
{ {
return _dataManager.GetExcelSheet<GatheringItem>()!.FirstOrDefault(x => x.RowId > 0 && x.Item.Row == itemId); return _dataManager.GetExcelSheet<GatheringItem>().FirstOrDefault(x => x.RowId > 0 && x.Item.RowId == itemId);
} }
private RetainerTaskNormal? GetVentureItem(uint itemId) private RetainerTaskNormal? GetVentureItem(uint itemId)
{ {
return _dataManager.GetExcelSheet<RetainerTaskNormal>()! return _dataManager.GetExcelSheet<RetainerTaskNormal>()
.FirstOrDefault(x => x.RowId > 0 && x.Item.Row == itemId); .FirstOrDefault(x => x.RowId > 0 && x.Item.RowId == itemId);
} }
private static bool IsValidItem(uint itemId) private static bool IsValidItem(uint itemId)

View File

@ -1,9 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.Sheets;
namespace Workshoppa.GameData; namespace Workshoppa.GameData;
@ -15,41 +16,45 @@ internal sealed class WorkshopCache
{ {
try try
{ {
Dictionary<ushort, Item> itemMapping = dataManager.GetExcelSheet<CompanyCraftSupplyItem>()! Dictionary<uint, Item> itemMapping = dataManager.GetExcelSheet<CompanyCraftSupplyItem>()
.Where(x => x.RowId > 0) .Where(x => x.RowId > 0)
.ToDictionary(x => (ushort)x.RowId, x => x.Item.Value!); .ToDictionary(x => x.RowId, x => x.Item.Value);
Crafts = dataManager.GetExcelSheet<CompanyCraftSequence>()! Crafts = dataManager.GetExcelSheet<CompanyCraftSequence>()
.Where(x => x.RowId > 0) .Where(x => x.RowId > 0)
.Select(x => new WorkshopCraft .Select(x => new WorkshopCraft
{ {
WorkshopItemId = x.RowId, WorkshopItemId = x.RowId,
ResultItem = x.ResultItem.Row, ResultItem = x.ResultItem.RowId,
Name = x.ResultItem.Value!.Name.ToString(), Name = x.ResultItem.Value.Name.ToString(),
IconId = x.ResultItem.Value!.Icon, IconId = x.ResultItem.Value.Icon,
Category = (WorkshopCraftCategory)x.CompanyCraftDraftCategory.Row, Category = (WorkshopCraftCategory)x.CompanyCraftDraftCategory.RowId,
Type = x.CompanyCraftType.Row, Type = x.CompanyCraftType.RowId,
Phases = x.CompanyCraftPart.Where(part => part.Row != 0) Phases = x.CompanyCraftPart.Where(part => part.RowId != 0)
.SelectMany(part => .SelectMany(part =>
part.Value!.CompanyCraftProcess part.Value.CompanyCraftProcess
.Where(y => y.Value!.UnkData0.Any(z => z.SupplyItem > 0))
.Select(y => (Type: part.Value!.CompanyCraftType.Value, Process: y)))
.Select(y => new WorkshopCraftPhase .Select(y => new WorkshopCraftPhase
{ {
Name = y.Type!.Name.ToString(), Name = part.Value.CompanyCraftType.Value.Name.ToString(),
Items = y.Process.Value!.UnkData0 Items = Enumerable.Range(0, y.Value.SupplyItem.Count)
.Where(item => item.SupplyItem > 0) .Select(i => new
{
SupplyItem = y.Value.SupplyItem[i],
SetsRequired = y.Value.SetsRequired[i],
SetQuantity = y.Value.SetQuantity[i],
})
.Where(item => item.SupplyItem.RowId > 0)
.Select(item => new WorkshopCraftItem .Select(item => new WorkshopCraftItem
{ {
ItemId = itemMapping[item.SupplyItem].RowId, ItemId = itemMapping[item.SupplyItem.RowId].RowId,
Name = itemMapping[item.SupplyItem].Name.ToString(), Name = itemMapping[item.SupplyItem.RowId].Name.ToString(),
IconId = itemMapping[item.SupplyItem].Icon, IconId = itemMapping[item.SupplyItem.RowId].Icon,
SetQuantity = item.SetQuantity, SetQuantity = item.SetQuantity,
SetsRequired = item.SetsRequired, SetsRequired = item.SetsRequired,
}) })
.ToList() .ToList()
.AsReadOnly(), .AsReadOnly(),
}) }))
.ToList() .ToList()
.AsReadOnly(), .AsReadOnly(),
}) })

View File

@ -70,7 +70,7 @@ internal sealed class MainWindow : LWindow, IPersistableWindowConfig
public ButtonState State { get; set; } = ButtonState.None; public ButtonState State { get; set; } = ButtonState.None;
private bool IsDiscipleOfHand => private bool IsDiscipleOfHand =>
_clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.Id is >= 8 and <= 15; _clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.RowId is >= 8 and <= 15;
public WindowConfig WindowConfig => _configuration.MainWindowConfig; public WindowConfig WindowConfig => _configuration.MainWindowConfig;

View File

@ -1,6 +1,6 @@
<Project Sdk="Dalamud.NET.Sdk/9.0.2"> <Project Sdk="Dalamud.NET.Sdk/11.0.0">
<PropertyGroup> <PropertyGroup>
<Version>6.2</Version> <Version>7.0</Version>
<OutputPath>dist</OutputPath> <OutputPath>dist</OutputPath>
</PropertyGroup> </PropertyGroup>

View File

@ -4,9 +4,9 @@
"net8.0-windows7.0": { "net8.0-windows7.0": {
"DalamudPackager": { "DalamudPackager": {
"type": "Direct", "type": "Direct",
"requested": "[2.1.13, )", "requested": "[11.0.0, )",
"resolved": "2.1.13", "resolved": "11.0.0",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" "contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
}, },
"DotNet.ReproducibleBuilds": { "DotNet.ReproducibleBuilds": {
"type": "Direct", "type": "Direct",
@ -79,7 +79,7 @@
"llib": { "llib": {
"type": "Project", "type": "Project",
"dependencies": { "dependencies": {
"DalamudPackager": "[2.1.13, )" "DalamudPackager": "[11.0.0, )"
} }
} }
} }