However, this approach does not work for everything, as we can't guarantee that these procs are called in testing. Right now I am adding a similar preview icon to teams, but I can't create every team in a test without more code, as some teams will want to use their members as part of the icon, or some other round state, which won't be defined/be inaccurate or null.
It would be cool if we could avoid these hacks and use something like virtual T proc() = 0; in C++, or abstract in Java.
I don't care about the syntax, but something like set must_override = TRUE would be good enough.
Ideally this would also stack, so that we can add more abstract subtypes. For example:
/datum/antagonist/proc/get_preview_icon()
set must_override = TRUE
/datum/antagonist/traitor/get_preview_icon()
// my code
// /datum/antagonist/team_based isn't a concrete type, and so we are okay with it not implementing get_preview_icon() as long as its own subtypes do.
/datum/antagonist/team_based/get_preview_icon()
set must_override = TRUE
Instantiating a datum that doesn't override the proc, and then calling it anyway should probably just run whatever is inside the proc body anyway, since we ideally still want ..() to work.
The common term for this is an abstract method.
But yeah, I love this.