@name ScreenMaster
@inputs Screen:entity
@outputs 
@persist User:entity [CornerPos1 CornerPos2]:vector 
interval(100)

if(first()) {
    Scale = vec(6,10,4) * 12
    
    Door = holoCreate(1)
    
    holoScaleUnits(1,Scale)
    holoPos(1,entity():isWeldedTo():toWorld(vec(60,0,-100)))
    holoAng(1,entity():isWeldedTo():angles())
    holoColor(1,vec(255,255,255),255)
    holoParent(1,entity())
    
    CornerPos1 = Scale / 2
    CornerPos2 = -CornerPos1
    
    CornerPos1 = Door:toWorld(CornerPos1)
    CornerPos2 = Door:toWorld(CornerPos2)
    
    CornerScale = vec() + 1
    
    holoCreate(2)
    holoPos(2,CornerPos1)
    holoScaleUnits(2,CornerScale)
    holoParent(2, Door)
    
    holoCreate(3)
    holoPos(3,CornerPos2)
    holoScaleUnits(3,CornerScale)
    holoParent(3, Door)
    
    for (I = 2,3) {holoColor(I,vec(),0)}
    holoAlpha(1,20)
    
    holoCreate(4)
}

findInBox(CornerPos1,CornerPos2)
findIncludeClass("player")
User = findClosest(holoEntity(1):pos())

if (User) {
    Screen:setPos(User:pos()+vec(-70,0,44))
    Screen:setAng(entity():isWeldedTo():toWorld(ang(-5,0,0)))
}

if (!User) {
    Screen:setPos(holoEntity(4):pos()-vec(0,0,40))
}
