From 3664d6f796a6e906e91f424a9fbb692a8a1e8496 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 19:48:53 -0800 Subject: [PATCH] add source --- Cargo.toml | 2 +- src/source.rs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f7e925f..1faa702 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [features] legacy = ["dep:lazy-regex"] #roblox = [] -#source = [] +source = [] [dependencies] lazy-regex = { version = "3.1.0", optional = true } diff --git a/src/source.rs b/src/source.rs index e69de29..a51b9fb 100644 --- a/src/source.rs +++ b/src/source.rs @@ -0,0 +1,38 @@ +use std::io::Read; +use std::path::PathBuf; +use std::collections::HashMap; +use crate::texture::{Texture,Textures}; +use strafesnet_common::model::{MeshId,TextureId}; +pub struct Loader{ + texture_paths:HashMap, + mesh_paths:HashMap, +} +impl Loader{ + pub fn new()->Self{ + Self{ + texture_paths:HashMap::new(), + mesh_paths:HashMap::new(), + } + } +} + +//cannot fail atm +enum AcquireTextureError{} +enum AcquireMeshError{} + +impl Loader{ + pub fn acquire_texture_id(&mut self,name:&str)->TextureId{ + let texture_id=TextureId::new(self.texture_paths.len() as u32); + *self.texture_paths.entry(name.into()).or_insert(texture_id) + } + pub fn acquire_mesh_id(&mut self,name:&str)->MeshId{ + let texture_id=MeshId::new(self.mesh_paths.len() as u32); + *self.mesh_paths.entry(name.into()).or_insert(texture_id) + } + pub fn load_textures(&self)->Result{ + Ok(Textures::new(Vec::new())) + } + // fn load_meshes(&self)->Result{ + // Ok(Meshes::new(Vec::new())) + // } +} \ No newline at end of file