48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package tins2020
|
|
|
|
type Flower struct {
|
|
ID string
|
|
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 anemone, a very generic flower that thrives in a moderate climate.
|
|
func NewPoppyTraits() FlowerTraits {
|
|
return FlowerTraits{
|
|
Spread: 0.0004,
|
|
Life: 0.99993,
|
|
Resistance: FlowerResistance{
|
|
Cold: 0.5,
|
|
Hot: 0.7,
|
|
Dry: 0.5,
|
|
Wet: 0.7,
|
|
},
|
|
}
|
|
}
|