Add food and yam interaction
This commit is contained in:
1 parent
2874c11658
commit
d20642e267
41 files changed
+2747
-42
No files matched your search
@@ -0,0 +1,25 @@
|
||||
extends Reference
|
||||
|
||||
const NAME = "blocked"
|
||||
|
||||
var ctx = null
|
||||
|
||||
func _init():
|
||||
pass
|
||||
|
||||
func enter_from(state):
|
||||
ctx.get_node("coin_machine").enabled = false
|
||||
ctx.get_node("item_holder").add_enabled = true
|
||||
|
||||
func exit_to(state):
|
||||
pass
|
||||
|
||||
func on_coin_machine_coin_requirement_met(player):
|
||||
assert(false)
|
||||
|
||||
func on_grow_timer_timeout():
|
||||
assert(false)
|
||||
|
||||
func on_item_holder_item_changed(item):
|
||||
if item == null:
|
||||
ctx.change_state(ctx.StateIdle.new())
|
||||
@@ -0,0 +1,30 @@
|
||||
extends Reference
|
||||
|
||||
const NAME = "growing"
|
||||
const raw_yam = preload("res://item_types/raw_yam.tres")
|
||||
|
||||
var ctx = null
|
||||
var mat: SpatialMaterial = SpatialMaterial.new()
|
||||
|
||||
func _init():
|
||||
mat.albedo_color = Color.green
|
||||
|
||||
func enter_from(state):
|
||||
ctx.get_node("coin_machine").enabled = false
|
||||
ctx.get_node("item_holder").add_enabled = false
|
||||
ctx.get_node("grow_timer").start()
|
||||
ctx.get_node("MeshInstance").set_surface_material(0, mat)
|
||||
|
||||
func exit_to(state):
|
||||
ctx.get_node("MeshInstance").set_surface_material(0, null)
|
||||
|
||||
func on_coin_machine_coin_requirement_met(player):
|
||||
assert(false, "coin machine should be disabled while growing")
|
||||
|
||||
func on_grow_timer_timeout():
|
||||
var item_holder = ctx.get_node("item_holder")
|
||||
item_holder.spawn_item(raw_yam)
|
||||
ctx.change_state(ctx.StateBlocked.new())
|
||||
|
||||
func on_item_holder_item_changed(item):
|
||||
assert(item.item_type == raw_yam)
|
||||
@@ -0,0 +1,25 @@
|
||||
extends Reference
|
||||
|
||||
const NAME = "idle"
|
||||
|
||||
var ctx = null
|
||||
|
||||
func _init():
|
||||
pass
|
||||
|
||||
func enter_from(state):
|
||||
ctx.get_node("coin_machine").enabled = true
|
||||
ctx.get_node("item_holder").add_enabled = true
|
||||
|
||||
func exit_to(state):
|
||||
pass
|
||||
|
||||
func on_coin_machine_coin_requirement_met(player):
|
||||
ctx.change_state(ctx.StateGrowing.new())
|
||||
|
||||
func on_grow_timer_timeout():
|
||||
assert(false, "grow timer shouldn't trigger while idle")
|
||||
|
||||
func on_item_holder_item_changed(item):
|
||||
assert(item != null)
|
||||
ctx.change_state(ctx.StateBlocked.new())
|
||||
Reference in new issue
Block a user