# file containing type information to be referrenced by other classes extends Node var debugSpeedEnabled: bool var debugAutoPlayEnabled: bool var player_save := ConfigFile.new() class World: enum Zone { TUTORIAL, } enum AreaType { PEACEFUL, URBAN, WILDS, DEEP_WILDS, DUNGEON, } enum Faction { CREATURE, MONSTER, } enum Tier { I, II, III, IV, V, VI, VII, VIII, IX, X } class Ability: enum PDamageType { SLICE, PUNCTURE, BASH, HACK, SHRED, } enum MDamageType { BURN, FREEZE, SHOCK, POISON, LIFE, MENTAL, RADIANT, ARCANE, FORCE } enum StatusModType { STUN, SLOW, ABSORB, SHIELD, DOT, DOTB, DOTE } class Weapon: enum WeaponType { SWORD, BOW, } func debug_print(value: String) -> void: if OS.is_debug_build(): print(value) func fade_node(node: Node, direction: String, duration: float) -> void: var modulation_step = 1.0 / (100 * duration) match direction: "in": node.modulate.a = 0 node.show() while node.modulate.a < 1: await get_tree().create_timer(0.01).timeout node.modulate.a += modulation_step "out": node.modulate.a = 1 while node.modulate.a > 0: await get_tree().create_timer(0.01).timeout node.modulate.a -= modulation_step node.hide() _: print("Unknown fade direction") func elapsed_time(seconds: float) -> Array: # returns array of time in format [seconds_remainder, minutes, hours, days] var seconds_remainder = fmod(seconds, 60) var seconds_int = floori(seconds) var minutes = seconds_int / 60 % 60 var hours = seconds_int / 60 / 60 % 24 var days = seconds_int / 60 / 60 / 24 return [seconds_remainder, minutes, hours, days] func elapsed_time_format(elapsed_time: Array, round_seconds: bool = true) -> String: var seconds_format = "%02.3f" var days_format = "%d days " if elapsed_time[3] == 0: days_format = "" elapsed_time = elapsed_time.slice(0, 3) if round_seconds: seconds_format = "%02d" elapsed_time.reverse() return (days_format + "%02d:%02d:" + seconds_format) % elapsed_time func _input(event: InputEvent) -> void: if OS.is_debug_build(): if event.is_action_pressed("game_speed_fast"): Engine.time_scale = 10.0 if event.is_action_pressed("game_speed_normal"): Engine.time_scale = 1.0 if event.is_action_pressed("game_speed_faster"): Engine.time_scale += 1.0 if event.is_action_pressed("game_speed_slower"): Engine.time_scale -= 1.0 func save_game() -> void: player_save.set_value("player", "player_name", PlayerState.player_name) player_save.set_value("player", "constitution", PlayerState.constitution) player_save.set_value("player", "experience", PlayerState.experience) player_save.set_value("player", "level", PlayerState.level) player_save.set_value("player", "base_health", PlayerState.base_health) player_save.set_value("player", "base_resource", PlayerState.base_resource) player_save.set_value("player", "weapon_type", PlayerState.weapon_type) player_save.set_value("player", "zone_duration", PlayerState.zone_duration) player_save.save_encrypted_pass("user://player_save.sav", "test") func load_game() -> void: var err = player_save.load_encrypted_pass("user://player_save.sav", "test") if err != OK: print("Failed to load save file.") return PlayerState.player_name = player_save.get_value("player", "player_name") PlayerState.constitution = player_save.get_value("player", "constitution") PlayerState.experience = player_save.get_value("player", "experience") PlayerState.level = player_save.get_value("player", "level") PlayerState.base_health = player_save.get_value("player", "base_health") PlayerState.base_resource = player_save.get_value("player", "base_resource") PlayerState.weapon_type = player_save.get_value("player", "weapon_type") PlayerState.zone_duration = player_save.get_value("player", "zone_duration")