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(); } }
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; } }
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; } }
void IMyStorage.Close() { m_trueStorage.Close(); m_trueStorage = null; }
public MyProxyStorage(bool isMutable, MyStorageBase trueStorage) { m_trueStorage = trueStorage; IsMutable = isMutable; }
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; }