@name DoormiscSponge
@inputs 
@outputs T
@outputs Player:entity Idx1 Idx2 YOffset X Y Z Origins:array Colors:array ActiveDistance Arrangment Coloring MovementType Interval PropIdx PropMode
@trigger 

if(first()){
    
    Player = findPlayerByName("Erza")
    Interval = 20 # HIGHEN IF TICKQUOTAS.
    
    Arrangment = 1
    # 1 - cube
    # 2 - wall
    
    MovementType = 3
    # 1 - Normal, medium range
    # 2 - Close range
    # 3 - smoothed
    
    Coloring = 2
    # 1 - default rainbow
    # 2 - black -> white
    # 3 - white -> black
    # 4 - white -> light grey
    
    PropMode
    # makes e2 create props and move them
    
    #Player=entity()
    ActiveDistance = 400
    Size=60
    
    if(Arrangment==1){
for(I=1,64){
    holoCreate(I)
    #holoMaterial(I, "effects/flashlight/square")
    #holoDisableShading(I, 1)
    
    #holoModel(I, "hq_rcube_thin")
    holoShadow(I, 1)
    #holoColor(I, hsv2rgb(vec(I*4,1,1)))
    holoScaleUnits(I, vec(Size))
    
    holoPos(I, entity():toWorld(vec(Idx1*Size,Y-YOffset,Z+30)))
    Origins:pushVector(entity():toWorld(vec(Idx1*Size,Y-YOffset,Z+30)))
    Colors:pushVector(hsv2rgb(vec(I*4,1,1)))
    
    Idx1++
    Idx2++
    if(Idx1>3){Y+=Size Idx1=0}
    if(Idx2>15){Z+=Size Idx2=0 YOffset+=(Size*4)}
    
    
    
    }
}


if(Arrangment==2){
for(I=1,64){
    holoCreate(I)
    #holoMaterial(I, "effects/flashlight/square")
    #holoDisableShading(I, 1)
    
    #holoModel(I, "hq_rcube_thin")
    holoShadow(I, 1)
    #holoColor(I, hsv2rgb(vec(I*4,1,1)))
    holoScaleUnits(I, vec(Size))
    
    holoPos(I, entity():toWorld(vec(Idx1*Size,Y-YOffset,Z+30)))
    Origins:pushVector(entity():toWorld(vec(Idx1*Size,Y-YOffset,Z+30)))
    Colors:pushVector(hsv2rgb(vec(I*4,1,1)))
    
    Idx1++
    Idx2++
    #if(Idx1>3){Y+=0 Idx1=0}
    if(Idx2>15){Z+=Size Idx1=0 Idx2=0 YOffset+=0}
    
    
    
    }
}




}

interval(Interval)
if(perf(60)){
for(I=1,64){
    
    if(Player:pos():distance(Origins[I,vector])<ActiveDistance*30){
        
######### MOVEMENT
        # DEFAULT
        if(MovementType==1){holoPos(I, Origins[I,vector]+(Player:pos()-Origins[I,vector]):normalized()*clamp((Player:pos():distance(Origins[I,vector])-(ActiveDistance/1)),-600,0))}
        
        # SMALL ARC
        if(MovementType==2){holoPos(I, Origins[I,vector]+(Player:pos()-Origins[I,vector]):normalized()*clamp((Player:pos():distance(Origins[I,vector])-(ActiveDistance/2)),-600,0))}
        
        # SMOOTHED(KINDA LAGS.)
        if(MovementType==3){
            Temporary = (Origins[I,vector]+(Player:pos()-Origins[I,vector]):normalized()*clamp((Player:pos():distance(Origins[I,vector])-(ActiveDistance/1.5)),-600,0))
            holoPos(I, holoEntity(I):pos() + (Temporary - holoEntity(I):pos()):normalized()*(holoEntity(I):pos():distance(Temporary)/4))
            }
        #(Origins[I,vector]+(Player:pos()-Origins[I,vector]):normalized()*clamp((Player:pos():distance(Origins[I,vector])-(ActiveDistance/1)),-600,0))
        
        #holoPos(1,Pos+(Tar-Pos):normalized()*Speed    )
        
        
        
        
######### COLORS
        # DEFAULT COLORS
        if(Coloring==1){holoColor(I, mix(vec(255),Colors[I,vector],clamp(clamp(Player:pos():distance(Origins[I,vector]),0,600)/450,0,1)))}
        
        # BLACK->WHITE
        if(Coloring==2){holoColor(I, vec(clamp(holoEntity(I):pos():distance(Origins[I,vector]),0,255)))}
        
        # WHITE->BLACK
        if(Coloring==3){holoColor(I, vec(255-clamp(holoEntity(I):pos():distance(Origins[I,vector]),0,255)))}
        
        # SOFT GREY
        if(Coloring==4){holoColor(I, vec(255-clamp(holoEntity(I):pos():distance(Origins[I,vector]),0,60)))}
        
        
        
        
    }
    
    
    
    
    
    
    
    
    
}}
holoColor(0, vec(255,0,0))

if(first()){
    entity():setAlpha(0)
    holoCreate(890)
    holoPos(890, entity():toWorld(vec(0,0,3)))
    holoAng(890, entity():toWorld(ang(0,0,0)))
    holoModel(890, "rcube_thin")
    holoScaleUnits(890,vec(6.6,6.6,6.6))
    holoClipEnabled(890,1,1)
    holoClip(890,1,vec(0,0,-2.3),vec(0,0,-1),0)
    holoParent(890,entity())
    holoColor(890, vec(60))
    #
    holoCreate(891)
    holoPos(891, entity():toWorld(vec(0,0,0.7)))
    holoAng(891, entity():toWorld(ang(0,0,0)))
    holoModel(891, "rcube_thin")
    holoScaleUnits(891,vec(6.6,6.6,0.01))
    holoParent(891,entity())
    holoColor(891, vec(60))
    holoMaterial(891, "debug/debugdrawflat")
    #
    holoCreate(892)
    holoPos(892, entity():toWorld(vec(0,0,0.75)))
    holoAng(892, entity():toWorld(ang(0,0,0)))
    holoModel(892, "rcube_thin")
    holoScaleUnits(892,vec(5.9,5.9,0.05))
    holoParent(892,entity())
    holoColor(892, vec(255))
    holoMaterial(892, "debug/debugdrawflat")
    #
    holoCreate(893)
    holoPos(893, entity():toWorld(vec(-1.5,-1.5,0.85)))
    holoAng(893, entity():toWorld(ang(0,0,0)))
    holoModel(893, "plane")
    holoScaleUnits(893,vec(8.6,8.6,10))
    holoParent(893,entity())
    holoColor(893, vec(160))
    holoMaterial(893, "expression 2/cog_prop")
    #
    holoClipEnabled(893,1,1)
    holoClipEnabled(893,2,1)
    holoClipEnabled(893,3,1)
    holoClip(893,1,entity():toWorld(vec(-2.85,-2.85,0.42)),entity():forward(),1)
    holoClip(893,2,entity():toWorld(vec(-2.85,-2.85,0.42)),-entity():right(),1)
    holoClip(893,3,entity():toWorld(vec(-2.2,-2.2,0.42)),entity():forward()-entity():right(),1)
    
    }
    
if(entity():vel()){
    holoClip(893,1,entity():toWorld(vec(-2.85,-1.5,0.42)),entity():forward(),1)
    holoClip(893,2,entity():toWorld(vec(-2.85,-2.85,0.42)),-entity():right(),1)
    holoClip(893,3,entity():toWorld(vec(-2.2,-2.2,0.42)),entity():forward()-entity():right(),1)
    }
    holoAng(893, entity():toWorld(ang(0,-curtime()*14,0)))
