mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-28 06:28:01 +01:00
migrate chat messages and phoron spider to self deleting timer (#16547)
* migrate to self deleting timer * . * fix phoron spider runtime on early deletes * .
This commit is contained in:
+11
-12
@@ -51,8 +51,6 @@ var/list/runechat_image_cache = list()
|
||||
/// If we are currently processing animation and cleanup at EOL
|
||||
var/ending_life
|
||||
|
||||
/// deletion timer
|
||||
var/timer_delete
|
||||
|
||||
/**
|
||||
* Constructs a chat message overlay
|
||||
@@ -75,9 +73,6 @@ var/list/runechat_image_cache = list()
|
||||
generate_image(text, target, owner, extra_classes, lifespan)
|
||||
|
||||
/datum/chatmessage/Destroy()
|
||||
if(timer_delete)
|
||||
deltimer(timer_delete)
|
||||
timer_delete = null
|
||||
if(istype(owned_by, /client)) // hopefully the PARENT_QDELETING on client should beat this if it's a disconnect
|
||||
UnregisterSignal(owned_by, COMSIG_PARENT_QDELETING)
|
||||
if(owned_by.seen_messages)
|
||||
@@ -99,7 +94,6 @@ var/list/runechat_image_cache = list()
|
||||
* * lifespan - The lifespan of the message in deciseconds
|
||||
*/
|
||||
/datum/chatmessage/proc/generate_image(text, atom/target, mob/owner, list/extra_classes, lifespan)
|
||||
set waitfor = FALSE
|
||||
|
||||
if(!target || !owner)
|
||||
qdel(src)
|
||||
@@ -193,8 +187,7 @@ var/list/runechat_image_cache = list()
|
||||
if(sched_remaining > CHAT_MESSAGE_SPAWN_TIME)
|
||||
var/remaining_time = (sched_remaining) * (CHAT_MESSAGE_EXP_DECAY ** idx++) * (CHAT_MESSAGE_HEIGHT_DECAY ** combined_height)
|
||||
m.scheduled_destruction = world.time + remaining_time
|
||||
spawn(remaining_time)
|
||||
m.end_of_life()
|
||||
m.schedule_end_of_life(remaining_time)
|
||||
|
||||
// Build message image
|
||||
message = image(loc = message_loc, layer = ABOVE_MOB_LAYER)
|
||||
@@ -220,13 +213,16 @@ var/list/runechat_image_cache = list()
|
||||
|
||||
// Prepare for destruction
|
||||
scheduled_destruction = world.time + (lifespan - CHAT_MESSAGE_EOL_FADE)
|
||||
spawn(lifespan - CHAT_MESSAGE_EOL_FADE)
|
||||
end_of_life()
|
||||
schedule_end_of_life(lifespan - CHAT_MESSAGE_EOL_FADE)
|
||||
|
||||
/datum/chatmessage/proc/unregister_qdel_self() // this should only call owned_by if the client is destroyed
|
||||
UnregisterSignal(owned_by, COMSIG_PARENT_QDELETING)
|
||||
owned_by = null
|
||||
qdel_self()
|
||||
|
||||
/datum/chatmessage/proc/schedule_end_of_life(var/schedule)
|
||||
addtimer(CALLBACK(src, PROC_REF(end_of_life)), schedule, TIMER_DELETE_ME)
|
||||
|
||||
/**
|
||||
* Applies final animations to overlay CHAT_MESSAGE_EOL_FADE deciseconds prior to message deletion
|
||||
*/
|
||||
@@ -235,7 +231,7 @@ var/list/runechat_image_cache = list()
|
||||
return
|
||||
ending_life = TRUE
|
||||
animate(message, alpha = 0, time = fadetime, flags = ANIMATION_PARALLEL)
|
||||
timer_delete = QDEL_IN(src, fadetime)
|
||||
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), src), fadetime, TIMER_DELETE_ME, TIMER_UNIQUE)
|
||||
|
||||
/**
|
||||
* Creates a message overlay at a defined location for a given speaker
|
||||
@@ -250,6 +246,9 @@ var/list/runechat_image_cache = list()
|
||||
if(!client)
|
||||
return
|
||||
|
||||
// Source Deleting
|
||||
if(QDELETED(speaker))
|
||||
return
|
||||
// Doesn't want to hear
|
||||
if(ismob(speaker) && !client.prefs?.read_preference(/datum/preference/toggle/runechat_mob))
|
||||
return
|
||||
@@ -356,7 +355,7 @@ var/list/runechat_image_cache = list()
|
||||
hearing_mobs = hear["mobs"]
|
||||
|
||||
for(var/mob/M as anything in hearing_mobs)
|
||||
if(!M.client)
|
||||
if(!M?.client)
|
||||
continue
|
||||
M.create_chat_message(src, message, italics, classes, audible)
|
||||
|
||||
|
||||
@@ -63,22 +63,16 @@
|
||||
adjust_scale(1.25)
|
||||
return ..()
|
||||
|
||||
/mob/living/simple_mob/animal/giant_spider/phorogenic/proc/explode()
|
||||
if(src && !exploded)
|
||||
visible_message(span_danger("\The [src]'s body detonates!"))
|
||||
exploded = TRUE
|
||||
explosion(src.loc, explosion_dev_range, explosion_heavy_range, explosion_light_range, explosion_flash_range)
|
||||
|
||||
/mob/living/simple_mob/animal/giant_spider/phorogenic/death()
|
||||
visible_message(span_critical("\The [src]'s body begins to rupture!"))
|
||||
var/delay = rand(explosion_delay_lower, explosion_delay_upper)
|
||||
spawn(0)
|
||||
// Flash black and red as a warning.
|
||||
for(var/i = 1 to delay)
|
||||
if(i % 2 == 0)
|
||||
color = "#000000"
|
||||
else
|
||||
color = "#FF0000"
|
||||
sleep(1)
|
||||
|
||||
spawn(delay)
|
||||
// The actual boom.
|
||||
if(src && !exploded)
|
||||
visible_message(span_danger("\The [src]'s body detonates!"))
|
||||
exploded = TRUE
|
||||
explosion(src.loc, explosion_dev_range, explosion_heavy_range, explosion_light_range, explosion_flash_range)
|
||||
animate(src, color = "#000000", time = 0.1 SECONDS, loop = ceil(delay/2))
|
||||
animate(color = "#FF0000", time = 0.1 SECONDS)
|
||||
addtimer(CALLBACK(src, PROC_REF(explode)), delay, TIMER_DELETE_ME)
|
||||
return ..()
|
||||
|
||||
Reference in New Issue
Block a user