From 563b9ee704a14322ed4805896c4f8ca3fa5df03a Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 25 Jul 2025 11:41:19 +0200 Subject: feat: Selection with priority --- entity.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'entity.go') diff --git a/entity.go b/entity.go index cf3f4ac..2b120f5 100644 --- a/entity.go +++ b/entity.go @@ -3,6 +3,7 @@ package main import ( "age_of_empires/ecs" "age_of_empires/physics" + "age_of_empires/selection" "image/color" "github.com/hajimehoshi/ebiten/v2" @@ -11,7 +12,7 @@ import ( type Entity struct { Position ecs.Component[physics.Point] Image ecs.Component[*ebiten.Image] - Selection ecs.Component[Selection] + Selection ecs.Component[selection.Selection] Move ecs.Component[physics.Move] Order ecs.Component[Order] ResourceGatherer ecs.Component[ResourceGatherer] @@ -49,16 +50,17 @@ func (b EntityBuilder) WithImage(image *ebiten.Image) EntityBuilder { var red = color.RGBA{0xff, 0x00, 0x00, 0xff} -func (b EntityBuilder) WithSelection(haloKind string) EntityBuilder { - b.entity.Selection = ecs.C(Selection{ +func (b EntityBuilder) WithSelection(haloKind string, priority selection.Priority) EntityBuilder { + b.entity.Selection = ecs.C(selection.Selection{ IsSelected: false, Halo: nil, + Priority: priority, }) switch haloKind { case "round": - b.entity.Selection.Value.Halo = NewStrokeCircleImage(110, SELECTION_HALO_WIDTH, red) + b.entity.Selection.Value.Halo = NewStrokeCircleImage(110, selection.HALO_WIDTH, red) case "square": - b.entity.Selection.Value.Halo = NewStrokeRectangleImage(physics.Point{X: 110, Y: 110}, SELECTION_HALO_WIDTH, red) + b.entity.Selection.Value.Halo = NewStrokeRectangleImage(physics.Point{X: 110, Y: 110}, selection.HALO_WIDTH, red) } return b } -- cgit v1.3