################
# > Light: Change the colour of your props depending on the distance from the E2 to create the effect of light.
# > How to use: Spawn it and it will light up your props if it is near to them.
################

@name Light
@outputs Props:array

interval(100)

findByClass("prop_physics")
findIncludePlayerProps(owner())
Props=findToArray()
Torch=entity():pos()
LightBrightness=480

if (changed(Torch)) {
    for (I=1,Props:count()) {
        Brightness=1-(Props[I,entity]:pos():distance(Torch)/LightBrightness)
        Props[I,entity]:setColor(vec(255,255,255)*Brightness*vec(1.2,1.2,1))
    }
}
