public unsafe Vector2 WorldToScreen(Vector3 vec3) { float x, y; long addr = Address + 0x5C; fixed(byte *numRef = M.ReadBytes(addr, 0x40)) { Matrix4x4 matrix = *(Matrix4x4 *)numRef; Vector4 cord = *(Vector4 *)&vec3; cord.W = 1; cord = Vector4.Transform(cord, matrix); cord = Vector4.Divide(cord, cord.W); x = (cord.X + 1.0f) * 0.5f * Width; y = (1.0f - cord.Y) * 0.5f * Height; } return(new Vector2(x, y)); }
public unsafe Vector2 WorldToScreen(Vector3 vec3, EntityWrapper entityWrapper) { Entity localPlayer = Game.IngameState.Data.LocalPlayer; var isplayer = localPlayer.Address == entityWrapper.Address && localPlayer.IsValid; var playerMoving = isplayer && localPlayer.GetComponent <Actor>().isMoving; float x, y; int addr = Address + 0x11C; fixed(byte *numRef = M.ReadBytes(addr, 0x40)) { Matrix4x4 matrix = *(Matrix4x4 *)numRef; Vector4 cord = *(Vector4 *)&vec3; cord.W = 1; cord = Vector4.Transform(cord, matrix); cord = Vector4.Divide(cord, cord.W); x = (cord.X + 1.0f) * 0.5f * Width; y = (1.0f - cord.Y) * 0.5f * Height; } var resultCord = new Vector2(x, y); if (playerMoving) { if (Math.Abs(oldplayerCord.X - resultCord.X) < 40 || (Math.Abs(oldplayerCord.X - resultCord.Y) < 40)) { resultCord = oldplayerCord; } else { oldplayerCord = resultCord; } } else if (isplayer) { oldplayerCord = resultCord; } return(resultCord); }