aboutsummaryrefslogtreecommitdiff
path: root/entity.go
diff options
context:
space:
mode:
Diffstat (limited to 'entity.go')
-rw-r--r--entity.go34
1 files changed, 21 insertions, 13 deletions
diff --git a/entity.go b/entity.go
index e111f06..cf3f4ac 100644
--- a/entity.go
+++ b/entity.go
@@ -27,64 +27,72 @@ func (e Entity) Bounds() physics.Rectangle {
}
}
-type EntityBuilder Entity
+type EntityBuilder struct {
+ entity Entity
+}
+
+func NewEntityBuilder() EntityBuilder {
+ return EntityBuilder{
+ entity: Entity{},
+ }
+}
func (b EntityBuilder) WithPosition(position physics.Point) EntityBuilder {
- b.Position = ecs.C(position)
+ b.entity.Position = ecs.C(position)
return b
}
func (b EntityBuilder) WithImage(image *ebiten.Image) EntityBuilder {
- b.Image = ecs.C(image)
+ b.entity.Image = ecs.C(image)
return b
}
var red = color.RGBA{0xff, 0x00, 0x00, 0xff}
func (b EntityBuilder) WithSelection(haloKind string) EntityBuilder {
- b.Selection = ecs.C(Selection{
+ b.entity.Selection = ecs.C(Selection{
IsSelected: false,
Halo: nil,
})
switch haloKind {
case "round":
- b.Selection.Value.Halo = NewStrokeCircleImage(110, SELECTION_HALO_WIDTH, red)
+ b.entity.Selection.Value.Halo = NewStrokeCircleImage(110, SELECTION_HALO_WIDTH, red)
case "square":
- b.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
}
func (b EntityBuilder) WithResourceStorage() EntityBuilder {
- b.ResourceStorage = ecs.C(ResourceStorage{})
+ b.entity.ResourceStorage = ecs.C(ResourceStorage{})
return b
}
func (b EntityBuilder) WithResourceSource(amount int) EntityBuilder {
- b.ResourceSource = ecs.C(ResourceSource{Remaining: amount})
+ b.entity.ResourceSource = ecs.C(ResourceSource{Remaining: amount})
return b
}
func (b EntityBuilder) WithSpawn(spawn Spawn) EntityBuilder {
- b.Spawn = ecs.C(spawn)
+ b.entity.Spawn = ecs.C(spawn)
return b
}
func (b EntityBuilder) WithMove() EntityBuilder {
- b.Move = ecs.C(physics.Move{IsActive: false})
+ b.entity.Move = ecs.C(physics.Move{IsActive: false})
return b
}
func (b EntityBuilder) WithOrder() EntityBuilder {
- b.Order.IsEnabled = true
+ b.entity.Order.IsEnabled = true
return b
}
func (b EntityBuilder) WithResourceGatherer(maxCapacity int) EntityBuilder {
- b.ResourceGatherer = ecs.C(ResourceGatherer{MaxCapacity: maxCapacity})
+ b.entity.ResourceGatherer = ecs.C(ResourceGatherer{MaxCapacity: maxCapacity})
return b
}
func (b EntityBuilder) Build() Entity {
- return Entity(b)
+ return b.entity
}