Singletons + refactor of /datum/observ (#15487)

This commit is contained in:
Fluffy
2023-01-05 18:41:40 +01:00
committed by GitHub
parent 95f8207f08
commit 0ddcf0817a
507 changed files with 7603 additions and 7214 deletions
@@ -1,6 +1,6 @@
/mob/living/carbon/human
var/decl/origin_item/culture/culture
var/decl/origin_item/origin/origin
var/singleton/origin_item/culture/culture
var/singleton/origin_item/origin/origin
/datum/category_item/player_setup_item/origin
name = "Origin"
@@ -68,20 +68,20 @@
/datum/category_item/player_setup_item/origin/sanitize_character(var/sql_load = 0)
var/datum/species/S = all_species[pref.species]
if(!istext(pref.culture) || !ispath(text2path(pref.culture), /decl/origin_item/culture))
var/decl/origin_item/culture/CI = S.possible_cultures[1]
if(!istext(pref.culture) || !ispath(text2path(pref.culture), /singleton/origin_item/culture))
var/singleton/origin_item/culture/CI = S.possible_cultures[1]
pref.culture = "[CI]"
var/decl/origin_item/culture/our_culture = decls_repository.get_decl(text2path(pref.culture))
if(!istext(pref.origin) || !ispath(text2path(pref.origin), /decl/origin_item/origin))
var/decl/origin_item/origin/OI = pick(our_culture.possible_origins)
var/singleton/origin_item/culture/our_culture = GET_SINGLETON(text2path(pref.culture))
if(!istext(pref.origin) || !ispath(text2path(pref.origin), /singleton/origin_item/origin))
var/singleton/origin_item/origin/OI = pick(our_culture.possible_origins)
pref.origin = "[OI]"
else
var/decl/origin_item/origin/origin_check = text2path(pref.origin)
var/singleton/origin_item/origin/origin_check = text2path(pref.origin)
if(!(origin_check in our_culture.possible_origins))
to_client_chat(SPAN_WARNING("Your origin has been reset due to it being incompatible with your culture!"))
var/decl/origin_item/origin/OI = pick(our_culture.possible_origins)
var/singleton/origin_item/origin/OI = pick(our_culture.possible_origins)
pref.origin = "[OI]"
var/decl/origin_item/origin/our_origin = decls_repository.get_decl(text2path(pref.origin))
var/singleton/origin_item/origin/our_origin = GET_SINGLETON(text2path(pref.origin))
if(!(pref.citizenship in our_origin.possible_citizenships))
to_client_chat(SPAN_WARNING("Your previous citizenship is invalid for this origin! Resetting."))
pref.citizenship = our_origin.possible_citizenships[1]
@@ -97,8 +97,8 @@
if(SSrecords.init_state != SS_INITSTATE_DONE)
return "<center><large>Records controller not initialized yet. Please wait a bit and reload this section.</large></center>"
var/list/dat = list()
var/decl/origin_item/culture/CL = decls_repository.get_decl(text2path(pref.culture))
var/decl/origin_item/origin/OR = decls_repository.get_decl(text2path(pref.origin))
var/singleton/origin_item/culture/CL = GET_SINGLETON(text2path(pref.culture))
var/singleton/origin_item/origin/OR = GET_SINGLETON(text2path(pref.origin))
dat += "<b>Culture: </b><a href='?src=\ref[src];open_culture_menu=1'>[CL.name]</a><br>"
dat += "<i>- [CL.desc]</i>"
if(CL.important_information)
@@ -118,25 +118,25 @@
var/datum/species/S = all_species[pref.species]
if(href_list["open_culture_menu"])
var/list/options = list()
var/list/possible_cultures = decls_repository.get_decls(S.possible_cultures)
var/list/possible_cultures = Singletons.GetList(S.possible_cultures)
for(var/decl_type in possible_cultures)
var/decl/origin_item/culture/CL = possible_cultures[decl_type]
var/singleton/origin_item/culture/CL = possible_cultures[decl_type]
options[CL.name] = CL
var/result = input(user, "Choose your character's culture.", "Culture") as null|anything in options
var/decl/origin_item/culture/chosen_culture = options[result]
var/singleton/origin_item/culture/chosen_culture = options[result]
if(chosen_culture)
show_window(chosen_culture, "set_culture_data", user)
return TOPIC_HANDLED
if(href_list["open_origin_menu"])
var/list/options = list()
var/decl/origin_item/culture/our_culture = decls_repository.get_decl(text2path(pref.culture)) //plutonians be like
var/list/decl/origin_item/origin/origins_list = decls_repository.get_decls(our_culture.possible_origins)
var/singleton/origin_item/culture/our_culture = GET_SINGLETON(text2path(pref.culture)) //plutonians be like
var/list/singleton/origin_item/origin/origins_list = Singletons.GetList(our_culture.possible_origins)
for(var/decl_type in origins_list)
var/decl/origin_item/origin/OR = origins_list[decl_type]
var/singleton/origin_item/origin/OR = origins_list[decl_type]
options[OR.name] = OR
var/result = input(user, "Choose your character's origin.", "Origins") as null|anything in options
var/decl/origin_item/origin/chosen_origin = options[result]
var/singleton/origin_item/origin/chosen_origin = options[result]
if(chosen_origin)
show_window(chosen_origin, "set_origin_data", user)
return TOPIC_HANDLED
@@ -160,7 +160,7 @@
return TOPIC_REFRESH
if(href_list["citizenship"])
var/decl/origin_item/origin/our_origin = decls_repository.get_decl(text2path(pref.origin))
var/singleton/origin_item/origin/our_origin = GET_SINGLETON(text2path(pref.origin))
var/choice = input(user, "Please choose your current citizenship.", "Character Preference", pref.citizenship) as null|anything in our_origin.possible_citizenships
if(!choice || !CanUseTopic(user))
return TOPIC_NOACTION
@@ -174,7 +174,7 @@
return TOPIC_REFRESH
if(href_list["religion"])
var/decl/origin_item/origin/our_origin = decls_repository.get_decl(text2path(pref.origin))
var/singleton/origin_item/origin/our_origin = GET_SINGLETON(text2path(pref.origin))
var/choice = input(user, "Please choose a religion.", "Character Preference", pref.religion) as null|anything in our_origin.possible_religions
if(!choice || !CanUseTopic(user))
return TOPIC_NOACTION
@@ -188,7 +188,7 @@
return TOPIC_REFRESH
if(href_list["accent"])
var/decl/origin_item/origin/our_origin = decls_repository.get_decl(text2path(pref.origin))
var/singleton/origin_item/origin/our_origin = GET_SINGLETON(text2path(pref.origin))
var/choice = input(user, "Please choose an accent.", "Character Preference", pref.accent) as null|anything in our_origin.possible_accents
if(!choice || !CanUseTopic(user))
return TOPIC_NOACTION
@@ -201,7 +201,7 @@
sanitize_character()
return TOPIC_REFRESH
/datum/category_item/player_setup_item/origin/proc/show_window(var/decl/origin_item/OI, var/topic_data, var/mob/user)
/datum/category_item/player_setup_item/origin/proc/show_window(var/singleton/origin_item/OI, var/topic_data, var/mob/user)
var/datum/browser/origin_win = new(user, topic_data, "Origins Selection")
var/dat = "<html><center><b>[OI.name]</center></b>"
dat += "<hr>[OI.desc]<br>"