Skip to content

Commit

Permalink
feat: camera packets
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-Kris committed Apr 8, 2024
1 parent 727069e commit 40c4a2c
Show file tree
Hide file tree
Showing 27 changed files with 1,248 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamLookAtEasedAngleRelative
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamLookAtEasedAngleAbsoluteEncoder : MessageEncoder<CamLookAtEasedAngleRelative> {
override val prot: ServerProt = GameServerProt.CAM_LOOKAT_EASED_ANGLE_ABSOLUTE

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamLookAtEasedAngleRelative,
) {
buffer.p2(message.yAngle)
buffer.p2(message.xAngle)
buffer.p2(message.duration)
buffer.p2Alt1(message.function.id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamLookAtEasedAngleRelative
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamLookAtEasedAngleRelativeEncoder : MessageEncoder<CamLookAtEasedAngleRelative> {
override val prot: ServerProt = GameServerProt.CAM_LOOKAT_EASED_ANGLE_RELATIVE

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamLookAtEasedAngleRelative,
) {
buffer.p2(message.yAngle)
buffer.p2(message.xAngle)
buffer.p2(message.duration)
buffer.p2Alt1(message.function.id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamLookAtEasedCoord
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamLookAtEasedCoordEncoder : MessageEncoder<CamLookAtEasedCoord> {
override val prot: ServerProt = GameServerProt.CAM_LOOKAT_EASED_COORD

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamLookAtEasedCoord,
) {
buffer.p1(message.destinationXInBuildArea)
buffer.p1(message.destinationZInBuildArea)
buffer.p2(message.height)
buffer.p2(message.duration)
buffer.p1(message.function.id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamLookAt
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamLookAtEncoder : MessageEncoder<CamLookAt> {
override val prot: ServerProt = GameServerProt.CAM_LOOKAT

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamLookAt,
) {
buffer.p1(message.destinationXInBuildArea)
buffer.p2Alt1(message.destinationZInBuildArea)
buffer.p2(message.height)
buffer.p1(message.speed)
buffer.p1(message.acceleration)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamMode
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder

public class CamModeEncoder : MessageEncoder<CamMode> {
override val prot: ServerProt = GameServerProt.CAM_MODE

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamMode,
) {
buffer.p1(message.mode)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamMoveToEasedCircular
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamMoveToEasedCircularEncoder : MessageEncoder<CamMoveToEasedCircular> {
override val prot: ServerProt = GameServerProt.CAM_MOVETO_EASED_CIRCULAR

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamMoveToEasedCircular,
) {
buffer.p1(message.destinationXInBuildArea)
buffer.p2Alt1(message.destinationZInBuildArea)
buffer.p2(message.height)
buffer.p1(message.centerXInBuildArea)
buffer.p1(message.centerZInBuildArea)
buffer.p2(message.duration)
buffer.pboolean(!message.maintainFixedAltitude)
buffer.p1(message.function.id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamMoveToEased
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamMoveToEasedEncoder : MessageEncoder<CamMoveToEased> {
override val prot: ServerProt = GameServerProt.CAM_MOVETO_EASED

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamMoveToEased,
) {
buffer.p1(message.destinationXInBuildArea)
buffer.p2Alt1(message.destinationZInBuildArea)
buffer.p2(message.height)
buffer.p2(message.duration)
buffer.pboolean(!message.maintainFixedAltitude)
buffer.p1(message.function.id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamMoveTo
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamMoveToEncoder : MessageEncoder<CamMoveTo> {
override val prot: ServerProt = GameServerProt.CAM_MOVETO

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamMoveTo,
) {
buffer.p1(message.destinationXInBuildArea)
buffer.p1(message.destinationZInBuildArea)
buffer.p2(message.height)
buffer.p1(message.speed)
buffer.p1(message.acceleration)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamReset
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamResetEncoder : MessageEncoder<CamReset> {
override val prot: ServerProt = GameServerProt.CAM_RESET

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamReset,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamShake
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamShakeEncoder : MessageEncoder<CamShake> {
override val prot: ServerProt = GameServerProt.CAM_SHAKE

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamShake,
) {
buffer.p1(message.type)
buffer.p1(message.randomAmount)
buffer.p1(message.sineAmount)
buffer.p1(message.sineFrequency)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.CamSmoothReset
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class CamSmoothResetEncoder : MessageEncoder<CamSmoothReset> {
override val prot: ServerProt = GameServerProt.CAM_SMOOTHRESET

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: CamSmoothReset,
) {
buffer.p1(message.cameraMoveConstantSpeed)
buffer.p1(message.cameraMoveProportionalSpeed)
buffer.p1(message.cameraLookConstantSpeed)
buffer.p1(message.cameraLookProportionalSpeed)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.rsprot.protocol.game.outgoing.codec.camera

import io.netty.channel.ChannelHandlerContext
import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ServerProt
import net.rsprot.protocol.game.outgoing.camera.OculusSync
import net.rsprot.protocol.game.outgoing.prot.GameServerProt
import net.rsprot.protocol.message.codec.MessageEncoder
import net.rsprot.protocol.metadata.Consistent

@Consistent
public class OculusSyncEncoder : MessageEncoder<OculusSync> {
override val prot: ServerProt = GameServerProt.OCULUS_SYNC

override fun encode(
ctx: ChannelHandlerContext,
buffer: JagByteBuf,
message: OculusSync,
) {
buffer.p4(message.value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ public enum class GameServerProt(
// Camera packets
CAM_SHAKE(GameServerProtId.CAM_SHAKE, 4),
CAM_RESET(GameServerProtId.CAM_RESET, 0),
CAM_SMOOTH_RESET(GameServerProtId.CAM_SMOOTH_RESET, 4),
CAM_SMOOTHRESET(GameServerProtId.CAM_SMOOTH_RESET, 4),
CAM_MOVETO(GameServerProtId.CAM_MOVETO, 6),
CAM_MOVETO_EASED(GameServerProtId.CAM_MOVETO_EASED, 8),
CAM_LOOKAT_EASED_COORD(GameServerProtId.CAM_LOOKAT_EASED_COORD, 7),
CAM_MOVETO_EASED_CIRCULAR(GameServerProtId.CAM_MOVETO_EASED_CIRCULAR, 10),
CAM_LOOKAT(GameServerProtId.CAM_LOOKAT, 6),
CAM_LOOKAT_EASED_COORD(GameServerProtId.CAM_LOOKAT_EASED_COORD, 7),
CAM_LOOKAT_EASED_ANGLE_RELATIVE(GameServerProtId.CAM_LOOKAT_EASED_ANGLE_RELATIVE, 7),
CAM_LOOKAT_EASED_ANGLE_ABSOLUTE(GameServerProtId.CAM_LOOKAT_EASED_ANGLE_ABSOLUTE, 7),
CAM_MODE(GameServerProtId.CAM_MODE, 1),
Expand Down
Loading

0 comments on commit 40c4a2c

Please sign in to comment.