@name EGP radar by Unsmart
@inputs W:wirelink Cube:entity
@outputs RealBear Arr:array Ent:entity Dist
@persist Ang
@trigger
interval(30)
if(first())
{
   #W:egpClear()
    Ang=1
    W:egpBox(1,0,0,512,512,255,0,0,255)#background
    W:egpCircle(2,256,256,512,512,13,66,13,255)#circle
   
    #inner circle*2
    W:egpCircle(3,512/2,512/2,512/2,512/2,255,255,255,255)#white spliter
    W:egpCircle(4,512/2,512/2,512/2-10,512/2-10,13,66,13,255)#back to green
   
    #Lines
    W:egpLine(5,256,512,256,0,150,150,150,255)#up->down
    W:egpLine(6,0,256,512,256,150,150,150,255)#left->right
    #hands of sweeper
    W:egpLine(7,256,256,256,0,255,255,255,255)
   
    #pos info
    W:egpText(8,"500",vec2(256-80,256-50),vec(100,100,100),255)
    W:egpText(9,"1000",vec2(256-200,256-50),vec(100,100,100),255)
   
    #render
    W:egpDraw()  
    print("base drawn")
    
    timer("find",50)
    timer("draw",100)
}

if(clk("draw"))
{
    for(I=10,22)
    {
        W:egpCircle(I,50,50,10,10,0,255,255,255)
    }
    #cover circles
    #W:egpCircle(50,60,60,15,15,0,100,0,255)
    print("addons drawn")
}




if(clk("find"))
{
    findInSphere(entity():pos(),1000)
    findClipToClass("player")
    #npc_*
    #player
    Arr=findToArray()
    timer("find",500)
   
   
    for(I=10,Arr:count()+10)#start at 10+
    {
        Ent=Arr[I-10,entity]
        Bear=Cube:bearing(Ent:pos())
       
    #angle math
    Dist=clamp((Cube:pos()-Ent:pos()):length(),10,500)
    Mul=clamp(Dist,1,1000)
   
    RealBear= (Bear+180+(360+90))%360
    RealBear= RealBear==0 ? -1 : RealBear
    W:egpPos(I,256-cos(RealBear)*Mul,256-sin(RealBear)*Mul)
    }
    for(I=Arr:count()+11,22)
    {
        W:egpPos(I,-1,-1)
        #print(I+"removed")
    }
    #W:egpPos(50,50,50)
    #make sure to remove unused crap
   
   
   
}



#hand circle
Ang= Ang<359 ? Ang+1 : 1
W:egpPos2(7,256+cos(Ang)*256,256+sin(Ang)*256)

#angle math

#Mul=clamp(Dist,10,500)
#
#RealBear= (Bear+180+(360+90))%360
#RealBear= RealBear==0 ? -1 : RealBear
#W:egpPos(8,256-5-cos(RealBear)*Mul,256-5-sin(RealBear)*Mul)
#


W:egpDraw()