goonscape/types/types.go

83 lines
1.8 KiB
Go
Raw Normal View History

2025-01-13 11:10:48 +01:00
package types
2024-10-31 01:06:39 +01:00
2025-01-13 00:31:15 +01:00
import (
"sync"
2025-01-13 11:10:48 +01:00
"time"
2025-01-13 00:31:15 +01:00
pb "gitea.boner.be/bdnugget/goonserver/actions"
rl "github.com/gen2brain/raylib-go/raylib"
)
2024-10-31 01:06:39 +01:00
type Tile struct {
X, Y int
Height float32
Walkable bool
}
type Player struct {
sync.Mutex
PosActual rl.Vector3
PosTile Tile
TargetPath []Tile
ActionQueue []*pb.Action
Speed float32
Model rl.Model
Texture rl.Texture2D
ID int32
CurrentTick int64
LastUpdateTime time.Time
LastAnimUpdate time.Time
InterpolationProgress float32
UserData interface{}
FloatingMessage *FloatingMessage
QuitDone chan struct{}
AnimationFrame int32
IsMoving bool
}
2025-01-20 14:30:34 +01:00
type AnimationSet struct {
Idle []rl.ModelAnimation
Walk []rl.ModelAnimation
// Can add more animation types later like:
// Attack []ModelAnimation
// Jump []ModelAnimation
2024-10-31 01:06:39 +01:00
}
2025-01-13 11:10:48 +01:00
type ModelAsset struct {
2025-01-20 14:30:34 +01:00
Model rl.Model
Texture rl.Texture2D
Animation []rl.ModelAnimation // Keep this for compatibility
AnimFrames int32 // Keep this for compatibility
Animations AnimationSet // New field for organized animations
2025-01-21 01:23:40 +01:00
YOffset float32 // Additional height offset (added to default 8.0)
2025-01-13 11:10:48 +01:00
}
2025-01-13 13:23:52 +01:00
type ChatMessage struct {
PlayerID int32
Username string
2025-01-13 13:23:52 +01:00
Content string
Time time.Time
}
type FloatingMessage struct {
Content string
ExpireTime time.Time
ScreenPos rl.Vector2 // Store the screen position for 2D rendering
}
2025-01-19 21:23:47 +01:00
type ChatMessageHandler interface {
HandleServerMessages([]*pb.ChatMessage)
}
2025-01-13 11:10:48 +01:00
const (
MapWidth = 50
MapHeight = 50
TileSize = 32
TileHeight = 2.0
// RuneScape-style tick rate (600ms)
ServerTickRate = 600 * time.Millisecond
ClientTickRate = 50 * time.Millisecond
MaxTickDesync = 5
)