mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
Converts 3 components into elements (#94589)
## 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 /🆑
This commit is contained in:
@@ -1,110 +0,0 @@
|
||||
///Influences the difficulty of the minigame when worn or if buckled to.
|
||||
/datum/component/adjust_fishing_difficulty
|
||||
///The additive numerical modifier to the difficulty of the minigame
|
||||
var/modifier
|
||||
///For items, in which slot it has to be worn to influence the difficulty of the minigame
|
||||
var/slots
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/Initialize(modifier, slots = NONE)
|
||||
if(!ismovable(parent) || !modifier)
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
|
||||
if(!isitem(parent))
|
||||
var/atom/movable/movable_parent = parent
|
||||
if(!movable_parent.can_buckle)
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
|
||||
src.modifier = modifier
|
||||
src.slots = slots
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/RegisterWithParent()
|
||||
if(isitem(parent))
|
||||
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equipped))
|
||||
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(on_dropped))
|
||||
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_item_examine))
|
||||
else
|
||||
RegisterSignal(parent, COMSIG_MOVABLE_BUCKLE, PROC_REF(on_buckle))
|
||||
RegisterSignal(parent, COMSIG_MOVABLE_UNBUCKLE, PROC_REF(on_unbuckle))
|
||||
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_buckle_examine))
|
||||
|
||||
update_check()
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/UnregisterFromParent()
|
||||
UnregisterSignal(parent, list(
|
||||
COMSIG_ATOM_EXAMINE,
|
||||
COMSIG_MOVABLE_BUCKLE,
|
||||
COMSIG_MOVABLE_UNBUCKLE,
|
||||
COMSIG_ITEM_EQUIPPED,
|
||||
COMSIG_ITEM_DROPPED,
|
||||
))
|
||||
|
||||
update_check(TRUE)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/update_check(removing = FALSE)
|
||||
var/atom/movable/movable_parent = parent
|
||||
for(var/mob/living/buckled_mob as anything in movable_parent.buckled_mobs)
|
||||
update_user(buckled_mob, removing)
|
||||
if(!isitem(movable_parent) || !isliving(movable_parent.loc))
|
||||
return
|
||||
var/mob/living/holder = movable_parent.loc
|
||||
var/obj/item/item = parent
|
||||
if(holder.get_slot_by_item(movable_parent) & (slots || item.slot_flags))
|
||||
update_user(holder, removing)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/on_item_examine(obj/item/item, mob/user, list/examine_text)
|
||||
SIGNAL_HANDLER
|
||||
if(!HAS_MIND_TRAIT(user, TRAIT_EXAMINE_FISH))
|
||||
return
|
||||
var/method = "[(slots || item.slot_flags) & ITEM_SLOT_HANDS ? "Holding" : "Wearing"] [item.p_them()]"
|
||||
add_examine_line(user, examine_text, method)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/on_buckle_examine(atom/movable/source, mob/user, list/examine_text)
|
||||
SIGNAL_HANDLER
|
||||
if(!HAS_MIND_TRAIT(user, TRAIT_EXAMINE_FISH))
|
||||
return
|
||||
add_examine_line(user, examine_text, "Buckling to [source.p_them()]")
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/add_examine_line(mob/user, list/examine_text, method)
|
||||
var/percent = HAS_MIND_TRAIT(user, TRAIT_EXAMINE_DEEPER_FISH) ? "[abs(modifier)]% " : ""
|
||||
var/text = "[method] will make fishing [percent][modifier < 0 ? "easier" : "harder"]."
|
||||
if(modifier < 0)
|
||||
examine_text += span_nicegreen(text)
|
||||
else
|
||||
examine_text += span_danger(text)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/on_buckle(atom/movable/source, mob/living/buckled_mob, forced)
|
||||
SIGNAL_HANDLER
|
||||
update_user(buckled_mob)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/on_unbuckle(atom/movable/source, mob/living/buckled_mob, forced)
|
||||
SIGNAL_HANDLER
|
||||
update_user(buckled_mob, TRUE)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/on_equipped(obj/item/source, mob/living/wearer, slot)
|
||||
SIGNAL_HANDLER
|
||||
if(slot & (slots || source.slot_flags))
|
||||
update_user(wearer)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/on_dropped(obj/item/source, mob/living/dropper)
|
||||
SIGNAL_HANDLER
|
||||
update_user(dropper, TRUE)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/update_user(mob/living/user, removing = FALSE)
|
||||
var/datum/fishing_challenge/challenge = GLOB.fishing_challenges_by_user[user]
|
||||
if(removing)
|
||||
UnregisterSignal(user, COMSIG_MOB_BEGIN_FISHING)
|
||||
if(challenge)
|
||||
UnregisterSignal(challenge, COMSIG_FISHING_CHALLENGE_GET_DIFFICULTY)
|
||||
else
|
||||
RegisterSignal(user, COMSIG_MOB_BEGIN_FISHING, PROC_REF(on_minigame_started), TRUE)
|
||||
if(challenge)
|
||||
RegisterSignal(challenge, COMSIG_FISHING_CHALLENGE_GET_DIFFICULTY, PROC_REF(adjust_difficulty), TRUE)
|
||||
challenge?.update_difficulty()
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/on_minigame_started(mob/living/source, datum/fishing_challenge/challenge)
|
||||
SIGNAL_HANDLER
|
||||
RegisterSignal(challenge, COMSIG_FISHING_CHALLENGE_GET_DIFFICULTY, PROC_REF(adjust_difficulty), TRUE)
|
||||
|
||||
/datum/component/adjust_fishing_difficulty/proc/adjust_difficulty(datum/fishing_challenge/challenge, reward_path, obj/item/fishing_rod/rod, mob/living/user, list/holder)
|
||||
SIGNAL_HANDLER
|
||||
holder[1] += modifier
|
||||
@@ -1,29 +0,0 @@
|
||||
/// Allows objects that entered parent's tile to move freely through other objects with this component regardless of density
|
||||
/datum/component/climb_walkable
|
||||
|
||||
/datum/component/climb_walkable/RegisterWithParent()
|
||||
var/static/list/turf_connections = list(
|
||||
COMSIG_ATOM_ENTERED = PROC_REF(on_enter),
|
||||
COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON = PROC_REF(on_enter),
|
||||
COMSIG_ATOM_EXITED = PROC_REF(on_exit),
|
||||
)
|
||||
AddComponent(/datum/component/connect_loc_behalf, parent, turf_connections)
|
||||
RegisterSignal(parent, COMSIG_ATOM_TRIED_PASS, PROC_REF(can_allow_through))
|
||||
|
||||
/datum/component/climb_walkable/UnregisterFromParent()
|
||||
UnregisterSignal(parent, COMSIG_ATOM_TRIED_PASS)
|
||||
for (var/atom/movable/climber in get_turf(parent))
|
||||
REMOVE_TRAIT(climber, TRAIT_ON_CLIMBABLE, REF(src))
|
||||
|
||||
/datum/component/climb_walkable/proc/on_enter(datum/source, atom/movable/arrived)
|
||||
SIGNAL_HANDLER
|
||||
ADD_TRAIT(arrived, TRAIT_ON_CLIMBABLE, REF(src))
|
||||
|
||||
/datum/component/climb_walkable/proc/on_exit(datum/source, atom/movable/gone, direction)
|
||||
SIGNAL_HANDLER
|
||||
REMOVE_TRAIT(gone, TRAIT_ON_CLIMBABLE, REF(src))
|
||||
|
||||
/datum/component/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
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
/datum/crafting_recipe/lamp/New()
|
||||
. = ..()
|
||||
blacklist += subtypesof(/obj/item/flashlight)
|
||||
LAZYADD(blacklist, subtypesof(/obj/item/flashlight))
|
||||
|
||||
/datum/crafting_recipe/lamp/green
|
||||
name = "Green Desk Lamp"
|
||||
|
||||
Reference in New Issue
Block a user