mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Ports Chemistry/NanoUI Fixes Early
Direct port of https://github.com/PolarisSS13/Polaris/pull/6039
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
SUBSYSTEM_DEF(nanoui)
|
SUBSYSTEM_DEF(nanoui)
|
||||||
name = "NanoUI"
|
name = "NanoUI"
|
||||||
wait = 20
|
wait = 5
|
||||||
// a list of current open /nanoui UIs, grouped by src_object and ui_key
|
// a list of current open /nanoui UIs, grouped by src_object and ui_key
|
||||||
var/list/open_uis = list()
|
var/list/open_uis = list()
|
||||||
// a list of current open /nanoui UIs, not grouped, for use in processing
|
// a list of current open /nanoui UIs, not grouped, for use in processing
|
||||||
@@ -23,6 +23,8 @@ SUBSYSTEM_DEF(nanoui)
|
|||||||
if(copytext(filename, length(filename)) != "/") // filenames which end in "/" are actually directories, which we want to ignore
|
if(copytext(filename, length(filename)) != "/") // filenames which end in "/" are actually directories, which we want to ignore
|
||||||
if(fexists(path + filename))
|
if(fexists(path + filename))
|
||||||
asset_files.Add(fcopy_rsc(path + filename)) // add this file to asset_files for sending to clients when they connect
|
asset_files.Add(fcopy_rsc(path + filename)) // add this file to asset_files for sending to clients when they connect
|
||||||
|
for(var/i in GLOB.clients)
|
||||||
|
addtimer(CALLBACK(src, .proc/send_resources, i), 10)
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/datum/controller/subsystem/nanoui/Recover()
|
/datum/controller/subsystem/nanoui/Recover()
|
||||||
@@ -40,3 +42,10 @@ SUBSYSTEM_DEF(nanoui)
|
|||||||
for(var/thing in processing_uis)
|
for(var/thing in processing_uis)
|
||||||
var/datum/nanoui/UI = thing
|
var/datum/nanoui/UI = thing
|
||||||
UI.process()
|
UI.process()
|
||||||
|
|
||||||
|
//Sends asset files to a client, called on client/New()
|
||||||
|
/datum/controller/subsystem/nanoui/proc/send_resources(client)
|
||||||
|
if(!subsystem_initialized)
|
||||||
|
return
|
||||||
|
for(var/file in asset_files)
|
||||||
|
client << browse_rsc(file) // send the file to the client
|
||||||
@@ -4,6 +4,7 @@ PROCESSING_SUBSYSTEM_DEF(chemistry)
|
|||||||
flags = SS_BACKGROUND|SS_POST_FIRE_TIMING
|
flags = SS_BACKGROUND|SS_POST_FIRE_TIMING
|
||||||
init_order = INIT_ORDER_CHEMISTRY
|
init_order = INIT_ORDER_CHEMISTRY
|
||||||
var/list/chemical_reactions = list()
|
var/list/chemical_reactions = list()
|
||||||
|
var/list/chemical_reactions_by_reagent = list()
|
||||||
var/list/chemical_reagents = list()
|
var/list/chemical_reagents = list()
|
||||||
|
|
||||||
/datum/controller/subsystem/processing/chemistry/Recover()
|
/datum/controller/subsystem/processing/chemistry/Recover()
|
||||||
@@ -22,15 +23,16 @@ PROCESSING_SUBSYSTEM_DEF(chemistry)
|
|||||||
// more than one chemical it will still only appear in only one of the sublists.
|
// more than one chemical it will still only appear in only one of the sublists.
|
||||||
/datum/controller/subsystem/processing/chemistry/proc/initialize_chemical_reactions()
|
/datum/controller/subsystem/processing/chemistry/proc/initialize_chemical_reactions()
|
||||||
var/paths = typesof(/datum/chemical_reaction) - /datum/chemical_reaction
|
var/paths = typesof(/datum/chemical_reaction) - /datum/chemical_reaction
|
||||||
SSchemistry.chemical_reactions = list()
|
chemical_reactions = list()
|
||||||
|
chemical_reactions_by_reagent = list()
|
||||||
|
|
||||||
for(var/path in paths)
|
for(var/path in paths)
|
||||||
var/datum/chemical_reaction/D = new path()
|
var/datum/chemical_reaction/D = new path
|
||||||
|
chemical_reactions += D
|
||||||
if(D.required_reagents && D.required_reagents.len)
|
if(D.required_reagents && D.required_reagents.len)
|
||||||
var/reagent_id = D.required_reagents[1]
|
var/reagent_id = D.required_reagents[1]
|
||||||
if(!chemical_reactions[reagent_id])
|
LAZYINITLIST(chemical_reactions_by_reagent[reagent_id])
|
||||||
chemical_reactions[reagent_id] = list()
|
chemical_reactions_by_reagent[reagent_id] += D
|
||||||
chemical_reactions[reagent_id] += D
|
|
||||||
|
|
||||||
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id
|
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id
|
||||||
/datum/controller/subsystem/processing/chemistry/proc/initialize_chemical_reagents()
|
/datum/controller/subsystem/processing/chemistry/proc/initialize_chemical_reagents()
|
||||||
|
|||||||
@@ -221,18 +221,4 @@
|
|||||||
|
|
||||||
oldMob.open_uis.Cut()
|
oldMob.open_uis.Cut()
|
||||||
|
|
||||||
return 1 // success
|
return 1 // success
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends all nano assets to the client
|
|
||||||
* This is called on user login
|
|
||||||
*
|
|
||||||
* @param client /client The user's client
|
|
||||||
*
|
|
||||||
* @return nothing
|
|
||||||
*/
|
|
||||||
|
|
||||||
/datum/controller/subsystem/nanoui/proc/send_resources(client)
|
|
||||||
for(var/file in asset_files)
|
|
||||||
client << browse_rsc(file) // send the file to the client
|
|
||||||
|
|
||||||
@@ -77,41 +77,31 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
/datum/reagents/proc/handle_reactions()
|
/datum/reagents/proc/handle_reactions()
|
||||||
START_PROCESSING(SSchemistry, src)
|
if(QDELETED(my_atom))
|
||||||
|
return FALSE
|
||||||
//returns 1 if the holder should continue reactiong, 0 otherwise.
|
if(my_atom.flags & NOREACT)
|
||||||
/datum/reagents/process()
|
return FALSE
|
||||||
if(QDELETED(my_atom)) //No container, no reaction.
|
var/reaction_occurred
|
||||||
return PROCESS_KILL
|
|
||||||
if(my_atom.flags & NOREACT) // No reactions here
|
|
||||||
return PROCESS_KILL
|
|
||||||
|
|
||||||
var/reaction_occured
|
|
||||||
var/list/effect_reactions = list()
|
|
||||||
var/list/eligible_reactions = list()
|
var/list/eligible_reactions = list()
|
||||||
for(var/i in 1 to PROCESS_REACTION_ITER)
|
var/list/effect_reactions = list()
|
||||||
reaction_occured = 0
|
do
|
||||||
|
reaction_occurred = FALSE
|
||||||
|
for(var/i in reagent_list)
|
||||||
|
var/datum/reagent/R = i
|
||||||
|
eligible_reactions |= SSchemistry.chemical_reactions_by_reagent[R.id]
|
||||||
|
|
||||||
//need to rebuild this to account for chain reactions
|
for(var/i in eligible_reactions)
|
||||||
for(var/datum/reagent/R in reagent_list)
|
var/datum/chemical_reaction/C = i
|
||||||
eligible_reactions |= SSchemistry.chemical_reactions[R.id]
|
|
||||||
|
|
||||||
for(var/datum/chemical_reaction/C in eligible_reactions)
|
|
||||||
if(C.can_happen(src) && C.process(src))
|
if(C.can_happen(src) && C.process(src))
|
||||||
effect_reactions |= C
|
effect_reactions |= C
|
||||||
reaction_occured = 1
|
|
||||||
|
|
||||||
eligible_reactions.Cut()
|
reaction_occurred = TRUE
|
||||||
|
eligible_reactions.len = 0
|
||||||
if(!reaction_occured)
|
while(reaction_occurred)
|
||||||
break
|
for(var/i in effect_reactions)
|
||||||
|
var/datum/chemical_reaction/C = i
|
||||||
for(var/datum/chemical_reaction/C in effect_reactions)
|
|
||||||
C.post_reaction(src)
|
C.post_reaction(src)
|
||||||
|
|
||||||
update_total()
|
update_total()
|
||||||
if(!reaction_occured)
|
|
||||||
return PROCESS_KILL
|
|
||||||
|
|
||||||
/* Holder-to-chemical */
|
/* Holder-to-chemical */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user