Beispiel #1
0
        public void DeleteObject(AssetsObject assetsObject)
        {
            Log.LogMsg($"Deleting object of type {assetsObject.GetType().Name}");
            //TODO: implement dispose on these or something?
            var obj = Metadata.ObjectInfos.FirstOrDefault(x => x == assetsObject.ObjectInfo);

            if (obj == null)
            {
                Log.LogErr("Tried to delete an object that wasn't part of this file");
                return;
            }

            Metadata.ObjectInfos.Remove(assetsObject.ObjectInfo);
            //TODO: IDs need to be shored up at all?  reflection loop through all objects looking for refs?

            CleanupPtrs(assetsObject.ObjectInfo);
        }
Beispiel #2
0
        public static SmartPtr <T> Read(AssetsFile assetsFile, AssetsObject owner, AssetsReader reader)
        {
            if (owner == null)
            {
                Log.LogErr("WARNING: SmartPtr created without an owner!");
            }
            int fileID = reader.ReadInt32();

            reader.AlignTo(4);
            Int64 pathID = reader.ReadInt64();

            if (fileID == 0 && pathID == 0)
            {
                return(new SmartPtr <T>());
            }

            var objInfo = assetsFile.GetObjectInfo <T>(fileID, pathID);

            if (objInfo == null)
            {
                Log.LogErr($"WARNING: Could not find objectinfo for creating SmartPtr of type {typeof(T).Name} on owner type {owner?.GetType()?.Name ?? "(null owner)"}!  Returned a null pointer instead.");
                return(null);
            }

            SmartPtr <T> ptr = new SmartPtr <T>(owner, assetsFile.GetObjectInfo <T>(fileID, pathID));

            //TODO: not sure this is only ever called by existing objects
            ptr.IsNew = false;

            return(ptr);
        }