mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
# About The Pull Request ## Nearsighted Sources Nearsighted now associates/tracks severity applied by each source. Previously, nearsighted only used a single variable which had to be shared by every source, which caused problems for things like scarred eyes which needed independent behaviour. This implementation allows sources with different severity levels to coexist without needing workarounds There are now two different severity types for nearsightedness: * Correctable: Can be mitigated with vision correction (like glasses) * Absolute: Cannot be mitigated from any source, used for scarred eyes Which can allow nearsighted sources to not be affected by vision correction. Also, since there is no more technical conflict between the two quirks, I've made it so that nearsighted and scarred eye can be selected together (as a QOL change) There is also a new unit test for this new behaviour (nearsighted_effect) that checks application and removal ## status_effect/grouped minor rework Grouped status effects now have `source_added()` and `source_removed()` procs, which are called whenever a source is added or removed from the effect I did this because the previous implementation was somewhat unwieldy. Inherited status effects would recieve the _currently existing_ effect through merge_with_existing, and require them to modify the existing effect's properties, which is odd and not intuitive to work with (the proc's `src` was not the existing effect) It not being called for every source also made users repeat code in `on_creation()` and `merge_with_existing()` for every source added. This new interface should prevent repetition and be generally more intuitive to work with. # Changelog 🆑 refactor: Nearsighted has been reworked to track severity applied from each source, as well as allow "non-correctable" nearsightedness (for things like scarred eyes). qol: The above being possible now means that you can select the Nearsighted and Scarred eye quirks together fix: Any bug that would occur from becoming nearsighted with a scarred eye should be fixed now code: status_effect/grouped merging code has been improved (i hope) /🆑
48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
/// Status effect from multiple sources, when all sources are removed, so is the effect
|
|
/datum/status_effect/grouped
|
|
id = STATUS_EFFECT_ID_ABSTRACT
|
|
alert_type = null
|
|
// Grouped effects adds itself to [var/sources] and destroys itself if one exists already, there are never actually multiple
|
|
status_type = STATUS_EFFECT_MULTIPLE
|
|
/// A list of all sources applying this status effect. Sources are a list of keys
|
|
var/list/sources = list()
|
|
|
|
/datum/status_effect/grouped/on_creation(mob/living/new_owner, source, ...)
|
|
//Get our supplied arguments, without new_owner
|
|
var/list/new_source_args = args.Copy(2)
|
|
|
|
var/datum/status_effect/grouped/existing = new_owner.has_status_effect(type)
|
|
if(existing)
|
|
existing.sources |= source
|
|
existing.source_added(arglist(new_source_args))
|
|
qdel(src)
|
|
return FALSE
|
|
|
|
/* We are the original */
|
|
|
|
. = ..()
|
|
if(.)
|
|
sources |= source
|
|
source_added(arglist(new_source_args))
|
|
|
|
/**
|
|
* Called after a source is added to the status effect,
|
|
* this includes the first source added after creation.
|
|
*/
|
|
/datum/status_effect/grouped/proc/source_added(source, ...)
|
|
return
|
|
|
|
/**
|
|
* Called after a source is removed from the status effect. \
|
|
* `removing` will be TRUE if this is the last source, which means
|
|
* the effect will be deleted.
|
|
*/
|
|
/datum/status_effect/grouped/proc/source_removed(source, removing)
|
|
return
|
|
|
|
/datum/status_effect/grouped/before_remove(source)
|
|
sources -= source
|
|
var/was_last_source = !length(sources)
|
|
source_removed(source, was_last_source)
|
|
return was_last_source
|