[NO GBP] Jetpack and spacedrift: Fixes and niceties (#66628)

* Jetpack and spacedrift: Fixes and niceties

Ok so when I ported spacemovement onto movement loop,
I neglected to port this behavior that existed to support jetpacks.

Basically, if something that lets you move while spacedrifing
completes a move while you're spacedrifting, the
drift should "disable" to let it complete, and then later restart.

I neglected to add support for that, so that's what this does.

There's some other stuff going on here, mostly things to let jetpacks
ignore some of drift's extra behavior, since when a jetpack is not on
stablized, we want both to coexist.

It's a bit of a mess, I'm sorry about that.

Oh and at temporal's suggestion I've moved the visual_delay set from
newtonian move to an istype on the drift component, that was a good
idea, thanks quiet

* Makes dropping a pull while drifting carry the momentum into the pulled thing\

* Adds some extra context to Process_Spacemove, fixes a bunch of stupid
space bugs

It used to be, if you called Process_Spacemove with a direction, it
assumed you were an "action", so a client or mob trying to move in a
direction.

Unfortuantely for it, I needed to be able to use direction to make mob
pull drifting work. So we now actually pass in a second variable
called continuous_move, which tracks if this Process_Spacemove is on
behalf of a continuous move or not

In addition to this, I've added logic to bumping "off" someone to
prevent backbumping if that makes sense, since the bump is in the form
of a newtonian move that's run before the thing that's bumping actually
moves, we need some way to exclude it from holding the other object in
place.

* Adds a jetpack component, uses it to unify all three versions of
jetpacking

I hate you fikou
There were three copies of the same behavior, which made it hard to fix
stuff. Let's just componentize it

* Fixes jetpacks stabalizing even without fuel

This is mildly hacky. The real fix is to do this with events, but I
really don't wanna bend my brain like that. This'll do

* Ensures turn_off always has a user)

* Shut pu

* Bulky drags no longer effect your movespeed in space, fixing a consistency issue between them and all other forms of drags

* Removes some redundant code, cleans up some messy stuff

* Removes redundant safety checking from jetpack code

* see above

* Removes redundant signals
This commit is contained in:
LemonInTheDark
2022-05-20 00:54:00 -07:00
committed by GitHub
parent 1095f90664
commit 7e9ff85f2a
31 changed files with 494 additions and 262 deletions
+53 -64
View File
@@ -128,81 +128,68 @@
actions_types = list(/datum/action/item_action/organ_action/toggle)
w_class = WEIGHT_CLASS_NORMAL
var/on = FALSE
var/datum/effect_system/trail_follow/ion/ion_trail
var/datum/callback/get_mover
var/datum/callback/check_on_move
/obj/item/organ/cyberimp/chest/thrusters/Insert(mob/living/carbon/thruster_owner, special = 0)
/obj/item/organ/cyberimp/chest/thrusters/Initialize(mapload)
. = ..()
if(!ion_trail)
ion_trail = new
ion_trail.auto_process = FALSE
ion_trail.set_up(thruster_owner)
get_mover = CALLBACK(src, .proc/get_user)
check_on_move = CALLBACK(src, .proc/allow_thrust, 0.01)
refresh_jetpack()
/obj/item/organ/cyberimp/chest/thrusters/Destroy()
get_mover = null
check_on_move = null
return ..()
/obj/item/organ/cyberimp/chest/thrusters/proc/refresh_jetpack()
AddComponent(/datum/component/jetpack, FALSE, COMSIG_THRUSTER_ACTIVATED, COMSIG_THRUSTER_DEACTIVATED, THRUSTER_ACTIVATION_FAILED, get_mover, check_on_move, /datum/effect_system/trail_follow/ion)
/obj/item/organ/cyberimp/chest/thrusters/Remove(mob/living/carbon/thruster_owner, special = 0)
if(on)
toggle(silent = TRUE)
deactivate(silent = TRUE)
..()
/obj/item/organ/cyberimp/chest/thrusters/ui_action_click()
toggle()
/obj/item/organ/cyberimp/chest/thrusters/proc/toggle(silent = FALSE)
if(!on)
if((organ_flags & ORGAN_FAILING))
if(!silent)
to_chat(owner, span_warning("Your thrusters set seems to be broken!"))
return FALSE
if(allow_thrust(0.01))
on = TRUE
ion_trail.start()
RegisterSignal(owner, COMSIG_MOVABLE_MOVED, .proc/move_react)
RegisterSignal(owner, COMSIG_MOVABLE_PRE_MOVE, .proc/pre_move_react)
RegisterSignal(owner, COMSIG_MOVABLE_SPACEMOVE, .proc/spacemove_react)
owner.add_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic)
if(!silent)
to_chat(owner, span_notice("You turn your thrusters set on."))
if(on)
deactivate()
else
ion_trail.stop()
UnregisterSignal(owner, COMSIG_MOVABLE_MOVED)
UnregisterSignal(owner, COMSIG_MOVABLE_PRE_MOVE)
UnregisterSignal(owner, COMSIG_MOVABLE_SPACEMOVE)
owner.remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic)
activate()
/obj/item/organ/cyberimp/chest/thrusters/proc/activate(silent = FALSE)
if(on)
return
if(organ_flags & ORGAN_FAILING)
if(!silent)
to_chat(owner, span_notice("You turn your thrusters set off."))
on = FALSE
to_chat(owner, span_warning("Your thrusters set seems to be broken!"))
return
if(SEND_SIGNAL(src, COMSIG_THRUSTER_ACTIVATED) & THRUSTER_ACTIVATION_FAILED)
return
on = TRUE
owner.add_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic)
if(!silent)
to_chat(owner, span_notice("You turn your thrusters set on."))
update_appearance()
/obj/item/organ/cyberimp/chest/thrusters/proc/deactivate(silent = FALSE)
if(!on)
return
SEND_SIGNAL(src, COMSIG_THRUSTER_DEACTIVATED)
owner.remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic)
if(!silent)
to_chat(owner, span_notice("You turn your thrusters set off."))
on = FALSE
update_appearance()
/obj/item/organ/cyberimp/chest/thrusters/update_icon_state()
icon_state = "[base_icon_state][on ? "-on" : null]"
return ..()
/obj/item/organ/cyberimp/chest/thrusters/proc/move_react()
SIGNAL_HANDLER
if(!on)//If jet dont work, it dont work
return
if(!owner)//Don't allow jet self using
return
if(!isturf(owner.loc))//You can't use jet in nowhere or in mecha/closet
return
if(!(owner.movement_type & FLOATING) || owner.buckled)//You don't want use jet in gravity or while buckled.
return
if(owner.pulledby)//You don't must use jet if someone pull you
return
if(owner.throwing)//You don't must use jet if you thrown
return
if(length(owner.client.keys_held & owner.client.movement_keys))//You use jet when press keys. yes.
allow_thrust(0.01)
/obj/item/organ/cyberimp/chest/thrusters/proc/pre_move_react()
SIGNAL_HANDLER
ion_trail.oldposition = get_turf(owner)
/obj/item/organ/cyberimp/chest/thrusters/proc/spacemove_react(mob/user, movement_dir)
SIGNAL_HANDLER
if(on && movement_dir)
return COMSIG_MOVABLE_STOP_SPACEMOVE
/obj/item/organ/cyberimp/chest/thrusters/proc/allow_thrust(num)
/obj/item/organ/cyberimp/chest/thrusters/proc/allow_thrust(num, use_fuel = TRUE)
if(!owner)
return FALSE
@@ -213,27 +200,29 @@
// Priority 1: use air from environment.
var/datum/gas_mixture/environment = owner_turf.return_air()
if(environment && environment.return_pressure() > 30)
ion_trail.generate_effect()
return TRUE
// Priority 2: use plasma from internal plasma storage.
// (just in case someone would ever use this implant system to make cyber-alien ops with jetpacks and taser arms)
if(owner.getPlasma() >= num*100)
owner.adjustPlasma(-num*100)
ion_trail.generate_effect()
if(owner.getPlasma() >= num * 100)
if(use_fuel)
owner.adjustPlasma(-num * 100)
return TRUE
// Priority 3: use internals tank.
var/datum/gas_mixture/internal_mix = owner.internal.return_air()
var/datum/gas_mixture/internal_mix = owner.internal?.return_air()
if(internal_mix && internal_mix.total_moles() > num)
if(!use_fuel)
return TRUE
var/datum/gas_mixture/removed = internal_mix.remove(num)
if(removed.total_moles() > 0.005)
owner_turf.assume_air(removed)
ion_trail.generate_effect()
return TRUE
else
owner_turf.assume_air(removed)
ion_trail.generate_effect()
toggle(silent = TRUE)
deactivate(silent = TRUE)
return FALSE
/obj/item/organ/cyberimp/chest/thrusters/proc/get_user()
return owner