@name Auto Survalance Camera
#@inputs Num:wirelink 
@inputs RTC:wirelink
@outputs LOS Cone:array Activate Hide [T Ranger]:entity 
#@persist Keys:array
@persist Hide
@trigger 

O=owner()

#In case I wanna use a standard RT camera
#if(first()){
#    Keys=array()
#    Keys=array("0","1","2","3","4","5","6","7","8","9","/","*","-","+","enter",".")
#}

if(first()){Hide=1}
Cam=entity():isConstrainedTo()
runOnChat(1)
Chat=O:lastSaid()
if(Chat&chatClk()){
    Com="RTC"
    Cloak="hide"
    Show="show"

    COM=Chat:find(Com)        
    CLOAK=Chat:find(Cloak)
    SHOW=Chat:find(Show)
    if(COM){
        if(CLOAK){Hide=1}
        if(SHOW){Hide=0}
    }
}
#interval(findUpdateRate())
runOnTick(1)
findInCone(Cam:pos(),Cam:forward(),1000,30)
findIncludeClass("player")
findSortByDistance(Cam:pos())
Cone=findToArray()


if(Cone:count()){
    for(C=1,Cone:count()){
        T=Cone[C,entity]
        Filter=array(Cam,entity())
        Loc=T:pos()+vec(0,0,T:height()/2)
        if(T:inVehicle()){
            #Filter:pushEntity(T:vehicle())
            Loc=T:pos()
            T=T:vehicle()
            
            
        }
        #holoCreate(1,Loc)
        rangerFilter(Filter)
        rangerHitEntities(1)
        rangerHitWater(0)
        rangerIgnoreWorld(0)
        Ranger=rangerOffset(Cam:pos(),Loc):entity()
        LOS=Ranger==T
    }

}else{LOS=0}


RTC["Activate",number]= (LOS ? 1 : 0)
RTC["Hide",number]=Hide
if(Hide){entity():setAlpha(0)}else{entity():setAlpha(255)}
