@name FailCake ApertureLaser Reflecting Cube
@persist [E]:entity GTABLE:gtable
@trigger all
@model models/hunter/blocks/cube025x025x025.mdl

interval(100)

if(first() | duped()){
    
E = entity()   

GTABLE = gTable("ApertureLaser",2)

E:setColor(255,0,0)
E:setAlpha(100)

holoCreate(1)
holoModel(1,"hqcone")
holoScaleUnits(1,vec(3,3,3))
holoColor(1,vec(70,70,70))
holoAlpha(1,200)
holoMaterial(1,"models/debug/debugwhite")
holoParent(1,E)
holoPos(1,E:toWorld(vec(0,0,0)))

holoCreate(2)
holoModel(2,"hqcylinder")
holoPos(2,E:toWorld(vec(0,0,10)))
holoColor(2,vec(200,0,0))
holoScaleUnits(2,vec(-1,-1,-10))
holoParent(2,E)
holoAlpha(2,0)
holoMaterial(2,"models/debug/debugwhite")  

holoCreate(3)
holoModel(3,"hqcylinder")
holoPos(3,E:toWorld(vec(0,0,10)))
holoColor(3,vec(150,0,0))
holoScaleUnits(3,vec(1,1,10))
holoParent(3,E)
holoAlpha(3,0)
holoMaterial(3,"models/debug/debugwhite")
}


Ranger = rangerOffset(400,E:pos(),E:up())
D=round(Ranger:distance())

holoPos(2, E:toWorld(vec(0,0,7))+E:up()*D/2)
holoScaleUnits(2, vec(-1,-1,-D))
holoPos(3, E:toWorld(vec(0,0,7))+E:up()*D/2)
holoScaleUnits(3, vec(0.5,0.5,D))

if(GTABLE["On_"+E:id(),number]){
holoAlpha(3,255)   
holoAlpha(2,255)
E:setColor(vec(0,255,0))
GTABLE["On_"+E:id(),number] = 0  

if(Ranger:hit() && Ranger:entity():type() == "gmod_wire_expression2" && Ranger:entity():model()=="models/hunter/blocks/cube025x025x025.mdl"){
GTABLE["On_"+Ranger:entity():id(),number] = 1  
}  
    
}else{
E:setColor(vec(255,0,0))
holoAlpha(2,0)
holoAlpha(3,0)
}



