// Call this if you don't want a level placed in RAM public void unpackWorld() { string dir = $"user://Worlds/{BinLoader.RootDirectory}"; GDKnyttAssetManager.ensureDirExists(dir); string marker_name = $"{dir}/_do_not_load_"; File marker = new File(); marker.Open(marker_name, File.ModeFlags.Write); marker.Close(); foreach (string filename in BinLoader.GetFileNames()) { string fullname = $"{dir}/{filename}"; GDKnyttAssetManager.ensureDirExists(fullname.Substring(0, fullname.LastIndexOf('/'))); File f = new File(); f.Open(fullname, File.ModeFlags.Write); f.StoreBuffer(BinLoader.GetFile(filename)); f.Close(); } new Directory().Remove(marker_name); new Directory().Remove(WorldDirectory); removeDirectory("user://Cache/" + GDKnyttAssetManager.extractFilename(WorldDirectory)); purgeBinFile(); setDirectory(dir, WorldDirectoryName); BinMode = false; }
public object getWorldSound(string filepath, bool loop) { if (BinMode) { var data = BinLoader.GetFile(filepath); if (data != null) { return(bytesToSound(data, loop)); } } else { var t = getExternalSound(filepath, loop); if (t != null) { return(t); } } return(getSystemSound(filepath, loop)); }
public object getWorldTexture(string filepath) { if (BinMode) { var data = BinLoader.GetFile(filepath); if (data != null) { return(bytesToTexture(data)); } } else { var t = getExternalTexture(filepath); if (t != null) { return(t); } } return(getSystemTexture(filepath)); }