// We need to set the correct collection for the actual material path that is loaded // before actually loading the file. private bool MtrlLoadHandler(Utf8String split, Utf8String path, ResourceManager *resourceManager, SeFileDescriptor *fileDescriptor, int priority, bool isSync, out byte ret) { ret = 0; if (fileDescriptor->ResourceHandle->FileType != ResourceType.Mtrl) { return(false); } var lastUnderscore = split.LastIndexOf(( byte )'_'); var name = lastUnderscore == -1 ? split.ToString() : split.Substring(0, lastUnderscore).ToString(); if (Penumbra.CollectionManager.ByName(name, out var collection)) { #if DEBUG PluginLog.Verbose("Using MtrlLoadHandler with collection {$Split:l} for path {$Path:l}.", name, path); #endif SetCollection(path, collection); } else { #if DEBUG PluginLog.Verbose("Using MtrlLoadHandler with no collection for path {$Path:l}.", path); #endif } // Force isSync = true for this call. I don't really understand why, // or where the difference even comes from. // Was called with True on my client and with false on other peoples clients, // which caused problems. ret = Penumbra.ResourceLoader.DefaultLoadResource(path, resourceManager, fileDescriptor, priority, true); PathCollections.TryRemove(path, out _); return(true); }
private void LoadMtrlHelper(IntPtr mtrlResourceHandle) { if (mtrlResourceHandle == IntPtr.Zero) { return; } var mtrl = ( MtrlResource * )mtrlResourceHandle; var mtrlPath = Utf8String.FromSpanUnsafe(mtrl->Handle.FileNameSpan(), true, null, true); _mtrlCollection = PathCollections.TryGetValue(mtrlPath, out var c) ? c : null; }