2020-06-13 18:32:09 -04:00
|
|
|
package d2netpacket
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
2020-06-25 14:56:49 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2hero"
|
2020-06-13 18:32:09 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2inventory"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket/d2netpackettype"
|
|
|
|
)
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// AddPlayerPacket contains the data required to create a Player entity.
|
|
|
|
// It is sent by the server to create the entity for a newly connected
|
|
|
|
// player on a client.
|
2020-06-13 18:32:09 -04:00
|
|
|
type AddPlayerPacket struct {
|
2020-07-17 22:11:16 -04:00
|
|
|
ID string `json:"id"`
|
2020-06-18 14:11:04 -04:00
|
|
|
Name string `json:"name"`
|
2020-06-13 18:32:09 -04:00
|
|
|
X int `json:"x"`
|
|
|
|
Y int `json:"y"`
|
|
|
|
HeroType d2enum.Hero `json:"hero"`
|
|
|
|
Equipment d2inventory.CharacterEquipment `json:"equipment"`
|
2020-07-17 22:11:16 -04:00
|
|
|
Stats *d2hero.HeroStatsState `json:"heroStats"`
|
2020-06-13 18:32:09 -04:00
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// CreateAddPlayerPacket returns a NetPacket which declares an
|
|
|
|
// AddPlayerPacket with the data in given parameters.
|
2020-07-17 22:11:16 -04:00
|
|
|
func CreateAddPlayerPacket(id, name string, x, y int, heroType d2enum.Hero,
|
|
|
|
stats *d2hero.HeroStatsState, equipment d2inventory.CharacterEquipment) NetPacket {
|
2020-06-13 18:32:09 -04:00
|
|
|
return NetPacket{
|
|
|
|
PacketType: d2netpackettype.AddPlayer,
|
|
|
|
PacketData: AddPlayerPacket{
|
2020-07-17 22:11:16 -04:00
|
|
|
ID: id,
|
2020-06-18 14:11:04 -04:00
|
|
|
Name: name,
|
2020-06-13 18:32:09 -04:00
|
|
|
X: x,
|
|
|
|
Y: y,
|
|
|
|
HeroType: heroType,
|
|
|
|
Equipment: equipment,
|
2020-06-29 17:01:26 -04:00
|
|
|
Stats: stats,
|
2020-06-13 18:32:09 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|