Ports Diagonal Movement

This commit is contained in:
Cerebulon
2022-10-08 08:36:14 +01:00
committed by VirgoBot
parent a637852c29
commit e99eba7945
18 changed files with 3539 additions and 2 deletions
@@ -4,11 +4,14 @@
// THE TRADITIONAL STYLE FROM /TG (modified)
/atom/movable/keyLoop(client/user)
<<<<<<< HEAD
// Bail out if the user is holding the "face direction" key (Maybe?)
// TODO - I think this breaks non-hotkeys WASD movement, so maybe adopt the /tg solution)
if(user.mod_keys_held & CTRL_KEY)
return
=======
>>>>>>> c463104999a... Ports Diagonal Movement (#8199)
var/must_call_move = FALSE
var/movement_dir = MOVEMENT_KEYS_TO_DIR(user.move_keys_held)
if(user.next_move_dir_add)
@@ -22,7 +22,11 @@ var/global/list/MOVE_KEY_MAPPINGS = list(
// Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
<<<<<<< HEAD
=======
>>>>>>> c463104999a... Ports Diagonal Movement (#8199)
// Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
log_debug("Client [ckey] sent an illegal movement key down: [movekeyName] ([movekey])")
@@ -54,12 +58,20 @@ var/global/list/MOVE_KEY_MAPPINGS = list(
// Map text sent by skin.dmf to our numeric codes. (This can be optimized away once we update skin.dmf)
var/movekey = MOVE_KEY_MAPPINGS[movekeyName]
<<<<<<< HEAD
=======
>>>>>>> c463104999a... Ports Diagonal Movement (#8199)
// Validate input. Must be one (and only one) of the key codes)
if(isnull(movekey) || (movekey & ~0xFFF) || (movekey & (movekey - 1)))
log_debug("Client [ckey] sent an illegal movement key up: [movekeyName] ([movekey])")
return
<<<<<<< HEAD
=======
>>>>>>> c463104999a... Ports Diagonal Movement (#8199)
// Clear bit indicating we were holding the key
move_keys_held &= ~movekey
mod_keys_held &= ~movekey
@@ -74,4 +86,8 @@ var/global/list/MOVE_KEY_MAPPINGS = list(
// Called every game tick
/client/keyLoop()
<<<<<<< HEAD
mob.focus?.keyLoop(src)
=======
mob.focus?.keyLoop(src)
>>>>>>> c463104999a... Ports Diagonal Movement (#8199)
+43
View File
@@ -1,5 +1,6 @@
// Set a client's focus to an object and override these procs on that object to let it handle keypresses
<<<<<<< HEAD
/datum/proc/key_down(key, client/user) // Called when a key is pressed down initially
return
/datum/proc/key_up(key, client/user) // Called when a key is released
@@ -10,6 +11,22 @@
/// Set mob's focus
/// TODO - Do we even need this concept?
=======
/// Called when a key is pressed down initially
/datum/proc/key_down(key, client/user)
return
/// Called when a key is released
/datum/proc/key_up(key, client/user)
return
/// Called once every server tick
/datum/proc/keyLoop(client/user)
set waitfor = FALSE
return
/// Set mob's focus. TODO: Decide if required.
>>>>>>> c463104999a... Ports Diagonal Movement (#8199)
/mob/proc/set_focus(datum/new_focus)
if(focus == new_focus)
return
@@ -20,6 +37,7 @@
if(!keys)
return ""
var/list/out = list()
<<<<<<< HEAD
if(keys & NORTH_KEY) out += "NORTH"
if(keys & SOUTH_KEY) out += "SOUTH"
if(keys & EAST_KEY) out += "EAST"
@@ -32,3 +50,28 @@
if(keys & SHIFT_KEY) out += "SHIFT"
if(keys & ALT_KEY) out += "ALT"
return out.Join(" ")
=======
if(keys & NORTH_KEY)
out += "NORTH"
if(keys & SOUTH_KEY)
out += "SOUTH"
if(keys & EAST_KEY)
out += "EAST"
if(keys & WEST_KEY)
out += "WEST"
if(keys & W_KEY)
out += "W"
if(keys & A_KEY)
out += "A"
if(keys & S_KEY)
out += "S"
if(keys & D_KEY)
out += "D"
if(keys & CTRL_KEY)
out += "CTRL"
if(keys & SHIFT_KEY)
out += "SHIFT"
if(keys & ALT_KEY)
out += "ALT"
return out.Join(" ")
>>>>>>> c463104999a... Ports Diagonal Movement (#8199)