Demodularizing the gear loadout code a little. (#12261)

This commit is contained in:
Ghom
2020-05-18 13:45:50 +02:00
committed by GitHub
parent 95249a4d79
commit 20ac2f26f4
10 changed files with 71 additions and 106 deletions
@@ -10,7 +10,6 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids)
/proc/load_loadout_config(loadout_config)
if(!loadout_config)
loadout_config = "config/loadout_config.txt"
LAZYINITLIST(GLOB.loadout_whitelist_ids)
var/list/file_lines = world.file2list(loadout_config)
for(var/line in file_lines)
if(!line || line[1] == "#")
@@ -26,12 +25,9 @@ GLOBAL_LIST_EMPTY(loadout_whitelist_ids)
GLOB.loadout_whitelist_ids["[lineID]"] = sublinecontent
/proc/initialize_global_loadout_items()
LAZYINITLIST(GLOB.loadout_items)
load_loadout_config()
for(var/item in subtypesof(/datum/gear))
var/datum/gear/I = new item
if(!GLOB.loadout_items[slot_to_string(I.category)])
LAZYINITLIST(GLOB.loadout_items[slot_to_string(I.category)])
LAZYSET(GLOB.loadout_items[slot_to_string(I.category)], I.name, I)
if(islist(I.geargroupID))
var/list/ggidlist = I.geargroupID
@@ -69,18 +69,6 @@
path = /obj/item/toy/katana
cost = 3
/datum/gear/box
name = "Spare box"
category = SLOT_IN_BACKPACK
path = /obj/item/storage/box
cost = 2
/datum/gear/crowbar
name = "Pocket Crowbar"
category = SLOT_IN_BACKPACK
path = /obj/item/crowbar
cost = 2
/datum/gear/tapeplayer
name = "Taperecorder"
category = SLOT_IN_BACKPACK
@@ -96,11 +84,6 @@
category = SLOT_IN_BACKPACK
path = /obj/item/newspaper
/datum/gear/paperbin
name = "Paper Bin"
category = SLOT_IN_BACKPACK
path = /obj/item/paper_bin
/datum/gear/crayons
name = "Box of crayons"
category = SLOT_IN_BACKPACK
@@ -146,4 +129,4 @@
category = SLOT_IN_BACKPACK
path = /obj/item/storage/fancy/ringbox/diamond
cost = 5
@@ -12,5 +12,5 @@
name = "Joy mask"
category = SLOT_WEAR_MASK
path = /obj/item/clothing/mask/joy
cost = 9
cost = 3
@@ -85,14 +85,6 @@
path = /obj/item/clothing/suit/hooded/wintercoat/polychromic
cost = 4 //too many people with neon green coats is hard on the eyes
/* Commented out until it is "balanced"
/datum/gear/coat/sec
name = "Security winter coat"
category = SLOT_WEAR_SUIT
path = /obj/item/clothing/suit/hooded/wintercoat/security
restricted_roles = list("Head of Security", "Warden", "Detective", "Security Officer") // Reserve it to the Security Departement
*/
/datum/gear/coat/med
name = "Medical winter coat"
category = SLOT_WEAR_SUIT
@@ -1,47 +0,0 @@
#define DEFAULT_SLOT_AMT 2
#define HANDS_SLOT_AMT 2
#define BACKPACK_SLOT_AMT 4
/datum/preferences
//gear
var/gear_points = 10
var/list/gear_categories
var/list/chosen_gear
var/gear_tab
//pref vars
var/screenshake = 100
var/damagescreenshake = 2
var/arousable = TRUE
var/widescreenpref = TRUE
var/autostand = TRUE
var/auto_ooc = FALSE
//vore prefs
var/toggleeatingnoise = TRUE
var/toggledigestionnoise = TRUE
var/hound_sleeper = TRUE
var/cit_toggles = TOGGLES_CITADEL
/datum/preferences/New(client/C)
..()
LAZYINITLIST(chosen_gear)
/datum/preferences/proc/is_loadout_slot_available(slot)
var/list/L
LAZYINITLIST(L)
for(var/i in chosen_gear)
var/datum/gear/G = i
var/occupied_slots = L[slot_to_string(initial(G.category))] ? L[slot_to_string(initial(G.category))] + 1 : 1
LAZYSET(L, slot_to_string(initial(G.category)), occupied_slots)
switch(slot)
if(SLOT_IN_BACKPACK)
if(L[slot_to_string(SLOT_IN_BACKPACK)] < BACKPACK_SLOT_AMT)
return TRUE
if(SLOT_HANDS)
if(L[slot_to_string(SLOT_HANDS)] < HANDS_SLOT_AMT)
return TRUE
else
if(L[slot_to_string(slot)] < DEFAULT_SLOT_AMT)
return TRUE
@@ -14,17 +14,6 @@
features["mcolor2"] = sanitize_hexcolor(features["mcolor2"], 3, 0)
features["mcolor3"] = sanitize_hexcolor(features["mcolor3"], 3, 0)
//gear loadout
var/text_to_load
S["loadout"] >> text_to_load
var/list/saved_loadout_paths = splittext(text_to_load, "|")
LAZYCLEARLIST(chosen_gear)
gear_points = initial(gear_points)
for(var/i in saved_loadout_paths)
var/datum/gear/path = text2path(i)
if(path)
LAZYADD(chosen_gear, path)
gear_points -= initial(path.cost)
/datum/preferences/proc/cit_character_pref_save(savefile/S)
//ipcs
@@ -47,10 +36,3 @@
//flavor text
WRITE_FILE(S["feature_flavor_text"], features["flavor_text"])
//gear loadout
if(islist(chosen_gear))
if(chosen_gear.len)
var/text_to_save = chosen_gear.Join("|")
S["loadout"] << text_to_save
else
S["loadout"] << "" //empty string to reset the value