@@ -23,11 +23,11 @@ enum LimitBehavior { REPLACE, NO_SPAWN }
23
23
24
24
## The period of time in seconds to spawn another component. If zero, they won't spawn
25
25
## automatically. Use the "Spawn" block.
26
- @export_range (0.0 , 10.0 , 0.1 , "or_greater" ) var spawn_frequency : float = 0.0 :
27
- set = _set_spawn_fraquency
26
+ @export_range (0.0 , 10.0 , 0.1 , "or_greater" , "suffix:s" ) var spawn_period : float = 0.0 :
27
+ set = _set_spawn_period
28
28
29
29
## How many spawned scenes are allowed. If zero, there is no limit.
30
- @export_range (0 , 50 , 0.1 , "or_greater" ) var spawn_limit : int = 50
30
+ @export_range (0 , 50 , 0.1 , "or_greater" , "suffix:scenes" ) var spawn_limit : int = 50
31
31
32
32
## What happens when the limit is reached and a new spawn is attempted:
33
33
## - Replace: Remove the oldest spawned scene and spawn a new one.
@@ -53,20 +53,20 @@ func _remove_oldest_spawned():
53
53
spawned .get_parent ().remove_child (spawned )
54
54
55
55
56
- func _set_spawn_fraquency ( new_frequency : float ):
57
- spawn_frequency = new_frequency
56
+ func _set_spawn_period ( new_period : float ):
57
+ spawn_period = new_period
58
58
if not _timer or not is_instance_valid (_timer ):
59
59
return
60
- _timer .wait_time = spawn_frequency
60
+ _timer .wait_time = spawn_period
61
61
62
62
63
63
func spawn_start ():
64
- if spawn_frequency == 0.0 :
64
+ if spawn_period == 0.0 :
65
65
return
66
66
if not _timer or not is_instance_valid (_timer ):
67
67
_timer = Timer .new ()
68
68
add_child (_timer )
69
- _timer .wait_time = spawn_frequency
69
+ _timer .wait_time = spawn_period
70
70
_timer .timeout .connect (spawn_once )
71
71
_timer .start ()
72
72
spawn_once .call_deferred ()
@@ -107,10 +107,6 @@ func spawn_once():
107
107
spawned .position = global_position
108
108
109
109
110
- func do_set_spawn_frequency (new_frequency : float ):
111
- _set_spawn_fraquency (new_frequency )
112
-
113
-
114
110
static func setup_custom_blocks ():
115
111
var _class_name = "SimpleSpawner"
116
112
var block_list : Array [BlockDefinition ] = []
@@ -153,22 +149,22 @@ static func setup_custom_blocks():
153
149
block_list .append (block_definition )
154
150
155
151
block_definition = BlockDefinition .new ()
156
- block_definition .name = & "simplespawner_set_spawn_frequency "
152
+ block_definition .name = & "simplespawner_set_spawn_period "
157
153
block_definition .target_node_class = _class_name
158
154
block_definition .category = "Lifecycle | Spawn"
159
155
block_definition .type = Types .BlockType .STATEMENT
160
- block_definition .display_template = "set spawn frequency to {new_frequency : FLOAT} "
161
- block_definition .code_template = "do_set_spawn_frequency( {new_frequency} ) "
156
+ block_definition .display_template = "set spawn period to {new_period : FLOAT} "
157
+ block_definition .code_template = "spawn_period = {new_period} "
162
158
block_list .append (block_definition )
163
159
164
160
block_definition = BlockDefinition .new ()
165
- block_definition .name = & "simplespawner_get_spawn_frequency "
161
+ block_definition .name = & "simplespawner_get_spawn_period "
166
162
block_definition .target_node_class = _class_name
167
163
block_definition .category = "Lifecycle | Spawn"
168
164
block_definition .type = Types .BlockType .VALUE
169
165
block_definition .variant_type = TYPE_FLOAT
170
- block_definition .display_template = "spawn frequency "
171
- block_definition .code_template = "spawn_frequency "
166
+ block_definition .display_template = "spawn period "
167
+ block_definition .code_template = "spawn_period "
172
168
block_list .append (block_definition )
173
169
174
170
BlocksCatalog .add_custom_blocks (_class_name , block_list , [], {})
0 commit comments