/// <summary> /// Gets the specified Gff resource. /// </summary> /// <param name="name">The resource name to fetch, without any filetype extensions.</param> /// <param name="type">The type of the file/resource.</param> /// <returns>A <see cref="GffResource"/> representation of the specified resource if it exists, otherwise null.</returns> public GffResource?GetGenericFile(string name, ResRefType type) { CResRef resRef = new CResRef(name); if (!ResMan.Exists(resRef, (ushort)type).ToBool()) { return(null); } CResGFF gff = new CResGFF((ushort)type, $"{type.ToString()} ".GetNullTerminatedString(), resRef); return(new GffResource(name, gff)); }
private bool TryGetNativeResource(string name, ResRefType type, [NotNullWhen(true)] out CRes?res) { res = default; CResRef resRef = new CResRef(name); if (!ResMan.Exists(resRef, (ushort)type).ToBool()) { return(false); } res = ResMan.GetResObject(resRef, (ushort)type); return(res != null); }
private uint OnModuleLoadProgressChange(void *pModule, int nAreasLoaded, int nAreasToLoad) { CNWSModule module = CNWSModule.FromPointer(pModule); int index = nAreasLoaded; CExoLinkedListNode node = module.m_lstModuleArea.m_pcExoLinkedListInternal.pHead; while (node != null && index != 0) { node = node.pNext; index--; } CResRef?resRef = node != null?CResRef.FromPointer(node.pObject) : null; if (resRef != null) { Log.Debug("Loading area {Area} ({AreaNum}/{AreaCount})", resRef.ToString(), nAreasLoaded + 1, nAreasToLoad); } uint retVal = loadModuleInProgressHook.CallOriginal(pModule, nAreasLoaded, nAreasToLoad); if (resRef != null) { switch (retVal) { case 0: Log.Debug("Loaded area {Area} ({AreaNum}/{AreaCount})", resRef.ToString(), nAreasLoaded + 1, nAreasToLoad); break; default: Log.Error("Failed to load area {Area}, error code {ErrorCode} ({AreaNum}/{AreaCount})", resRef.ToString(), retVal, nAreasLoaded + 1, nAreasToLoad); break; } } return(retVal); }
public static bool TryReadCResRef(this CResGFF resGff, CResStruct resStruct, byte *fieldName, out CResRef value) { int bSuccess; value = resGff.ReadFieldCResRef(resStruct, fieldName, &bSuccess); return(bSuccess.ToBool()); }