@name CakeUIHoloModule
@persist [E O]:entity I
@trigger all


if(first() || duped()){
    
function number entity:isInHoloImprv(HoloIndx:number){
local HPos = holoEntity(HoloIndx):pos() local PPos = This:shootPos() local Mins = (HPos-PPos) return acos((Mins:normalized()):dot(This:eye())) < atan(holoScaleUnits(HoloIndx):x() / 2 / Mins:length())
}
    
}

if(first() || duped()){

    runOnTick(1)
    
    E = entity()
    O = owner()
    
    local I = 1
    local X = 0
    local Y = 0
    
    while(Y < 40){
        
        holoCreate(I)
        holoModel(I,"cube")
        holoScaleUnits(I,vec(5,5,1.5))
        holoParent(I,E)
        holoPos(I,E:toWorld(vec(X,Y,1)))
        
        X+=6
        I++
        if(X > 40){
         X = 0
         Y+=6 
        }
    }

}


while(perf()){

    if(O:isInHoloImprv(I) != 0){
        holoColor(I,vec(0,0,255))
        
        if(holoScaleUnits(I):z() < 10){
         holoScaleUnits(I,vec(5,5,holoScaleUnits(I):z() + 1))
        }
    }else{
        holoColor(I,vec(255,0,0))
        if(holoScaleUnits(I):z() > 1.5){
         holoScaleUnits(I,vec(5,5,holoScaleUnits(I):z() - 1))
        }
    }
    
    if(I < 49){
        I++
    }else{
        I = 0
    }
}

