diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-25 12:20:07 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-25 12:20:07 +0200 |
| commit | 34455230043d42e4324fc27483688a856851d65d (patch) | |
| tree | 967f1d30f471946ab2843e8023755becd7381075 /selection | |
| parent | a4db8814ccb2fc255bd909d8fa827ba23896322f (diff) | |
refactor: ECS bounds
Diffstat (limited to 'selection')
| -rw-r--r-- | selection/selection.go | 12 |
1 files changed, 6 insertions, 6 deletions
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 |
