mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-18 21:53:22 +00:00
* Experiment with replacing weakrefs in AI blackboard with deleting signals, ideally making it easier to work with and harder to cause hard deletes (#74791) ## About The Pull Request Replaces weakref usage in AI blackboards with deleting signals All blackboard var setting must go through setters rather than directly ## Why It's Good For The Game This both makes it a ton easier to develop AI for, and also makes it harder for hard deletes to sneak in, as has been seen with recent 515 prs showing hard deletes in AI blackboards (To quantify "making it easier to develop AI", I found multiple bugs in existing AI code due to the usage of weakrefs.) I'm looking for `@ Jacquerel` `@ tralezab` 's opinions on the matter, also maybe `@ LemonInTheDark` if they're interested ## Changelog 🆑 Melbert refactor: Mob ai refactored once again /🆑 * Experiment with replacing weakrefs in AI blackboard with deleting signals, ideally making it easier to work with and harder to cause hard deletes --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
25 lines
775 B
Plaintext
25 lines
775 B
Plaintext
/**
|
|
* # cursed element!
|
|
*
|
|
*Attaching this element to something will make it float, and get a special ai controller!
|
|
*/
|
|
/datum/element/cursed
|
|
|
|
/datum/element/cursed/Attach(datum/target, slot)
|
|
. = ..()
|
|
if(!isitem(target))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/obj/item/master = target
|
|
var/datum/ai_controller/ai = new /datum/ai_controller/cursed(master)
|
|
ai.set_blackboard_key(BB_TARGET_SLOT, slot)
|
|
master.ai_controller = ai
|
|
master.AddElement(/datum/element/movetype_handler)
|
|
ADD_TRAIT(master, TRAIT_MOVE_FLYING, ELEMENT_TRAIT(type))
|
|
|
|
/datum/element/cursed/Detach(datum/source)
|
|
. = ..()
|
|
var/obj/item/master = source
|
|
QDEL_NULL(master.ai_controller)
|
|
REMOVE_TRAIT(master, TRAIT_MOVE_FLYING, ELEMENT_TRAIT(type))
|
|
master.RemoveElement(/datum/element/movetype_handler)
|