last_light/game/npc/entity.go

62 lines
808 B
Go
Raw Normal View History

2024-05-30 23:39:54 +03:00
package npc
2024-04-24 17:11:33 +03:00
import (
2024-05-06 21:19:08 +03:00
"mvvasilev/last_light/engine"
2024-04-24 17:11:33 +03:00
"github.com/gdamore/tcell/v2"
"github.com/google/uuid"
)
type Direction int
const (
DirectionNone Direction = iota
2024-05-30 23:39:54 +03:00
North
South
West
East
2024-04-24 17:11:33 +03:00
)
2024-05-30 23:39:54 +03:00
func DirectionName(dir Direction) string {
switch dir {
case North:
return "North"
case South:
return "South"
case West:
return "West"
case East:
return "East"
default:
return "Unknown"
}
}
func MovementDirectionOffset(dir Direction) (int, int) {
switch dir {
2024-05-30 23:39:54 +03:00
case North:
return 0, -1
2024-05-30 23:39:54 +03:00
case South:
return 0, 1
2024-05-30 23:39:54 +03:00
case West:
return -1, 0
2024-05-30 23:39:54 +03:00
case East:
return 1, 0
}
return 0, 0
}
2024-04-24 17:11:33 +03:00
type Entity interface {
UniqueId() uuid.UUID
Input(e *tcell.EventKey)
Tick(dt int64)
}
type MovableEntity interface {
2024-05-06 21:19:08 +03:00
Position() engine.Position
MoveTo(newPosition engine.Position)
2024-05-06 18:59:14 +03:00
Entity
2024-04-24 17:11:33 +03:00
}