Updatd crafting station to have the output be right on the table on one of the slots. Also added a ready state to the crafting station
This commit is contained in:
parent
373838d3e7
commit
dfd6fe9bb4
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,5 +10,8 @@ export_presets.cfg
|
|||||||
.mono/
|
.mono/
|
||||||
data_*/
|
data_*/
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
bin/
|
||||||
|
|
||||||
# Local settings
|
# Local settings
|
||||||
override.cfg
|
override.cfg
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=9 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scenes/item_holder.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://scenes/item_holder.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://scripts/crafting_station/crafting_station.gd" type="Script" id=2]
|
[ext_resource path="res://scripts/crafting_station/crafting_station.gd" type="Script" id=2]
|
||||||
@ -7,43 +7,15 @@
|
|||||||
[ext_resource path="res://scenes/status_light.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://scenes/status_light.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://item_types/ore.tres" type="Resource" id=7]
|
[ext_resource path="res://item_types/ore.tres" type="Resource" id=7]
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id=1]
|
|
||||||
height = 0.936
|
|
||||||
radial_segments = 8
|
|
||||||
|
|
||||||
[sub_resource type="ConvexPolygonShape" id=2]
|
|
||||||
points = PoolVector3Array( -0.0608763, 0.449247, 0.974783, -0.0608763, -0.464612, -0.974783, -0.0608763, 0.449247, -0.974783, 0.974783, -0.464612, -0.0608763, -0.974783, -0.464612, 0.0608763, 0.974783, 0.449247, 0.0608763, 0.0606902, -0.464648, 0.97486, -0.974783, 0.449247, -0.0608763, 0.7071, 0.453517, -0.7071, -0.705748, -0.468, -0.705748, -0.7071, 0.453517, 0.7071, 0.7071, 0.453517, 0.7071, 0.705748, -0.468, 0.705748, -0.705748, -0.468, 0.705748, 0.705748, -0.468, -0.705748, -0.7071, 0.453517, -0.7071, 0.0606902, -0.464648, -0.97486, -0.974783, -0.464612, -0.0608763, 0.974783, -0.464612, 0.0608763, -0.0608763, -0.464612, 0.974783, 0.0606902, 0.449283, 0.97486, 0.0606902, 0.449283, -0.97486, 0.974783, 0.449247, -0.0608763, -0.974783, 0.449247, 0.0608763, -0.642208, -0.46642, 0.73398, -0.642208, -0.46642, -0.73398, 0.578116, -0.464071, -0.760529, 0.578116, -0.464071, 0.760529, 0.760589, -0.464107, 0.577971, -0.760589, -0.464107, 0.577971, -0.760589, -0.464107, -0.577971, 0.760589, -0.464107, -0.577971 )
|
|
||||||
|
|
||||||
[node name="crafting_station" type="Spatial" groups=["damageable"]]
|
[node name="crafting_station" type="Spatial" groups=["damageable"]]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
start_broken = true
|
start_broken = true
|
||||||
|
|
||||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.372095, 0 )
|
|
||||||
mesh = SubResource( 1 )
|
|
||||||
|
|
||||||
[node name="progress_text" type="Label3D" parent="MeshInstance"]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
transform = Transform( -8.74228e-08, 0, 2, 0, 2, 0, -2, 0, -8.74228e-08, -0.455111, 1.28108, 1.98935e-08 )
|
|
||||||
modulate = Color( 0, 0, 0, 1 )
|
|
||||||
text = "Progress: 20%"
|
|
||||||
|
|
||||||
[node name="StaticBody" type="StaticBody" parent="."]
|
|
||||||
|
|
||||||
[node name="CollisionShape2" type="CollisionShape" parent="StaticBody"]
|
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.372095, 0 )
|
|
||||||
shape = SubResource( 2 )
|
|
||||||
|
|
||||||
[node name="item_slot_1" parent="." groups=["crafting_item_slots"] instance=ExtResource( 1 )]
|
[node name="item_slot_1" parent="." groups=["crafting_item_slots"] instance=ExtResource( 1 )]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2.16895 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.553907, -0.287795, 4.17596 )
|
||||||
|
|
||||||
[node name="item_slot_2" parent="." groups=["crafting_item_slots"] instance=ExtResource( 1 )]
|
[node name="item_slot_2" parent="." groups=["crafting_item_slots"] instance=ExtResource( 1 )]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4.09219 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.553907, -0.287795, 2.17596 )
|
||||||
|
|
||||||
[node name="item_holder" parent="." instance=ExtResource( 1 )]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.36294 )
|
|
||||||
add_enabled = false
|
|
||||||
|
|
||||||
[node name="coin_machine" parent="." instance=ExtResource( 3 )]
|
[node name="coin_machine" parent="." instance=ExtResource( 3 )]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
@ -60,9 +32,15 @@ item_count_0 = 6
|
|||||||
|
|
||||||
[node name="status_light" parent="." instance=ExtResource( 5 )]
|
[node name="status_light" parent="." instance=ExtResource( 5 )]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1, 0, 0 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.627, 0.786, 0 )
|
||||||
|
|
||||||
|
[node name="progress_text" type="Label3D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
transform = Transform( -8.74228e-08, 0, 2, 0, 2, 0, -2, 0, -8.74228e-08, -0.455111, 1.65317, 1.98935e-08 )
|
||||||
|
visible = false
|
||||||
|
modulate = Color( 0, 0, 0, 1 )
|
||||||
|
text = "Progress: 20%"
|
||||||
|
|
||||||
[connection signal="item_changed" from="item_holder" to="." method="_on_item_holder_item_changed"]
|
|
||||||
[connection signal="coin_requirement_met" from="coin_machine" to="." method="_on_coin_machine_coin_requirement_met"]
|
[connection signal="coin_requirement_met" from="coin_machine" to="." method="_on_coin_machine_coin_requirement_met"]
|
||||||
[connection signal="timeout" from="gen_timer" to="." method="_on_gen_timer_timeout"]
|
[connection signal="timeout" from="gen_timer" to="." method="_on_gen_timer_timeout"]
|
||||||
[connection signal="item_dump_completed" from="item_dump" to="." method="_on_item_dump_item_dump_completed"]
|
[connection signal="item_dump_completed" from="item_dump" to="." method="_on_item_dump_item_dump_completed"]
|
||||||
|
@ -84,6 +84,9 @@ adjustment_contrast = 1.97
|
|||||||
[node name="main" type="Spatial"]
|
[node name="main" type="Spatial"]
|
||||||
|
|
||||||
[node name="Level" parent="." instance=ExtResource( 1 )]
|
[node name="Level" parent="." instance=ExtResource( 1 )]
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_group_": true
|
||||||
|
}
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource( 3 )]
|
[node name="Player" parent="." instance=ExtResource( 3 )]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4.35996 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4.35996 )
|
||||||
@ -304,7 +307,7 @@ modulate = Color( 0, 0, 0, 1 )
|
|||||||
text = "Crafting"
|
text = "Crafting"
|
||||||
|
|
||||||
[node name="crafting_station" parent="Crafting_Room" instance=ExtResource( 12 )]
|
[node name="crafting_station" parent="Crafting_Room" instance=ExtResource( 12 )]
|
||||||
transform = Transform( 0, 0, -0.999999, 0, 1, 0, 0.999999, 0, 0, 1.01718, 0, -9.07657 )
|
transform = Transform( 0, 0, -0.999999, 0, 1, 0, 0.999999, 0, 0, 3.43733, 0.789991, -9.25881 )
|
||||||
recipes = ExtResource( 20 )
|
recipes = ExtResource( 20 )
|
||||||
gen_time = 20.0
|
gen_time = 20.0
|
||||||
|
|
||||||
|
@ -3,18 +3,18 @@ extends Damageable
|
|||||||
export var recipes: Resource
|
export var recipes: Resource
|
||||||
export var gen_time : float = 10.0
|
export var gen_time : float = 10.0
|
||||||
|
|
||||||
enum EState {IDLE, WORKING, BLOCKED, BROKEN, NUM_STATES}
|
enum EState {IDLE, READY, WORKING, BLOCKED, BROKEN, NUM_STATES}
|
||||||
|
|
||||||
const States = {
|
const States = {
|
||||||
EState.IDLE : preload("res://scripts/crafting_station/state/idle.gd"),
|
EState.IDLE : preload("res://scripts/crafting_station/state/idle.gd"),
|
||||||
|
EState.READY : preload("res://scripts/crafting_station/state/ready.gd"),
|
||||||
EState.WORKING : preload("res://scripts/crafting_station/state/working.gd"),
|
EState.WORKING : preload("res://scripts/crafting_station/state/working.gd"),
|
||||||
EState.BLOCKED : preload("res://scripts/crafting_station/state/blocked.gd"),
|
EState.BLOCKED : preload("res://scripts/crafting_station/state/blocked.gd"),
|
||||||
EState.BROKEN : preload("res://scripts/crafting_station/state/broken.gd")
|
EState.BROKEN : preload("res://scripts/crafting_station/state/broken.gd"),
|
||||||
}
|
}
|
||||||
|
|
||||||
const RepairKit : Resource = preload("res://item_types/repair_kit.tres")
|
const RepairKit : Resource = preload("res://item_types/repair_kit.tres")
|
||||||
|
|
||||||
onready var item_holder = $"%item_holder"
|
|
||||||
onready var coin_machine = $"%coin_machine"
|
onready var coin_machine = $"%coin_machine"
|
||||||
onready var gen_timer = $"%gen_timer"
|
onready var gen_timer = $"%gen_timer"
|
||||||
onready var progress_text = $"%progress_text"
|
onready var progress_text = $"%progress_text"
|
||||||
@ -23,6 +23,8 @@ onready var status_light = $"%status_light"
|
|||||||
|
|
||||||
var item_slots = null
|
var item_slots = null
|
||||||
var state = null
|
var state = null
|
||||||
|
var items_in_slots = []
|
||||||
|
var item_to_craft : Resource = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
assert(recipes != null)
|
assert(recipes != null)
|
||||||
@ -59,10 +61,15 @@ func _on_gen_timer_timeout():
|
|||||||
state.on_gen_timer_timeout()
|
state.on_gen_timer_timeout()
|
||||||
|
|
||||||
func _on_slot_item_changed(item):
|
func _on_slot_item_changed(item):
|
||||||
|
items_in_slots.clear()
|
||||||
|
for item_slot in item_slots:
|
||||||
|
if item_slot.has_item():
|
||||||
|
items_in_slots.append(item_slot.item_in_hold.item_type)
|
||||||
|
if items_in_slots.size() < 2:
|
||||||
|
item_to_craft = null
|
||||||
|
else:
|
||||||
|
item_to_craft = recipes.find_recipe(items_in_slots)
|
||||||
state.on_slot_item_changed(item)
|
state.on_slot_item_changed(item)
|
||||||
|
|
||||||
func _on_item_holder_item_changed(item):
|
|
||||||
state.on_item_holder_item_changed(item)
|
|
||||||
|
|
||||||
func _on_item_dump_item_dump_completed():
|
func _on_item_dump_item_dump_completed():
|
||||||
state.on_item_dump_item_dump_completed()
|
state.on_item_dump_item_dump_completed()
|
||||||
|
@ -3,16 +3,14 @@ extends Reference
|
|||||||
const NAME = "blocked"
|
const NAME = "blocked"
|
||||||
|
|
||||||
var ctx = null
|
var ctx = null
|
||||||
var label : String = "Blocked!"
|
|
||||||
|
|
||||||
func _init(block_string : String):
|
func _init():
|
||||||
label = block_string
|
pass
|
||||||
|
|
||||||
func enter_from(state):
|
func enter_from(state):
|
||||||
ctx.progress_text.text = label
|
ctx.progress_text.text = "Blocked!"
|
||||||
ctx.coin_machine.enabled = false
|
ctx.coin_machine.enabled = false
|
||||||
ctx.item_dump.enabled = false
|
ctx.item_dump.enabled = false
|
||||||
ctx.item_holder.add_enabled = true
|
|
||||||
for item_slot in ctx.item_slots:
|
for item_slot in ctx.item_slots:
|
||||||
item_slot.add_enabled = true
|
item_slot.add_enabled = true
|
||||||
item_slot.remove_enabled = true
|
item_slot.remove_enabled = true
|
||||||
@ -31,11 +29,10 @@ func on_gen_timer_timeout():
|
|||||||
assert(false)
|
assert(false)
|
||||||
|
|
||||||
func on_slot_item_changed(item):
|
func on_slot_item_changed(item):
|
||||||
pass
|
if ctx.items_in_slots.size() < 2:
|
||||||
|
|
||||||
func on_item_holder_item_changed(item):
|
|
||||||
if item == null:
|
|
||||||
ctx.change_state(ctx.States[ctx.EState.IDLE].new())
|
ctx.change_state(ctx.States[ctx.EState.IDLE].new())
|
||||||
|
elif ctx.item_to_craft != null:
|
||||||
|
ctx.change_state(ctx.States[ctx.EState.READY].new())
|
||||||
|
|
||||||
func on_item_dump_item_dump_completed():
|
func on_item_dump_item_dump_completed():
|
||||||
pass
|
pass
|
||||||
|
@ -11,7 +11,6 @@ func enter_from(state):
|
|||||||
ctx.coin_machine.enabled = false
|
ctx.coin_machine.enabled = false
|
||||||
ctx.item_dump.enabled = true
|
ctx.item_dump.enabled = true
|
||||||
ctx.item_dump.reset()
|
ctx.item_dump.reset()
|
||||||
ctx.item_holder.add_enabled = true
|
|
||||||
ctx.progress_text.text = "Broken"
|
ctx.progress_text.text = "Broken"
|
||||||
for item_slot in ctx.item_slots:
|
for item_slot in ctx.item_slots:
|
||||||
item_slot.add_enabled = true
|
item_slot.add_enabled = true
|
||||||
@ -33,15 +32,15 @@ func on_gen_timer_timeout():
|
|||||||
func on_slot_item_changed(item):
|
func on_slot_item_changed(item):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func on_item_holder_item_changed(item):
|
|
||||||
pass
|
|
||||||
|
|
||||||
func on_item_dump_item_dump_completed():
|
func on_item_dump_item_dump_completed():
|
||||||
ctx.full_heal()
|
ctx.full_heal()
|
||||||
if ctx.item_holder.item_in_hold == null:
|
if ctx.items_in_slots.size() < 2:
|
||||||
ctx.change_state(ctx.States[ctx.EState.IDLE].new())
|
ctx.change_state(ctx.States[ctx.EState.IDLE].new())
|
||||||
|
elif ctx.item_to_craft != null:
|
||||||
|
ctx.change_state(ctx.States[ctx.EState.READY].new())
|
||||||
else:
|
else:
|
||||||
ctx.change_state(ctx.States[ctx.EState.BLOCKED].new("Blocked!"))
|
ctx.change_state(ctx.States[ctx.EState.BLOCKED].new())
|
||||||
|
|
||||||
|
|
||||||
func on_damage_taken():
|
func on_damage_taken():
|
||||||
assert(false, "cant take damage if already broken")
|
assert(false, "cant take damage if already broken")
|
||||||
|
@ -3,7 +3,6 @@ extends Reference
|
|||||||
const NAME = "idle"
|
const NAME = "idle"
|
||||||
|
|
||||||
var ctx = null
|
var ctx = null
|
||||||
var item_to_craft = null
|
|
||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
pass
|
pass
|
||||||
@ -12,10 +11,10 @@ func enter_from(state):
|
|||||||
for item_slot in ctx.item_slots:
|
for item_slot in ctx.item_slots:
|
||||||
item_slot.add_enabled = true
|
item_slot.add_enabled = true
|
||||||
item_slot.remove_enabled = true
|
item_slot.remove_enabled = true
|
||||||
ctx.item_holder.add_enabled = true
|
|
||||||
ctx.item_dump.enabled = false
|
ctx.item_dump.enabled = false
|
||||||
ctx.progress_text.text = "Ready!"
|
ctx.coin_machine.enabled = false
|
||||||
update_coin_machine_status()
|
ctx.progress_text.text = "Idle"
|
||||||
|
ctx.status_light.idle()
|
||||||
|
|
||||||
func exit_to(state):
|
func exit_to(state):
|
||||||
pass
|
pass
|
||||||
@ -24,21 +23,19 @@ func update(delta):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func on_coin_machine_coin_requirement_met(player):
|
func on_coin_machine_coin_requirement_met(player):
|
||||||
item_to_craft = get_craft_recipe_item()
|
assert(false, "shouldn't trigger while idle")
|
||||||
assert(item_to_craft != null)
|
|
||||||
ctx.change_state(ctx.States[ctx.EState.WORKING].new(item_to_craft) )
|
|
||||||
|
|
||||||
func on_gen_timer_timeout():
|
func on_gen_timer_timeout():
|
||||||
assert(false, "gen timer shouldn't trigger while idle")
|
assert(false, "gen timer shouldn't trigger while idle")
|
||||||
|
|
||||||
func on_slot_item_changed(item):
|
func on_slot_item_changed(item):
|
||||||
# enable coin machine if you have a valid combo of items
|
if ctx.items_in_slots.size() < 2:
|
||||||
update_coin_machine_status()
|
return
|
||||||
|
|
||||||
func on_item_holder_item_changed(item):
|
if ctx.item_to_craft != null:
|
||||||
# if target spot is occupied, go to blocked state
|
ctx.change_state(ctx.States[ctx.EState.READY].new())
|
||||||
if item != null:
|
else:
|
||||||
ctx.change_state(ctx.States[ctx.EState.BLOCKED].new("Blocked!"))
|
ctx.change_state(ctx.States[ctx.EState.BLOCKED].new())
|
||||||
|
|
||||||
func on_item_dump_item_dump_completed():
|
func on_item_dump_item_dump_completed():
|
||||||
pass
|
pass
|
||||||
@ -46,20 +43,4 @@ func on_item_dump_item_dump_completed():
|
|||||||
func on_damage_taken():
|
func on_damage_taken():
|
||||||
if ctx.current_hp <= 0:
|
if ctx.current_hp <= 0:
|
||||||
ctx.change_state(ctx.States[ctx.EState.BROKEN].new())
|
ctx.change_state(ctx.States[ctx.EState.BROKEN].new())
|
||||||
|
|
||||||
func get_craft_recipe_item():
|
|
||||||
var items_in_slots = []
|
|
||||||
for item_slot in ctx.item_slots:
|
|
||||||
if item_slot.has_item():
|
|
||||||
items_in_slots.append(item_slot.item_in_hold.item_type)
|
|
||||||
if items_in_slots.empty():
|
|
||||||
return null
|
|
||||||
return ctx.recipes.find_recipe(items_in_slots)
|
|
||||||
|
|
||||||
func update_coin_machine_status():
|
|
||||||
var can_craft_recipe : bool = get_craft_recipe_item() != null
|
|
||||||
ctx.coin_machine.enabled = can_craft_recipe
|
|
||||||
if can_craft_recipe:
|
|
||||||
ctx.status_light.prime()
|
|
||||||
else:
|
|
||||||
ctx.status_light.idle()
|
|
||||||
|
45
scripts/crafting_station/state/ready.gd
Normal file
45
scripts/crafting_station/state/ready.gd
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
extends Reference
|
||||||
|
|
||||||
|
const NAME = "ready"
|
||||||
|
|
||||||
|
var ctx = null
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func enter_from(state):
|
||||||
|
assert(ctx.item_to_craft != null)
|
||||||
|
for item_slot in ctx.item_slots:
|
||||||
|
item_slot.add_enabled = true
|
||||||
|
item_slot.remove_enabled = true
|
||||||
|
ctx.item_dump.enabled = false
|
||||||
|
ctx.coin_machine.enabled = true
|
||||||
|
ctx.progress_text.text = "Ready!"
|
||||||
|
ctx.status_light.prime()
|
||||||
|
|
||||||
|
func exit_to(state):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func update(delta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func on_coin_machine_coin_requirement_met(player):
|
||||||
|
assert(ctx.item_to_craft != null)
|
||||||
|
ctx.change_state(ctx.States[ctx.EState.WORKING].new() )
|
||||||
|
|
||||||
|
func on_gen_timer_timeout():
|
||||||
|
assert(false, "gen timer shouldn't trigger while ready")
|
||||||
|
|
||||||
|
func on_slot_item_changed(item):
|
||||||
|
if ctx.items_in_slots.size() < 2:
|
||||||
|
ctx.change_state(ctx.States[ctx.EState.IDLE].new())
|
||||||
|
elif ctx.item_to_craft == null:
|
||||||
|
ctx.change_state(ctx.States[ctx.EState.BLOCKED].new())
|
||||||
|
|
||||||
|
func on_item_dump_item_dump_completed():
|
||||||
|
assert(false, "shouldn't trigger while ready")
|
||||||
|
|
||||||
|
func on_damage_taken():
|
||||||
|
if ctx.current_hp <= 0:
|
||||||
|
ctx.change_state(ctx.States[ctx.EState.BROKEN].new())
|
||||||
|
|
@ -3,16 +3,14 @@ extends Reference
|
|||||||
const NAME = "working"
|
const NAME = "working"
|
||||||
|
|
||||||
var ctx = null
|
var ctx = null
|
||||||
var crafting_item = null
|
|
||||||
|
|
||||||
func _init(item_to_craft : Resource):
|
func _init():
|
||||||
crafting_item = item_to_craft
|
pass
|
||||||
assert(crafting_item != null)
|
|
||||||
|
|
||||||
func enter_from(state):
|
func enter_from(state):
|
||||||
|
assert(ctx.item_to_craft != null)
|
||||||
ctx.coin_machine.enabled = false
|
ctx.coin_machine.enabled = false
|
||||||
ctx.item_dump.enabled = false
|
ctx.item_dump.enabled = false
|
||||||
ctx.item_holder.add_enabled = false
|
|
||||||
for item_slot in ctx.item_slots:
|
for item_slot in ctx.item_slots:
|
||||||
item_slot.add_enabled = false
|
item_slot.add_enabled = false
|
||||||
item_slot.remove_enabled = false
|
item_slot.remove_enabled = false
|
||||||
@ -21,14 +19,14 @@ func enter_from(state):
|
|||||||
ctx.progress_text.text = "Progress: 0%"
|
ctx.progress_text.text = "Progress: 0%"
|
||||||
|
|
||||||
func exit_to(state):
|
func exit_to(state):
|
||||||
pass
|
ctx.gen_timer.stop()
|
||||||
|
|
||||||
func update(delta):
|
func update(delta):
|
||||||
var time_left : float = ctx.gen_timer.time_left
|
var time_left : float = ctx.gen_timer.time_left
|
||||||
var time_passed : float = ctx.gen_time - time_left
|
var time_passed : float = ctx.gen_time - time_left
|
||||||
var percent_complete : float = (time_passed / ctx.gen_time) * 100.0
|
var percent_complete : float = (time_passed / ctx.gen_time) * 100.0
|
||||||
ctx.progress_text.text = "Progress: %d%%" % percent_complete
|
ctx.progress_text.text = "Progress: %d%%" % percent_complete
|
||||||
|
|
||||||
func on_coin_machine_coin_requirement_met(player):
|
func on_coin_machine_coin_requirement_met(player):
|
||||||
assert(false, "coin machine should be disabled while crafting")
|
assert(false, "coin machine should be disabled while crafting")
|
||||||
|
|
||||||
@ -36,19 +34,16 @@ func on_item_dump_item_dump_completed():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func on_gen_timer_timeout():
|
func on_gen_timer_timeout():
|
||||||
|
var crafted_item : Resource = ctx.item_to_craft
|
||||||
for item_slot in ctx.item_slots:
|
for item_slot in ctx.item_slots:
|
||||||
if item_slot.has_item():
|
if item_slot.has_item():
|
||||||
item_slot.destroy_item()
|
item_slot.destroy_item()
|
||||||
ctx.item_holder.spawn_item(crafting_item)
|
ctx.item_slots[0].spawn_item(crafted_item)
|
||||||
ctx.change_state(ctx.States[ctx.EState.BLOCKED].new("Finished: %s" % crafting_item.name))
|
ctx.change_state(ctx.States[ctx.EState.IDLE].new())
|
||||||
|
|
||||||
func on_slot_item_changed(item):
|
func on_slot_item_changed(item):
|
||||||
assert(item == null, "slot items can only be destroyed at this point")
|
pass
|
||||||
|
|
||||||
func on_item_holder_item_changed(item):
|
|
||||||
assert(item.item_type == crafting_item, "only the crafted item can be added to the item holder")
|
|
||||||
|
|
||||||
func on_damage_taken():
|
func on_damage_taken():
|
||||||
if ctx.current_hp <= 0:
|
if ctx.current_hp <= 0:
|
||||||
ctx.gen_timer.stop()
|
|
||||||
ctx.change_state(ctx.States[ctx.EState.BROKEN].new())
|
ctx.change_state(ctx.States[ctx.EState.BROKEN].new())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user