From 0da52009164975394989cd9444665f18c503a6d5 Mon Sep 17 00:00:00 2001 From: lisk77 Date: Fri, 25 Jul 2025 00:25:56 +0200 Subject: [PATCH] feat(ecs): added utility methods --- crates/comet_ecs/src/component.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/comet_ecs/src/component.rs b/crates/comet_ecs/src/component.rs index c98d172..1e4d604 100755 --- a/crates/comet_ecs/src/component.rs +++ b/crates/comet_ecs/src/component.rs @@ -227,8 +227,11 @@ impl Position3D { } impl Rectangle2D { - pub fn new(position: Position2D, size: v2) -> Self { - Self { position, size } + pub fn with_size(width: f32, height: f32) -> Self { + Self { + position: Position2D::from_vec(v2::new(0.0, 0.0)), + size: v2::new(width, height), + } } pub fn position(&self) -> Position2D { @@ -262,6 +265,16 @@ impl Collider for Rectangle2D { } } +impl Render2D { + pub fn with_texture(texture: &'static str) -> Self { + Self { + is_visible: true, + texture_name: texture, + scale: v2::new(1.0, 1.0), + } + } +} + impl Render for Render2D { fn is_visible(&self) -> bool { self.is_visible