public bool TryAllocateTag(out CachedTagInstance result, Type type, string name = null)
{
result = null;
try
{
var structure = TagStructure.GetTagStructureInfo(type, Version).Structure;
if (structure == null)
{
Console.WriteLine($"TagStructure attribute not found for type \"{type.Name}\".");
return(false);
}
var groupTag = new Tag(structure.Tag);
if (!TagGroup.Instances.ContainsKey(groupTag))
{
Console.WriteLine($"TagGroup not found for type \"{type.Name}\" ({structure.Tag}).");
return(false);
}
result = TagCache.AllocateTag(TagGroup.Instances[groupTag], name);
if (result == null)
{
return(false);
}
}
catch (Exception e)
{
Console.WriteLine($"{e.GetType().Name}: {e.Message}");
return(false);
}
return(true);
}