Closed archanyhm closed 1 year ago
I will keep this in mind going forward, and try to remove null instances wherever possible. This is another instance, I believe, of trying to copy the python code a little too closely.
Fetch_cat can no longer return Null. Since fading cats aren't implemented, it just throws an exception if the cat is not in the cat dictionary.
https://github.com/keyraven/ClanGen-CSharp/blob/f155ae5f56ee7b8cec15dd9b49b8d7d0bfccd882/Clangen/Models/World.cs#L140C26-L140C26
This is just one single example, but I've noticed quite a lot: things are either by default null or somehow are able to return null. Attempting to load a cat with an ID that doesn't exist should be treated as exceptional and treated as such. If a cat gets completely removed from the game in a way where they cannot be retrieved anymore, any references to that cat ID have to be removed as well. Otherwise this leads to inconsistent data state. Therefore, if the code tries to retrieve a cat that doesn't exist, throw an exception.
A lot of the structures in ClanGen are basically set up in a way mirroring commonplace database systems. A lot of the data is relational. References by ID to different "tables" or "entities" need to retain referential integrity. If we do not desire referential integrity, place redundant data in places where you'd rely on a reference to a different entity to retrieve the data you need.