2024-01-27 20:10:50 +00:00
|
|
|
class_name Crowd
|
2024-01-26 19:54:22 +00:00
|
|
|
extends Node2D
|
|
|
|
|
2024-01-27 19:46:22 +00:00
|
|
|
@export_range(1, 16, 1) var max_persons = 16
|
|
|
|
|
2024-01-26 19:54:22 +00:00
|
|
|
|
2024-01-27 20:10:50 +00:00
|
|
|
var audience : Array[AudienceMember] = []
|
|
|
|
var overall_mood : float = 0
|
|
|
|
|
2024-01-26 19:54:22 +00:00
|
|
|
func _ready():
|
|
|
|
var counter = 0
|
|
|
|
var person = preload("res://scenes/crowd/person.tscn")
|
|
|
|
for seat in $Seats.get_children():
|
2024-01-27 15:45:22 +00:00
|
|
|
var person_node = person.instantiate()
|
|
|
|
person_node.color = AudienceMember.get_random_color()
|
|
|
|
seat.add_child(person_node)
|
2024-01-27 20:10:50 +00:00
|
|
|
audience.append(person_node)
|
2024-01-27 14:50:20 +00:00
|
|
|
|
2024-01-26 19:54:22 +00:00
|
|
|
counter += 1
|
|
|
|
if counter == max_persons:
|
|
|
|
break
|
2024-01-27 20:10:50 +00:00
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(_delta):
|
|
|
|
overall_mood = 0
|
|
|
|
for m in audience:
|
2024-01-28 09:30:18 +00:00
|
|
|
overall_mood += m.mood * 10
|