mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-10 07:41:16 +01:00
cf14dcfc1a
## About The Pull Request `adjust_fishing_difficulty` is a good one to make into a bespoke element since a number of the same clothing item are created in the wardrobe system. climb_walkable is also good due to how prevalent it is, and it is a bit of a two for one since it also removes the need for the `/component/connect_loc_behalf` Also stops adding the on_climbable trait to literally everything in the turf, it now only applies it to atoms with density. So no more pipes and stuff getting trait lists created for no reason. <details><summary> Tested + things still work as before </summary> <img width="422" height="122" alt="image" src="https://github.com/user-attachments/assets/b23696f5-cd16-4150-aeb3-14ea6bd256fc" /> </details> ## Why It's Good For The Game Lessens overhead, fixes a bug as well. ## Changelog 🆑 fix: fixes a pushed crate not removing on_climbable trait properly off the mob standing atop it /🆑
44 lines
2.0 KiB
Plaintext
44 lines
2.0 KiB
Plaintext
/// Allows objects that entered parent's tile to move freely through other objects with this component regardless of density
|
|
/datum/element/climb_walkable
|
|
var/static/list/turf_connections = list(
|
|
COMSIG_ATOM_ENTERED = TYPE_PROC_REF(/obj/structure, on_climb_enter),
|
|
COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON = TYPE_PROC_REF(/obj/structure, on_climb_enter),
|
|
COMSIG_ATOM_EXITED = TYPE_PROC_REF(/obj/structure, on_climb_exit),
|
|
)
|
|
|
|
/datum/element/climb_walkable/Attach(datum/target)
|
|
. = ..()
|
|
target.AddElement(/datum/element/connect_loc, turf_connections)
|
|
RegisterSignal(target, COMSIG_ATOM_TRIED_PASS, PROC_REF(can_allow_through))
|
|
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_climbable_moved))
|
|
|
|
/datum/element/climb_walkable/Detach(datum/source, ...)
|
|
. = ..()
|
|
UnregisterSignal(source, list(COMSIG_ATOM_TRIED_PASS, COMSIG_MOVABLE_MOVED))
|
|
for (var/atom/movable/climber in get_turf(source))
|
|
if(HAS_TRAIT(climber, TRAIT_ON_CLIMBABLE))
|
|
REMOVE_TRAIT(climber, TRAIT_ON_CLIMBABLE, ELEMENT_TRAIT(type))
|
|
source.RemoveElement(/datum/element/connect_loc, turf_connections)
|
|
|
|
/datum/element/climb_walkable/proc/can_allow_through(datum/source, atom/movable/mover, border_dir)
|
|
SIGNAL_HANDLER
|
|
if(HAS_TRAIT(mover, TRAIT_ON_CLIMBABLE))
|
|
return COMSIG_COMPONENT_PERMIT_PASSAGE
|
|
|
|
// Removes the climbable trait if the crate or whatever it is gets pushed away.
|
|
/datum/element/climb_walkable/proc/on_climbable_moved(datum/source, atom/old_loc)
|
|
SIGNAL_HANDLER
|
|
for (var/atom/movable/climber in get_turf(old_loc))
|
|
if(HAS_TRAIT(climber, TRAIT_ON_CLIMBABLE))
|
|
REMOVE_TRAIT(climber, TRAIT_ON_CLIMBABLE, ELEMENT_TRAIT(type))
|
|
|
|
/obj/structure/proc/on_climb_enter(datum/source, atom/movable/arrived)
|
|
SIGNAL_HANDLER
|
|
if(arrived.density)
|
|
ADD_TRAIT(arrived, TRAIT_ON_CLIMBABLE, ELEMENT_TRAIT(/datum/element/climb_walkable))
|
|
|
|
/obj/structure/proc/on_climb_exit(datum/source, atom/movable/gone, direction)
|
|
SIGNAL_HANDLER
|
|
if(HAS_TRAIT(gone, TRAIT_ON_CLIMBABLE))
|
|
REMOVE_TRAIT(gone, TRAIT_ON_CLIMBABLE, ELEMENT_TRAIT(/datum/element/climb_walkable))
|