2020-05-09 17:34:43 +00:00
|
|
|
package tins2020
|
|
|
|
|
|
|
|
type Flower struct {
|
|
|
|
Traits FlowerTraits
|
|
|
|
}
|
|
|
|
|
|
|
|
type FlowerTraits struct {
|
|
|
|
Spread float32
|
|
|
|
Life float32
|
|
|
|
LifeModifier float32
|
|
|
|
Resistance FlowerResistance
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *FlowerTraits) UpdateModifier(temp, humid float32) {
|
|
|
|
mod := float32(1)
|
|
|
|
cold := temp * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Cold*t.Resistance.Cold+cold*cold))
|
|
|
|
hot := (1 - temp) * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Hot*t.Resistance.Hot+hot*hot))
|
|
|
|
dry := humid * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Dry*t.Resistance.Dry+dry*dry))
|
|
|
|
wet := (1 - humid) * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Wet*t.Resistance.Wet+wet*wet))
|
|
|
|
t.LifeModifier = mod
|
|
|
|
}
|
|
|
|
|
|
|
|
type FlowerResistance struct {
|
|
|
|
Cold float32 // 0 will die almost instantly, 1 is completely resistant.
|
|
|
|
Hot float32
|
|
|
|
Dry float32
|
|
|
|
Wet float32
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewPoppyTraits creates the traits of a poppy, a very generic flower that thrives in a moderate climate.
|
|
|
|
func NewPoppyTraits() FlowerTraits {
|
|
|
|
return FlowerTraits{
|
2020-05-09 22:19:44 +00:00
|
|
|
Spread: 0.0007,
|
|
|
|
Life: 0.99991,
|
2020-05-09 17:34:43 +00:00
|
|
|
Resistance: FlowerResistance{
|
|
|
|
Cold: 0.3,
|
|
|
|
Hot: 0.3,
|
|
|
|
Dry: 0.3,
|
|
|
|
Wet: 0.3,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|