2020-05-10 21:00:19 +00:00
|
|
|
package tins2020
|
|
|
|
|
|
|
|
type Map struct {
|
|
|
|
Temp NoiseMap
|
|
|
|
Humid NoiseMap
|
|
|
|
Variant NoiseMap
|
|
|
|
PlaceX NoiseMap // displacement map of props
|
|
|
|
PlaceY NoiseMap
|
|
|
|
|
2020-05-11 01:09:01 +00:00
|
|
|
Center Point
|
2020-05-10 21:00:19 +00:00
|
|
|
Flowers map[Point]Flower
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Map) AddFlower(pos Point, id string, traits FlowerTraits) {
|
|
|
|
m.Flowers[pos] = m.NewFlower(pos, id, traits)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Map) DigFlower(pos Point) string {
|
|
|
|
flower, ok := m.Flowers[pos]
|
|
|
|
if !ok {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
delete(m.Flowers, pos)
|
|
|
|
return flower.ID
|
|
|
|
}
|
|
|
|
|
2020-05-11 12:41:42 +00:00
|
|
|
func (m *Map) HasFlower(pos Point) bool {
|
|
|
|
_, ok := m.Flowers[pos]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2020-05-10 21:00:19 +00:00
|
|
|
func (m *Map) NewFlower(pos Point, id string, traits FlowerTraits) Flower {
|
|
|
|
flower := Flower{
|
|
|
|
ID: id,
|
|
|
|
Traits: traits,
|
|
|
|
}
|
|
|
|
temp, humid := float32(m.Temp.Value(pos.X, pos.Y)), float32(m.Humid.Value(pos.X, pos.Y))
|
|
|
|
flower.Traits.UpdateModifier(temp, humid)
|
|
|
|
return flower
|
|
|
|
}
|