Compare commits
11 Commits
ca681f08cd
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ab80969b9 | |||
| 2b7bef30fa | |||
| fe428bee12 | |||
| 913d5e93d4 | |||
| ad6a061e5a | |||
| efbc59ce2d | |||
| d8d942f8e5 | |||
| 9610fc5322 | |||
| 9345b49f57 | |||
| c439c42b2f | |||
| cc9edb7825 |
BIN
client/assets/dino_blue.png
Normal file
BIN
client/assets/dino_blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
client/assets/dino_green.png
Normal file
BIN
client/assets/dino_green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
client/assets/dino_red.png
Normal file
BIN
client/assets/dino_red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
client/assets/dino_yellow.png
Normal file
BIN
client/assets/dino_yellow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
51
client/assets/imagebank.go
Normal file
51
client/assets/imagebank.go
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package assets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
_ "embed"
|
||||||
|
"image"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ImgAssetName string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Green ImgAssetName = "Green"
|
||||||
|
Blue ImgAssetName = "Blue"
|
||||||
|
Yellow ImgAssetName = "Yellow"
|
||||||
|
Red ImgAssetName = "Red"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ImageBank map[ImgAssetName]*ebiten.Image
|
||||||
|
|
||||||
|
//go:embed dino_blue.png
|
||||||
|
blue_img []byte
|
||||||
|
//go:embed dino_green.png
|
||||||
|
green_img []byte
|
||||||
|
//go:embed dino_red.png
|
||||||
|
red_img []byte
|
||||||
|
//go:embed dino_yellow.png
|
||||||
|
yellow_img []byte
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
ImageBank = make(map[ImgAssetName]*ebiten.Image)
|
||||||
|
|
||||||
|
ImageBank[Blue] = LoadImageFatal(blue_img)
|
||||||
|
ImageBank[Green] = LoadImageFatal(green_img)
|
||||||
|
ImageBank[Red] = LoadImageFatal(red_img)
|
||||||
|
ImageBank[Yellow] = LoadImageFatal(yellow_img)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadImageFatal(b []byte) *ebiten.Image {
|
||||||
|
|
||||||
|
img, _, err := image.Decode(bytes.NewReader(b))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
return ebiten.NewImageFromImage(img)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"client/pb"
|
||||||
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
@@ -16,8 +20,10 @@ func NewClient() *Client {
|
|||||||
connected: false,
|
connected: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
//conn, err := net.Dial("tcp", "localhost:501")
|
//conn, err := net.Dial("tcp", "localhost:5001")
|
||||||
conn, err := net.Dial("tcp", "192.168.5.100:501")
|
conn, err := net.Dial("tcp", "192.168.5.100:5001")
|
||||||
|
//conn, err := net.Dial("tcp", "134.231.47.14:5001")
|
||||||
|
//conn, err := net.Dial("tcp", "192.168.5.66:5001")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error connecting to server:", err)
|
fmt.Println("Error connecting to server:", err)
|
||||||
} else {
|
} else {
|
||||||
@@ -28,27 +34,50 @@ func NewClient() *Client {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SendData(msg string) {
|
func (c *Client) SendBuffer(conn net.Conn, buf []byte) {
|
||||||
// Send input to the server
|
// Ensure complete write
|
||||||
//fmt.Fprintf(c.conn, msg)
|
totalWritten := 0
|
||||||
_, err := c.conn.Write([]byte(msg))
|
for totalWritten < len(buf) {
|
||||||
|
n, err := conn.Write(buf[totalWritten:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error writing to connection:", err)
|
fmt.Printf("Error writing to connection: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
totalWritten += n
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ReadData(callback func(string)) {
|
func (c *Client) ReadData(callback func(*pb.ServerEnvelope)) {
|
||||||
|
|
||||||
|
if c.connected {
|
||||||
for {
|
for {
|
||||||
message, err := bufio.NewReader(c.conn).ReadString('\n')
|
lengthBuf := make([]byte, 4)
|
||||||
|
_, err := io.ReadFull(c.conn, lengthBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error reading from server:", err)
|
fmt.Println("failed to read length prefix: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
length := binary.BigEndian.Uint32(lengthBuf)
|
||||||
|
|
||||||
|
data := make([]byte, length)
|
||||||
|
_, err = io.ReadFull(c.conn, data)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("failed to read data: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var envelope pb.ServerEnvelope
|
||||||
|
err = proto.Unmarshal(data, &envelope)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Couldn't deserialize envelope : ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if callback != nil {
|
if callback != nil {
|
||||||
callback(message)
|
callback(&envelope)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,3 +95,18 @@ func (c *Client) Disconnect() {
|
|||||||
c.conn.Close()
|
c.conn.Close()
|
||||||
c.connected = false
|
c.connected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) SendMessage(msg *pb.ClientEnvelope) {
|
||||||
|
data, err := proto.Marshal(msg)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("error serializing: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
length := len(data)
|
||||||
|
buf := make([]byte, length+4)
|
||||||
|
binary.BigEndian.PutUint32(buf[:4], uint32(length))
|
||||||
|
copy(buf[4:], data)
|
||||||
|
|
||||||
|
c.SendBuffer(c.conn, buf)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package elements
|
|||||||
import (
|
import (
|
||||||
"client/gamedata"
|
"client/gamedata"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
"math"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
)
|
)
|
||||||
@@ -11,22 +12,37 @@ type Block struct {
|
|||||||
Sprite *ebiten.Image
|
Sprite *ebiten.Image
|
||||||
cycle int
|
cycle int
|
||||||
position gamedata.Coordinates
|
position gamedata.Coordinates
|
||||||
|
target gamedata.Coordinates
|
||||||
|
hit bool
|
||||||
|
clr color.RGBA
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlock() *Block {
|
func NewBlock() *Block {
|
||||||
return &Block{
|
return &Block{
|
||||||
Sprite: ebiten.NewImage(20, 20),
|
Sprite: ebiten.NewImage(20, 20),
|
||||||
cycle: 0,
|
cycle: 0,
|
||||||
|
clr: color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0x00},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) Update() {
|
func (b *Block) Update() {
|
||||||
|
|
||||||
|
dx := b.target.X - b.position.X
|
||||||
|
dy := b.target.Y - b.position.Y
|
||||||
|
|
||||||
|
delta := math.Sqrt(dx*dx + dy*dy)
|
||||||
|
angle := math.Atan2(dy, dx)
|
||||||
|
if delta > 0.5 {
|
||||||
|
b.position.X += delta * math.Cos(angle) / 2
|
||||||
|
b.position.Y += delta * math.Sin(angle) / 2
|
||||||
|
}
|
||||||
|
|
||||||
b.cycle++
|
b.cycle++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) Draw() {
|
func (b *Block) Draw() {
|
||||||
b.Sprite.Clear()
|
b.Sprite.Clear()
|
||||||
b.Sprite.Fill(color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0x00})
|
b.Sprite.Fill(b.clr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) SetPosition(pos gamedata.Coordinates) {
|
func (b *Block) SetPosition(pos gamedata.Coordinates) {
|
||||||
@@ -36,3 +52,19 @@ func (b *Block) SetPosition(pos gamedata.Coordinates) {
|
|||||||
func (b *Block) GetPosition() gamedata.Coordinates {
|
func (b *Block) GetPosition() gamedata.Coordinates {
|
||||||
return b.position
|
return b.position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Block) SetTargetPosition(pos gamedata.Coordinates) {
|
||||||
|
b.target = pos
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Block) GetTargetosition() gamedata.Coordinates {
|
||||||
|
return b.target
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Block) GetHit() bool {
|
||||||
|
return b.hit
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Block) SetColor(clr color.RGBA) {
|
||||||
|
b.clr = clr
|
||||||
|
}
|
||||||
|
|||||||
106
client/elements/dino.go
Normal file
106
client/elements/dino.go
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package elements
|
||||||
|
|
||||||
|
import (
|
||||||
|
"client/assets"
|
||||||
|
"client/gamedata"
|
||||||
|
"image"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
dinoWidth = 24
|
||||||
|
dinoHeight = 24
|
||||||
|
)
|
||||||
|
|
||||||
|
type DinoInfo struct {
|
||||||
|
DinoAction gamedata.DinoAction
|
||||||
|
NumCycles int
|
||||||
|
XOffset int
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
dinoCycleCount = []DinoInfo{
|
||||||
|
{gamedata.DinoActionIdle, 4, 0},
|
||||||
|
{gamedata.DinoActionWalk, 6, 4},
|
||||||
|
{gamedata.DinoActionSlap, 3, 10},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type Dino struct {
|
||||||
|
Sprite *ebiten.Image
|
||||||
|
dinotype gamedata.DinoType
|
||||||
|
dinoaction gamedata.DinoAction
|
||||||
|
cycle int
|
||||||
|
asset *ebiten.Image
|
||||||
|
left bool
|
||||||
|
slapping bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDino(dtype gamedata.DinoType) *Dino {
|
||||||
|
dino := &Dino{
|
||||||
|
Sprite: ebiten.NewImage(dinoWidth*2, dinoHeight*2),
|
||||||
|
cycle: 0,
|
||||||
|
dinotype: dtype,
|
||||||
|
dinoaction: gamedata.DinoActionIdle,
|
||||||
|
}
|
||||||
|
|
||||||
|
switch dtype {
|
||||||
|
case gamedata.DinoTypeBlue:
|
||||||
|
dino.asset = assets.ImageBank[assets.Blue]
|
||||||
|
case gamedata.DinoTypeGreen:
|
||||||
|
dino.asset = assets.ImageBank[assets.Green]
|
||||||
|
case gamedata.DinoTypeRed:
|
||||||
|
dino.asset = assets.ImageBank[assets.Red]
|
||||||
|
case gamedata.DinoTypeYellow:
|
||||||
|
dino.asset = assets.ImageBank[assets.Yellow]
|
||||||
|
}
|
||||||
|
|
||||||
|
return dino
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Dino) Update() {
|
||||||
|
d.cycle++
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Dino) Draw() {
|
||||||
|
d.Sprite.Clear()
|
||||||
|
|
||||||
|
idx := d.cycle / 8 % dinoCycleCount[d.dinoaction].NumCycles
|
||||||
|
x0 := dinoWidth * (idx + dinoCycleCount[d.dinoaction].XOffset)
|
||||||
|
y0 := 0
|
||||||
|
x1 := x0 + dinoWidth
|
||||||
|
y1 := dinoHeight
|
||||||
|
|
||||||
|
op := &ebiten.DrawImageOptions{}
|
||||||
|
if d.left {
|
||||||
|
op.GeoM.Scale(-1, 1)
|
||||||
|
op.GeoM.Translate(dinoWidth, 0)
|
||||||
|
}
|
||||||
|
op.GeoM.Translate(-dinoWidth/2, -dinoHeight/2)
|
||||||
|
op.GeoM.Scale(2, 2)
|
||||||
|
op.GeoM.Translate(dinoWidth, dinoHeight)
|
||||||
|
d.Sprite.DrawImage(d.asset.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), op)
|
||||||
|
|
||||||
|
if d.slapping && idx >= dinoCycleCount[d.dinoaction].NumCycles-1 {
|
||||||
|
d.slapping = false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Dino) SetAction(action gamedata.DinoAction) {
|
||||||
|
if d.slapping {
|
||||||
|
//wait until we're done slapping
|
||||||
|
} else {
|
||||||
|
d.dinoaction = action
|
||||||
|
if action == gamedata.DinoActionSlap {
|
||||||
|
d.cycle = 0
|
||||||
|
d.slapping = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Dino) SetLeft(left bool) {
|
||||||
|
d.left = left
|
||||||
|
}
|
||||||
@@ -5,23 +5,36 @@ import (
|
|||||||
"client/elements"
|
"client/elements"
|
||||||
"client/fonts"
|
"client/fonts"
|
||||||
"client/gamedata"
|
"client/gamedata"
|
||||||
|
"client/pb"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"image/color"
|
||||||
"maps"
|
"maps"
|
||||||
"strconv"
|
"math"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||||
"github.com/hajimehoshi/ebiten/v2/text/v2"
|
"github.com/hajimehoshi/ebiten/v2/text/v2"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/vector"
|
||||||
"golang.org/x/exp/rand"
|
"golang.org/x/exp/rand"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
const (
|
||||||
screenWidth = 640
|
screenWidth = 640
|
||||||
screenHeight = 480
|
screenHeight = 480
|
||||||
|
movementLimit = 5
|
||||||
|
stageRadius = 200
|
||||||
|
)
|
||||||
|
|
||||||
namelist = []string{"slappy", "mick", "rodney", "george", "ringo", "robin", "temitry "}
|
var (
|
||||||
|
namelist = []string{"slappy", "mick", "rodney", "george", "ringo",
|
||||||
|
"robin", "temitry", "evangeline", "ron", "abigail", "lester",
|
||||||
|
"maynard", "agnes", "stacey", "wendell", "susanne", "myrtle",
|
||||||
|
"teresa", "kristi", "genos", "felton", "lawrence", "rosie",
|
||||||
|
"nigel", "constance", "maryellen", "dollie", "markus",
|
||||||
|
"dorthy", "lazaro", "willa", "dino", "gustavo", "conrad",
|
||||||
|
"georgia", "lucinda", "saitama"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -29,58 +42,65 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ClientData struct {
|
type ClientData struct {
|
||||||
|
Id int
|
||||||
Address string
|
Address string
|
||||||
Name string
|
Name string
|
||||||
Position gamedata.Coordinates
|
Position gamedata.Coordinates
|
||||||
|
Hit bool
|
||||||
|
Eliminated bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
name string
|
name string
|
||||||
blocky *elements.Block
|
blocky *elements.Block
|
||||||
|
hitblocky *elements.Block
|
||||||
//players map[client.Identity]
|
elimblocky *elements.Block
|
||||||
|
gameId int
|
||||||
clients map[string]ClientData
|
realclients map[int]ClientData
|
||||||
|
|
||||||
gameclient *client.Client
|
gameclient *client.Client
|
||||||
cycle int
|
cycle int
|
||||||
|
|
||||||
position gamedata.Coordinates
|
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
|
||||||
|
//similar fields that we see in the client list, but for us
|
||||||
|
eliminated bool
|
||||||
|
hit bool
|
||||||
|
|
||||||
|
dino *elements.Dino
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGame() *Game {
|
func NewGame() *Game {
|
||||||
g := &Game{
|
g := &Game{
|
||||||
gameclient: client.NewClient(),
|
gameclient: client.NewClient(),
|
||||||
blocky: elements.NewBlock(),
|
blocky: elements.NewBlock(),
|
||||||
|
hitblocky: elements.NewBlock(),
|
||||||
|
elimblocky: elements.NewBlock(),
|
||||||
cycle: 0,
|
cycle: 0,
|
||||||
name: namelist[rand.Intn(len(namelist))],
|
name: namelist[rand.Intn(len(namelist))],
|
||||||
|
dino: elements.NewDino(gamedata.DinoTypeGreen),
|
||||||
}
|
}
|
||||||
g.clients = make(map[string]ClientData)
|
|
||||||
|
g.blocky.SetColor(color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff})
|
||||||
|
g.hitblocky.SetColor(color.RGBA{R: 0x00, G: 0xff, B: 0xff, A: 0xff})
|
||||||
|
g.elimblocky.SetColor(color.RGBA{R: 0x00, G: 0x00, B: 0xff, A: 0xff})
|
||||||
|
|
||||||
|
g.blocky.SetPosition(gamedata.Coordinates{X: float64(screenWidth) / 2, Y: float64(screenHeight) / 2})
|
||||||
|
g.blocky.SetTargetPosition(gamedata.Coordinates{X: float64(screenWidth) / 2, Y: float64(screenHeight) / 2})
|
||||||
|
|
||||||
|
g.realclients = make(map[int]ClientData)
|
||||||
|
|
||||||
|
//g.gameId = g.gameclient.GetIdentity()
|
||||||
go g.gameclient.ReadData(g.HandleServerData)
|
go g.gameclient.ReadData(g.HandleServerData)
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) Update() error {
|
func (g *Game) Update() error {
|
||||||
|
|
||||||
x, y := ebiten.CursorPosition()
|
g.blocky.Update()
|
||||||
g.position.X = float64(x)
|
g.dino.Update()
|
||||||
g.position.Y = float64(y)
|
//g.hitblocky.Update()
|
||||||
|
|
||||||
g.blocky.SetPosition(g.position)
|
g.HandleInput()
|
||||||
|
g.SendPosition()
|
||||||
//broadcast our position
|
|
||||||
if g.cycle%2 == 0 {
|
|
||||||
if g.gameclient.IsConnected() {
|
|
||||||
g.gameclient.SendData(fmt.Sprintf("%s,%.0f,%.0f\n", g.name, g.position.X, g.position.Y))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//cleanup client list every 2 seconds
|
|
||||||
if g.cycle%120 == 0 {
|
|
||||||
go g.CleanupClients()
|
|
||||||
}
|
|
||||||
|
|
||||||
g.cycle++
|
g.cycle++
|
||||||
return nil
|
return nil
|
||||||
@@ -90,10 +110,23 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
screen.Clear()
|
screen.Clear()
|
||||||
|
|
||||||
g.blocky.Draw()
|
g.blocky.Draw()
|
||||||
|
g.hitblocky.Draw()
|
||||||
|
g.elimblocky.Draw()
|
||||||
|
|
||||||
|
vector.StrokeCircle(screen, float32(screenWidth)/2, float32(screenHeight)/2, stageRadius, 3, color.White, true)
|
||||||
|
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Translate(-float64(g.blocky.Sprite.Bounds().Dx())/2, -float64(g.blocky.Sprite.Bounds().Dy())/2)
|
op.GeoM.Translate(-float64(g.blocky.Sprite.Bounds().Dx())/2, -float64(g.blocky.Sprite.Bounds().Dy())/2)
|
||||||
op.GeoM.Translate(g.blocky.GetPosition().X, g.blocky.GetPosition().Y)
|
op.GeoM.Translate(g.blocky.GetPosition().X, g.blocky.GetPosition().Y)
|
||||||
|
if !g.eliminated {
|
||||||
|
if !g.hit {
|
||||||
screen.DrawImage(g.blocky.Sprite, op)
|
screen.DrawImage(g.blocky.Sprite, op)
|
||||||
|
} else {
|
||||||
|
screen.DrawImage(g.hitblocky.Sprite, op)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
screen.DrawImage(g.elimblocky.Sprite, op)
|
||||||
|
}
|
||||||
f2 := &text.GoTextFace{
|
f2 := &text.GoTextFace{
|
||||||
Source: fonts.LaunchyFont.New,
|
Source: fonts.LaunchyFont.New,
|
||||||
Size: 12,
|
Size: 12,
|
||||||
@@ -103,13 +136,22 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
text.Draw(screen, "you ("+g.name+")", f2, top)
|
text.Draw(screen, "you ("+g.name+")", f2, top)
|
||||||
|
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
clientcopy := maps.Clone(g.clients)
|
clientcopy := maps.Clone(g.realclients)
|
||||||
g.mu.Unlock()
|
g.mu.Unlock()
|
||||||
for _, client := range clientcopy {
|
for _, client := range clientcopy {
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Translate(-float64(g.blocky.Sprite.Bounds().Dx())/2, -float64(g.blocky.Sprite.Bounds().Dy())/2)
|
op.GeoM.Translate(-float64(g.blocky.Sprite.Bounds().Dx())/2, -float64(g.blocky.Sprite.Bounds().Dy())/2)
|
||||||
op.GeoM.Translate(client.Position.X, client.Position.Y)
|
op.GeoM.Translate(client.Position.X, client.Position.Y)
|
||||||
|
|
||||||
|
if client.Eliminated {
|
||||||
|
screen.DrawImage(g.elimblocky.Sprite, op)
|
||||||
|
} else {
|
||||||
|
if !client.Hit {
|
||||||
screen.DrawImage(g.blocky.Sprite, op)
|
screen.DrawImage(g.blocky.Sprite, op)
|
||||||
|
} else {
|
||||||
|
screen.DrawImage(g.hitblocky.Sprite, op)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
f2 := &text.GoTextFace{
|
f2 := &text.GoTextFace{
|
||||||
Source: fonts.LaunchyFont.New,
|
Source: fonts.LaunchyFont.New,
|
||||||
@@ -120,56 +162,180 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
text.Draw(screen, client.Name, f2, top)
|
text.Draw(screen, client.Name, f2, top)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.dino.Draw()
|
||||||
|
dop := &ebiten.DrawImageOptions{}
|
||||||
|
dop.GeoM.Translate(-float64(g.dino.Sprite.Bounds().Dx())/2, -float64(g.dino.Sprite.Bounds().Dy())/2)
|
||||||
|
dop.GeoM.Translate(g.blocky.GetPosition().X, g.blocky.GetPosition().Y)
|
||||||
|
screen.DrawImage(g.dino.Sprite, dop)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenwidth, screenheight int) {
|
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenwidth, screenheight int) {
|
||||||
return screenWidth, screenHeight
|
return screenWidth, screenHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) HandleServerData(data string) {
|
func (g *Game) HandleServerData(envelope *pb.ServerEnvelope) {
|
||||||
//log.Println(data)
|
|
||||||
|
|
||||||
raw := data[1 : len(data)-1]
|
switch payload := envelope.Payload.(type) {
|
||||||
clientinfo := strings.Split(raw, ";")
|
case *pb.ServerEnvelope_Broadcast:
|
||||||
for _, info := range clientinfo {
|
//fmt.Println("Here comes the broadcast!")
|
||||||
subdata := strings.Split(info, ",")
|
|
||||||
|
|
||||||
if len(subdata) == 4 {
|
|
||||||
|
|
||||||
if g.gameclient.GetLocalAddr() != subdata[0] {
|
|
||||||
|
|
||||||
x, err := strconv.Atoi(subdata[2])
|
|
||||||
if err != nil {
|
|
||||||
x = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
y, err := strconv.Atoi(subdata[3])
|
|
||||||
if err != nil {
|
|
||||||
y = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for _, client := range payload.Broadcast.Clients {
|
||||||
|
if client.Id != int32(g.gameId) {
|
||||||
update := ClientData{
|
update := ClientData{
|
||||||
Address: subdata[0],
|
Id: int(client.Id),
|
||||||
Name: subdata[1],
|
Address: client.Address,
|
||||||
|
Name: client.Name,
|
||||||
Position: gamedata.Coordinates{
|
Position: gamedata.Coordinates{
|
||||||
X: float64(x),
|
X: client.Coordinates.X,
|
||||||
Y: float64(y),
|
Y: client.Coordinates.Y,
|
||||||
|
},
|
||||||
|
Hit: client.Hit,
|
||||||
|
Eliminated: client.Eliminated,
|
||||||
|
}
|
||||||
|
|
||||||
|
g.mu.Lock()
|
||||||
|
g.realclients[int(client.Id)] = update
|
||||||
|
g.mu.Unlock()
|
||||||
|
} else {
|
||||||
|
g.eliminated = client.Eliminated
|
||||||
|
g.hit = client.Hit
|
||||||
|
//this is us
|
||||||
|
|
||||||
|
//g.blocky.SetHit(client.Hit)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case *pb.ServerEnvelope_Event:
|
||||||
|
//add or remove client from client list
|
||||||
|
if payload.Event.Connected && payload.Event.Id != int32(g.gameId) {
|
||||||
|
realclient := ClientData{
|
||||||
|
Id: int(payload.Event.Id),
|
||||||
|
}
|
||||||
|
g.realclients[int(payload.Event.Id)] = realclient
|
||||||
|
} else {
|
||||||
|
delete(g.realclients, int(payload.Event.Id))
|
||||||
|
}
|
||||||
|
case *pb.ServerEnvelope_Identity:
|
||||||
|
fmt.Println("Server is trying to give us our id: ", payload.Identity.Id)
|
||||||
|
g.gameId = int(payload.Identity.Id)
|
||||||
|
case *pb.ServerEnvelope_Gameevent:
|
||||||
|
//fmt.Printf("someone slapping! target:%d, instigator:%d isSlap:%d", payload.Gameevent.Target, payload.Gameevent.Instigator, payload.Gameevent.Slap)
|
||||||
|
|
||||||
|
switch payload.Gameevent.Event.(type) {
|
||||||
|
case *pb.GameEvent_Slap:
|
||||||
|
if payload.Gameevent.Target == int32(g.gameId) {
|
||||||
|
g.mu.Lock()
|
||||||
|
dx := g.blocky.GetPosition().X - g.realclients[int(payload.Gameevent.Instigator)].Position.X
|
||||||
|
dy := g.blocky.GetPosition().Y - g.realclients[int(payload.Gameevent.Instigator)].Position.Y
|
||||||
|
g.mu.Unlock()
|
||||||
|
|
||||||
|
if dx != 0 {
|
||||||
|
dx = (dx / math.Abs(dx)) * 100
|
||||||
|
}
|
||||||
|
if dy != 0 {
|
||||||
|
dy = (dy / math.Abs(dy)) * 100
|
||||||
|
}
|
||||||
|
if dx == 0 && dy == 0 {
|
||||||
|
b := rand.Intn(2)
|
||||||
|
if b == 0 {
|
||||||
|
dx = 100
|
||||||
|
dy = 100
|
||||||
|
} else {
|
||||||
|
dx = -100
|
||||||
|
dy = -100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cpos := gamedata.Coordinates{}
|
||||||
|
cpos.X = g.blocky.GetPosition().X + dx
|
||||||
|
cpos.Y = g.blocky.GetPosition().Y + dy
|
||||||
|
g.blocky.SetTargetPosition(cpos)
|
||||||
|
}
|
||||||
|
case *pb.GameEvent_Eliminated:
|
||||||
|
fmt.Println("someone eliminated...", payload.Gameevent.Target)
|
||||||
|
|
||||||
|
/*
|
||||||
|
g.mu.Lock()
|
||||||
|
client := g.realclients[int(payload.Gameevent.Target)]
|
||||||
|
client.Eliminated = true
|
||||||
|
g.realclients[int(payload.Gameevent.Target)] = client
|
||||||
|
g.mu.Unlock()
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Game) HandleInput() {
|
||||||
|
|
||||||
|
dx := 0
|
||||||
|
dy := 0
|
||||||
|
|
||||||
|
if ebiten.IsKeyPressed(ebiten.KeyW) {
|
||||||
|
dy = -movementLimit
|
||||||
|
}
|
||||||
|
if ebiten.IsKeyPressed(ebiten.KeyS) {
|
||||||
|
dy = +movementLimit
|
||||||
|
}
|
||||||
|
if ebiten.IsKeyPressed(ebiten.KeyA) {
|
||||||
|
dx = -movementLimit
|
||||||
|
g.dino.SetLeft(true)
|
||||||
|
}
|
||||||
|
if ebiten.IsKeyPressed(ebiten.KeyD) {
|
||||||
|
dx = +movementLimit
|
||||||
|
g.dino.SetLeft(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if math.Abs(float64(dx)) > 0 || math.Abs(float64(dy)) > 0 {
|
||||||
|
g.dino.SetAction(gamedata.DinoActionWalk)
|
||||||
|
} else {
|
||||||
|
g.dino.SetAction(gamedata.DinoActionIdle)
|
||||||
|
}
|
||||||
|
|
||||||
|
cpos := g.blocky.GetPosition()
|
||||||
|
cpos.X += float64(dx)
|
||||||
|
cpos.Y += float64(dy)
|
||||||
|
g.blocky.SetTargetPosition(cpos)
|
||||||
|
|
||||||
|
if inpututil.IsKeyJustPressed(ebiten.KeySpace) {
|
||||||
|
g.SendSlap()
|
||||||
|
g.dino.SetAction(gamedata.DinoActionSlap)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Game) SendPosition() {
|
||||||
|
//broadcast our position
|
||||||
|
if g.gameclient.IsConnected() {
|
||||||
|
cd := &pb.ClientCoordinates{
|
||||||
|
Name: g.name,
|
||||||
|
Coordinates: &pb.Coordinates{
|
||||||
|
X: g.blocky.GetPosition().X, //g.position.X,
|
||||||
|
Y: g.blocky.GetPosition().Y, //g.position.Y,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
g.mu.Lock()
|
envelope := &pb.ClientEnvelope{
|
||||||
g.clients[update.Address] = update
|
Payload: &pb.ClientEnvelope_Coordinates{
|
||||||
g.mu.Unlock()
|
Coordinates: cd,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.gameclient.SendMessage(envelope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Game) SendSlap() {
|
||||||
|
if g.gameclient.IsConnected() {
|
||||||
|
slap := &pb.SlapEvent{
|
||||||
|
Slap: true,
|
||||||
|
}
|
||||||
|
envelope := &pb.ClientEnvelope{
|
||||||
|
Payload: &pb.ClientEnvelope_Slap{
|
||||||
|
Slap: slap,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) CleanupClients() {
|
g.gameclient.SendMessage(envelope)
|
||||||
g.mu.Lock()
|
|
||||||
for k := range g.clients {
|
|
||||||
delete(g.clients, k)
|
|
||||||
}
|
}
|
||||||
g.mu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,33 @@
|
|||||||
package gamedata
|
package gamedata
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
|
type DinoType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
DinoTypeGreen DinoType = iota
|
||||||
|
DinoTypeBlue
|
||||||
|
DinoTypeRed
|
||||||
|
DinoTypeYellow
|
||||||
|
DinoTypeMax
|
||||||
|
)
|
||||||
|
|
||||||
|
type DinoAction int
|
||||||
|
|
||||||
|
const (
|
||||||
|
DinoActionIdle DinoAction = iota
|
||||||
|
DinoActionWalk
|
||||||
|
DinoActionSlap
|
||||||
|
DinoActionMax
|
||||||
|
)
|
||||||
|
|
||||||
type Coordinates struct {
|
type Coordinates struct {
|
||||||
X float64 `json:"X"`
|
X float64 `json:"X"`
|
||||||
Y float64 `json:"Y"`
|
Y float64 `json:"Y"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Coordinates) Distance(p Coordinates) float64 {
|
||||||
|
dx := p.X - c.X
|
||||||
|
dy := p.Y - c.Y
|
||||||
|
return math.Sqrt(dx*dx + dy*dy)
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ go 1.22.0
|
|||||||
toolchain go1.22.10
|
toolchain go1.22.10
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/golang/protobuf v1.5.4
|
||||||
github.com/hajimehoshi/ebiten/v2 v2.8.5
|
github.com/hajimehoshi/ebiten/v2 v2.8.5
|
||||||
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d
|
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d
|
||||||
golang.org/x/image v0.20.0
|
golang.org/x/image v0.20.0
|
||||||
|
google.golang.org/protobuf v1.35.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
889
client/pb/clientdata.pb.go
Normal file
889
client/pb/clientdata.pb.go
Normal file
@@ -0,0 +1,889 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.35.2
|
||||||
|
// protoc v5.29.1
|
||||||
|
// source: clientdata.proto
|
||||||
|
|
||||||
|
package pb
|
||||||
|
|
||||||
|
import (
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
type MessageType int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
MessageType_MSG_TYPE_BROADCAST MessageType = 0
|
||||||
|
MessageType_MSG_TYPE_IDENTITY MessageType = 1
|
||||||
|
MessageType_MSG_TYPE_COORDINATES MessageType = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enum value maps for MessageType.
|
||||||
|
var (
|
||||||
|
MessageType_name = map[int32]string{
|
||||||
|
0: "MSG_TYPE_BROADCAST",
|
||||||
|
1: "MSG_TYPE_IDENTITY",
|
||||||
|
2: "MSG_TYPE_COORDINATES",
|
||||||
|
}
|
||||||
|
MessageType_value = map[string]int32{
|
||||||
|
"MSG_TYPE_BROADCAST": 0,
|
||||||
|
"MSG_TYPE_IDENTITY": 1,
|
||||||
|
"MSG_TYPE_COORDINATES": 2,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (x MessageType) Enum() *MessageType {
|
||||||
|
p := new(MessageType)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x MessageType) String() string {
|
||||||
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (MessageType) Descriptor() protoreflect.EnumDescriptor {
|
||||||
|
return file_clientdata_proto_enumTypes[0].Descriptor()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (MessageType) Type() protoreflect.EnumType {
|
||||||
|
return &file_clientdata_proto_enumTypes[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x MessageType) Number() protoreflect.EnumNumber {
|
||||||
|
return protoreflect.EnumNumber(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use MessageType.Descriptor instead.
|
||||||
|
func (MessageType) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Coordinates struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
X float64 `protobuf:"fixed64,1,opt,name=X,proto3" json:"X,omitempty"`
|
||||||
|
Y float64 `protobuf:"fixed64,2,opt,name=Y,proto3" json:"Y,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) Reset() {
|
||||||
|
*x = Coordinates{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Coordinates) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Coordinates) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[0]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Coordinates.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Coordinates) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) GetX() float64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.X
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) GetY() float64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Y
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientData struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||||
|
Address string `protobuf:"bytes,2,opt,name=Address,proto3" json:"Address,omitempty"`
|
||||||
|
Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||||
|
Coordinates *Coordinates `protobuf:"bytes,4,opt,name=coordinates,proto3" json:"coordinates,omitempty"`
|
||||||
|
Hit bool `protobuf:"varint,5,opt,name=hit,proto3" json:"hit,omitempty"`
|
||||||
|
Eliminated bool `protobuf:"varint,6,opt,name=Eliminated,proto3" json:"Eliminated,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) Reset() {
|
||||||
|
*x = ClientData{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientData) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientData) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[1]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientData.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientData) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetAddress() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Address
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetCoordinates() *Coordinates {
|
||||||
|
if x != nil {
|
||||||
|
return x.Coordinates
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetHit() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Hit
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetEliminated() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Eliminated
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientCoordinates struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||||
|
Coordinates *Coordinates `protobuf:"bytes,2,opt,name=coordinates,proto3" json:"coordinates,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) Reset() {
|
||||||
|
*x = ClientCoordinates{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientCoordinates) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[2]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientCoordinates.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientCoordinates) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) GetCoordinates() *Coordinates {
|
||||||
|
if x != nil {
|
||||||
|
return x.Coordinates
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type AllClients struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Clients []*ClientData `protobuf:"bytes,1,rep,name=Clients,proto3" json:"Clients,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AllClients) Reset() {
|
||||||
|
*x = AllClients{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[3]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AllClients) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*AllClients) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *AllClients) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[3]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use AllClients.ProtoReflect.Descriptor instead.
|
||||||
|
func (*AllClients) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{3}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AllClients) GetClients() []*ClientData {
|
||||||
|
if x != nil {
|
||||||
|
return x.Clients
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientIdentity struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) Reset() {
|
||||||
|
*x = ClientIdentity{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[4]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientIdentity) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[4]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientIdentity.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientIdentity) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{4}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEnvelope struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// Types that are assignable to Payload:
|
||||||
|
//
|
||||||
|
// *ClientEnvelope_Coordinates
|
||||||
|
// *ClientEnvelope_Slap
|
||||||
|
Payload isClientEnvelope_Payload `protobuf_oneof:"Payload"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) Reset() {
|
||||||
|
*x = ClientEnvelope{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[5]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientEnvelope) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[5]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientEnvelope.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientEnvelope) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{5}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ClientEnvelope) GetPayload() isClientEnvelope_Payload {
|
||||||
|
if m != nil {
|
||||||
|
return m.Payload
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) GetCoordinates() *ClientCoordinates {
|
||||||
|
if x, ok := x.GetPayload().(*ClientEnvelope_Coordinates); ok {
|
||||||
|
return x.Coordinates
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) GetSlap() *SlapEvent {
|
||||||
|
if x, ok := x.GetPayload().(*ClientEnvelope_Slap); ok {
|
||||||
|
return x.Slap
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type isClientEnvelope_Payload interface {
|
||||||
|
isClientEnvelope_Payload()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEnvelope_Coordinates struct {
|
||||||
|
Coordinates *ClientCoordinates `protobuf:"bytes,1,opt,name=coordinates,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEnvelope_Slap struct {
|
||||||
|
Slap *SlapEvent `protobuf:"bytes,2,opt,name=slap,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientEnvelope_Coordinates) isClientEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ClientEnvelope_Slap) isClientEnvelope_Payload() {}
|
||||||
|
|
||||||
|
type SlapEvent struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Slap bool `protobuf:"varint,1,opt,name=Slap,proto3" json:"Slap,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *SlapEvent) Reset() {
|
||||||
|
*x = SlapEvent{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[6]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *SlapEvent) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*SlapEvent) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *SlapEvent) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[6]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use SlapEvent.ProtoReflect.Descriptor instead.
|
||||||
|
func (*SlapEvent) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{6}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *SlapEvent) GetSlap() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Slap
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEvent struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||||
|
Connected bool `protobuf:"varint,2,opt,name=Connected,proto3" json:"Connected,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) Reset() {
|
||||||
|
*x = ClientEvent{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[7]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientEvent) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientEvent) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[7]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientEvent.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientEvent) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{7}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) GetConnected() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Connected
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameEvent struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Instigator int32 `protobuf:"varint,1,opt,name=Instigator,proto3" json:"Instigator,omitempty"`
|
||||||
|
Target int32 `protobuf:"varint,2,opt,name=Target,proto3" json:"Target,omitempty"`
|
||||||
|
// Types that are assignable to Event:
|
||||||
|
//
|
||||||
|
// *GameEvent_Slap
|
||||||
|
// *GameEvent_Eliminated
|
||||||
|
Event isGameEvent_Event `protobuf_oneof:"Event"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) Reset() {
|
||||||
|
*x = GameEvent{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[8]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GameEvent) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GameEvent) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[8]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use GameEvent.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GameEvent) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{8}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetInstigator() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Instigator
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetTarget() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Target
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GameEvent) GetEvent() isGameEvent_Event {
|
||||||
|
if m != nil {
|
||||||
|
return m.Event
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetSlap() bool {
|
||||||
|
if x, ok := x.GetEvent().(*GameEvent_Slap); ok {
|
||||||
|
return x.Slap
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetEliminated() bool {
|
||||||
|
if x, ok := x.GetEvent().(*GameEvent_Eliminated); ok {
|
||||||
|
return x.Eliminated
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type isGameEvent_Event interface {
|
||||||
|
isGameEvent_Event()
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameEvent_Slap struct {
|
||||||
|
Slap bool `protobuf:"varint,3,opt,name=Slap,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameEvent_Eliminated struct {
|
||||||
|
Eliminated bool `protobuf:"varint,4,opt,name=Eliminated,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GameEvent_Slap) isGameEvent_Event() {}
|
||||||
|
|
||||||
|
func (*GameEvent_Eliminated) isGameEvent_Event() {}
|
||||||
|
|
||||||
|
type ServerEnvelope struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// Types that are assignable to Payload:
|
||||||
|
//
|
||||||
|
// *ServerEnvelope_Identity
|
||||||
|
// *ServerEnvelope_Broadcast
|
||||||
|
// *ServerEnvelope_Event
|
||||||
|
// *ServerEnvelope_Gameevent
|
||||||
|
Payload isServerEnvelope_Payload `protobuf_oneof:"Payload"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) Reset() {
|
||||||
|
*x = ServerEnvelope{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[9]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ServerEnvelope) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[9]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ServerEnvelope.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ServerEnvelope) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{9}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ServerEnvelope) GetPayload() isServerEnvelope_Payload {
|
||||||
|
if m != nil {
|
||||||
|
return m.Payload
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetIdentity() *ClientIdentity {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Identity); ok {
|
||||||
|
return x.Identity
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetBroadcast() *AllClients {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Broadcast); ok {
|
||||||
|
return x.Broadcast
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetEvent() *ClientEvent {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Event); ok {
|
||||||
|
return x.Event
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetGameevent() *GameEvent {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Gameevent); ok {
|
||||||
|
return x.Gameevent
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type isServerEnvelope_Payload interface {
|
||||||
|
isServerEnvelope_Payload()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Identity struct {
|
||||||
|
Identity *ClientIdentity `protobuf:"bytes,1,opt,name=identity,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Broadcast struct {
|
||||||
|
Broadcast *AllClients `protobuf:"bytes,2,opt,name=broadcast,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Event struct {
|
||||||
|
Event *ClientEvent `protobuf:"bytes,3,opt,name=event,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Gameevent struct {
|
||||||
|
Gameevent *GameEvent `protobuf:"bytes,4,opt,name=gameevent,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Identity) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Broadcast) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Event) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Gameevent) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
var File_clientdata_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_clientdata_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x10, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f,
|
||||||
|
0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x29, 0x0a, 0x0b, 0x43, 0x6f, 0x6f, 0x72,
|
||||||
|
0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x12, 0x0c, 0x0a, 0x01, 0x58, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x01, 0x52, 0x01, 0x58, 0x12, 0x0c, 0x0a, 0x01, 0x59, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01,
|
||||||
|
0x52, 0x01, 0x59, 0x22, 0xb1, 0x01, 0x0a, 0x0a, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x61,
|
||||||
|
0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02,
|
||||||
|
0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20,
|
||||||
|
0x01, 0x28, 0x09, 0x52, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04,
|
||||||
|
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65,
|
||||||
|
0x12, 0x33, 0x0a, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x18,
|
||||||
|
0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6f,
|
||||||
|
0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x52, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69,
|
||||||
|
0x6e, 0x61, 0x74, 0x65, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01,
|
||||||
|
0x28, 0x08, 0x52, 0x03, 0x68, 0x69, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x45, 0x6c, 0x69, 0x6d, 0x69,
|
||||||
|
0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x45, 0x6c, 0x69,
|
||||||
|
0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x22, 0x5c, 0x0a, 0x11, 0x43, 0x6c, 0x69, 0x65, 0x6e,
|
||||||
|
0x74, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04,
|
||||||
|
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65,
|
||||||
|
0x12, 0x33, 0x0a, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x18,
|
||||||
|
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6f,
|
||||||
|
0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x52, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69,
|
||||||
|
0x6e, 0x61, 0x74, 0x65, 0x73, 0x22, 0x38, 0x0a, 0x0a, 0x41, 0x6c, 0x6c, 0x43, 0x6c, 0x69, 0x65,
|
||||||
|
0x6e, 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01,
|
||||||
|
0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65,
|
||||||
|
0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x52, 0x07, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22,
|
||||||
|
0x20, 0x0a, 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
|
||||||
|
0x79, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49,
|
||||||
|
0x64, 0x22, 0x7f, 0x0a, 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x45, 0x6e, 0x76, 0x65, 0x6c,
|
||||||
|
0x6f, 0x70, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74,
|
||||||
|
0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e,
|
||||||
|
0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65,
|
||||||
|
0x73, 0x48, 0x00, 0x52, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73,
|
||||||
|
0x12, 0x25, 0x0a, 0x04, 0x73, 0x6c, 0x61, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
|
||||||
|
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x53, 0x6c, 0x61, 0x70, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48,
|
||||||
|
0x00, 0x52, 0x04, 0x73, 0x6c, 0x61, 0x70, 0x42, 0x09, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
|
||||||
|
0x61, 0x64, 0x22, 0x1f, 0x0a, 0x09, 0x53, 0x6c, 0x61, 0x70, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12,
|
||||||
|
0x12, 0x0a, 0x04, 0x53, 0x6c, 0x61, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x53,
|
||||||
|
0x6c, 0x61, 0x70, 0x22, 0x3b, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x45, 0x76, 0x65,
|
||||||
|
0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02,
|
||||||
|
0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18,
|
||||||
|
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64,
|
||||||
|
0x22, 0x84, 0x01, 0x0a, 0x09, 0x47, 0x61, 0x6d, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1e,
|
||||||
|
0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x16,
|
||||||
|
0x0a, 0x06, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06,
|
||||||
|
0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x04, 0x53, 0x6c, 0x61, 0x70, 0x18, 0x03,
|
||||||
|
0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x04, 0x53, 0x6c, 0x61, 0x70, 0x12, 0x20, 0x0a, 0x0a,
|
||||||
|
0x45, 0x6c, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08,
|
||||||
|
0x48, 0x00, 0x52, 0x0a, 0x45, 0x6c, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x42, 0x07,
|
||||||
|
0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0xdd, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76,
|
||||||
|
0x65, 0x72, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x69, 0x64,
|
||||||
|
0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d,
|
||||||
|
0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69,
|
||||||
|
0x74, 0x79, 0x48, 0x00, 0x52, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x30,
|
||||||
|
0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
|
0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x41, 0x6c, 0x6c, 0x43, 0x6c, 0x69, 0x65,
|
||||||
|
0x6e, 0x74, 0x73, 0x48, 0x00, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
|
||||||
|
0x12, 0x29, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||||
|
0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x45, 0x76, 0x65,
|
||||||
|
0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x0a, 0x09, 0x67,
|
||||||
|
0x61, 0x6d, 0x65, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
|
||||||
|
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x47, 0x61, 0x6d, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48,
|
||||||
|
0x00, 0x52, 0x09, 0x67, 0x61, 0x6d, 0x65, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x09, 0x0a, 0x07,
|
||||||
|
0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x56, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||||
|
0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x4d, 0x53, 0x47, 0x5f, 0x54, 0x59,
|
||||||
|
0x50, 0x45, 0x5f, 0x42, 0x52, 0x4f, 0x41, 0x44, 0x43, 0x41, 0x53, 0x54, 0x10, 0x00, 0x12, 0x15,
|
||||||
|
0x0a, 0x11, 0x4d, 0x53, 0x47, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x44, 0x45, 0x4e, 0x54,
|
||||||
|
0x49, 0x54, 0x59, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x4d, 0x53, 0x47, 0x5f, 0x54, 0x59, 0x50,
|
||||||
|
0x45, 0x5f, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x49, 0x4e, 0x41, 0x54, 0x45, 0x53, 0x10, 0x02, 0x42,
|
||||||
|
0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_clientdata_proto_rawDescOnce sync.Once
|
||||||
|
file_clientdata_proto_rawDescData = file_clientdata_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_clientdata_proto_rawDescGZIP() []byte {
|
||||||
|
file_clientdata_proto_rawDescOnce.Do(func() {
|
||||||
|
file_clientdata_proto_rawDescData = protoimpl.X.CompressGZIP(file_clientdata_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_clientdata_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_clientdata_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
|
var file_clientdata_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||||
|
var file_clientdata_proto_goTypes = []any{
|
||||||
|
(MessageType)(0), // 0: main.MessageType
|
||||||
|
(*Coordinates)(nil), // 1: main.Coordinates
|
||||||
|
(*ClientData)(nil), // 2: main.ClientData
|
||||||
|
(*ClientCoordinates)(nil), // 3: main.ClientCoordinates
|
||||||
|
(*AllClients)(nil), // 4: main.AllClients
|
||||||
|
(*ClientIdentity)(nil), // 5: main.ClientIdentity
|
||||||
|
(*ClientEnvelope)(nil), // 6: main.ClientEnvelope
|
||||||
|
(*SlapEvent)(nil), // 7: main.SlapEvent
|
||||||
|
(*ClientEvent)(nil), // 8: main.ClientEvent
|
||||||
|
(*GameEvent)(nil), // 9: main.GameEvent
|
||||||
|
(*ServerEnvelope)(nil), // 10: main.ServerEnvelope
|
||||||
|
}
|
||||||
|
var file_clientdata_proto_depIdxs = []int32{
|
||||||
|
1, // 0: main.ClientData.coordinates:type_name -> main.Coordinates
|
||||||
|
1, // 1: main.ClientCoordinates.coordinates:type_name -> main.Coordinates
|
||||||
|
2, // 2: main.AllClients.Clients:type_name -> main.ClientData
|
||||||
|
3, // 3: main.ClientEnvelope.coordinates:type_name -> main.ClientCoordinates
|
||||||
|
7, // 4: main.ClientEnvelope.slap:type_name -> main.SlapEvent
|
||||||
|
5, // 5: main.ServerEnvelope.identity:type_name -> main.ClientIdentity
|
||||||
|
4, // 6: main.ServerEnvelope.broadcast:type_name -> main.AllClients
|
||||||
|
8, // 7: main.ServerEnvelope.event:type_name -> main.ClientEvent
|
||||||
|
9, // 8: main.ServerEnvelope.gameevent:type_name -> main.GameEvent
|
||||||
|
9, // [9:9] is the sub-list for method output_type
|
||||||
|
9, // [9:9] is the sub-list for method input_type
|
||||||
|
9, // [9:9] is the sub-list for extension type_name
|
||||||
|
9, // [9:9] is the sub-list for extension extendee
|
||||||
|
0, // [0:9] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_clientdata_proto_init() }
|
||||||
|
func file_clientdata_proto_init() {
|
||||||
|
if File_clientdata_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
file_clientdata_proto_msgTypes[5].OneofWrappers = []any{
|
||||||
|
(*ClientEnvelope_Coordinates)(nil),
|
||||||
|
(*ClientEnvelope_Slap)(nil),
|
||||||
|
}
|
||||||
|
file_clientdata_proto_msgTypes[8].OneofWrappers = []any{
|
||||||
|
(*GameEvent_Slap)(nil),
|
||||||
|
(*GameEvent_Eliminated)(nil),
|
||||||
|
}
|
||||||
|
file_clientdata_proto_msgTypes[9].OneofWrappers = []any{
|
||||||
|
(*ServerEnvelope_Identity)(nil),
|
||||||
|
(*ServerEnvelope_Broadcast)(nil),
|
||||||
|
(*ServerEnvelope_Event)(nil),
|
||||||
|
(*ServerEnvelope_Gameevent)(nil),
|
||||||
|
}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: file_clientdata_proto_rawDesc,
|
||||||
|
NumEnums: 1,
|
||||||
|
NumMessages: 10,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_clientdata_proto_goTypes,
|
||||||
|
DependencyIndexes: file_clientdata_proto_depIdxs,
|
||||||
|
EnumInfos: file_clientdata_proto_enumTypes,
|
||||||
|
MessageInfos: file_clientdata_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_clientdata_proto = out.File
|
||||||
|
file_clientdata_proto_rawDesc = nil
|
||||||
|
file_clientdata_proto_goTypes = nil
|
||||||
|
file_clientdata_proto_depIdxs = nil
|
||||||
|
}
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.35.2
|
|
||||||
// protoc v5.29.1
|
|
||||||
// source: clientdata.proto
|
|
||||||
|
|
||||||
package __
|
|
||||||
|
|
||||||
import (
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
type ClientData struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Address string `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address,omitempty"`
|
|
||||||
Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`
|
|
||||||
Coordinates *ClientData_Coordinates `protobuf:"bytes,4,opt,name=coordinates,proto3" json:"coordinates,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData) Reset() {
|
|
||||||
*x = ClientData{}
|
|
||||||
mi := &file_clientdata_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*ClientData) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *ClientData) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_clientdata_proto_msgTypes[0]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use ClientData.ProtoReflect.Descriptor instead.
|
|
||||||
func (*ClientData) Descriptor() ([]byte, []int) {
|
|
||||||
return file_clientdata_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData) GetAddress() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Address
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData) GetName() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Name
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData) GetCoordinates() *ClientData_Coordinates {
|
|
||||||
if x != nil {
|
|
||||||
return x.Coordinates
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type ClientData_Coordinates struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
X float64 `protobuf:"fixed64,1,opt,name=X,proto3" json:"X,omitempty"`
|
|
||||||
Y float64 `protobuf:"fixed64,2,opt,name=Y,proto3" json:"Y,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData_Coordinates) Reset() {
|
|
||||||
*x = ClientData_Coordinates{}
|
|
||||||
mi := &file_clientdata_proto_msgTypes[1]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData_Coordinates) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*ClientData_Coordinates) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *ClientData_Coordinates) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_clientdata_proto_msgTypes[1]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use ClientData_Coordinates.ProtoReflect.Descriptor instead.
|
|
||||||
func (*ClientData_Coordinates) Descriptor() ([]byte, []int) {
|
|
||||||
return file_clientdata_proto_rawDescGZIP(), []int{0, 0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData_Coordinates) GetX() float64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.X
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *ClientData_Coordinates) GetY() float64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Y
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_clientdata_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_clientdata_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x10, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f,
|
|
||||||
0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0xa5, 0x01, 0x0a, 0x0a, 0x43, 0x6c, 0x69,
|
|
||||||
0x65, 0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65,
|
|
||||||
0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73,
|
|
||||||
0x73, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
|
||||||
0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e,
|
|
||||||
0x61, 0x74, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6d, 0x61, 0x69,
|
|
||||||
0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6f,
|
|
||||||
0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x52, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69,
|
|
||||||
0x6e, 0x61, 0x74, 0x65, 0x73, 0x1a, 0x29, 0x0a, 0x0b, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e,
|
|
||||||
0x61, 0x74, 0x65, 0x73, 0x12, 0x0c, 0x0a, 0x01, 0x58, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52,
|
|
||||||
0x01, 0x58, 0x12, 0x0c, 0x0a, 0x01, 0x59, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x59,
|
|
||||||
0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_clientdata_proto_rawDescOnce sync.Once
|
|
||||||
file_clientdata_proto_rawDescData = file_clientdata_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_clientdata_proto_rawDescGZIP() []byte {
|
|
||||||
file_clientdata_proto_rawDescOnce.Do(func() {
|
|
||||||
file_clientdata_proto_rawDescData = protoimpl.X.CompressGZIP(file_clientdata_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_clientdata_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_clientdata_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
|
||||||
var file_clientdata_proto_goTypes = []any{
|
|
||||||
(*ClientData)(nil), // 0: main.ClientData
|
|
||||||
(*ClientData_Coordinates)(nil), // 1: main.ClientData.Coordinates
|
|
||||||
}
|
|
||||||
var file_clientdata_proto_depIdxs = []int32{
|
|
||||||
1, // 0: main.ClientData.coordinates:type_name -> main.ClientData.Coordinates
|
|
||||||
1, // [1:1] is the sub-list for method output_type
|
|
||||||
1, // [1:1] is the sub-list for method input_type
|
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
|
||||||
1, // [1:1] is the sub-list for extension extendee
|
|
||||||
0, // [0:1] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_clientdata_proto_init() }
|
|
||||||
func file_clientdata_proto_init() {
|
|
||||||
if File_clientdata_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_clientdata_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 2,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_clientdata_proto_goTypes,
|
|
||||||
DependencyIndexes: file_clientdata_proto_depIdxs,
|
|
||||||
MessageInfos: file_clientdata_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_clientdata_proto = out.File
|
|
||||||
file_clientdata_proto_rawDesc = nil
|
|
||||||
file_clientdata_proto_goTypes = nil
|
|
||||||
file_clientdata_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,68 @@ syntax="proto3";
|
|||||||
|
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
option go_package = "./";
|
option go_package = "./pb";
|
||||||
|
|
||||||
message ClientData {
|
|
||||||
string Address = 1;
|
|
||||||
string Name = 2;
|
|
||||||
message Coordinates {
|
message Coordinates {
|
||||||
double X=1;
|
double X=1;
|
||||||
double Y=2;
|
double Y=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ClientData {
|
||||||
|
int32 Id = 1;
|
||||||
|
string Address = 2;
|
||||||
|
string Name = 3;
|
||||||
Coordinates coordinates = 4;
|
Coordinates coordinates = 4;
|
||||||
|
bool hit = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ClientCoordinates {
|
||||||
|
string Name = 1;
|
||||||
|
Coordinates coordinates = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AllClients{
|
||||||
|
repeated ClientData Clients = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ClientIdentity{
|
||||||
|
int32 Id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ClientEnvelope {
|
||||||
|
oneof Payload {
|
||||||
|
ClientCoordinates coordinates = 1;
|
||||||
|
SlapEvent slap = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message SlapEvent {
|
||||||
|
bool Slap = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ClientEvent {
|
||||||
|
int32 Id = 1;
|
||||||
|
bool Connected = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GameEvent {
|
||||||
|
int32 Instigator = 1;
|
||||||
|
int32 Target = 2;
|
||||||
|
bool Slap = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ServerEnvelope {
|
||||||
|
oneof Payload {
|
||||||
|
ClientIdentity identity = 1;
|
||||||
|
AllClients broadcast = 2;
|
||||||
|
ClientEvent event = 3;
|
||||||
|
GameEvent gameevent = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MessageType {
|
||||||
|
MSG_TYPE_BROADCAST = 0;
|
||||||
|
MSG_TYPE_IDENTITY = 1;
|
||||||
|
MSG_TYPE_COORDINATES = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
package gamedata
|
package gamedata
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
type Coordinates struct {
|
type Coordinates struct {
|
||||||
X float64
|
X float64
|
||||||
Y float64
|
Y float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Coordinates) Distance(p Coordinates) float64 {
|
||||||
|
dx := p.X - c.X
|
||||||
|
dy := p.Y - c.Y
|
||||||
|
return math.Sqrt(dx*dx + dy*dy)
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
fmt.Println("Server v0.04")
|
fmt.Println("Server v0.04")
|
||||||
server := server.NewServer()
|
server := server.NewServer()
|
||||||
server.Start(501)
|
server.Start(5001)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
889
server/pb/clientdata.pb.go
Normal file
889
server/pb/clientdata.pb.go
Normal file
@@ -0,0 +1,889 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.35.2
|
||||||
|
// protoc v5.29.1
|
||||||
|
// source: clientdata.proto
|
||||||
|
|
||||||
|
package pb
|
||||||
|
|
||||||
|
import (
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
type MessageType int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
MessageType_MSG_TYPE_BROADCAST MessageType = 0
|
||||||
|
MessageType_MSG_TYPE_IDENTITY MessageType = 1
|
||||||
|
MessageType_MSG_TYPE_COORDINATES MessageType = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enum value maps for MessageType.
|
||||||
|
var (
|
||||||
|
MessageType_name = map[int32]string{
|
||||||
|
0: "MSG_TYPE_BROADCAST",
|
||||||
|
1: "MSG_TYPE_IDENTITY",
|
||||||
|
2: "MSG_TYPE_COORDINATES",
|
||||||
|
}
|
||||||
|
MessageType_value = map[string]int32{
|
||||||
|
"MSG_TYPE_BROADCAST": 0,
|
||||||
|
"MSG_TYPE_IDENTITY": 1,
|
||||||
|
"MSG_TYPE_COORDINATES": 2,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (x MessageType) Enum() *MessageType {
|
||||||
|
p := new(MessageType)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x MessageType) String() string {
|
||||||
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (MessageType) Descriptor() protoreflect.EnumDescriptor {
|
||||||
|
return file_clientdata_proto_enumTypes[0].Descriptor()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (MessageType) Type() protoreflect.EnumType {
|
||||||
|
return &file_clientdata_proto_enumTypes[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x MessageType) Number() protoreflect.EnumNumber {
|
||||||
|
return protoreflect.EnumNumber(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use MessageType.Descriptor instead.
|
||||||
|
func (MessageType) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Coordinates struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
X float64 `protobuf:"fixed64,1,opt,name=X,proto3" json:"X,omitempty"`
|
||||||
|
Y float64 `protobuf:"fixed64,2,opt,name=Y,proto3" json:"Y,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) Reset() {
|
||||||
|
*x = Coordinates{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Coordinates) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Coordinates) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[0]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Coordinates.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Coordinates) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) GetX() float64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.X
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Coordinates) GetY() float64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Y
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientData struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||||
|
Address string `protobuf:"bytes,2,opt,name=Address,proto3" json:"Address,omitempty"`
|
||||||
|
Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||||
|
Coordinates *Coordinates `protobuf:"bytes,4,opt,name=coordinates,proto3" json:"coordinates,omitempty"`
|
||||||
|
Hit bool `protobuf:"varint,5,opt,name=hit,proto3" json:"hit,omitempty"`
|
||||||
|
Eliminated bool `protobuf:"varint,6,opt,name=Eliminated,proto3" json:"Eliminated,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) Reset() {
|
||||||
|
*x = ClientData{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientData) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientData) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[1]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientData.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientData) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetAddress() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Address
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetCoordinates() *Coordinates {
|
||||||
|
if x != nil {
|
||||||
|
return x.Coordinates
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetHit() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Hit
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientData) GetEliminated() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Eliminated
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientCoordinates struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||||
|
Coordinates *Coordinates `protobuf:"bytes,2,opt,name=coordinates,proto3" json:"coordinates,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) Reset() {
|
||||||
|
*x = ClientCoordinates{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientCoordinates) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[2]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientCoordinates.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientCoordinates) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) GetName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientCoordinates) GetCoordinates() *Coordinates {
|
||||||
|
if x != nil {
|
||||||
|
return x.Coordinates
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type AllClients struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Clients []*ClientData `protobuf:"bytes,1,rep,name=Clients,proto3" json:"Clients,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AllClients) Reset() {
|
||||||
|
*x = AllClients{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[3]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AllClients) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*AllClients) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *AllClients) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[3]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use AllClients.ProtoReflect.Descriptor instead.
|
||||||
|
func (*AllClients) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{3}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AllClients) GetClients() []*ClientData {
|
||||||
|
if x != nil {
|
||||||
|
return x.Clients
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientIdentity struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) Reset() {
|
||||||
|
*x = ClientIdentity{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[4]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientIdentity) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[4]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientIdentity.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientIdentity) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{4}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientIdentity) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEnvelope struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// Types that are assignable to Payload:
|
||||||
|
//
|
||||||
|
// *ClientEnvelope_Coordinates
|
||||||
|
// *ClientEnvelope_Slap
|
||||||
|
Payload isClientEnvelope_Payload `protobuf_oneof:"Payload"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) Reset() {
|
||||||
|
*x = ClientEnvelope{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[5]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientEnvelope) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[5]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientEnvelope.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientEnvelope) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{5}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ClientEnvelope) GetPayload() isClientEnvelope_Payload {
|
||||||
|
if m != nil {
|
||||||
|
return m.Payload
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) GetCoordinates() *ClientCoordinates {
|
||||||
|
if x, ok := x.GetPayload().(*ClientEnvelope_Coordinates); ok {
|
||||||
|
return x.Coordinates
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEnvelope) GetSlap() *SlapEvent {
|
||||||
|
if x, ok := x.GetPayload().(*ClientEnvelope_Slap); ok {
|
||||||
|
return x.Slap
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type isClientEnvelope_Payload interface {
|
||||||
|
isClientEnvelope_Payload()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEnvelope_Coordinates struct {
|
||||||
|
Coordinates *ClientCoordinates `protobuf:"bytes,1,opt,name=coordinates,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEnvelope_Slap struct {
|
||||||
|
Slap *SlapEvent `protobuf:"bytes,2,opt,name=slap,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientEnvelope_Coordinates) isClientEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ClientEnvelope_Slap) isClientEnvelope_Payload() {}
|
||||||
|
|
||||||
|
type SlapEvent struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Slap bool `protobuf:"varint,1,opt,name=Slap,proto3" json:"Slap,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *SlapEvent) Reset() {
|
||||||
|
*x = SlapEvent{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[6]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *SlapEvent) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*SlapEvent) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *SlapEvent) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[6]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use SlapEvent.ProtoReflect.Descriptor instead.
|
||||||
|
func (*SlapEvent) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{6}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *SlapEvent) GetSlap() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Slap
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientEvent struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"`
|
||||||
|
Connected bool `protobuf:"varint,2,opt,name=Connected,proto3" json:"Connected,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) Reset() {
|
||||||
|
*x = ClientEvent{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[7]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ClientEvent) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ClientEvent) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[7]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ClientEvent.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ClientEvent) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{7}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) GetId() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ClientEvent) GetConnected() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Connected
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameEvent struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Instigator int32 `protobuf:"varint,1,opt,name=Instigator,proto3" json:"Instigator,omitempty"`
|
||||||
|
Target int32 `protobuf:"varint,2,opt,name=Target,proto3" json:"Target,omitempty"`
|
||||||
|
// Types that are assignable to Event:
|
||||||
|
//
|
||||||
|
// *GameEvent_Slap
|
||||||
|
// *GameEvent_Eliminated
|
||||||
|
Event isGameEvent_Event `protobuf_oneof:"Event"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) Reset() {
|
||||||
|
*x = GameEvent{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[8]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GameEvent) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GameEvent) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[8]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use GameEvent.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GameEvent) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{8}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetInstigator() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Instigator
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetTarget() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Target
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *GameEvent) GetEvent() isGameEvent_Event {
|
||||||
|
if m != nil {
|
||||||
|
return m.Event
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetSlap() bool {
|
||||||
|
if x, ok := x.GetEvent().(*GameEvent_Slap); ok {
|
||||||
|
return x.Slap
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GameEvent) GetEliminated() bool {
|
||||||
|
if x, ok := x.GetEvent().(*GameEvent_Eliminated); ok {
|
||||||
|
return x.Eliminated
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type isGameEvent_Event interface {
|
||||||
|
isGameEvent_Event()
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameEvent_Slap struct {
|
||||||
|
Slap bool `protobuf:"varint,3,opt,name=Slap,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameEvent_Eliminated struct {
|
||||||
|
Eliminated bool `protobuf:"varint,4,opt,name=Eliminated,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GameEvent_Slap) isGameEvent_Event() {}
|
||||||
|
|
||||||
|
func (*GameEvent_Eliminated) isGameEvent_Event() {}
|
||||||
|
|
||||||
|
type ServerEnvelope struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// Types that are assignable to Payload:
|
||||||
|
//
|
||||||
|
// *ServerEnvelope_Identity
|
||||||
|
// *ServerEnvelope_Broadcast
|
||||||
|
// *ServerEnvelope_Event
|
||||||
|
// *ServerEnvelope_Gameevent
|
||||||
|
Payload isServerEnvelope_Payload `protobuf_oneof:"Payload"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) Reset() {
|
||||||
|
*x = ServerEnvelope{}
|
||||||
|
mi := &file_clientdata_proto_msgTypes[9]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ServerEnvelope) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_clientdata_proto_msgTypes[9]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ServerEnvelope.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ServerEnvelope) Descriptor() ([]byte, []int) {
|
||||||
|
return file_clientdata_proto_rawDescGZIP(), []int{9}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ServerEnvelope) GetPayload() isServerEnvelope_Payload {
|
||||||
|
if m != nil {
|
||||||
|
return m.Payload
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetIdentity() *ClientIdentity {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Identity); ok {
|
||||||
|
return x.Identity
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetBroadcast() *AllClients {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Broadcast); ok {
|
||||||
|
return x.Broadcast
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetEvent() *ClientEvent {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Event); ok {
|
||||||
|
return x.Event
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ServerEnvelope) GetGameevent() *GameEvent {
|
||||||
|
if x, ok := x.GetPayload().(*ServerEnvelope_Gameevent); ok {
|
||||||
|
return x.Gameevent
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type isServerEnvelope_Payload interface {
|
||||||
|
isServerEnvelope_Payload()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Identity struct {
|
||||||
|
Identity *ClientIdentity `protobuf:"bytes,1,opt,name=identity,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Broadcast struct {
|
||||||
|
Broadcast *AllClients `protobuf:"bytes,2,opt,name=broadcast,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Event struct {
|
||||||
|
Event *ClientEvent `protobuf:"bytes,3,opt,name=event,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerEnvelope_Gameevent struct {
|
||||||
|
Gameevent *GameEvent `protobuf:"bytes,4,opt,name=gameevent,proto3,oneof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Identity) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Broadcast) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Event) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
func (*ServerEnvelope_Gameevent) isServerEnvelope_Payload() {}
|
||||||
|
|
||||||
|
var File_clientdata_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
var file_clientdata_proto_rawDesc = []byte{
|
||||||
|
0x0a, 0x10, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f,
|
||||||
|
0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x29, 0x0a, 0x0b, 0x43, 0x6f, 0x6f, 0x72,
|
||||||
|
0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x12, 0x0c, 0x0a, 0x01, 0x58, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x01, 0x52, 0x01, 0x58, 0x12, 0x0c, 0x0a, 0x01, 0x59, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01,
|
||||||
|
0x52, 0x01, 0x59, 0x22, 0xb1, 0x01, 0x0a, 0x0a, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x61,
|
||||||
|
0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02,
|
||||||
|
0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20,
|
||||||
|
0x01, 0x28, 0x09, 0x52, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04,
|
||||||
|
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65,
|
||||||
|
0x12, 0x33, 0x0a, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x18,
|
||||||
|
0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6f,
|
||||||
|
0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x52, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69,
|
||||||
|
0x6e, 0x61, 0x74, 0x65, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01,
|
||||||
|
0x28, 0x08, 0x52, 0x03, 0x68, 0x69, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x45, 0x6c, 0x69, 0x6d, 0x69,
|
||||||
|
0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x45, 0x6c, 0x69,
|
||||||
|
0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x22, 0x5c, 0x0a, 0x11, 0x43, 0x6c, 0x69, 0x65, 0x6e,
|
||||||
|
0x74, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04,
|
||||||
|
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65,
|
||||||
|
0x12, 0x33, 0x0a, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x18,
|
||||||
|
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6f,
|
||||||
|
0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73, 0x52, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69,
|
||||||
|
0x6e, 0x61, 0x74, 0x65, 0x73, 0x22, 0x38, 0x0a, 0x0a, 0x41, 0x6c, 0x6c, 0x43, 0x6c, 0x69, 0x65,
|
||||||
|
0x6e, 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x07, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01,
|
||||||
|
0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65,
|
||||||
|
0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x52, 0x07, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22,
|
||||||
|
0x20, 0x0a, 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
|
||||||
|
0x79, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49,
|
||||||
|
0x64, 0x22, 0x7f, 0x0a, 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x45, 0x6e, 0x76, 0x65, 0x6c,
|
||||||
|
0x6f, 0x70, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74,
|
||||||
|
0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e,
|
||||||
|
0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65,
|
||||||
|
0x73, 0x48, 0x00, 0x52, 0x0b, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x73,
|
||||||
|
0x12, 0x25, 0x0a, 0x04, 0x73, 0x6c, 0x61, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
|
||||||
|
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x53, 0x6c, 0x61, 0x70, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48,
|
||||||
|
0x00, 0x52, 0x04, 0x73, 0x6c, 0x61, 0x70, 0x42, 0x09, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
|
||||||
|
0x61, 0x64, 0x22, 0x1f, 0x0a, 0x09, 0x53, 0x6c, 0x61, 0x70, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12,
|
||||||
|
0x12, 0x0a, 0x04, 0x53, 0x6c, 0x61, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x53,
|
||||||
|
0x6c, 0x61, 0x70, 0x22, 0x3b, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x45, 0x76, 0x65,
|
||||||
|
0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02,
|
||||||
|
0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18,
|
||||||
|
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64,
|
||||||
|
0x22, 0x84, 0x01, 0x0a, 0x09, 0x47, 0x61, 0x6d, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1e,
|
||||||
|
0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x16,
|
||||||
|
0x0a, 0x06, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06,
|
||||||
|
0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x04, 0x53, 0x6c, 0x61, 0x70, 0x18, 0x03,
|
||||||
|
0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x04, 0x53, 0x6c, 0x61, 0x70, 0x12, 0x20, 0x0a, 0x0a,
|
||||||
|
0x45, 0x6c, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08,
|
||||||
|
0x48, 0x00, 0x52, 0x0a, 0x45, 0x6c, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x42, 0x07,
|
||||||
|
0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0xdd, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76,
|
||||||
|
0x65, 0x72, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x69, 0x64,
|
||||||
|
0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d,
|
||||||
|
0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69,
|
||||||
|
0x74, 0x79, 0x48, 0x00, 0x52, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x30,
|
||||||
|
0x0a, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
|
0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x41, 0x6c, 0x6c, 0x43, 0x6c, 0x69, 0x65,
|
||||||
|
0x6e, 0x74, 0x73, 0x48, 0x00, 0x52, 0x09, 0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
|
||||||
|
0x12, 0x29, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||||
|
0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x45, 0x76, 0x65,
|
||||||
|
0x6e, 0x74, 0x48, 0x00, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x0a, 0x09, 0x67,
|
||||||
|
0x61, 0x6d, 0x65, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f,
|
||||||
|
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x47, 0x61, 0x6d, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48,
|
||||||
|
0x00, 0x52, 0x09, 0x67, 0x61, 0x6d, 0x65, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x09, 0x0a, 0x07,
|
||||||
|
0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x56, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||||
|
0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x4d, 0x53, 0x47, 0x5f, 0x54, 0x59,
|
||||||
|
0x50, 0x45, 0x5f, 0x42, 0x52, 0x4f, 0x41, 0x44, 0x43, 0x41, 0x53, 0x54, 0x10, 0x00, 0x12, 0x15,
|
||||||
|
0x0a, 0x11, 0x4d, 0x53, 0x47, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x44, 0x45, 0x4e, 0x54,
|
||||||
|
0x49, 0x54, 0x59, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x4d, 0x53, 0x47, 0x5f, 0x54, 0x59, 0x50,
|
||||||
|
0x45, 0x5f, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x49, 0x4e, 0x41, 0x54, 0x45, 0x53, 0x10, 0x02, 0x42,
|
||||||
|
0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_clientdata_proto_rawDescOnce sync.Once
|
||||||
|
file_clientdata_proto_rawDescData = file_clientdata_proto_rawDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_clientdata_proto_rawDescGZIP() []byte {
|
||||||
|
file_clientdata_proto_rawDescOnce.Do(func() {
|
||||||
|
file_clientdata_proto_rawDescData = protoimpl.X.CompressGZIP(file_clientdata_proto_rawDescData)
|
||||||
|
})
|
||||||
|
return file_clientdata_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_clientdata_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
|
var file_clientdata_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||||
|
var file_clientdata_proto_goTypes = []any{
|
||||||
|
(MessageType)(0), // 0: main.MessageType
|
||||||
|
(*Coordinates)(nil), // 1: main.Coordinates
|
||||||
|
(*ClientData)(nil), // 2: main.ClientData
|
||||||
|
(*ClientCoordinates)(nil), // 3: main.ClientCoordinates
|
||||||
|
(*AllClients)(nil), // 4: main.AllClients
|
||||||
|
(*ClientIdentity)(nil), // 5: main.ClientIdentity
|
||||||
|
(*ClientEnvelope)(nil), // 6: main.ClientEnvelope
|
||||||
|
(*SlapEvent)(nil), // 7: main.SlapEvent
|
||||||
|
(*ClientEvent)(nil), // 8: main.ClientEvent
|
||||||
|
(*GameEvent)(nil), // 9: main.GameEvent
|
||||||
|
(*ServerEnvelope)(nil), // 10: main.ServerEnvelope
|
||||||
|
}
|
||||||
|
var file_clientdata_proto_depIdxs = []int32{
|
||||||
|
1, // 0: main.ClientData.coordinates:type_name -> main.Coordinates
|
||||||
|
1, // 1: main.ClientCoordinates.coordinates:type_name -> main.Coordinates
|
||||||
|
2, // 2: main.AllClients.Clients:type_name -> main.ClientData
|
||||||
|
3, // 3: main.ClientEnvelope.coordinates:type_name -> main.ClientCoordinates
|
||||||
|
7, // 4: main.ClientEnvelope.slap:type_name -> main.SlapEvent
|
||||||
|
5, // 5: main.ServerEnvelope.identity:type_name -> main.ClientIdentity
|
||||||
|
4, // 6: main.ServerEnvelope.broadcast:type_name -> main.AllClients
|
||||||
|
8, // 7: main.ServerEnvelope.event:type_name -> main.ClientEvent
|
||||||
|
9, // 8: main.ServerEnvelope.gameevent:type_name -> main.GameEvent
|
||||||
|
9, // [9:9] is the sub-list for method output_type
|
||||||
|
9, // [9:9] is the sub-list for method input_type
|
||||||
|
9, // [9:9] is the sub-list for extension type_name
|
||||||
|
9, // [9:9] is the sub-list for extension extendee
|
||||||
|
0, // [0:9] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_clientdata_proto_init() }
|
||||||
|
func file_clientdata_proto_init() {
|
||||||
|
if File_clientdata_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
file_clientdata_proto_msgTypes[5].OneofWrappers = []any{
|
||||||
|
(*ClientEnvelope_Coordinates)(nil),
|
||||||
|
(*ClientEnvelope_Slap)(nil),
|
||||||
|
}
|
||||||
|
file_clientdata_proto_msgTypes[8].OneofWrappers = []any{
|
||||||
|
(*GameEvent_Slap)(nil),
|
||||||
|
(*GameEvent_Eliminated)(nil),
|
||||||
|
}
|
||||||
|
file_clientdata_proto_msgTypes[9].OneofWrappers = []any{
|
||||||
|
(*ServerEnvelope_Identity)(nil),
|
||||||
|
(*ServerEnvelope_Broadcast)(nil),
|
||||||
|
(*ServerEnvelope_Event)(nil),
|
||||||
|
(*ServerEnvelope_Gameevent)(nil),
|
||||||
|
}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: file_clientdata_proto_rawDesc,
|
||||||
|
NumEnums: 1,
|
||||||
|
NumMessages: 10,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 0,
|
||||||
|
},
|
||||||
|
GoTypes: file_clientdata_proto_goTypes,
|
||||||
|
DependencyIndexes: file_clientdata_proto_depIdxs,
|
||||||
|
EnumInfos: file_clientdata_proto_enumTypes,
|
||||||
|
MessageInfos: file_clientdata_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_clientdata_proto = out.File
|
||||||
|
file_clientdata_proto_rawDesc = nil
|
||||||
|
file_clientdata_proto_goTypes = nil
|
||||||
|
file_clientdata_proto_depIdxs = nil
|
||||||
|
}
|
||||||
@@ -1,24 +1,40 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"server/gamedata"
|
"server/gamedata"
|
||||||
"strconv"
|
"server/pb"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
boxwidth = 20
|
||||||
|
boxheight = 20
|
||||||
|
checkRadius = 200
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientData struct {
|
type ClientData struct {
|
||||||
|
Id int
|
||||||
Address string
|
Address string
|
||||||
Name string
|
Name string
|
||||||
Position gamedata.Coordinates
|
Position gamedata.Coordinates
|
||||||
|
Hit bool
|
||||||
|
Target int
|
||||||
|
Targets []int
|
||||||
|
Slapping bool
|
||||||
|
Eliminated bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
generatorId int
|
||||||
//clientlist map[net.Conn]string
|
//clientlist map[net.Conn]string
|
||||||
clientlist map[net.Conn]ClientData
|
clientlist map[net.Conn]ClientData
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
@@ -49,11 +65,15 @@ func (s *Server) Start(port int) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Println("New connection " + conn.RemoteAddr().String())
|
log.Println("New connection " + conn.RemoteAddr().String())
|
||||||
go s.HandleClient(conn)
|
|
||||||
|
//increment the client count by one
|
||||||
|
s.generatorId++
|
||||||
|
|
||||||
|
go s.HandleClient(conn, s.generatorId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) HandleClient(conn net.Conn) {
|
func (s *Server) HandleClient(conn net.Conn, id int) {
|
||||||
|
|
||||||
//remove client from list upon disconnection
|
//remove client from list upon disconnection
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -61,53 +81,116 @@ func (s *Server) HandleClient(conn net.Conn) {
|
|||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
delete(s.clientlist, conn)
|
delete(s.clientlist, conn)
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
s.SendClientEvent(conn, id, false)
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
//create the outline of client data, so far we know only
|
//before we add the client to the clientlist, let's send them their unique id first
|
||||||
//their addr, then add it to our client list
|
s.SendClientIdentity(conn, id)
|
||||||
clientdata := ClientData{
|
s.SendClientEvent(conn, id, true)
|
||||||
Address: conn.RemoteAddr().String(),
|
|
||||||
}
|
|
||||||
s.mu.Lock()
|
|
||||||
//s.clientlist[conn] = conn.RemoteAddr().String()
|
|
||||||
s.clientlist[conn] = clientdata
|
|
||||||
s.mu.Unlock()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// Read data from the client
|
// Read data from the client
|
||||||
data, err := bufio.NewReader(conn).ReadString('\n')
|
|
||||||
|
// Read the length prefix (4 bytes)
|
||||||
|
lengthBuf := make([]byte, 4)
|
||||||
|
_, err := io.ReadFull(conn, lengthBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return // Exit the Goroutine when the client disconnects
|
if err == io.EOF {
|
||||||
|
fmt.Println("client closed connection")
|
||||||
|
} else {
|
||||||
|
fmt.Println("failed to read length prefix: ", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Received:", string(data))
|
length := binary.BigEndian.Uint32(lengthBuf)
|
||||||
data = data[:len(data)-1]
|
|
||||||
//s.BroadcastMessage(conn, string(data))
|
|
||||||
|
|
||||||
//now we update our information with their data:
|
// Read the protobuf data
|
||||||
serverinfo := strings.Split(string(data), ",")
|
data := make([]byte, length)
|
||||||
if len(serverinfo) == 3 {
|
_, err = io.ReadFull(conn, data)
|
||||||
|
|
||||||
x, err := strconv.Atoi(serverinfo[1])
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
x = 0
|
fmt.Println("failed to read data: ", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
y, err := strconv.Atoi(serverinfo[2])
|
var clientenvelope pb.ClientEnvelope
|
||||||
|
err = proto.Unmarshal(data, &clientenvelope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
y = 0
|
fmt.Println("failed to deserialize: ", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch payload := clientenvelope.Payload.(type) {
|
||||||
|
case *pb.ClientEnvelope_Coordinates:
|
||||||
cd := ClientData{
|
cd := ClientData{
|
||||||
|
Id: id,
|
||||||
Address: conn.RemoteAddr().String(),
|
Address: conn.RemoteAddr().String(),
|
||||||
Name: serverinfo[0],
|
Name: payload.Coordinates.Name,
|
||||||
Position: gamedata.Coordinates{X: float64(x), Y: float64(y)},
|
Position: gamedata.Coordinates{X: payload.Coordinates.Coordinates.X, Y: payload.Coordinates.Coordinates.Y},
|
||||||
|
Hit: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
//check if we have any collisions with other entities
|
||||||
|
for _, client := range s.clientlist {
|
||||||
|
if client.Id != id {
|
||||||
|
|
||||||
|
dx := client.Position.X - cd.Position.X
|
||||||
|
dy := client.Position.Y - cd.Position.Y
|
||||||
|
if math.Abs(dx) < boxwidth && math.Abs(dy) < boxheight {
|
||||||
|
//collision, mark it
|
||||||
|
cd.Hit = true
|
||||||
|
//cd.Target = client.Id
|
||||||
|
cd.Targets = append(cd.Targets, client.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p1 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X - boxwidth/2,
|
||||||
|
Y: cd.Position.Y - boxheight/2,
|
||||||
|
}
|
||||||
|
p2 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X - boxwidth/2,
|
||||||
|
Y: cd.Position.Y + boxheight/2,
|
||||||
|
}
|
||||||
|
p3 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X + boxwidth/2,
|
||||||
|
Y: cd.Position.Y + boxheight/2,
|
||||||
|
}
|
||||||
|
p4 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X + boxwidth/2,
|
||||||
|
Y: cd.Position.Y - boxheight/2,
|
||||||
|
}
|
||||||
|
circle := gamedata.Coordinates{
|
||||||
|
X: 640 / 2,
|
||||||
|
Y: 480 / 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
if circle.Distance(p1) > checkRadius &&
|
||||||
|
circle.Distance(p2) > checkRadius &&
|
||||||
|
circle.Distance(p3) > checkRadius &&
|
||||||
|
circle.Distance(p4) > checkRadius {
|
||||||
|
fmt.Println("client is OUT ", cd.Id)
|
||||||
|
cd.Eliminated = true
|
||||||
|
}
|
||||||
|
//update the client list
|
||||||
s.clientlist[conn] = cd
|
s.clientlist[conn] = cd
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
|
//s.CheckElimination(cd)
|
||||||
|
|
||||||
|
case *pb.ClientEnvelope_Slap:
|
||||||
|
|
||||||
|
s.mu.Lock()
|
||||||
|
slapper := s.clientlist[conn]
|
||||||
|
s.mu.Unlock()
|
||||||
|
|
||||||
|
for _, target := range slapper.Targets {
|
||||||
|
s.BroadcastSlap(id, target)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -134,32 +217,180 @@ func (s *Server) ManageBroadcast() {
|
|||||||
|
|
||||||
broadcastmsg := s.BuildBroadcastMessage()
|
broadcastmsg := s.BuildBroadcastMessage()
|
||||||
|
|
||||||
s.mu.Lock()
|
envelope := &pb.ServerEnvelope{
|
||||||
for client, data := range s.clientlist {
|
Payload: &pb.ServerEnvelope_Broadcast{
|
||||||
_, err := client.Write([]byte(broadcastmsg))
|
Broadcast: broadcastmsg,
|
||||||
if err != nil {
|
},
|
||||||
fmt.Println("Error sending message to ", data.Address, ": ", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.mu.Lock()
|
||||||
|
for client := range s.clientlist {
|
||||||
|
s.SendMessage(client, envelope)
|
||||||
}
|
}
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
//fmt.Println("Broadcasting:: ", broadcastmsg)
|
|
||||||
time.Sleep(time.Millisecond * 30)
|
time.Sleep(time.Millisecond * 15)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) BuildBroadcastMessage() string {
|
func (s *Server) BuildBroadcastMessage() *pb.AllClients {
|
||||||
|
|
||||||
|
result := &pb.AllClients{}
|
||||||
|
|
||||||
msg := "{"
|
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
|
||||||
for _, data := range s.clientlist {
|
for _, data := range s.clientlist {
|
||||||
msg = msg + fmt.Sprintf("%s,%s,%.0f,%.0f;", data.Address, data.Name, data.Position.X, data.Position.Y)
|
clientdata := &pb.ClientData{
|
||||||
|
Id: int32(data.Id),
|
||||||
|
Address: data.Address,
|
||||||
|
Name: data.Name,
|
||||||
|
Coordinates: &pb.Coordinates{
|
||||||
|
X: data.Position.X,
|
||||||
|
Y: data.Position.Y,
|
||||||
|
},
|
||||||
|
Hit: data.Hit,
|
||||||
|
Eliminated: data.Eliminated,
|
||||||
|
}
|
||||||
|
result.Clients = append(result.Clients, clientdata)
|
||||||
}
|
}
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
msg = msg + "}\n"
|
|
||||||
|
|
||||||
return msg
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Disconnect() {
|
func (s *Server) Disconnect() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) SendMessage(conn net.Conn, details *pb.ServerEnvelope) {
|
||||||
|
data, err := proto.Marshal(details)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("error serializing msg details: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//prepend message length
|
||||||
|
length := len(data)
|
||||||
|
buf := make([]byte, 4+length)
|
||||||
|
binary.BigEndian.PutUint32(buf[:4], uint32(length))
|
||||||
|
copy(buf[4:], data)
|
||||||
|
|
||||||
|
s.SendBuffer(conn, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) SendBuffer(conn net.Conn, buf []byte) {
|
||||||
|
//write until entire buffer transmitted
|
||||||
|
totalWritten := 0
|
||||||
|
for totalWritten < len(buf) {
|
||||||
|
n, err := conn.Write(buf[totalWritten:])
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("error writing to connection ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
totalWritten += n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) SendClientIdentity(conn net.Conn, id int) {
|
||||||
|
identifier := &pb.ClientIdentity{
|
||||||
|
Id: int32(id),
|
||||||
|
}
|
||||||
|
|
||||||
|
envelope := &pb.ServerEnvelope{
|
||||||
|
Payload: &pb.ServerEnvelope_Identity{
|
||||||
|
Identity: identifier,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.SendMessage(conn, envelope)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) SendClientEvent(conn net.Conn, id int, connected bool) {
|
||||||
|
event := &pb.ClientEvent{
|
||||||
|
Id: int32(id),
|
||||||
|
Connected: connected,
|
||||||
|
}
|
||||||
|
envelope := &pb.ServerEnvelope{
|
||||||
|
Payload: &pb.ServerEnvelope_Event{
|
||||||
|
Event: event,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.mu.Lock()
|
||||||
|
for conn := range s.clientlist {
|
||||||
|
s.SendMessage(conn, envelope)
|
||||||
|
}
|
||||||
|
s.mu.Unlock()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) BroadcastSlap(instigator, target int) {
|
||||||
|
|
||||||
|
slap := &pb.GameEvent_Slap{
|
||||||
|
Slap: true,
|
||||||
|
}
|
||||||
|
envelope := &pb.ServerEnvelope{
|
||||||
|
Payload: &pb.ServerEnvelope_Gameevent{
|
||||||
|
Gameevent: &pb.GameEvent{
|
||||||
|
Instigator: int32(instigator),
|
||||||
|
Target: int32(target),
|
||||||
|
Event: slap,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.mu.Lock()
|
||||||
|
for conn := range s.clientlist {
|
||||||
|
s.SendMessage(conn, envelope)
|
||||||
|
}
|
||||||
|
s.mu.Unlock()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) CheckElimination(cd ClientData) {
|
||||||
|
p1 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X - boxwidth/2,
|
||||||
|
Y: cd.Position.Y - boxheight/2,
|
||||||
|
}
|
||||||
|
p2 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X - boxwidth/2,
|
||||||
|
Y: cd.Position.Y + boxheight/2,
|
||||||
|
}
|
||||||
|
p3 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X + boxwidth/2,
|
||||||
|
Y: cd.Position.Y + boxheight/2,
|
||||||
|
}
|
||||||
|
p4 := gamedata.Coordinates{
|
||||||
|
X: cd.Position.X + boxwidth/2,
|
||||||
|
Y: cd.Position.Y - boxheight/2,
|
||||||
|
}
|
||||||
|
circle := gamedata.Coordinates{
|
||||||
|
X: 640 / 2,
|
||||||
|
Y: 480 / 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
if circle.Distance(p1) > checkRadius &&
|
||||||
|
circle.Distance(p2) > checkRadius &&
|
||||||
|
circle.Distance(p3) > checkRadius &&
|
||||||
|
circle.Distance(p4) > checkRadius {
|
||||||
|
fmt.Println("client is OUT ", cd.Id)
|
||||||
|
|
||||||
|
elim := &pb.GameEvent_Eliminated{
|
||||||
|
Eliminated: true,
|
||||||
|
}
|
||||||
|
envelope := &pb.ServerEnvelope{
|
||||||
|
Payload: &pb.ServerEnvelope_Gameevent{
|
||||||
|
Gameevent: &pb.GameEvent{
|
||||||
|
Target: int32(cd.Id),
|
||||||
|
Event: elim,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
s.mu.Lock()
|
||||||
|
for conn := range s.clientlist {
|
||||||
|
s.SendMessage(conn, envelope)
|
||||||
|
}
|
||||||
|
s.mu.Unlock()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user