@@ -93,7 +93,11 @@ public class MovedStatics {
93
93
public static int anInt573 = -1 ;
94
94
public static boolean menuOpen = false ;
95
95
public static volatile long aLong174 = 0L ;
96
- public static int anInt175 = 0 ;
96
+
97
+ /**
98
+ * Position of the hint icon in world coordinates (e.g. 3222,3222).
99
+ */
100
+ public static int hintIconPosY = 0 ;
97
101
public static int [] anIntArray178 ;
98
102
public static int [] chatboxLineOffsets ;
99
103
public static int anInt199 = 0 ;
@@ -1947,54 +1951,69 @@ public static void method311(Component arg1) {
1947
1951
arg1 .removeFocusListener (Class59 .keyFocusListener );
1948
1952
}
1949
1953
1950
- public static void method450 () {
1951
- if ( Player . headIconDrawType == 2 ) {
1952
- MovedStatics . method312 ( 2 * ActorDefinition . anInt2404 , Class35 . anInt1730 + (- Class26 . baseY + anInt175 << 7 ), ( ProducingGraphicsBuffer . anInt1637 + - baseX << 7 ) + Landscape . anInt1170 , 4976905 );
1953
- if ( ISAAC . anInt522 > - 1 && pulseCycle % 20 < 10 )
1954
- hintIconSprites [ 0 ]. drawImage ( ISAAC . anInt522 + - 12 , - 28 + Class44 . anInt1048 );
1955
- }
1956
- }
1954
+ /**
1955
+ * Draws the 2d yellow arrow hint icon in the world.
1956
+ */
1957
+ public static void drawPositionHintIcon () {
1958
+ if ( Player . headIconDrawType != 2 ) {
1959
+ return ;
1960
+ }
1957
1961
1958
- public static void method312 (int arg0 , int arg1 , int arg2 , int arg3 ) {
1959
- if (arg2 < 128 || arg1 < 128 || arg2 > 13056 || arg1 > 13056 ) {
1960
- Class44 .anInt1048 = -1 ;
1961
- ISAAC .anInt522 = -1 ;
1962
- } else {
1963
- int i = Scene .getFloorDrawHeight (Player .worldLevel , arg2 , arg1 ) + -arg0 ;
1964
-
1965
- Point3d cameraPos = Main .getActiveCamera ().getPosition ();
1966
- CameraRotation rotation = Main .getActiveCamera ().getRotation ();
1967
-
1968
- arg1 -= cameraPos .y ;
1969
- i -= cameraPos .z ;
1970
- int i_1_ = Model .COSINE [rotation .pitch ];
1971
- int i_2_ = Model .SINE [rotation .pitch ];
1972
- arg2 -= cameraPos .x ;
1973
- int i_3_ = Model .SINE [rotation .yaw ];
1974
- int i_4_ = Model .COSINE [rotation .yaw ];
1975
- int i_5_ = arg1 * i_3_ + arg2 * i_4_ >> 16 ;
1976
- arg1 = i_4_ * arg1 - arg2 * i_3_ >> 16 ;
1977
- if (arg3 != 4976905 )
1978
- English .password = null ;
1979
- arg2 = i_5_ ;
1980
- i_5_ = i * i_1_ - arg1 * i_2_ >> 16 ;
1981
- arg1 = arg1 * i_1_ + i * i_2_ >> 16 ;
1982
- i = i_5_ ;
1983
- if (arg1 < 50 ) {
1984
- Class44 .anInt1048 = -1 ;
1985
- ISAAC .anInt522 = -1 ;
1986
- } else {
1987
- if (ScreenController .frameMode == ScreenMode .FIXED ){
1988
- ISAAC .anInt522 = 256 + (arg2 << 9 ) / arg1 ;
1989
- Class44 .anInt1048 = (i << 9 ) / arg1 + 167 ;
1990
- } else {
1991
- ISAAC .anInt522 = ScreenController .drawWidth /2 + (arg2 << 9 ) / arg1 ;
1992
- Class44 .anInt1048 = (i << 9 ) / arg1 + ScreenController .drawHeight /2 ;
1993
- }
1994
-
1995
- }
1996
- }
1997
- }
1962
+ Point2d screenPos = MovedStatics .getProjectedScreenPosition (2 * ActorDefinition .hintIconPosZ , Class35 .hintIconInnerPosY + (-Class26 .baseY + hintIconPosY << 7 ), (ProducingGraphicsBuffer .hintIconPosX + -baseX << 7 ) + Landscape .hintIconInnerPosX );
1963
+
1964
+ if (screenPos == null ) {
1965
+ return ;
1966
+ }
1967
+
1968
+ if (pulseCycle % 20 < 10 )
1969
+ hintIconSprites [0 ].drawImage (screenPos .x - 12 , screenPos .y - 28 );
1970
+ }
1971
+
1972
+ /**
1973
+ * Project 3d pos to 3d
1974
+ */
1975
+ public static Point2d getProjectedScreenPosition (int z , int y , int x ) {
1976
+ if (x < 128 || y < 128 || x > 13056 || y > 13056 ) {
1977
+ return null ;
1978
+ }
1979
+
1980
+ int drawHeight = Scene .getFloorDrawHeight (Player .worldLevel , x , y ) - z ;
1981
+
1982
+ Point3d cameraPos = Main .getActiveCamera ().getPosition ();
1983
+ CameraRotation rotation = Main .getActiveCamera ().getRotation ();
1984
+
1985
+ x -= cameraPos .x ;
1986
+ y -= cameraPos .y ;
1987
+ drawHeight -= cameraPos .z ;
1988
+ int cosinePitch = Model .COSINE [rotation .pitch ];
1989
+ int sinePitch = Model .SINE [rotation .pitch ];
1990
+ int sineYaw = Model .SINE [rotation .yaw ];
1991
+ int cosineYaw = Model .COSINE [rotation .yaw ];
1992
+
1993
+ // rotate x/y/z according to camera pos
1994
+ int tmp = y * sineYaw + x * cosineYaw >> 16 ;
1995
+ y = cosineYaw * y - x * sineYaw >> 16 ;
1996
+ x = tmp ;
1997
+ tmp = drawHeight * cosinePitch - y * sinePitch >> 16 ;
1998
+ y = y * cosinePitch + drawHeight * sinePitch >> 16 ;
1999
+ drawHeight = tmp ;
2000
+
2001
+ // TODO (jkm) why don't we draw below y=50?
2002
+ if (y < 50 ) {
2003
+ return null ;
2004
+ }
2005
+
2006
+ return new Point2d ((x << 9 ) / y , (drawHeight << 9 ) / y )
2007
+ .add (getScreenMidpoint ());
2008
+ }
2009
+
2010
+ public static Point2d getScreenMidpoint () {
2011
+ if (ScreenController .frameMode == ScreenMode .FIXED ) {
2012
+ return new Point2d (256 , 167 );
2013
+ } else {
2014
+ return new Point2d (ScreenController .drawWidth / 2 , ScreenController .drawHeight / 2 );
2015
+ }
2016
+ }
1998
2017
1999
2018
public static void method313 () {
2000
2019
for (int i = -1 ; Player .localPlayerCount > i ; i ++) {
0 commit comments