private static object DoLoad(string file, string ext) { if (ext == "grf") { return(File.OpenRead(file)); } else { using (var br = ReadSync(file)) { if (br == null) { throw new Exception($"Could not load file: {file}"); } switch (ext) { // Images case "jpg": case "jpeg": case "png": return(new RawImage() { data = br.ToArray() }); case "bmp": return(loader.LoadBMP(br)); case "tga": return(TGALoader.LoadTGA(br)); // Text case "txt": case "xml": case "lua": return(Encoding.UTF8.GetString(br.ToArray())); case "spr": SPR spr = SpriteLoader.Load(br); spr.SwitchToRGBA(); spr.Compile(); spr.filename = file; return(spr); case "str": return(EffectLoader.Load(br, Path.GetDirectoryName(file).Replace("\\", "/"))); case "act": return(ActionLoader.Load(br)); // Binary case "gat": return(AltitudeLoader.Load(br)); case "rsw": return(WorldLoader.Load(br)); case "gnd": return(GroundLoader.Load(br)); case "rsm": return(ModelLoader.Load(br)); // Audio case "wav": WAVLoader.WAVFile wav = WAVLoader.OpenWAV(br.ToArray()); AudioClip clip = AudioClip.Create(file, wav.samples, wav.channels, wav.sampleRate, false); clip.SetData(wav.leftChannel, 0); return(clip); case "mp3": case "ogg": break; case "json": return(JObject.Parse(Encoding.UTF8.GetString(br.ToArray()))); default: throw new Exception($"Unsuported file format: {ext} for file {file}"); } } } return(null); }
public Altitude(BinaryReader stream) { gat = AltitudeLoader.Load(stream); init(gat); }
public Altitude(ROIO.Utils.MemoryStreamReader stream) { gat = AltitudeLoader.Load(stream); init(gat); }
public Altitude(BinaryReader stream) { gat = AltitudeLoader.Load(stream); //TODO init pathfinding }