Cleanbot: Ability to restrict targeting to map areas (#24715)

* TGUI

* Process scan + Glass

* Section

* area clean and glass

* bot_reset

* sprites

* space BEGONE

* "

* cleanbot0

* Build and update tgui

* sprite fix?

* _1

* nvm revert

* sprite fix

* update_icon

* sprites

* overlay

* icon_state + update_overlays

* animation

* sprites

* haduken

* henri review

Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>

* Update code/modules/mob/living/simple_animal/bot/cleanbot.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* get_area

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* review early return

* TGUI

* overlay not not

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

---------

Co-authored-by: /tg/ui <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
This commit is contained in:
Deniz
2024-04-06 23:41:34 +00:00
committed by GitHub
co-authored by Henri215 Contrabang /tg/ui <41898282+github-actions[bot]@users.noreply.github.com>
parent 5f45d8c594
commit 6aee94a2fc
5 changed files with 55 additions and 17 deletions
@@ -208,7 +208,7 @@
on = TRUE
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, "depowered")
set_light(initial(light_range))
update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS)
update_icon()
update_controls()
diag_hud_set_botstat()
return TRUE
@@ -218,7 +218,7 @@
ADD_TRAIT(src, TRAIT_IMMOBILIZED, "depowered")
set_light(0)
bot_reset() // Resets an AI's call, should it exist.
update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS)
update_icon()
update_controls()
/mob/living/simple_animal/bot/Initialize(mapload)
@@ -3,7 +3,7 @@
name = "\improper Cleanbot"
desc = "A little cleaning robot, he looks so excited!"
icon = 'icons/obj/aibots.dmi'
icon_state = "cleanbot0"
icon_state = "cleanbot"
density = FALSE
anchored = FALSE
health = 25
@@ -29,6 +29,7 @@
var/failed_steps
var/next_dest
var/next_dest_loc
var/area/area_locked
var/static/list/clean_dirt = list(
/obj/effect/decal/cleanable/vomit,
/obj/effect/decal/cleanable/blood/gibs/robot,
@@ -41,7 +42,8 @@
/obj/effect/decal/cleanable/flour,
/obj/effect/decal/cleanable/ash,
/obj/effect/decal/cleanable/greenglow,
/obj/effect/decal/cleanable/dirt
/obj/effect/decal/cleanable/dirt,
/obj/effect/decal/cleanable/glass
)
var/static/list/clean_blood = list(
/obj/effect/decal/cleanable/blood,
@@ -50,7 +52,7 @@
/mob/living/simple_animal/bot/cleanbot/Initialize(mapload)
. = ..()
icon_state = "cleanbot[on]"
update_icon(UPDATE_OVERLAYS)
clean_dirt = typecacheof(clean_dirt)
clean_blood = typecacheof(clean_blood)
@@ -59,19 +61,26 @@
access_card.access += J.get_access()
prev_access = access_card.access
/mob/living/simple_animal/bot/cleanbot/turn_on()
..()
icon_state = "cleanbot[on]"
/mob/living/simple_animal/bot/cleanbot/update_icon_state()
return
/mob/living/simple_animal/bot/cleanbot/turn_off()
..()
icon_state = "cleanbot[on]"
/mob/living/simple_animal/bot/cleanbot/update_overlays()
. = ..()
if(!on)
. += "clean_off"
return
if(mode == BOT_CLEANING)
. += "clean_brush"
. += "clean[area_locked ? "_restrict" : ""]_work"
return
. += "clean_[area_locked ? "restrict" : "on"]"
/mob/living/simple_animal/bot/cleanbot/bot_reset()
..()
ignore_list.Cut() //Allows the bot to clean targets it previously ignored due to being unreachable.
target = null
oldloc = null
area_locked = null
/mob/living/simple_animal/bot/cleanbot/set_custom_texts()
text_hack = "You corrupt [name]'s cleaning software."
@@ -100,8 +109,14 @@
to_chat(user, "<span class='danger'>[src] buzzes and beeps.</span>")
/mob/living/simple_animal/bot/cleanbot/process_scan(obj/effect/decal/cleanable/D)
if(is_type_in_typecache(D, clean_dirt) || blood && is_type_in_typecache(D, clean_blood))
if(!(is_type_in_typecache(D, clean_dirt) || blood && is_type_in_typecache(D, clean_blood)))
return FALSE
if(!area_locked)
return D
var/area/target_area = get_area(D)
if(target_area == area_locked)
return D
return FALSE
/mob/living/simple_animal/bot/cleanbot/handle_automated_action()
if(!..())
@@ -157,11 +172,18 @@
oldloc = loc
/mob/living/simple_animal/bot/cleanbot/proc/assign_area()
if(area_locked)
area_locked = null
else
area_locked = get_area(loc)
update_icon(UPDATE_OVERLAYS)
/mob/living/simple_animal/bot/cleanbot/proc/start_clean(obj/effect/decal/cleanable/target)
anchored = TRUE
icon_state = "cleanbot-c"
visible_message("<span class='notice'>[src] begins to clean up [target]</span>")
mode = BOT_CLEANING
update_icon(UPDATE_OVERLAYS)
addtimer(CALLBACK(src, PROC_REF(do_clean), target), 5 SECONDS)
/mob/living/simple_animal/bot/cleanbot/proc/do_clean(obj/effect/decal/cleanable/target)
@@ -170,7 +192,7 @@
QDEL_NULL(target)
anchored = FALSE
mode = BOT_IDLE
icon_state = "cleanbot[on]"
update_icon(UPDATE_OVERLAYS)
/mob/living/simple_animal/bot/cleanbot/explode()
on = FALSE
@@ -200,6 +222,7 @@
/mob/living/simple_animal/bot/cleanbot/ui_data(mob/user)
var/list/data = ..()
data["cleanblood"] = blood
data["area"] = get_area_name(area_locked)
return data
/mob/living/simple_animal/bot/cleanbot/ui_act(action, params)
@@ -225,6 +248,8 @@
remote_disabled = !remote_disabled
if("blood")
blood =!blood
if("area")
assign_area()
if("ejectpai")
ejectpai()