@name EGPWindowBlocker
@inputs [E1 E2 E3 E4 E5 E6 E7 E8 L]:entity Open 
@outputs 
@persist A State 
@trigger 
runOnTick(1)

if (first()) {
    holoCreate(1)
    holoModel(1,"plane")
    holoPos(1,E1:toWorld(vec(0,0,-2.4)))
    holoAng(1,E1:angles()+ang(0,180,0))
    holoScale(1,E1:boxSize()/12)
    holoClipEnabled(1,1,1)
    holoClip(1,holoEntity(1):pos()+vec(0,0,64),vec(0,0,-1),1)
    
    holoCreate(2)
    holoModel(2,"plane")
    holoPos(2,E2:toWorld(vec(0,0,2.4)))
    holoAng(2,E2:angles())
    holoScale(2,E2:boxSize()/12)
    holoClipEnabled(2,1,1)
    holoClip(2,holoEntity(2):pos()+vec(0,0,64),vec(0,0,-1),1)
    
    holoCreate(3)
    holoModel(3,"plane")
    holoPos(3,E3:toWorld(vec(-6,-17.6,-0.2)))
    holoAng(3,E3:angles()+ang(0,180,0))
    holoScale(3,E3:boxSize()/12)
    holoClipEnabled(3,1,1)
    holoClip(3,holoEntity(3):pos()+vec(0,0,71.6),vec(0,0,-1),1)
    
    holoCreate(4)
    holoModel(4,"plane")
    holoPos(4,E4:toWorld(vec(-6,-17.6,12)))
    holoAng(4,E4:angles())
    holoScale(4,E4:boxSize()/12)
    holoClipEnabled(4,1,1)
    holoClip(4,holoEntity(4):pos()+vec(0,0,71.6),vec(0,0,-1),1)
    
    holoCreate(5)
    holoModel(5,"plane")
    holoPos(5,E5:toWorld(vec(-12,-17.6,6)))
    holoAng(5,E5:angles()-ang(0,90,0))
    holoScale(5,E5:boxSize()/12)
    holoClipEnabled(5,1,1)
    holoClip(5,holoEntity(5):pos()+vec(0,0,71.6),vec(0,0,-1),1)
    
    holoCreate(6)
    holoModel(6,"plane")
    holoPos(6,E6:toWorld(vec(-12,-17.6,6)))
    holoAng(6,E6:angles()-ang(0,90,0))
    holoScale(6,E6:boxSize()/12)
    holoClipEnabled(6,1,1)
    holoClip(6,holoEntity(6):pos()+vec(0,0,71.6),vec(0,0,-1),1)
    
    holoCreate(7)
    holoModel(7,"plane")
    holoPos(7,E7:toWorld(vec(0,0,-2.4)))
    holoAng(7,E7:angles()+ang(0,180,0))
    holoScale(7,E7:boxSize()/12)
    holoClipEnabled(7,1,1)
    holoClip(7,holoEntity(7):pos()+vec(0,0,64),vec(0,0,-1),1)
    
    holoCreate(8)
    holoModel(8,"plane")
    holoPos(8,E8:toWorld(vec(0,0,-2.4)))
    holoAng(8,E8:angles()+ang(0,180,0))
    holoScale(8,E8:boxSize()/12)
    holoClipEnabled(8,1,1)
    holoClip(8,holoEntity(8):pos()+vec(0,0,64),vec(0,0,-1),1)
    
    for (Mat = 1,8) { holoMaterial(Mat,"phoenix_storms/dome")}
    lightCreate(1)
    lightPos(1,L:pos())
    lightColor(1,vec(255,0,0))
}

#if(changed(Open) & Open) {if(State == 0) {State = 1} else {State = 0}}

if(State == 1) {
    if(A < 1) {
        A += 0.004
        holoPos(1,holoEntity(1):pos()+vec(0,0,0.5))
        holoPos(2,holoEntity(2):pos()+vec(0,0,0.5))
        holoPos(3,holoEntity(3):pos()+vec(0,0,0.5))
        holoPos(4,holoEntity(4):pos()+vec(0,0,0.5))
        holoPos(5,holoEntity(5):pos()+vec(0,0,0.5))
        holoPos(6,holoEntity(6):pos()+vec(0,0,0.5))
        holoPos(7,holoEntity(7):pos()+vec(0,0,0.5))
        holoPos(8,holoEntity(8):pos()+vec(0,0,0.5))
        lightColor(1,vec(0,0,0))
    }
} else {
    if(A > 0) {
        A -= 0.004
        holoPos(1,holoEntity(1):pos()+vec(0,0,-0.5))
        holoPos(2,holoEntity(2):pos()+vec(0,0,-0.5))
        holoPos(3,holoEntity(3):pos()+vec(0,0,-0.5))
        holoPos(4,holoEntity(4):pos()+vec(0,0,-0.5))
        holoPos(5,holoEntity(5):pos()+vec(0,0,-0.5))
        holoPos(6,holoEntity(6):pos()+vec(0,0,-0.5))
        holoPos(7,holoEntity(7):pos()+vec(0,0,-0.5))
        holoPos(8,holoEntity(8):pos()+vec(0,0,-0.5))
        lightColor(1,vec(255,0,0))
    }
}
