So this is actually so crazy I have no idea what is causing this.
The setup: I have a script called weapon.gd, which I use to store this variable:
static var held_weapon_data: Dictionary[WeaponType, HeldWeaponData]
containing certain data about the weapons in my game. Here's weapon.gd:
class_name Weapon
extends RefCounted
enum WeaponType {
SWORD,
HAMMER,
DRILL,
}
static var held_weapon_data: Dictionary[WeaponType, HeldWeaponData] = {
WeaponType.SWORD: preload("res://src/entities/weapons/sword/sword_held_data.tres"),
WeaponType.HAMMER: preload("res://src/entities/weapons/hammer/hammer_held_data.tres"),
WeaponType.DRILL: preload("res://src/entities/weapons/drill/drill_held_data.tres")
}
This has been working fine for months, no issues. But today I've been trying to implement a COMPLETELY DIFFERENT system in the game, saving and loading persistent data. I re-iterate, I'm like 99.99% sure that these two systems in my game do NOT intersect whatsoever, and neither has any syntax errors in their associated scripts.
The persistent data system is used for tracking certain repetitive things between scenes, like which enemies have been killed, doors that have been opened, etc... it is a class called PersistentData
I've just been trying to implement this system on my Enemy class, but for some reason, including a reference to the PersistentData class anywhere in my enemy.gd script causes the following errors:
weapon.gd:17 @ @static_initializer(): Attempted to assign an object into a TypedDictionary.Value, that does not inherit from 'GDScript'.
weapon.gd:17 @ @static_initializer(): Unable to convert value at key "0" from "Object" to "Object".
And then the error which actually causes the crash:
Player._ready: Out of bounds get index '0' (on base: 'Dictionary[int, HeldWeaponData]')
Simply from trying to access Weapon.held_weapon_data???
I have no idea what is causing this ;_: