Move Object Identification and Path Parsing to GameData, create initializable static Identifier in GameData.

This commit is contained in:
Ottermandias 2021-07-25 02:41:36 +02:00
parent b93c5376de
commit 702f8e3967
13 changed files with 88 additions and 35 deletions

View file

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using Penumbra.GameData.Util;
namespace Penumbra.GameData
{
public static class ObjectIdentifier
{
private static ObjectIdentification? _identification = null;
public static bool Initialize( DalamudPluginInterface pi )
{
if( _identification != null )
{
return true;
}
try
{
_identification = new ObjectIdentification( pi );
return true;
}
catch( Exception e )
{
_identification = null;
PluginLog.Error( $"Failure while initializing Object Identifier:\n{e}" );
return false;
}
}
private static void Verify()
{
if( _identification == null )
{
throw new Exception( "Object Identifier not initialized." );
}
}
public static void Identify( IDictionary< string, object? > set, GamePath path )
{
Verify();
_identification!.Identify( set, path );
}
public static Dictionary< string, object? > Identify( GamePath path )
{
Dictionary< string, object? > ret = new();
Identify( ret, path );
return ret;
}
public static Item? Identify( SetId setId, WeaponType weaponType, ushort variant, EquipSlot slot )
{
Verify();
return _identification!.Identify( setId, weaponType, variant, slot );
}
}
}