From 34455230043d42e4324fc27483688a856851d65d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 25 Jul 2025 12:20:07 +0200 Subject: refactor: ECS bounds --- selection/selection.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'selection/selection.go') diff --git a/selection/selection.go b/selection/selection.go index d8fa6fe..eb12c91 100644 --- a/selection/selection.go +++ b/selection/selection.go @@ -40,12 +40,12 @@ func NewMultiple(start physics.Point, end physics.Point) Multiple { } } -func (m *Multiple) Preselect(position ecs.Component[physics.Point], bounds physics.Rectangle, selection *ecs.Component[Selection]) { - if !selection.IsEnabled { +func (m *Multiple) Preselect(position ecs.Component[physics.Point], relBounds ecs.Component[physics.Rectangle], selection *ecs.Component[Selection]) { + if !selection.IsEnabled || !position.IsEnabled || !relBounds.IsEnabled { return } selection.Value.IsSelected = false - if m.Bounds.Overlaps(bounds) { + if m.Bounds.Overlaps(physics.Translate(relBounds.Value, position.Value)) { m.Preselected = append(m.Preselected, selection) } } @@ -79,12 +79,12 @@ func NewSingle(cursor physics.Point) Single { } } -func (s *Single) Select(position ecs.Component[physics.Point], bounds physics.Rectangle, selection *ecs.Component[Selection]) { - if !selection.IsEnabled { +func (s *Single) Select(position ecs.Component[physics.Point], relBounds ecs.Component[physics.Rectangle], selection *ecs.Component[Selection]) { + if !selection.IsEnabled || !position.IsEnabled || !relBounds.IsEnabled { return } selection.Value.IsSelected = false - if s.HasSelected || !s.Cursor.In(bounds) { + if s.HasSelected || !s.Cursor.In(physics.Translate(relBounds.Value, position.Value)) { return } selection.Value.IsSelected = true -- cgit v1.3