#include "socket.h"
#include "simpleclass.h"

void CMissile::read(Socket &socket){
	ClassName = socket.nextInt();
	PositionX = socket.nextFloat();
	PositionY = socket.nextFloat();
	VelocityX = socket.nextFloat();
	VelocityY = socket.nextFloat();
	Radius = socket.nextFloat();
	HitPoints = socket.nextFloat();
	MaxHitPoints = socket.nextFloat();
	Damage = socket.nextFloat();
}

void CMissile::write(Socket &socket) const{
	socket.writeInt(ClassName);
	socket.writeFloat(PositionX);
	socket.writeFloat(PositionY);
	socket.writeFloat(VelocityX);
	socket.writeFloat(VelocityY);
	socket.writeFloat(Radius);
	socket.writeFloat(HitPoints);
	socket.writeFloat(MaxHitPoints);
	socket.writeFloat(Damage);
}

void CPlayer::read(Socket &socket){
	ClassName = socket.nextInt();
	PositionX = socket.nextFloat();
	PositionY = socket.nextFloat();
	VelocityX = socket.nextFloat();
	VelocityY = socket.nextFloat();
	Radius = socket.nextFloat();
	HitPoints = socket.nextFloat();
	MaxHitPoints = socket.nextFloat();
	MaxVelocity = socket.nextFloat();
	MaxAcceleration = socket.nextFloat();
	GunCooldownRemaining = socket.nextFloat();
	GunCooldownPeriod = socket.nextFloat();
	BulletDamage = socket.nextFloat();
	BulletHitPoints = socket.nextFloat();
	BulletVelocity = socket.nextFloat();
	BulletRadius = socket.nextFloat();
	ShootX = socket.nextFloat();
	ShootY = socket.nextFloat();
	RunX = socket.nextFloat();
	RunY = socket.nextFloat();
	Time = socket.nextInt();
}

void CPlayer::write(Socket &socket) const{
	socket.writeInt(ClassName);
	socket.writeFloat(PositionX);
	socket.writeFloat(PositionY);
	socket.writeFloat(VelocityX);
	socket.writeFloat(VelocityY);
	socket.writeFloat(Radius);
	socket.writeFloat(HitPoints);
	socket.writeFloat(MaxHitPoints);
	socket.writeFloat(MaxVelocity);
	socket.writeFloat(MaxAcceleration);
	socket.writeFloat(GunCooldownRemaining);
	socket.writeFloat(GunCooldownPeriod);
	socket.writeFloat(BulletDamage);
	socket.writeFloat(BulletHitPoints);
	socket.writeFloat(BulletVelocity);
	socket.writeFloat(BulletRadius);
	socket.writeFloat(ShootX);
	socket.writeFloat(ShootY);
	socket.writeFloat(RunX);
	socket.writeFloat(RunY);
	socket.writeInt(Time);
}

void CMonster::read(Socket &socket){
	ClassName = socket.nextInt();
	PositionX = socket.nextFloat();
	PositionY = socket.nextFloat();
	VelocityX = socket.nextFloat();
	VelocityY = socket.nextFloat();
	Radius = socket.nextFloat();
	HitPoints = socket.nextFloat();
	MaxHitPoints = socket.nextFloat();
	MaxVelocity = socket.nextFloat();
	MaxAcceleration = socket.nextFloat();
	GunCooldownRemaining = socket.nextFloat();
	GunCooldownPeriod = socket.nextFloat();
	BulletDamage = socket.nextFloat();
	BulletHitPoints = socket.nextFloat();
	BulletVelocity = socket.nextFloat();
	BulletRadius = socket.nextFloat();
	TeethCooldownRemaining = socket.nextFloat();
	TeethCooldownPeriod = socket.nextFloat();
	BiteDamage = socket.nextFloat();
}

void CMonster::write(Socket &socket) const{
	socket.writeInt(ClassName);
	socket.writeFloat(PositionX);
	socket.writeFloat(PositionY);
	socket.writeFloat(VelocityX);
	socket.writeFloat(VelocityY);
	socket.writeFloat(Radius);
	socket.writeFloat(HitPoints);
	socket.writeFloat(MaxHitPoints);
	socket.writeFloat(MaxVelocity);
	socket.writeFloat(MaxAcceleration);
	socket.writeFloat(GunCooldownRemaining);
	socket.writeFloat(GunCooldownPeriod);
	socket.writeFloat(BulletDamage);
	socket.writeFloat(BulletHitPoints);
	socket.writeFloat(BulletVelocity);
	socket.writeFloat(BulletRadius);
	socket.writeFloat(TeethCooldownRemaining);
	socket.writeFloat(TeethCooldownPeriod);
	socket.writeFloat(BiteDamage);
}

