go-teeworlds-protocol/messages7/snap_empty.go

54 lines
991 B
Go
Raw Permalink Normal View History

2024-06-22 05:07:47 +00:00
package messages7
import (
"slices"
"github.com/teeworlds-go/go-teeworlds-protocol/chunk7"
"github.com/teeworlds-go/go-teeworlds-protocol/network7"
"github.com/teeworlds-go/go-teeworlds-protocol/packer"
2024-06-22 05:07:47 +00:00
)
type SnapEmpty struct {
ChunkHeader *chunk7.ChunkHeader
GameTick int
DeltaTick int
}
func (msg *SnapEmpty) MsgId() int {
2024-06-22 05:07:47 +00:00
return network7.MsgSysSnapEmpty
}
func (msg *SnapEmpty) MsgType() network7.MsgType {
2024-06-22 05:07:47 +00:00
return network7.TypeNet
}
func (msg *SnapEmpty) System() bool {
2024-06-22 05:07:47 +00:00
return true
}
func (msg *SnapEmpty) Vital() bool {
2024-06-22 05:07:47 +00:00
return false
}
func (msg *SnapEmpty) Pack() []byte {
2024-06-22 05:07:47 +00:00
return slices.Concat(
packer.PackInt(msg.GameTick),
packer.PackInt(msg.DeltaTick),
)
}
func (msg *SnapEmpty) Unpack(u *packer.Unpacker) error {
2024-06-22 05:07:47 +00:00
msg.GameTick = u.GetInt()
msg.DeltaTick = u.GetInt()
return nil
2024-06-22 05:07:47 +00:00
}
func (msg *SnapEmpty) Header() *chunk7.ChunkHeader {
return msg.ChunkHeader
}
func (msg *SnapEmpty) SetHeader(header *chunk7.ChunkHeader) {
msg.ChunkHeader = header
}