2019-11-11 10:24:29 +01:00
|
|
|
extends NPC
|
2019-10-28 01:21:41 +01:00
|
|
|
|
|
|
|
|
2019-10-30 01:01:02 +01:00
|
|
|
export(NodePath) var _visibility_path: NodePath
|
2019-11-11 23:02:38 +01:00
|
|
|
export(int) var _player_follow_pill_level = 3
|
2019-10-30 01:01:02 +01:00
|
|
|
|
|
|
|
var _visibility: Area
|
|
|
|
|
|
|
|
|
2019-10-28 01:21:41 +01:00
|
|
|
func _ready():
|
2019-11-11 10:16:03 +01:00
|
|
|
Logger.set_logger_level(Logger.LOG_LEVEL_FINE)
|
2019-10-30 01:01:02 +01:00
|
|
|
_visibility = get_node(_visibility_path) as Area
|
|
|
|
|
|
|
|
if _visibility:
|
|
|
|
_visibility.connect("body_entered", self, "_on_body_entered_visibility")
|
|
|
|
_visibility.connect("body_exited", self, "_on_body_exited_visibility")
|
|
|
|
|
|
|
|
|
2019-12-27 19:09:11 +01:00
|
|
|
func _process(_delta):
|
|
|
|
# stop following player if pill level is high enough
|
|
|
|
if current_target and Pills.get_round_level() > _player_follow_pill_level:
|
|
|
|
current_target = null
|
|
|
|
|
|
|
|
|
2019-11-11 10:44:20 +01:00
|
|
|
func _on_body_entered_visibility(body: PhysicsBody):
|
2019-12-14 21:05:09 +01:00
|
|
|
#Logger.trace("Meldewesen seeing %s" % [body])
|
2019-11-11 10:20:23 +01:00
|
|
|
|
2019-10-30 01:01:02 +01:00
|
|
|
if body.is_in_group("Player"):
|
2019-11-02 20:06:20 +01:00
|
|
|
Logger.info("Seeing player!")
|
2019-10-30 01:01:02 +01:00
|
|
|
|
2019-12-27 19:09:11 +01:00
|
|
|
# TODO: check if player is in illegal area
|
|
|
|
#var player = get_node("")
|
|
|
|
|
2019-11-11 23:02:38 +01:00
|
|
|
# If the player didn't take enough pills lately, they're suspicious -> Run towards them!
|
|
|
|
if Pills.get_round_level() <= _player_follow_pill_level:
|
|
|
|
Logger.info("The player's pill level is too low - following!")
|
|
|
|
current_target = body.transform.origin
|
2019-10-30 01:01:02 +01:00
|
|
|
|
2019-10-28 01:21:41 +01:00
|
|
|
|
2019-11-11 10:44:20 +01:00
|
|
|
func _on_body_exited_visibility(body: PhysicsBody):
|
2019-10-30 01:01:02 +01:00
|
|
|
if body.is_in_group("Player"):
|
2019-11-02 20:06:20 +01:00
|
|
|
Logger.info("Stopped seeing player!")
|
2019-11-11 10:44:20 +01:00
|
|
|
current_target = null
|