last_light/game/npc/npc.go

49 lines
873 B
Go
Raw Normal View History

2024-05-30 23:39:54 +03:00
package npc
2024-05-12 23:22:39 +03:00
import (
"mvvasilev/last_light/engine"
"github.com/gdamore/tcell/v2"
"github.com/google/uuid"
)
2024-06-01 11:20:51 +03:00
type NPC interface {
Name() string
MovableEntity
}
2024-05-21 23:08:51 +03:00
type BasicNPC struct {
2024-06-01 11:20:51 +03:00
id uuid.UUID
name string
presentation rune
style tcell.Style
2024-05-12 23:22:39 +03:00
engine.Positioned
}
2024-06-01 11:20:51 +03:00
func CreateNPC(pos engine.Position, name string, presentation rune, style tcell.Style) *BasicNPC {
2024-05-21 23:08:51 +03:00
return &BasicNPC{
2024-06-01 11:20:51 +03:00
id: uuid.New(),
name: name,
presentation: presentation,
style: style,
Positioned: engine.WithPosition(pos),
2024-05-12 23:22:39 +03:00
}
}
2024-06-01 11:20:51 +03:00
func (c *BasicNPC) Name() string {
return c.name
}
2024-05-21 23:08:51 +03:00
func (c *BasicNPC) MoveTo(newPosition engine.Position) {
2024-05-12 23:22:39 +03:00
c.Positioned.SetPosition(newPosition)
}
2024-05-21 23:08:51 +03:00
func (c *BasicNPC) UniqueId() uuid.UUID {
2024-05-12 23:22:39 +03:00
return c.id
}
2024-06-01 11:20:51 +03:00
func (c *BasicNPC) Presentation() (rune, tcell.Style) {
return c.presentation, c.style
2024-05-12 23:22:39 +03:00
}