1package com.runehive.game.world.entity.mob.player.camera;
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.game.world.position.Position;
5import com.runehive.game.world.entity.mob.npc.Npc;
6import com.runehive.net.packet.out.SendCameraMove;
7import com.runehive.net.packet.out.SendCameraTurn;
8import com.runehive.net.packet.out.SendCameraReset;
21 private static final boolean DEBUG =
true;
24 private static final double BACK = 1.7;
28 private static final int MOVE_Z = 220;
51 System.out.println(
"[DialogueCam] Delay complete, activating BEHIND_PLAYER mode");
55 System.out.println(
"[DialogueCam] Delaying activation: " + p.
dialogueCamDelayTicks +
" ticks remaining");
73 final boolean swapBoost = p.dialogueCamSwapBoostTicks > 0;
87 case BEHIND_PLAYER -> {
88 shoulderShot(p, playerPos, npcPos, moveConst, moveVar, turnConst, turnVar);
91 shoulderShot(p, npcPos, playerPos, moveConst, moveVar, turnConst, turnVar);
93 case RESET_PENDING -> {
98 p.dialogueCamNpc =
null;
99 p.dialogueCamSwapBoostTicks = 0;
111 int moveConst,
int moveVar,
int turnConst,
int turnVar) {
112 System.out.println(
"== Dialogue Camera Shot ==");
113 System.out.println(
"Player world pos : " + from);
114 System.out.println(
"Target world pos : " + to);
115 System.out.println(
"Player position : " + p.
getPosition());
121 final double dx = to.
getX() - from.
getX();
122 final double dy = to.
getY() - from.
getY();
123 final double len = Math.max(1e-6, Math.hypot(dx, dy));
126 final double fx = dx / len;
127 final double fy = dy / len;
130 final double rx = fy, ry = -fx;
150 if ((localCamX|localCamY|localLookX|localLookY) < 0 ||
151 localCamX > 104 || localCamY > 104 || localLookX > 104 || localLookY > 104) {
152 System.err.printf(
"[Camera BUG] Out-of-bounds: LocalCam=(%d,%d) LocalLook=(%d,%d)%n",
153 localCamX, localCamY, localLookX, localLookY);
158 System.out.printf(
"GlobalCam=(%d,%d) GlobalLook=(%d,%d) | SceneBaseTiles=(%d,%d) | LocalCam=(%d,%d) LocalLook=(%d,%d)%n",
162 localCamX, localCamY,
163 localLookX, localLookY
Represents a non-player character in the in-game world.
This class represents a character controlled by a player.
transient int dialogueCamDelayTicks
Delay ticks before camera activates (prevents coordinate misalignment at dialogue start).
int toSceneLocalX(int worldX)
transient int dialogueCamSwapBoostTicks
While >0, camera turns use slightly faster "swap" speeds for a smoother P↔NPC flip.
transient com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.Mode dialogueCamMode
Dialogue camera system.
transient com.runehive.game.world.entity.mob.npc.Npc dialogueCamNpc
int toSceneLocalY(int worldY)
void send(OutgoingPacket encoder)
static final int TURN_CONST_SWAP
static void requestReset(Player p)
Ask for a smooth reset on the next tick.
static final double RIGHT
static void tick(Player p)
Recompute and send camera on each tick while active.
static final int TURN_VAR_SWAP
static final int MOVE_CONST_SWAP
static final int TURN_TILT_Z
static void shoulderShot(Player p, Position from, Position to, int moveConst, int moveVar, int turnConst, int turnVar)
Place camera behind 'from' and turn toward 'to'.
static final double RIGHT_NUDGE
static final int MOVE_VAR_BASE
static final int TURN_VAR_BASE
static final int MOVE_VAR_SWAP
static final double RIGHT_BASE
static final int TURN_CONST_BASE
static void boostSwap(Player p, int ticks)
Small helper to prime faster turn for a few ticks after a mode swap.
static final boolean DEBUG
static final int MOVE_CONST_BASE
Represents a single tile on the game world.
int getHeight()
Gets the height coordinate, or height.
int getY()
Gets the absolute y coordinate.
int getX()
Gets the absolute x coordinate.
int getLocalY()
Gets the local y coordinate relative to this region.
int getLocalX()
Gets the local x coordinate relative to this region.
The OutgoingPacket resets the camera position for Player.