38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
#pragma warning disable CS8601 // Possible null reference assignment.
|
|
#pragma warning disable CS8603 // Possible null reference return.
|
|
namespace Fantasy;
|
|
|
|
public sealed partial class ContainerConfigData
|
|
{
|
|
private readonly Dictionary<int, ContainerConfig> _configsByType = new Dictionary<int, ContainerConfig>();
|
|
|
|
public override void EndInit()
|
|
{
|
|
foreach (var containerConfig in List)
|
|
{
|
|
_configsByType.Add(containerConfig.Type, containerConfig);
|
|
}
|
|
}
|
|
|
|
public ContainerConfig GetConfig(ContainerType containerType)
|
|
{
|
|
if (!_configsByType.TryGetValue((int)containerType, out var config))
|
|
{
|
|
Log.Error($"containerType {containerType} not found!");
|
|
return null;
|
|
}
|
|
|
|
return config;
|
|
}
|
|
|
|
public bool TryGetConfig(ContainerType containerType, out ContainerConfig containerConfig)
|
|
{
|
|
if (!_configsByType.TryGetValue((int)containerType, out containerConfig))
|
|
{
|
|
Log.Error($"containerType {containerType} not found!");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
} |