-
Notifications
You must be signed in to change notification settings - Fork 3
/
debris_resource.gd
57 lines (41 loc) · 1.44 KB
/
debris_resource.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
extends Area2D
# class member variables go here, for example:
@export var resource: int = 1
enum elements {CARBON, IRON, MAGNESIUM, SILICON, HYDROGEN, NICKEL, SILVER, PLATINUM, GOLD, SULFUR}
func _ready():
# Called when the node is added to the scene for the first time.
# Initialization here
pass
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
func _on_debris_area_entered(area):
if area.get_parent().get_groups().has("player"):
#print("debris entered by " + area.get_parent().get_name())
var res_id = elements.keys()[resource]
#print("Picked up 1 unit of " + str(res_id))
if not area.cargo.has(elements.keys()[resource]):
# we don't have Dictionary.append, so just create
area.cargo[res_id] = 1
else:
area.cargo[res_id] += 1
# listing (player-only)
if 'HUD' in area:
area.HUD.update_cargo_listing(area.cargo)
get_parent().queue_free()
if area.get_groups().has("friendly") or area.get_groups().has("enemy"):
#print("debris entered by " + area.get_parent().get_name())
# paranoia
if not 'cargo' in area:
return
var res_id = elements.keys()[resource]
print("1 unit of " + str(res_id))
if not area.cargo.has(elements.keys()[resource]):
# we don't have Dictionary.append, so just create
area.cargo[res_id] = 1
else:
area.cargo[res_id] += 1
# trigger AI routines
area.resource_picked()
get_parent().queue_free()