Renew IPC mechanism

This commit is contained in:
Ottermandias 2021-09-01 21:49:49 +02:00
parent db23235191
commit 041485cad4
4 changed files with 64 additions and 13 deletions

View file

@ -0,0 +1,40 @@
using System;
using Lumina.Excel.GeneratedSheets;
using Action = Lumina.Excel.GeneratedSheets.Action;
namespace Penumbra.GameData.Enums
{
public enum ChangedItemType
{
None,
Item,
Action,
Customization,
}
public static class ChangedItemExtensions
{
public static (ChangedItemType, uint) ChangedItemToTypeAndId( object? item )
{
return item switch
{
null => ( ChangedItemType.None, 0 ),
Item i => ( ChangedItemType.Item, i.RowId ),
Action a => ( ChangedItemType.Action, a.RowId ),
_ => ( ChangedItemType.Customization, 0 ),
};
}
public static object? GetObject( this ChangedItemType type, uint id )
{
return type switch
{
ChangedItemType.None => null,
ChangedItemType.Item => ObjectIdentification.DataManager?.GetExcelSheet< Item >()?.GetRow( id ),
ChangedItemType.Action => ObjectIdentification.DataManager?.GetExcelSheet< Action >()?.GetRow( id ),
ChangedItemType.Customization => null,
_ => throw new ArgumentOutOfRangeException( nameof( type ), type, null )
};
}
}
}

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;

View file

@ -13,6 +13,7 @@ namespace Penumbra.GameData
{
internal class ObjectIdentification : IObjectIdentifier
{
public static DataManager? DataManager = null!;
private readonly List< (ulong, HashSet< Item >) > _weapons;
private readonly List< (ulong, HashSet< Item >) > _equipment;
private readonly Dictionary< string, HashSet< Action > > _actions;
@ -66,6 +67,7 @@ namespace Penumbra.GameData
public ObjectIdentification( DataManager dataManager, ClientLanguage clientLanguage )
{
DataManager = dataManager;
var items = dataManager.GetExcelSheet< Item >( clientLanguage )!;
SortedList< ulong, HashSet< Item > > weapons = new();
SortedList< ulong, HashSet< Item > > equipment = new();