Skip to content

Commit

Permalink
Add maximum generation count to coloy spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Haldane authored and caldane committed May 1, 2023
1 parent af536f7 commit fde566d
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions Sick_Day_Delivery/Scripts/infection_spawner.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
extends Timer

@export var colony_max := 1
@export var colony_max_on_screen := 1
@export var colony_max_generations := 12

@export_range(0, 20, 2) var spawn_rate: int
@export_range(0, 1, .025) var spawn_chance: float
@export var colonyScene: PackedScene

@onready var spawns = $SpawnPoints.get_children()

var colony_generation = 1

# Called when the node enters the scene tree for the first time.
func _ready():
Expand All @@ -18,16 +20,18 @@ func _process(delta):
pass

func createColony():
var child_count = 0
for child in $Colonies.get_children():
if child.process_priority != 0:
child_count += 1
if child_count < colony_max:
var colony = colonyScene.instantiate()
var current_colony_name = spawns[0].name
while current_colony_name == spawns[0].name:
spawns.shuffle()
print_debug(spawns[0].name + ": " + str(spawns[0].position))
colony.process_priority = 1
colony.position = spawns[0].position
$Colonies.add_child(colony)
if colony_generation < colony_max_generations:
var child_count = 0
for child in $Colonies.get_children():
if child.process_priority != 0:
child_count += 1
if child_count < colony_max_on_screen:
colony_generation += 1
var colony = colonyScene.instantiate()
var current_colony_name = spawns[0].name
while current_colony_name == spawns[0].name:
spawns.shuffle()
print_debug(spawns[0].name + ": " + str(spawns[0].position))
colony.process_priority = 1
colony.position = spawns[0].position
$Colonies.add_child(colony)

0 comments on commit fde566d

Please sign in to comment.