Files
TarnaWijaya 26ed99fda6
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
up3
2026-07-09 08:33:57 +08:00

37 lines
980 B
Go

package effect
import (
"github.com/df-mc/dragonfly/server/world"
"image/color"
)
// Regeneration is an effect that causes the entity that it is added to slowly
// regenerate health. The level of the effect influences the speed with which
// the entity regenerates.
var Regeneration regeneration
type regeneration struct {
nopLasting
}
// Apply applies health to the world.Entity passed if the duration of the effect is at the right tick.
func (regeneration) Apply(e world.Entity, eff Effect) {
interval := max(50>>(eff.Level()-1), 1)
if eff.Tick()%interval == 0 {
if l, ok := e.(living); ok {
l.Heal(1, RegenerationHealingSource{})
}
}
}
// RGBA ...
func (regeneration) RGBA() color.RGBA {
return color.RGBA{R: 0xcd, G: 0x5c, B: 0xab, A: 0xff}
}
// RegenerationHealingSource is a healing source used when an entity regenerates
// health from an effect.regeneration.
type RegenerationHealingSource struct{}
func (RegenerationHealingSource) HealingSource() {}