extends Node3D

var params = ['clap', 'clap_fast', 'clap_fast_stand', 'facepalm', 
			  'look_at_phone', 'shake_head', 'stand_cheer']

var likelihood_matrix = [
	[ 0.0, 0.0, 0.0, 0.5, 0.1, 0.5, 0.0], # 0
	[ 0.2, 0.0, 0.0, 0.1, 0.5, 0.1, 0.0], # 1
	[ 0.4, 0.0, 0.0, 0.1, 0.4, 0.1, 0.0], # 2 
	[ 0.4, 0.1, 0.0, 0.0, 0.2, 0.0, 0.0], # 3 
	[ 0.4, 0.2, 0.1, 0.0, 0.1, 0.0, 0.0], # 4 
	[ 0.0, 0.3, 0.4, 0.0, 0.0, 0.0, 0.4], # 5
	[ 0.0, 0.0, 0.9, 0.0, 0.0, 0.0, 0.9], # 6
]

var rng = RandomNumberGenerator.new()

# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.
	
func clear_all_params():
	for i in self.get_children ():
		var a_tree = i.get_node("AnimationTree")
		
		for param in params:
			a_tree["parameters/StateMachine/conditions/" + param] = false
			
		a_tree["parameters/StateMachine/conditions/reset"] = false
			
func reset_react():
	for i in self.get_children ():
		var a_tree = i.get_node("AnimationTree")
		
		a_tree["parameters/StateMachine/conditions/reset"] = true

func set_reaction(react, amt):
	#print("ere")
	
	for i in self.get_children ():
		var a_tree = i.get_node("AnimationTree")
		
		for x in range(0, params.size()):
			var a = rng.randf_range(0.001, 1.0)
			if a < likelihood_matrix[react][x]*amt:
				a_tree["parameters/StateMachine/conditions/" + params[x]] = true
				#print(a, " ", likelihood_matrix[react][x], " ", params[x])
				a_tree["parameters/TimeScale/scale"] = rng.randf_range(0.5,1.2)
				

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
	#clear_all_params()
	
			
	pass
	
