@name Hitch
@inputs 
@outputs BA:array 
@persist R:ranger [H Prop]:entity HS:vector 
@autoupdate
interval(50)

if (first()) {    
    H = holoCreate(2)
    holoPos(2,entity():toWorld(vec(0,0,20)))
    #holoParent(2,entity():isWeldedTo())
    HS = H:boxSize()
}

if(dupefinished()){
    reset()
}

R = rangerOffsetHull(5,H:pos(),entity():up(),HS)

if (R:entity():model() == "models/props_lab/jar01a.mdl") {
    BA:pushEntity(R:entity())
    Prop=BA[1,entity]
    Prop:propFreeze(1)
    Prop:setPos(holoEntity(2):toWorld(vec(0,0,0)))
    Prop:setAng(ang(0,0,0))
    holoColor(2,vec(0,255,0))
} else {
    holoColor(2,vec(255,255,255))
}

if (owner():aimEntity() == Prop & owner():keyWalk()) {
    Prop:propFreeze(0)
    BA:clear()
    reset()
    Prop:setPos(holoEntity(2):pos()+vec(0,-10,0))
}
