Beispiel #1
0
        public static bool CreateFromResRef(ResRefType resRefType, string resRef, Action <CResGFF, CResStruct> deserializeAction)
        {
            if (string.IsNullOrEmpty(resRef))
            {
                return(false);
            }

            if (!ResourceManager.IsValidResource(resRef, resRefType))
            {
                return(false);
            }

            CResGFF resGff = new CResGFF((ushort)resRefType, $"{resRefType} ".GetNullTerminatedString(), resRef.ToResRef());

            if (!resGff.m_bLoaded.ToBool())
            {
                Log.Warn($"Unable to load ResRef: {resRef}");
                return(false);
            }

            CResStruct resStruct = new CResStruct();

            resGff.GetTopLevelStruct(resStruct).ToBool();
            deserializeAction(resGff, resStruct);

            resStruct.Dispose();
            resGff.Dispose();
            return(true);
        }
Beispiel #2
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Module = (NwModule)objSelf;
     Alias  = EventsPlugin.GetEventData("ALIAS");
     ResRef = EventsPlugin.GetEventData("RESREF");
     Type   = (ResRefType)EventsPlugin.GetEventData("TYPE").ParseInt();
 }
Beispiel #3
0
 public static string GetFirstResRef(ResRefType type, string regexFilter = "", bool moduleResourcesOnly = true)
 {
     Internal.NativeFunctions.nwnxSetFunction(PLUGIN_NAME, "GetFirstResRef");
     Internal.NativeFunctions.nwnxPushInt(moduleResourcesOnly ? 1 : 0);
     Internal.NativeFunctions.nwnxPushString(regexFilter);
     Internal.NativeFunctions.nwnxPushInt((int)type);
     Internal.NativeFunctions.nwnxCallFunction();
     return(Internal.NativeFunctions.nwnxPopString());
 }
Beispiel #4
0
 /// <summary>
 /// Determines if the supplied resref exists and is of the specified type.
 /// </summary>
 /// <param name="resRef">The resref to check.</param>
 /// <param name="type">The type of this resref.</param>
 /// <returns>true if the supplied resref exists and is of the specified type, otherwise false.</returns>
 public static int IsValidResRef(this string resRef, ResRefType type = ResRefType.Creature) => UtilPlugin.IsValidResRef(resRef);
 public void InvalidResourceIsUnavailable(ResRefType resRefType)
 {
     Assert.That(ResourceManager.IsValidResource("invalid_res", resRefType), Is.False);
 }