Add loadable profile data

This commit is contained in:
Waldemar Tomme 2024-01-27 15:56:50 +01:00
parent 4095d4df0f
commit 7764ec3fd1
1 changed files with 30 additions and 0 deletions

View File

@ -1,6 +1,22 @@
class_name AudienceProfile class_name AudienceProfile
extends Node2D extends Node2D
class ProfileData:
var happy_threshold: float
var angry_threshold: float
var lashout_threshold: float
var happiness_decay: float
var lashout_decay: float
var joke_mood_mapping: Dictionary
func _init(happy_threshold, angry_threshold, lashout_threshold, happiness_decay, lashout_decay, joke_mood_mapping):
self.happy_threshold = happy_threshold
self.angry_threshold = angry_threshold
self.lashout_threshold = lashout_threshold
self.happiness_decay = happiness_decay
self.lashout_decay = lashout_decay
self.joke_mood_mapping = joke_mood_mapping
@export var happy_threshold : float @export var happy_threshold : float
@export var angry_threshold : float @export var angry_threshold : float
@export var lashout_threshold : float @export var lashout_threshold : float
@ -11,6 +27,12 @@ extends Node2D
# Maps JokeType (as int) to mood change (as float) # Maps JokeType (as int) to mood change (as float)
@export var joke_mood_mapping: Dictionary @export var joke_mood_mapping: Dictionary
static func get_profile_data(index) -> ProfileData:
var profiles = [
ProfileData.new(3, -3, -10, 1, 10, { 0: 1, 1: 0, 2: -0.5 }),
]
return profiles[index]
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
@ -18,3 +40,11 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta): func _process(_delta):
pass pass
func load_data(data: ProfileData):
happy_threshold = data.happy_threshold
angry_threshold = data.angry_threshold
lashout_threshold = data.lashout_threshold
happiness_decay = data.happiness_decay
lashout_decay = data.lashout_decay
joke_mood_mapping = data.joke_mood_mapping