Exemplo n.º 1
0
        private static MyStorageBase Load(MyVoxelMap voxelMap, Stream stream, string name)
        {
            Profiler.Begin("MyStorageBase.Load");
            try
            {
                string                  storageType = stream.ReadString();
                int                     version     = stream.Read7BitEncodedInt();
                MyStorageBase           storage     = null;
                MyVoxelStorageAttribute attr;
                if (!m_attributesByName.TryGetValue(storageType, out attr))
                {
                    Debug.Fail(string.Format("Encountered unknown storage type in voxel file: {0}", storageType));
                    return(null);
                }
                storage          = Activator.CreateInstance(attr.StorageType, name) as MyStorageBase;
                storage.VoxelMap = voxelMap;
                storage.LoadInternal(version, stream);

                return(storage);
            }
            finally
            {
                Profiler.End();
            }
        }
Exemplo n.º 2
0
        private void EnsureMutable()
        {
            if (!IsMutable)
            {
                MyStorageBase existingStorage = null;
                string        newName;
                do
                {
                    newName = string.Format("{0}-{1}", m_trueStorage.Name, MyVRageUtils.GetRandomInt(int.MaxValue).ToString("########"));
                    MySession.Static.VoxelMaps.TryGetStorage(newName, out existingStorage);
                }while(existingStorage != null);

                m_trueStorage = m_trueStorage.DeepCopy(newName);
                IsMutable     = true;
            }
        }
Exemplo n.º 3
0
        private void EnsureMutable()
        {
            if (!IsMutable)
            {
                MyStorageBase existingStorage = null;
                string newName;
                do
                {
                    newName = string.Format("{0}-{1}", m_trueStorage.Name, MyVRageUtils.GetRandomInt(int.MaxValue).ToString("########"));
                    MySession.Static.VoxelMaps.TryGetStorage(newName, out existingStorage);
                }
                while(existingStorage != null);

                m_trueStorage = m_trueStorage.DeepCopy(newName);
                IsMutable = true;
            }
        }
Exemplo n.º 4
0
 void IMyStorage.Close()
 {
     m_trueStorage.Close();
     m_trueStorage = null;
 }
Exemplo n.º 5
0
 public MyProxyStorage(bool isMutable, MyStorageBase trueStorage)
 {
     m_trueStorage = trueStorage;
     IsMutable = isMutable;
 }
Exemplo n.º 6
0
        public void Init(MyStorageBase storage, bool isStorageMutable)
        {
            Flags |= EntityFlags.NeedsUpdate10;
            SyncFlag = true;

            base.Init(null);

            m_storage = new MyProxyStorage(isStorageMutable, storage);
            InitVoxelMap(Vector3.Zero);
            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }
Exemplo n.º 7
0
 void IMyStorage.Close()
 {
     m_trueStorage.Close();
     m_trueStorage = null;
 }
Exemplo n.º 8
0
 public MyProxyStorage(bool isMutable, MyStorageBase trueStorage)
 {
     m_trueStorage = trueStorage;
     IsMutable     = isMutable;
 }