mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-16 12:07:48 +00:00
* Out of the way pixel shift? No way! * Push suggestions and a logic fix! * *Much* better logic! * Oops comment! * Apply suggestions! Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> * Document var! Website moment! * Apply suggestions! * Fix inaccurate comment! * Update modular_skyrat/modules/pixel_shift/code/pixel_shift.dm Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
98 lines
2.6 KiB
Plaintext
98 lines
2.6 KiB
Plaintext
#define MAXIMUM_PIXEL_SHIFT 16
|
|
#define PASSABLE_SHIFT_THRESHOLD 8
|
|
|
|
/mob
|
|
/// Whether the mob is pixel shifted or not
|
|
var/is_shifted = FALSE
|
|
/// If we are in the shifting setting.
|
|
var/shifting = FALSE
|
|
|
|
/// Takes the four cardinal direction defines. Any atoms moving into this atom's tile will be allowed to from the added directions.
|
|
var/passthroughable = NONE
|
|
|
|
/datum/keybinding/mob/pixel_shift
|
|
hotkey_keys = list("B")
|
|
name = "pixel_shift"
|
|
full_name = "Pixel Shift"
|
|
description = "Shift your characters offset."
|
|
category = CATEGORY_MOVEMENT
|
|
keybind_signal = COMSIG_KB_MOB_PIXELSHIFT
|
|
|
|
/datum/keybinding/mob/pixel_shift/down(client/user)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
var/mob/M = user.mob
|
|
M.shifting = TRUE
|
|
return TRUE
|
|
|
|
/datum/keybinding/mob/pixel_shift/up(client/user)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
var/mob/M = user.mob
|
|
M.shifting = FALSE
|
|
return TRUE
|
|
|
|
/mob/proc/unpixel_shift()
|
|
return
|
|
|
|
/mob/living/unpixel_shift()
|
|
. = ..()
|
|
passthroughable = NONE
|
|
if(is_shifted)
|
|
is_shifted = FALSE
|
|
pixel_x = body_position_pixel_x_offset + base_pixel_x
|
|
pixel_y = body_position_pixel_y_offset + base_pixel_y
|
|
|
|
/mob/proc/pixel_shift(direction)
|
|
return
|
|
|
|
/mob/living/set_pull_offsets(mob/living/pull_target, grab_state)
|
|
pull_target.unpixel_shift()
|
|
return ..()
|
|
|
|
/mob/living/reset_pull_offsets(mob/living/pull_target, override)
|
|
pull_target.unpixel_shift()
|
|
return ..()
|
|
|
|
/mob/living/pixel_shift(direction)
|
|
passthroughable = NONE
|
|
switch(direction)
|
|
if(NORTH)
|
|
if(pixel_y <= MAXIMUM_PIXEL_SHIFT + base_pixel_y)
|
|
pixel_y++
|
|
is_shifted = TRUE
|
|
if(EAST)
|
|
if(pixel_x <= MAXIMUM_PIXEL_SHIFT + base_pixel_x)
|
|
pixel_x++
|
|
is_shifted = TRUE
|
|
if(SOUTH)
|
|
if(pixel_y >= -MAXIMUM_PIXEL_SHIFT + base_pixel_y)
|
|
pixel_y--
|
|
is_shifted = TRUE
|
|
if(WEST)
|
|
if(pixel_x >= -MAXIMUM_PIXEL_SHIFT + base_pixel_x)
|
|
pixel_x--
|
|
is_shifted = TRUE
|
|
|
|
// Yes, I know this sets it to true for everything if more than one is matched.
|
|
// Movement doesn't check diagonals, and instead just checks EAST or WEST, depending on where you are for those.
|
|
if(pixel_y > PASSABLE_SHIFT_THRESHOLD)
|
|
passthroughable |= EAST | SOUTH | WEST
|
|
if(pixel_x > PASSABLE_SHIFT_THRESHOLD)
|
|
passthroughable |= NORTH | SOUTH | WEST
|
|
if(pixel_y < -PASSABLE_SHIFT_THRESHOLD)
|
|
passthroughable |= NORTH | EAST | WEST
|
|
if(pixel_x < -PASSABLE_SHIFT_THRESHOLD)
|
|
passthroughable |= NORTH | EAST | SOUTH
|
|
|
|
/mob/living/CanAllowThrough(atom/movable/mover, border_dir)
|
|
// Make sure to not allow projectiles of any kind past where they normally wouldn't.
|
|
if(!istype(mover, /obj/projectile) && !mover.throwing && passthroughable & border_dir)
|
|
return TRUE
|
|
return ..()
|
|
|
|
#undef MAXIMUM_PIXEL_SHIFT
|
|
#undef PASSABLE_SHIFT_THRESHOLD
|