forked from interstellar_development/freeftf
31 lines
690 B
GDScript3
31 lines
690 B
GDScript3
|
extends StaticBody3D
|
||
|
|
||
|
var trapped_body
|
||
|
var occupied = false
|
||
|
var living = true
|
||
|
|
||
|
func _process(delta):
|
||
|
if occupied:
|
||
|
trapped_body.position = position
|
||
|
if occupied and trapped_body.hp == 0:
|
||
|
living = false
|
||
|
|
||
|
func _on_area_3d_body_entered(body):
|
||
|
if body is StaticBody3D:
|
||
|
pass
|
||
|
elif body.beast and body.got_person and !occupied:
|
||
|
trapped_body = body.caught_body
|
||
|
occupied = true
|
||
|
living = true
|
||
|
body.lost_one()
|
||
|
trapped_body.frozen()
|
||
|
elif !body.beast and occupied and living and body != trapped_body:
|
||
|
trapped_body.unfreeze()
|
||
|
trapped_body._on_time_in_bag_timeout()
|
||
|
occupied = false
|
||
|
trapped_body = null
|
||
|
|
||
|
func _on_timer_timeout():
|
||
|
if occupied and living:
|
||
|
trapped_body.hp -= 2
|