示例#1
0
        public ObjectStorage GetObjectStorage(ICGameObject gameObject)
        {
            if (!objectStorage.TryGetValue(gameObject.Pointer, out ObjectStorage? storage))
            {
                storage = new ObjectStorage();
                objectStorage[gameObject.Pointer] = storage;
            }

            return(storage);
        }
示例#2
0
        internal ObjectStorage Clone()
        {
            ObjectStorage clone = new ObjectStorage
            {
                intMap    = new Dictionary <string, ObjectStorageValue <int> >(intMap),
                floatMap  = new Dictionary <string, ObjectStorageValue <float> >(floatMap),
                stringMap = new Dictionary <string, ObjectStorageValue <string> >(stringMap),
            };

            return(clone);
        }
示例#3
0
        private int OnLoadFromGff(void *pUUID, void *pRes, void *pStruct)
        {
            CNWSUUID   uuid      = CNWSUUID.FromPointer(pUUID);
            CResGFF    resGff    = CResGFF.FromPointer(pRes);
            CResStruct resStruct = CResStruct.FromPointer(pStruct);

            bool hasAnvilPos = resGff.TryReadCExoString(resStruct, AnvilGffFieldNamePtr, out CExoString anvilSerialized);
            bool hasNwnxPos  = resGff.TryReadCExoString(resStruct, NWNXGffFieldNamePtr, out CExoString nwnxSerialized);

            if (!hasAnvilPos && !hasNwnxPos)
            {
                return(loadFromGffHook.CallOriginal(pUUID, pRes, pStruct));
            }

            ObjectStorage storage = GetObjectStorage(uuid.m_parent);

            storage.Clear();

            if (hasNwnxPos)
            {
                try
                {
                    storage.Deserialize(nwnxSerialized.ToString());
                }
                catch (Exception e)
                {
                    Log.Error(e, "Failed to import NWNX object storage");
                }
            }

            if (hasAnvilPos)
            {
                try
                {
                    storage.Deserialize(anvilSerialized.ToString());
                }
                catch (Exception e)
                {
                    Log.Error(e, "Failed to load Anvil object storage");
                }
            }

            return(loadFromGffHook.CallOriginal(pUUID, pRes, pStruct));
        }