extends Human
class_name Baker

var freq = 2
var phase = 0
var amplitude = 0.2

var float_up = false
var float_accel = 0.02
var floatspeed_max =1
var floatspeed = 0

var eye_mat = load("res://human_eyemat.tres")
var red_mat = load("res://saucemat.tres")
onready var eyes = find_node("eyes") as MeshInstance
onready var def_human_scale = $Spatial.scale.x

var angry = false

func _process(delta):
	if angry:
		$Spatial.scale = Vector3(1,1,1+amplitude*abs(sin(phase)))*def_human_scale
		phase=wrapf(phase+delta*6.28*freq,0,6.28)
	if float_up:
		if $Camera:
			var vec = Vector3(0,floatspeed*delta,0)
			$CameraPlace.translation+=vec
			$Camera.translation+=vec
			if floatspeed < floatspeed_max:
				floatspeed+=float_accel*delta

func _ready():
	pass

func get_angry():
	angry = true
	eyes.set_surface_material(0, red_mat)

func calm_down():
	angry = false
	$Spatial.scale = Vector3(1,1,1)*def_human_scale
	eyes.set_surface_material(0, eye_mat)

func init_():
	
	return [
		Saying.new(Saying.MYSELF, "hello"),
		Saying.new(Saying.ITSELF, "hi to you too!"),
		Saying.new(Saying.ITSELF, "want a donut or a pie?") if not (MAIN.girl_fed or MAIN.baker_feeds_girl) else NULL_SAY, 
		Unconditional.new("main_choice_"),
	]

func main_choice_():
	
	return [
		[
			Choice.new("no money","donut") if not (MAIN.girl_fed or MAIN.baker_feeds_girl) else NULL_CHOICE,
			Choice.new("why angry?","booze") if angry and not (MAIN.drunkards_fed or MAIN.baker_feeds_drunkards) else NULL_CHOICE,
			Choice.new("enslavement","slave_") if MAIN.baker_secret else NULL_CHOICE,
			Choice.new("be my mommy?[End]", "mommy") if MAIN.baker_confessed else NULL_CHOICE, #TODO: maybe also sth connected with parents
			Choice.new("bye...", "bye_"),
		],	
	]

func endgame():
	get_tree().change_scene("res://END2.tscn")
	pass

func start_float():
	float_up = true

func mommy():
	
	return [
		Saying.new(Saying.MYSELF, "Will you be my mommy?"),
		Saying.new(Saying.ITSELF, "..."),
		Saying.new(Saying.ITSELF, "... what??? ..."),
		Saying.new(Saying.MYSELF, "I have a bit of trouble"),
		Saying.new(Saying.MYSELF, "being on my own"),
		Saying.new(Saying.ITSELF, "you don't have parents?"),
		Saying.new(Saying.ITSELF, "i see."),
		Saying.new(Saying.ITSELF, "ok..."),
		Saying.new(Saying.ITSELF, "well"),
		Saying.new(Saying.ITSELF, "if you're not scared"),
		Saying.new(Saying.ITSELF, "by that girl episode"),
		Saying.new(Saying.ITSELF, "are you into this stuff?","start_float"),
		Saying.new(Saying.ITSELF, "by any chance?"),
		Saying.new(Saying.MYSELF, "idk yet."),
		Saying.new(Saying.MYSELF, "Are you even... sexy?"),
		Saying.new(Saying.ITSELF, "i believe i am!"),
		Saying.new(Saying.ITSELF, "no ugly grannies here"),
		########## Ending animations and whatnot while they are talking ######
		Saying.new(Saying.MYSELF, "can you cook?"),
		Saying.new(Saying.ITSELF, "are you stupid or what?"),
		Saying.new(Saying.MYSELF, "oh, forgot"),
		Saying.new(Saying.ITSELF, "don't worry"),
		Saying.new(Saying.ITSELF, "everything will be fine"),
		Saying.new(Saying.ITSELF, "..."),
		Saying.new(Saying.DRUNK, "[End the game]"),
		Saying.new(Saying.DRUNK, "[End the game]","endgame"),
	]

func slave_():
	return [
		Saying.new(Saying.MYSELF, "is it true"),
		Saying.new(Saying.MYSELF, "that you tried"),
		Saying.new(Saying.MYSELF, "to enslave girl you fed?"),
		Saying.new(Saying.ITSELF, "..."),
		Saying.new(Saying.ITSELF, "..."),
		Saying.new(Saying.ITSELF, "Sadly  it is"),
		Saying.new(Saying.ITSELF, "i am sorry kid"),
		Saying.new(Saying.ITSELF, "it is very easy"),
		Saying.new(Saying.ITSELF, "to get driven away"),
		Saying.new(Saying.ITSELF, "and stop discerning"),
		Saying.new(Saying.ITSELF, "between love and lust"),
		Saying.new(Saying.ITSELF, "at the last moment"),
		Saying.new(Saying.ITSELF, "i did realise"),
		Saying.new(Saying.ITSELF, "that i love her"),
		Saying.new(Saying.ITSELF, "and cancelled the thing", "confess"),
		Saying.new(Saying.MYSELF, "so what now?"),
		Saying.new(Saying.ITSELF, "idk"),
		Saying.new(Saying.ITSELF, "she doesn't seem to like me"),
		Saying.new(Saying.ITSELF, "that's why i was anxious"),
		Saying.new(Saying.ITSELF, "but she likes my donuts"),
		Saying.new(Saying.ITSELF, "munches through them"),
		Saying.new(Saying.ITSELF, "while listening to head"),
		Saying.new(Saying.ITSELF, "so i guess"),
		Saying.new(Saying.ITSELF, "will just continue"),
		Saying.new(Saying.ITSELF, "making bakery for her"),
		Saying.new(Saying.ITSELF, "the least i can do"),
		Saying.new(Saying.ITSELF, "maybe one day"),
		Saying.new(Saying.ITSELF, "her heart will change"),
		Saying.new(Saying.ITSELF, "unlikely though"),
		]



func bye_():
	return [
		Saying.new(Saying.MYSELF, "have to go"),
		Saying.new(Saying.ITSELF, "take care"),
		]

func donut():
	return [
		Saying.new(Saying.MYSELF, "no crypto"),
		Saying.new(Saying.ITSELF, "no worries"),
		Saying.new(Saying.ITSELF, "do me a favor instead"),
		Saying.new(Saying.ITSELF, "see that girl near Head?"),
		Saying.new(Saying.ITSELF, "give her one donut"),
		Saying.new(Saying.ITSELF, "from me"),
		Saying.new(Saying.ITSELF, "here..."),
		Saying.new(Saying.ITSELF, "take two and eat one", "give_donut"),
		Saying.new(Saying.MYSELF, "wow thx"),
		Saying.new(Saying.MYSELF, "it is delicious"),
		Saying.new(Saying.ITSELF, "i know, right?"),
		]

func booze():
	return [
		Saying.new(Saying.MYSELF, "why are you so angry?"),
		Saying.new(Saying.ITSELF, "again these drunkards!"),
		Saying.new(Saying.ITSELF, "scaring away clients!"),
		Saying.new(Saying.ITSELF, "can't understand them"),
		Saying.new(Saying.ITSELF, "there are food synths"),
		Saying.new(Saying.ITSELF, "they are opensource"),
		Saying.new(Saying.ITSELF, "and energy is plenty!"),
		Saying.new(Saying.ITSELF, "if they are hungry"),
		Saying.new(Saying.ITSELF, "or want to get drunk"),
		Saying.new(Saying.ITSELF, "no need to startle people"),
		Saying.new(Saying.ITSELF, "here, take a donut", "give_donut_drunk"),
		Saying.new(Saying.ITSELF, "and tell them to get out!"),
		]


func confess():
	MAIN.baker_confessed = true

func give_donut():
	PLAYER.take("Donut")
	MAIN.baker_feeds_girl = true
	
func give_donut_drunk():
	PLAYER.take("Donut")
	MAIN.baker_feeds_drunkards = true

