static esp* es;
EntityManager *entityManager = new EntityManager();
void *myPlayer = NULL;
void *enemyPlayer = NULL;
void(*old_Player_Update)(void *Player);
void Player_Update(void * Player) {
if (Player != NULL) {
entityManager -> tryAddEnemy(Player);
entityManager -> updateEnemies(Player);
std::vector < enemy_t * > * enemies = entityManager -> GetAllEnemies();
std::vector < player_t * > * pplayers = nullptr;
UIWindow * main = [UIApplication sharedApplication].keyWindow;
void *mycam = camera();
old_Player_Update(Player);
enemyPlayer = Player;
Vector3 mPos = GetPlayerLocation(enemyPlayer);
//if ([switches isSwitchOn: @ "Esp"])
if (!IsPlayerDead(Player)){
for (int i = 0; i < entityManager -> enemies -> size(); i++) {
(*enemies) -> location = GetPlayerLocation((*enemies) -> object);
Vector3 orig = (*enemies) -> location;
(*enemies) -> worldtoscreen = WorldToViewportPoint_Injected(mycam, orig);
(*enemies) -> enemy = true;
float xd = pow(mPos.x - (*enemies) -> location.x, 2);
float xd1 = pow(mPos.y - (*enemies) -> location.y, 2);
float xd2 = pow(mPos.z - (*enemies) -> location.z, 2);
float dist = sqrt(xd + xd1 + xd2);
(*enemies) -> distance = dist;
if (!pplayers) {
pplayers = new std::vector < player_t * > ();
}
if (!enemies -> empty()) {
for (int i = 0; i < enemies -> size(); i++) {
if ((*enemies) -> worldtoscreen.z > 0) {
player_t * newplayer = new player_t();
Vector3 newvec = (*enemies) -> worldtoscreen;
newvec.y = fabsf(1 - newvec.y);
float dx = 100.0f / (newvec.z / 4);
float dy = 180.0f / (newvec.z / 4);
float xxxx = (main.frame.size.width * newvec.x) - dx / 2;
float yyyy = (main.frame.size.height * newvec.y) - dy;
newplayer -> health = (*enemies) -> health;
newplayer -> enemy = (*enemies) -> enemy;
newplayer -> distance = (*enemies) -> distance;
newplayer -> rect = CGRectMake(xxxx, yyyy, dx, dy);
newplayer -> background = CGRectMake(xxxx, yyyy, dx, dy);
newplayer -> healthbar = CGRectMake(xxxx, yyyy, 1, dy);
newplayer -> topofbox = CGPointMake(xxxx, yyyy);
pplayers -> push_back(newplayer);
}
}
es.players = pplayers;
}
if([switches isSwitchOn:@"Box"]){
es.espboxes = true;
}else{
es.espboxes = false;
}
if([switches isSwitchOn:@"Lines"]){
es.esplines = true;
}else{
es.esplines = false;
}
}
}else{
entityManager->removeEnemyGivenObject(Player);
}
}
old_Player_Update(Player);
}