mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 08:36:00 +01:00
8d48f8d4d2
## About The Pull Request Partially a port of https://github.com/DaedalusDock/daedalusdock/pull/1163 which is a port of my own code from bitbus Closes #88579 Instead of manually setting hud images and positioning we now can use set_hud_image_state which also updates their position to ensure that they scale with the owner atom. HUDs had RESET_COLOR and RESET_TRANSFORM but no KEEP_APART, so they were stuck with mobs all this time. I replaced RESET_TRANSFORM with PIXEL_SCALE (shouldn't be reserved to mob huds only to be honest) and added KEEP_APART, so that HUDs still scale/rotate with their owner but don't inherit their color. Also fixed the dragon issue, that's where this PR actually started. Closes https://github.com/tgstation/tgstation/issues/45411 ## Why It's Good For The Game I don't want my HUDs to be pretty pink when I make a barbie Clarke. ## Changelog 🆑 refactor: Rewrote some of HUD code so they're no longer colored in their owner's color fix: Space dragons no longer turn invisible when toggling seethrough mode /🆑
120 lines
4.4 KiB
Plaintext
120 lines
4.4 KiB
Plaintext
/mob/living/basic/bot/proc/diag_hud_set_bothealth()
|
|
set_hud_image_state(DIAG_HUD, "huddiag[RoundDiagBar(health/maxHealth)]")
|
|
|
|
/mob/living/basic/bot/proc/diag_hud_set_botstat() //On (With wireless on or off), Off, EMP'ed
|
|
if(bot_mode_flags & BOT_MODE_ON)
|
|
set_hud_image_state(DIAG_STAT_HUD, "hudstat")
|
|
return
|
|
|
|
if(stat != CONSCIOUS)
|
|
set_hud_image_state(DIAG_STAT_HUD, "hudoffline")
|
|
return
|
|
|
|
set_hud_image_state(DIAG_STAT_HUD, "huddead2")
|
|
|
|
/mob/living/basic/bot/proc/diag_hud_set_botmode() //Shows a bot's current operation
|
|
if(client) //If the bot is player controlled, it will not be following mode logic!
|
|
set_hud_image_state(DIAG_BOT_HUD, "hudsentient")
|
|
return
|
|
|
|
switch(mode)
|
|
if(BOT_SUMMON, BOT_RESPONDING) //Responding to PDA or AI summons
|
|
set_hud_image_state(DIAG_BOT_HUD, "hudcalled")
|
|
if(BOT_CLEANING, BOT_HEALING) //Cleanbot cleaning, Floorbot fixing, or Medibot Healing
|
|
set_hud_image_state(DIAG_BOT_HUD, "hudworking")
|
|
if(BOT_PATROL, BOT_START_PATROL) //Patrol mode
|
|
set_hud_image_state(DIAG_BOT_HUD, "hudpatrol")
|
|
if(BOT_PREP_ARREST, BOT_ARREST, BOT_HUNT) //STOP RIGHT THERE, CRIMINAL SCUM!
|
|
set_hud_image_state(DIAG_BOT_HUD, "hudalert")
|
|
if(BOT_MOVING, BOT_DELIVER, BOT_GO_HOME, BOT_NAV) //Moving to target for normal bots, moving to deliver or go home for MULES.
|
|
set_hud_image_state(DIAG_BOT_HUD, "hudmove")
|
|
else
|
|
set_hud_image_state(DIAG_BOT_HUD, "")
|
|
|
|
///proc that handles drawing and transforming the bot's path onto diagnostic huds
|
|
/mob/living/basic/bot/proc/generate_bot_path(datum/move_loop/has_target/jps/source)
|
|
SIGNAL_HANDLER
|
|
|
|
UnregisterSignal(src, COMSIG_MOVELOOP_JPS_FINISHED_PATHING)
|
|
|
|
if(isnull(ai_controller))
|
|
return
|
|
|
|
//Removes path images and handles removing hud client images
|
|
clear_path_hud()
|
|
|
|
var/list/path_huds_watching_me = list(GLOB.huds[DATA_HUD_DIAGNOSTIC], GLOB.huds[DATA_HUD_BOT_PATH])
|
|
|
|
var/list/path_images = active_hud_list[DIAG_PATH_HUD]
|
|
LAZYCLEARLIST(path_images)
|
|
|
|
|
|
var/atom/move_target = ai_controller.current_movement_target
|
|
if(move_target != ai_controller.blackboard[BB_BEACON_TARGET])
|
|
return
|
|
|
|
var/list/our_path = source.movement_path
|
|
if(!length(our_path))
|
|
return
|
|
|
|
for(var/index in 1 to our_path.len)
|
|
if(index == 1 || index == our_path.len)
|
|
continue
|
|
var/turf/current_turf = our_path[index]
|
|
var/turf/previous_turf = our_path[index - 1]
|
|
|
|
var/turf/next_turf = our_path[index + 1]
|
|
var/next_direction = get_dir(previous_turf, next_turf)
|
|
var/previous_direction = get_dir(current_turf, previous_turf)
|
|
|
|
var/image/path_display = image(icon = path_image_icon, loc = current_turf, icon_state = path_image_icon_state, layer = BOT_PATH_LAYER, dir = next_direction)
|
|
|
|
SET_PLANE(path_display, GAME_PLANE, current_turf)
|
|
|
|
if((ISDIAGONALDIR(next_direction) && (previous_direction & (NORTH|SOUTH))))
|
|
var/turn_value = (next_direction == SOUTHWEST || next_direction == NORTHEAST) ? 90 : -90
|
|
path_display.transform = path_display.transform.Turn(turn_value)
|
|
path_display.transform = path_display.transform.Scale(1, -1)
|
|
|
|
path_display.color = path_image_color
|
|
path_images += path_display
|
|
current_pathed_turfs[current_turf] = path_display
|
|
|
|
for(var/datum/atom_hud/hud as anything in path_huds_watching_me)
|
|
hud.add_atom_to_hud(src)
|
|
|
|
///proc that handles moving along the bot's drawn path
|
|
/mob/living/basic/bot/proc/handle_loop_movement(atom/movable/source, atom/oldloc, dir, forced)
|
|
SIGNAL_HANDLER
|
|
|
|
handle_hud_path()
|
|
on_bot_movement(source, oldloc, dir, forced)
|
|
|
|
/mob/living/basic/bot/proc/handle_hud_path()
|
|
if(client || !length(current_pathed_turfs) || isnull(ai_controller))
|
|
return
|
|
|
|
var/atom/move_target = ai_controller.current_movement_target
|
|
|
|
if(move_target != ai_controller.blackboard[BB_BEACON_TARGET])
|
|
clear_path_hud()
|
|
|
|
var/turf/our_turf = get_turf(src)
|
|
var/image/target_image = current_pathed_turfs[our_turf]
|
|
if(target_image)
|
|
animate(target_image, alpha = 0, time = 0.3 SECONDS)
|
|
current_pathed_turfs -= our_turf
|
|
|
|
///proc that handles deleting the bot's drawn path when needed
|
|
/mob/living/basic/bot/proc/clear_path_hud()
|
|
for(var/turf/index as anything in current_pathed_turfs)
|
|
var/image/our_image = current_pathed_turfs[index]
|
|
animate(our_image, alpha = 0, time = 0.3 SECONDS)
|
|
current_pathed_turfs -= index
|
|
|
|
// Call hud remove handlers to ensure viewing user client images are removed
|
|
var/list/path_huds_watching_me = list(GLOB.huds[DATA_HUD_DIAGNOSTIC], GLOB.huds[DATA_HUD_BOT_PATH])
|
|
for(var/datum/atom_hud/hud as anything in path_huds_watching_me)
|
|
hud.remove_atom_from_hud(src)
|
|
|