mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-22 09:07:04 +01:00
* shit code goes in the comedy bin * stubs * move those * w * vehicle repath * maybe that instead * aouhgoawhuh3ho * markers * a * fixes * hell * let the great refactoring begin * a * aouhg * changes * augh * signals * s * offhand stuff * wrappers * stuff * modifications * a * stuff * base component * Stuff * a * stuff * ay * Ay * ? * fix * a * augh * aough * mark those * sigh * correction * that * let the good times roll * more * more * on god * aoihgouh * fixes * done with that ifle * sigh * a * s * fuck off voremobs * stuff * pain * some more * changes * changes * f/r * sigh * impl * out with the useless * fix * Fixes * a * fixes * move that * pain * fix * m * pain * WHY * regex * s * just offsets to go * reserve those words * that * stuff * stuff * not sure if list ops were a good ide abut whatever * fix * and once more with energy! * and once more with energy! * fixes * offsets * fix * lmao! * ay * patch * fixes * propagate that shit through * ayo * bruh? * e * PLEASE END MY SUFFERING * ah. * that * fix * fix * fixes * e * Fix * fix * fix * Fix * fix * fix Co-authored-by: VM_USER <VM_USER>
99 lines
2.7 KiB
Plaintext
99 lines
2.7 KiB
Plaintext
/**
|
|
* riding filters for mobs
|
|
*
|
|
* can require offhands on mobs and the person riding
|
|
*/
|
|
/datum/component/riding_filter/mob
|
|
expected_typepath = /mob
|
|
handler_typepath = /datum/component/riding_handler/mob
|
|
|
|
/// base number of offhands required on us
|
|
var/offhands_needed_ridden = 0
|
|
|
|
/**
|
|
* called to check offhands needed
|
|
*
|
|
* @params
|
|
* - buckling - if we're asking because we're about to buckle a ne wmob
|
|
* - semantic - for buckling
|
|
*/
|
|
/datum/component/riding_filter/mob/proc/ridden_offhands_needed(mob/buckling, semantic)
|
|
var/mob/ridden = parent
|
|
if(!ridden.has_buckled_mobs() && !buckling)
|
|
return 0
|
|
return offhands_needed_ridden
|
|
|
|
/datum/component/riding_filter/mob/allocate_offhands(mob/rider, semantic, list/offhands)
|
|
. = ..()
|
|
if(!.)
|
|
return
|
|
var/needed = ridden_offhands_needed(rider, semantic) - current_ridden_offhand_count()
|
|
if(needed <= 0)
|
|
return TRUE
|
|
for(var/i in 1 to needed)
|
|
var/obj/item/offhand/riding/R = try_equip_offhand_to_ridden()
|
|
if(!R)
|
|
return FALSE
|
|
offhands += R
|
|
return TRUE
|
|
|
|
/datum/component/riding_filter/mob/proc/current_ridden_offhand_count()
|
|
var/mob/ridden = parent
|
|
. = 0
|
|
for(var/obj/item/offhand/riding/R in ridden.get_held_items())
|
|
if(R.filter == src)
|
|
++.
|
|
|
|
/datum/component/riding_filter/mob/proc/get_ridden_offhand()
|
|
var/mob/ridden = parent
|
|
for(var/obj/item/offhand/riding/R in ridden.get_held_items())
|
|
if(R.filter == src)
|
|
return R
|
|
|
|
/datum/component/riding_filter/mob/check_offhands(mob/rider, unbuckling)
|
|
// we do our checks first, as they're cheaper in cases of riders > 1
|
|
var/needed = ridden_offhands_needed()
|
|
var/current = current_ridden_offhand_count()
|
|
if(unbuckling)
|
|
if(current > needed)
|
|
for(var/i in 1 to current - needed)
|
|
var/obj/item/offhand/riding/R = get_ridden_offhand()
|
|
if(!R)
|
|
stack_trace("failed to find an offhand even though current > needed? at i = [i]")
|
|
continue
|
|
R._silently_erase()
|
|
our_offhands -= R
|
|
else
|
|
if(current < needed)
|
|
var/mob/ridden = parent
|
|
ridden.unbuckle_all_mobs(BUCKLE_OP_FORCE)
|
|
return FALSE
|
|
return ..()
|
|
|
|
/datum/component/riding_filter/mob/proc/try_equip_offhand_to_ridden()
|
|
RETURN_TYPE(/obj/item/offhand/riding)
|
|
var/mob/M = parent
|
|
var/obj/item/offhand/riding/R = M.allocate_offhand(/obj/item/offhand/riding)
|
|
if(!R)
|
|
return
|
|
R.filter = src
|
|
R.owner = M
|
|
LAZYADD(our_offhands, R)
|
|
return R
|
|
|
|
/datum/component/riding_filter/mob/offhand_destroyed(obj/item/offhand/riding/offhand, mob/rider)
|
|
if(rider == parent)
|
|
check_offhands()
|
|
return
|
|
return ..()
|
|
|
|
/datum/component/riding_handler/mob
|
|
expected_typepath = /mob
|
|
rider_offsets = list(
|
|
list(0, 8, 0.01, null),
|
|
list(0, 8, 0.01, null),
|
|
list(0, 8, -0.01, null),
|
|
list(0, 8, 0.01, null)
|
|
)
|
|
rider_offset_format = CF_RIDING_OFFSETS_DIRECTIONAL
|