Skip to content

Commit 89f3c72

Browse files
committed
refactor: move rendering to Game
1 parent 84c1809 commit 89f3c72

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

src/main/java/org/runejs/client/Game.java

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,8 @@ public static void method353() {
769769
renderNPCs(true);
770770
renderPlayers(0, false);
771771
renderNPCs(false);
772-
MovedStatics.renderProjectiles();
773-
MovedStatics.renderSpotAnims();
772+
renderProjectiles();
773+
renderSpotAnims();
774774
if(!Player.cutsceneActive) {
775775
int pitch = Game.playerCamera.getPitch();
776776
if(SceneCamera.cameraTerrainMinScaledPitch / 256 > pitch) {
@@ -2075,6 +2075,49 @@ public static void clearCaches() {
20752075
CacheArchive.clientScriptCacheArchive.clearCache();
20762076
}
20772077

2078+
public static void renderProjectiles() {
2079+
Projectile projectile = (Projectile) MovedStatics.projectileQueue.peekFirst();
2080+
for (/**/; projectile != null; projectile = (Projectile) MovedStatics.projectileQueue.pollFirst()) {
2081+
if (Player.worldLevel == projectile.anInt2981 && MovedStatics.pulseCycle <= projectile.endCycle) {
2082+
if (projectile.delay <= MovedStatics.pulseCycle) {
2083+
if (projectile.entityIndex > 0) {
2084+
Npc npc = Player.npcs[-1 + projectile.entityIndex];
2085+
if (npc != null && npc.worldX >= 0 && npc.worldX < 13312 && npc.worldY >= 0 && npc.worldY < 13312)
2086+
projectile.trackTarget(MovedStatics.pulseCycle, 61 + -61, npc.worldY, Scene.getFloorDrawHeight(projectile.anInt2981, npc.worldX, npc.worldY) - projectile.endHeight, npc.worldX);
2087+
}
2088+
if (projectile.entityIndex < 0) {
2089+
int i = -1 + -projectile.entityIndex;
2090+
Player player;
2091+
if (i != Player.localPlayerId)
2092+
player = Player.trackedPlayers[i];
2093+
else
2094+
player = Player.localPlayer;
2095+
if (player != null && player.worldX >= 0 && player.worldX < 13312 && player.worldY >= 0 && player.worldY < 13312)
2096+
projectile.trackTarget(MovedStatics.pulseCycle, 0, player.worldY, Scene.getFloorDrawHeight(projectile.anInt2981, player.worldX, player.worldY) - projectile.endHeight, player.worldX);
2097+
}
2098+
projectile.move(MovedStatics.anInt199);
2099+
currentScene.method134(Player.worldLevel, (int) projectile.currentX, (int) projectile.currentY, (int) projectile.currentHeight, 60, projectile, projectile.anInt3013, -1, false);
2100+
}
2101+
} else
2102+
projectile.unlink();
2103+
}
2104+
}
2105+
2106+
public static void renderSpotAnims() {
2107+
for (SpotAnim spotAnim = (SpotAnim) MovedStatics.spotAnimQueue.peekFirst(); spotAnim != null; spotAnim = (SpotAnim) MovedStatics.spotAnimQueue.pollFirst()) {
2108+
if (Player.worldLevel == spotAnim.plane && !spotAnim.animationFinished) {
2109+
if (MovedStatics.pulseCycle >= spotAnim.startCycle) {
2110+
spotAnim.method834(MovedStatics.anInt199);
2111+
if (spotAnim.animationFinished)
2112+
spotAnim.unlink();
2113+
else
2114+
currentScene.method134(spotAnim.plane, spotAnim.x, spotAnim.y, spotAnim.z, 60, spotAnim, 0, -1, false);
2115+
}
2116+
} else
2117+
spotAnim.unlink();
2118+
}
2119+
}
2120+
20782121
public void method35(int arg1) {
20792122
if (currentPort != gameServerPort)
20802123
currentPort = gameServerPort;

src/main/java/org/runejs/client/MovedStatics.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -472,21 +472,6 @@ public static void method996() {
472472
sidebarOffsets = Rasterizer3D.setLineOffsets(sidebarOffsets);
473473
}
474474

475-
public static void renderSpotAnims() {
476-
for (SpotAnim spotAnim = (SpotAnim) spotAnimQueue.peekFirst(); spotAnim != null; spotAnim = (SpotAnim) spotAnimQueue.pollFirst()) {
477-
if (Player.worldLevel == spotAnim.plane && !spotAnim.animationFinished) {
478-
if (pulseCycle >= spotAnim.startCycle) {
479-
spotAnim.method834(anInt199);
480-
if (spotAnim.animationFinished)
481-
spotAnim.unlink();
482-
else
483-
Game.currentScene.method134(spotAnim.plane, spotAnim.x, spotAnim.y, spotAnim.z, 60, spotAnim, 0, -1, false);
484-
}
485-
} else
486-
spotAnim.unlink();
487-
}
488-
}
489-
490475
public static int getCutsceneCameraPlane() {
491476
if (!Configuration.ROOFS_ENABLED) {
492477
return Player.worldLevel;
@@ -545,34 +530,6 @@ public static RSString intToStr(int arg0) {
545530
return method521(false, 10, arg0);
546531
}
547532

548-
public static void renderProjectiles() {
549-
Projectile projectile = (Projectile) projectileQueue.peekFirst();
550-
for (/**/; projectile != null; projectile = (Projectile) projectileQueue.pollFirst()) {
551-
if (Player.worldLevel == projectile.anInt2981 && pulseCycle <= projectile.endCycle) {
552-
if (projectile.delay <= pulseCycle) {
553-
if (projectile.entityIndex > 0) {
554-
Npc class40_sub5_sub17_sub4_sub2 = Player.npcs[-1 + projectile.entityIndex];
555-
if (class40_sub5_sub17_sub4_sub2 != null && class40_sub5_sub17_sub4_sub2.worldX >= 0 && class40_sub5_sub17_sub4_sub2.worldX < 13312 && class40_sub5_sub17_sub4_sub2.worldY >= 0 && class40_sub5_sub17_sub4_sub2.worldY < 13312)
556-
projectile.trackTarget(pulseCycle, 61 + -61, class40_sub5_sub17_sub4_sub2.worldY, Scene.getFloorDrawHeight(projectile.anInt2981, class40_sub5_sub17_sub4_sub2.worldX, class40_sub5_sub17_sub4_sub2.worldY) - projectile.endHeight, class40_sub5_sub17_sub4_sub2.worldX);
557-
}
558-
if (projectile.entityIndex < 0) {
559-
int i = -1 + -projectile.entityIndex;
560-
Player class40_sub5_sub17_sub4_sub1;
561-
if (i != Player.localPlayerId)
562-
class40_sub5_sub17_sub4_sub1 = Player.trackedPlayers[i];
563-
else
564-
class40_sub5_sub17_sub4_sub1 = Player.localPlayer;
565-
if (class40_sub5_sub17_sub4_sub1 != null && class40_sub5_sub17_sub4_sub1.worldX >= 0 && class40_sub5_sub17_sub4_sub1.worldX < 13312 && class40_sub5_sub17_sub4_sub1.worldY >= 0 && class40_sub5_sub17_sub4_sub1.worldY < 13312)
566-
projectile.trackTarget(pulseCycle, 0, class40_sub5_sub17_sub4_sub1.worldY, Scene.getFloorDrawHeight(projectile.anInt2981, class40_sub5_sub17_sub4_sub1.worldX, class40_sub5_sub17_sub4_sub1.worldY) - projectile.endHeight, class40_sub5_sub17_sub4_sub1.worldX);
567-
}
568-
projectile.move(anInt199);
569-
Game.currentScene.method134(Player.worldLevel, (int) projectile.currentX, (int) projectile.currentY, (int) projectile.currentHeight, 60, projectile, projectile.anInt3013, -1, false);
570-
}
571-
} else
572-
projectile.unlink();
573-
}
574-
}
575-
576533
public static int perlinNoise(int x, int y, int scale) {
577534
int muX = x & -1 + scale;
578535
int scaledY = y / scale;

0 commit comments

Comments
 (0)