remove game object handles

This commit is contained in:
2021-10-14 05:30:55 +02:00
parent ea9490ad3a
commit ba172ea332
5 changed files with 110 additions and 114 deletions

View File

@@ -39,6 +39,10 @@ impl GameObject {
descriptor_sets: vec![], is_selected: false, pipeline_index: mesh.pipeline_index }
}
pub fn init_descriptor_sets(&mut self, renderer: &mut VulkanRenderer) {
self.descriptor_sets = renderer.pipelines[self.pipeline_index].create_descriptor_set(&self.textures, renderer);
}
pub fn _set_position(&mut self, x: f32, y: f32, z: f32) {
self.position.x = x;
self.position.y = y;
@@ -80,21 +84,8 @@ impl GameObject {
}
}
#[derive(Debug, Clone, Copy)]
pub struct GameObjectHandle {
pub object_index: usize
}
impl GameObjectHandle {
pub fn get_game_object<'a>(&self, renderer: &'a VulkanRenderer) -> Option<&'a GameObject> {
renderer.game_data.game_objects.get(self.object_index)
}
pub fn get_game_object_mut<'a>(&mut self, renderer: &'a mut VulkanRenderer) -> Option<&'a mut GameObject> {
renderer.game_data.game_objects.get_mut(self.object_index)
}
}
pub type GameObjectHandle = usize;
pub trait Updatable {
fn update(&mut self, delta_time: f32, input: &InputState, renderer: &mut VulkanRenderer);
fn update(&mut self, delta_time: f32, input: &InputState, renderer: &mut VulkanRenderer, game_objects: &mut Vec<GameObject>);
}