mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
Done using this command sed -Ei 's/(\s*\S+)\s*\t+/\1 /g' code/**/*.dm We have countless examples in the codebase with this style gone wrong, and defines and such being on hideously different levels of indentation. Fixing this to keep the alignment involves tainting the blames of code your PR doesn't need to be touching at all. And ultimately, it's hideous. There are some files that this sed makes uglier. I can fix these when they are pointed out, but I believe this is ultimately for the greater good of readability. I'm more concerned with if any strings relied on this. Hi codeowners! Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com>
56 lines
1.3 KiB
Plaintext
56 lines
1.3 KiB
Plaintext
/*
|
|
* WARRANTY VOID IF CODE USED
|
|
*/
|
|
|
|
|
|
/datum/events
|
|
var/list/events
|
|
|
|
/datum/events/New()
|
|
..()
|
|
events = new
|
|
|
|
/datum/events/Destroy()
|
|
for(var/elist in events)
|
|
for(var/e in events[elist])
|
|
qdel(e)
|
|
events = null
|
|
return ..()
|
|
|
|
/datum/events/proc/addEventType(event_type as text)
|
|
if(!(event_type in events) || !islist(events[event_type]))
|
|
events[event_type] = list()
|
|
return TRUE
|
|
return FALSE
|
|
|
|
// Arguments: event_type as text, proc_holder as datum, proc_name as text
|
|
// Returns: New event, null on error.
|
|
/datum/events/proc/addEvent(event_type as text, datum/callback/cb)
|
|
if(!event_type || !cb)
|
|
return
|
|
addEventType(event_type)
|
|
var/list/event = events[event_type]
|
|
event += cb
|
|
return cb
|
|
|
|
// Arguments: event_type as text, any number of additional arguments to pass to event handler
|
|
// Returns: null
|
|
/datum/events/proc/fireEvent(eventName, ...)
|
|
|
|
var/list/event = LAZYACCESS(events,eventName)
|
|
if(istype(event))
|
|
for(var/E in event)
|
|
var/datum/callback/cb = E
|
|
cb.InvokeAsync(arglist(args.Copy(2)))
|
|
|
|
// Arguments: event_type as text, E as /datum/event
|
|
// Returns: TRUE if event cleared, FALSE on error
|
|
|
|
/datum/events/proc/clearEvent(event_type as text, datum/callback/cb)
|
|
if(!event_type || !cb)
|
|
return FALSE
|
|
var/list/event = LAZYACCESS(events,event_type)
|
|
event -= cb
|
|
qdel(cb)
|
|
return TRUE
|