mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
converted on_destroyed to lazy events (#27260)
This commit is contained in:
@@ -489,7 +489,7 @@ var/global/list/radial_menus = list()
|
|||||||
// Copying atoms is stupid and this is a stupid solution
|
// Copying atoms is stupid and this is a stupid solution
|
||||||
var/list/variables_not_to_be_copied = list(
|
var/list/variables_not_to_be_copied = list(
|
||||||
"type","loc","locs","vars","parent","parent_type","verbs","ckey","key",
|
"type","loc","locs","vars","parent","parent_type","verbs","ckey","key",
|
||||||
"group","on_destroyed","on_density_change",
|
"group","on_density_change","registered_events",
|
||||||
"on_use","on_emote","on_life","on_resist",
|
"on_use","on_emote","on_life","on_resist",
|
||||||
"on_spellcast","on_uattack","on_ruattack","on_logout","on_damaged",
|
"on_spellcast","on_uattack","on_ruattack","on_logout","on_damaged",
|
||||||
"on_death","on_clickon","on_attackhand","on_attackby",
|
"on_death","on_clickon","on_attackhand","on_attackby",
|
||||||
|
|||||||
@@ -78,6 +78,13 @@
|
|||||||
// atom/movable/mover: the movable itself.
|
// atom/movable/mover: the movable itself.
|
||||||
/lazy_event/on_moved
|
/lazy_event/on_moved
|
||||||
|
|
||||||
|
// Called whenever a datum is destroyed.
|
||||||
|
// Currently, as an optimization, only /atom/movable invokes this but
|
||||||
|
// it can be changed to /datum if the need arises.
|
||||||
|
/lazy_event/on_destroyed
|
||||||
|
// Arguments:
|
||||||
|
// datum/thing: the datum being destroyed.
|
||||||
|
|
||||||
/datum
|
/datum
|
||||||
/// Associative list of type path -> list(),
|
/// Associative list of type path -> list(),
|
||||||
/// where the type path is a descendant of /event_type.
|
/// where the type path is a descendant of /event_type.
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ var/runechat_icon = null
|
|||||||
var/scheduled_destruction
|
var/scheduled_destruction
|
||||||
/// Contains the approximate amount of lines for height decay
|
/// Contains the approximate amount of lines for height decay
|
||||||
var/approx_lines
|
var/approx_lines
|
||||||
/// Reference to on_destroyed event from master
|
|
||||||
var/destroyed_ev_key
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a chat message overlay
|
* Constructs a chat message overlay
|
||||||
@@ -56,7 +54,7 @@ var/runechat_icon = null
|
|||||||
if (owned_by)
|
if (owned_by)
|
||||||
owned_by.seen_messages.Remove(src)
|
owned_by.seen_messages.Remove(src)
|
||||||
owned_by.images.Remove(message)
|
owned_by.images.Remove(message)
|
||||||
owned_by.mob.on_destroyed.Remove(destroyed_ev_key)
|
owned_by.mob.lazy_unregister_event(/lazy_event/on_destroyed, src, .proc/qdel_self)
|
||||||
owned_by = null
|
owned_by = null
|
||||||
message_loc = null
|
message_loc = null
|
||||||
message = null
|
message = null
|
||||||
@@ -76,7 +74,7 @@ var/runechat_icon = null
|
|||||||
set waitfor = FALSE
|
set waitfor = FALSE
|
||||||
// Register client who owns this message
|
// Register client who owns this message
|
||||||
owned_by = owner.client
|
owned_by = owner.client
|
||||||
destroyed_ev_key = owner.on_destroyed.Add(src, .proc/qdel_self)
|
owner.lazy_register_event(/lazy_event/on_destroyed, src, .proc/qdel_self)
|
||||||
|
|
||||||
// Clip message
|
// Clip message
|
||||||
var/maxlen = owned_by.prefs.max_chat_length
|
var/maxlen = owned_by.prefs.max_chat_length
|
||||||
@@ -161,7 +159,7 @@ var/runechat_icon = null
|
|||||||
spawn(lifespan - CHAT_MESSAGE_EOL_FADE)
|
spawn(lifespan - CHAT_MESSAGE_EOL_FADE)
|
||||||
end_of_life()
|
end_of_life()
|
||||||
|
|
||||||
/datum/chatmessage/proc/qdel_self()
|
/datum/chatmessage/proc/qdel_self(datum/thing)
|
||||||
qdel(src)
|
qdel(src)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,14 +87,12 @@ var/list/datum/map_element/map_elements = list()
|
|||||||
if(!istype(A))
|
if(!istype(A))
|
||||||
return
|
return
|
||||||
|
|
||||||
A.on_destroyed.Add(src, "clear_references")
|
A.lazy_register_event(/lazy_event/on_destroyed, src, .proc/clear_references)
|
||||||
|
|
||||||
return A
|
return A
|
||||||
|
|
||||||
|
|
||||||
/datum/map_element/proc/clear_references(list/params)
|
/datum/map_element/proc/clear_references(datum/thing)
|
||||||
var/atom/movable/A = params["atom"]
|
if(!thing)
|
||||||
if(!A)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
//Remove instances by brute force (there aren't that many vars in map element datums)
|
//Remove instances by brute force (there aren't that many vars in map element datums)
|
||||||
@@ -102,11 +100,11 @@ var/list/datum/map_element/map_elements = list()
|
|||||||
if(key == "vars")
|
if(key == "vars")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if(vars[key] == A)
|
if(vars[key] == thing)
|
||||||
vars[key] = null
|
vars[key] = null
|
||||||
else if(istype(vars[key], /list))
|
else if(istype(vars[key], /list))
|
||||||
var/list/L = vars[key]
|
var/list/L = vars[key]
|
||||||
|
|
||||||
//Remove all instances from the list
|
//Remove all instances from the list
|
||||||
while(L.Remove(A))
|
while(L.Remove(thing))
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -45,9 +45,6 @@
|
|||||||
var/throwpass = 0
|
var/throwpass = 0
|
||||||
var/level = 2
|
var/level = 2
|
||||||
|
|
||||||
// When the object is qdel'd
|
|
||||||
var/event/on_destroyed
|
|
||||||
|
|
||||||
var/atom/movable/tether_master
|
var/atom/movable/tether_master
|
||||||
var/list/tether_slaves
|
var/list/tether_slaves
|
||||||
var/list/current_tethers
|
var/list/current_tethers
|
||||||
@@ -67,8 +64,6 @@
|
|||||||
for(var/matID in starting_materials)
|
for(var/matID in starting_materials)
|
||||||
materials.addAmount(matID, starting_materials[matID])
|
materials.addAmount(matID, starting_materials[matID])
|
||||||
|
|
||||||
on_destroyed = new("owner"=src)
|
|
||||||
|
|
||||||
/atom/movable/Destroy()
|
/atom/movable/Destroy()
|
||||||
var/turf/T = loc
|
var/turf/T = loc
|
||||||
if (opacity && istype(T))
|
if (opacity && istype(T))
|
||||||
@@ -78,10 +73,7 @@
|
|||||||
qdel(materials)
|
qdel(materials)
|
||||||
materials = null
|
materials = null
|
||||||
|
|
||||||
INVOKE_EVENT(on_destroyed, list("atom" = src)) // 1 argument - the object itself
|
lazy_invoke_event(/lazy_event/on_destroyed, list("thing" = src))
|
||||||
if(on_destroyed)
|
|
||||||
on_destroyed.holder = null
|
|
||||||
on_destroyed = null
|
|
||||||
|
|
||||||
var/turf/un_opaque
|
var/turf/un_opaque
|
||||||
if (opacity && isturf(loc))
|
if (opacity && isturf(loc))
|
||||||
@@ -646,7 +638,6 @@
|
|||||||
/atom/movable/overlay
|
/atom/movable/overlay
|
||||||
var/atom/master = null
|
var/atom/master = null
|
||||||
var/follow_proc = /atom/movable/overlay/proc/move_to_turf_or_null
|
var/follow_proc = /atom/movable/overlay/proc/move_to_turf_or_null
|
||||||
var/master_destroyed_key
|
|
||||||
anchored = 1
|
anchored = 1
|
||||||
|
|
||||||
/atom/movable/overlay/New()
|
/atom/movable/overlay/New()
|
||||||
@@ -665,17 +656,17 @@
|
|||||||
SetInitLoc()
|
SetInitLoc()
|
||||||
if (istype(master, /atom/movable))
|
if (istype(master, /atom/movable))
|
||||||
var/atom/movable/AM = master
|
var/atom/movable/AM = master
|
||||||
master_destroyed_key = AM.on_destroyed.Add(src, .proc/qdel_self)
|
AM.lazy_register_event(/lazy_event/on_destroyed, src, .proc/qdel_self)
|
||||||
verbs.len = 0
|
verbs.len = 0
|
||||||
|
|
||||||
/atom/movable/overlay/proc/qdel_self()
|
/atom/movable/overlay/proc/qdel_self(datum/thing)
|
||||||
qdel(src) // Rest in peace
|
qdel(src) // Rest in peace
|
||||||
|
|
||||||
/atom/movable/overlay/Destroy()
|
/atom/movable/overlay/Destroy()
|
||||||
if(istype(master, /atom/movable))
|
if(istype(master, /atom/movable))
|
||||||
var/atom/movable/AM = master
|
var/atom/movable/AM = master
|
||||||
AM.lazy_unregister_event(/lazy_event/on_moved, src, follow_proc)
|
AM.lazy_unregister_event(/lazy_event/on_moved, src, follow_proc)
|
||||||
AM.on_destroyed.Remove(master_destroyed_key)
|
AM.lazy_unregister_event(/lazy_event/on_destroyed, src, .proc/qdel_self)
|
||||||
master = null
|
master = null
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,6 @@
|
|||||||
if (src.holding)
|
if (src.holding)
|
||||||
src.holding.forceMove(src.loc)
|
src.holding.forceMove(src.loc)
|
||||||
src.holding = null
|
src.holding = null
|
||||||
INVOKE_EVENT(on_destroyed, list())
|
|
||||||
nanomanager.update_uis(src)
|
nanomanager.update_uis(src)
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -34,19 +34,18 @@
|
|||||||
detectTime = world.time // start the clock
|
detectTime = world.time // start the clock
|
||||||
if (!(target in motionTargets))
|
if (!(target in motionTargets))
|
||||||
motionTargets += target
|
motionTargets += target
|
||||||
target.on_destroyed.Add(src, "clearDeletedTarget")
|
target.lazy_register_event(/lazy_event/on_destroyed, src, .proc/clearDeletedTarget)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/obj/machinery/camera/proc/lostTarget(var/mob/target)
|
/obj/machinery/camera/proc/lostTarget(var/mob/target)
|
||||||
if (target in motionTargets)
|
if (target in motionTargets)
|
||||||
motionTargets -= target
|
motionTargets -= target
|
||||||
target.on_destroyed.Remove("\ref[src]:clearDeletedTarget")
|
target.lazy_unregister_event(/lazy_event/on_destroyed, src, .proc/clearDeletedTarget)
|
||||||
if (motionTargets.len == 0)
|
if (motionTargets.len == 0)
|
||||||
cancelAlarm()
|
cancelAlarm()
|
||||||
|
|
||||||
/obj/machinery/camera/proc/clearDeletedTarget(list/params)
|
/obj/machinery/camera/proc/clearDeletedTarget(datum/thing)
|
||||||
var/atom/destroyed = params["atom"]
|
lostTarget(thing)
|
||||||
lostTarget(destroyed)
|
|
||||||
|
|
||||||
/obj/machinery/camera/proc/cancelAlarm()
|
/obj/machinery/camera/proc/cancelAlarm()
|
||||||
if (detectTime == -1)
|
if (detectTime == -1)
|
||||||
|
|||||||
@@ -61,7 +61,6 @@
|
|||||||
var/stepped=0
|
var/stepped=0
|
||||||
var/steps=0 // How many steps we've made from the emitter. Used in infinite loop avoidance.
|
var/steps=0 // How many steps we've made from the emitter. Used in infinite loop avoidance.
|
||||||
var/am_connector=0
|
var/am_connector=0
|
||||||
var/targetDestroyKey=null // Key for the on_destroyed listener.
|
|
||||||
var/targetDensityKey=null // Key for the on_density_change listener
|
var/targetDensityKey=null // Key for the on_density_change listener
|
||||||
var/targetContactLoc=null // Where we hit the target (used for target_moved)
|
var/targetContactLoc=null // Where we hit the target (used for target_moved)
|
||||||
var/locDensity=null
|
var/locDensity=null
|
||||||
@@ -174,23 +173,13 @@
|
|||||||
// Disconnect and re-emit.
|
// Disconnect and re-emit.
|
||||||
disconnect()
|
disconnect()
|
||||||
|
|
||||||
// Listener for /atom/on_destroyed
|
// Listener for /lazy_event/on_destroyed
|
||||||
/obj/effect/beam/proc/target_destroyed(var/list/args)
|
/obj/effect/beam/proc/target_destroyed(datum/thing)
|
||||||
if(master)
|
if(master)
|
||||||
beam_testing("Child got target_destroyed! Feeding to master.")
|
beam_testing("Child got target_destroyed! Feeding to master.")
|
||||||
master.target_destroyed(args)
|
master.target_destroyed(thing)
|
||||||
return
|
return
|
||||||
|
|
||||||
var/event/E = args["event"]
|
|
||||||
|
|
||||||
if(!targetDestroyKey)
|
|
||||||
E.handlers.Remove("\ref[src]:target_destroyed")
|
|
||||||
beam_testing("Uh oh, got a target_destroyed when we weren't listening for one.")
|
|
||||||
return
|
|
||||||
|
|
||||||
if(E.holder != target)
|
|
||||||
E.handlers.Remove("\ref[src]:target_destroyed")
|
|
||||||
return
|
|
||||||
beam_testing("\ref[src] Disconnecting: \ref[target] Target destroyed.")
|
beam_testing("\ref[src] Disconnecting: \ref[target] Target destroyed.")
|
||||||
// Disconnect and re-emit.
|
// Disconnect and re-emit.
|
||||||
disconnect()
|
disconnect()
|
||||||
@@ -250,9 +239,7 @@
|
|||||||
BM.update_end_icon()
|
BM.update_end_icon()
|
||||||
if(istype(AM))
|
if(istype(AM))
|
||||||
AM.lazy_register_event(/lazy_event/on_moved, BM, .proc/target_moved)
|
AM.lazy_register_event(/lazy_event/on_moved, BM, .proc/target_moved)
|
||||||
if (!AM.on_destroyed)
|
AM.lazy_register_event(/lazy_event/on_destroyed, BM, .proc/target_destroyed)
|
||||||
AM.on_destroyed = new("owner"=AM)
|
|
||||||
BM.targetDestroyKey = AM.on_destroyed.Add(BM,"target_destroyed")
|
|
||||||
BM.targetDensityKey = AM.on_density_change.Add(BM,"target_density_change")
|
BM.targetDensityKey = AM.on_density_change.Add(BM,"target_density_change")
|
||||||
BM.targetContactLoc = AM.loc
|
BM.targetContactLoc = AM.loc
|
||||||
beam_testing("\ref[BM] - Connected to [AM]")
|
beam_testing("\ref[BM] - Connected to [AM]")
|
||||||
@@ -295,12 +282,9 @@
|
|||||||
if(_master.target)
|
if(_master.target)
|
||||||
if(ismovable(_master.target))
|
if(ismovable(_master.target))
|
||||||
_master.target.lazy_unregister_event(/lazy_event/on_moved, _master, .proc/target_moved)
|
_master.target.lazy_unregister_event(/lazy_event/on_moved, _master, .proc/target_moved)
|
||||||
if (!_master.target.on_destroyed)
|
_master.target.lazy_unregister_event(/lazy_event/on_destroyed, src, .proc/target_destroyed)
|
||||||
_master.target.on_destroyed = new("owner"=_master.target)
|
|
||||||
_master.target.on_destroyed.Remove(_master.targetDestroyKey)
|
|
||||||
_master.target.beam_disconnect(_master)
|
_master.target.beam_disconnect(_master)
|
||||||
_master.target=null
|
_master.target=null
|
||||||
_master.targetDestroyKey=null
|
|
||||||
//if(_master.next)
|
//if(_master.next)
|
||||||
// BEAM_DEL(_master.next)
|
// BEAM_DEL(_master.next)
|
||||||
if(re_emit)
|
if(re_emit)
|
||||||
|
|||||||
@@ -152,18 +152,15 @@
|
|||||||
icon_state = "pipe_tomahawk_glass"
|
icon_state = "pipe_tomahawk_glass"
|
||||||
item_state = "pipe_tomahawk_glass"
|
item_state = "pipe_tomahawk_glass"
|
||||||
ispipe = 1
|
ispipe = 1
|
||||||
var/current_blunt = null
|
var/obj/item/clothing/mask/cigarette/blunt/rolled/current_blunt = null
|
||||||
var/blunt_name = null
|
var/blunt_name = null
|
||||||
var/is_lit = 0
|
var/is_lit = 0
|
||||||
var/blunt_hook = null //the hook to call the burnout proc when the blunt is destroyed
|
|
||||||
var/not_burned_out = 0 //prevent the going-out message from qdel()s other than the blunt's own qdel().
|
var/not_burned_out = 0 //prevent the going-out message from qdel()s other than the blunt's own qdel().
|
||||||
slot_flags = SLOT_MASK
|
slot_flags = SLOT_MASK
|
||||||
|
|
||||||
/obj/item/weapon/hatchet/tomahawk/pipe/Destroy()
|
/obj/item/weapon/hatchet/tomahawk/pipe/Destroy()
|
||||||
if(blunt_hook && current_blunt)
|
|
||||||
var/obj/item/clothing/mask/cigarette/blunt/rolled/B = current_blunt
|
|
||||||
B.on_destroyed.Remove()
|
|
||||||
if(current_blunt)
|
if(current_blunt)
|
||||||
|
current_blunt.lazy_unregister_event(/lazy_event/on_destroyed, src, .proc/burnout)
|
||||||
qdel(current_blunt)
|
qdel(current_blunt)
|
||||||
current_blunt = null
|
current_blunt = null
|
||||||
..()
|
..()
|
||||||
@@ -182,7 +179,7 @@
|
|||||||
return
|
return
|
||||||
to_chat(user, "<span class='notice'>You crush \the [W] into \the [src].</span>")
|
to_chat(user, "<span class='notice'>You crush \the [W] into \the [src].</span>")
|
||||||
var/obj/item/clothing/mask/cigarette/blunt/rolled/B = new/obj/item/clothing/mask/cigarette/blunt/rolled(src)
|
var/obj/item/clothing/mask/cigarette/blunt/rolled/B = new/obj/item/clothing/mask/cigarette/blunt/rolled(src)
|
||||||
blunt_hook = B.on_destroyed.Add(src, "burnout")
|
B.lazy_register_event(/lazy_event/on_destroyed, src, .proc/burnout)
|
||||||
B.inside_item = 1
|
B.inside_item = 1
|
||||||
W.reagents.trans_to(B, (W.reagents.total_volume))
|
W.reagents.trans_to(B, (W.reagents.total_volume))
|
||||||
B.update_brightness()
|
B.update_brightness()
|
||||||
@@ -325,7 +322,7 @@
|
|||||||
return
|
return
|
||||||
to_chat(user, "<span class='notice'>You crush \the [W] into \the [src].</span>")
|
to_chat(user, "<span class='notice'>You crush \the [W] into \the [src].</span>")
|
||||||
var/obj/item/clothing/mask/cigarette/blunt/rolled/B = new/obj/item/clothing/mask/cigarette/blunt/rolled(src)
|
var/obj/item/clothing/mask/cigarette/blunt/rolled/B = new/obj/item/clothing/mask/cigarette/blunt/rolled(src)
|
||||||
blunt_hook = B.on_destroyed.Add(src, "burnout")
|
B.lazy_register_event(/lazy_event/on_destroyed, src, .proc/burnout)
|
||||||
B.inside_item = 1
|
B.inside_item = 1
|
||||||
W.reagents.trans_to(B, (W.reagents.total_volume))
|
W.reagents.trans_to(B, (W.reagents.total_volume))
|
||||||
B.update_brightness()
|
B.update_brightness()
|
||||||
@@ -384,7 +381,7 @@
|
|||||||
current_blunt = null
|
current_blunt = null
|
||||||
verbs -= /obj/item/weapon/broken_pipe_tomahawk/verb/empty_pipe
|
verbs -= /obj/item/weapon/broken_pipe_tomahawk/verb/empty_pipe
|
||||||
|
|
||||||
/obj/item/weapon/broken_pipe_tomahawk/proc/burnout()
|
/obj/item/weapon/broken_pipe_tomahawk/proc/burnout(datum/thing)
|
||||||
current_blunt = null
|
current_blunt = null
|
||||||
set_light(0)
|
set_light(0)
|
||||||
is_lit = 0
|
is_lit = 0
|
||||||
@@ -399,4 +396,4 @@
|
|||||||
H.update_inv_wear_mask()
|
H.update_inv_wear_mask()
|
||||||
verbs -= /obj/item/weapon/broken_pipe_tomahawk/verb/empty_pipe
|
verbs -= /obj/item/weapon/broken_pipe_tomahawk/verb/empty_pipe
|
||||||
|
|
||||||
//BROKEN PIPE TOMAHAWK END
|
//BROKEN PIPE TOMAHAWK END
|
||||||
|
|||||||
@@ -114,13 +114,11 @@
|
|||||||
|
|
||||||
for(var/obj/structure/closet/crate/sokoban/crate in objects)
|
for(var/obj/structure/closet/crate/sokoban/crate in objects)
|
||||||
//check_cheat performs some additional checks first, and only then marks the user as a cheater
|
//check_cheat performs some additional checks first, and only then marks the user as a cheater
|
||||||
crate.on_destroyed.Add(crate, "check_cheat")
|
|
||||||
crate.lazy_register_event(/lazy_event/on_moved, crate, /obj/structure/closet/crate/sokoban/proc/check_cheat)
|
crate.lazy_register_event(/lazy_event/on_moved, crate, /obj/structure/closet/crate/sokoban/proc/check_cheat)
|
||||||
crate.parent = src.parent
|
crate.parent = src.parent
|
||||||
|
|
||||||
for(var/obj/structure/sokoban_teleporter/teleporter in objects)
|
for(var/obj/structure/sokoban_teleporter/teleporter in objects)
|
||||||
//Teleporters are supposed to be unmovable, so if they're moved or deleted - it's guaranteed cheating
|
//Teleporters are supposed to be unmovable, so if they're moved or deleted - it's guaranteed cheating
|
||||||
teleporter.on_destroyed.Add(parent, "on_cheat")
|
|
||||||
teleporter.lazy_register_event(/lazy_event/on_moved, parent, /datum/map_element/vault/sokoban/proc/on_cheat)
|
teleporter.lazy_register_event(/lazy_event/on_moved, parent, /datum/map_element/vault/sokoban/proc/on_cheat)
|
||||||
|
|
||||||
if(parent)
|
if(parent)
|
||||||
@@ -188,6 +186,10 @@ This ladder stuff looks confusing, so here's an illustration!!!
|
|||||||
|
|
||||||
var/datum/map_element/vault/sokoban/parent
|
var/datum/map_element/vault/sokoban/parent
|
||||||
|
|
||||||
|
/obj/structure/closet/crate/sokoban/Destroy()
|
||||||
|
check_cheat()
|
||||||
|
..()
|
||||||
|
|
||||||
/obj/structure/closet/crate/sokoban/proc/check_cheat(atom/movable/mover)
|
/obj/structure/closet/crate/sokoban/proc/check_cheat(atom/movable/mover)
|
||||||
if(shipped)
|
if(shipped)
|
||||||
return //Teleported crates can be destroyed safely
|
return //Teleported crates can be destroyed safely
|
||||||
|
|||||||
@@ -238,19 +238,6 @@ var/list/clothing_prices = list() //gets filled on initialize()
|
|||||||
|
|
||||||
/area/vault/supermarket/shop/proc/setup()
|
/area/vault/supermarket/shop/proc/setup()
|
||||||
spawn()
|
spawn()
|
||||||
/*
|
|
||||||
looping:
|
|
||||||
for(var/obj/item/I in contents)
|
|
||||||
for(var/type in shop_prices + circuitboard_prices + clothing_prices)
|
|
||||||
if(istype(I, type))
|
|
||||||
I.name = "[I.name] ($[shop_prices[type]])"
|
|
||||||
I.on_destroyed.Add(src, "item_destroyed") //Only trigger alarm when an item for sale is destroyed
|
|
||||||
|
|
||||||
items[I] = shop_prices[type]
|
|
||||||
|
|
||||||
continue looping
|
|
||||||
*/ //This is handled by spawners now
|
|
||||||
|
|
||||||
var/area/vault/supermarket/entrance/E = locate(/area/vault/supermarket/entrance)
|
var/area/vault/supermarket/entrance/E = locate(/area/vault/supermarket/entrance)
|
||||||
var/list/protected_objects = list(
|
var/list/protected_objects = list(
|
||||||
/obj/structure/window, //Destroying these objects triggers an alarm
|
/obj/structure/window, //Destroying these objects triggers an alarm
|
||||||
@@ -263,9 +250,7 @@ var/list/clothing_prices = list() //gets filled on initialize()
|
|||||||
for(var/atom/movable/AM in (src.contents + E.contents))
|
for(var/atom/movable/AM in (src.contents + E.contents))
|
||||||
|
|
||||||
if(!is_type_in_list(AM, protected_objects)) continue
|
if(!is_type_in_list(AM, protected_objects)) continue
|
||||||
|
AM.lazy_register_event(/lazy_event/on_destroyed, src, .proc/item_destroyed)
|
||||||
if(AM.on_destroyed)
|
|
||||||
AM.on_destroyed.Add(src, "item_destroyed")
|
|
||||||
|
|
||||||
/area/vault/supermarket/shop/Exited(atom/movable/AM, atom/newloc)
|
/area/vault/supermarket/shop/Exited(atom/movable/AM, atom/newloc)
|
||||||
..()
|
..()
|
||||||
@@ -290,8 +275,8 @@ var/list/clothing_prices = list() //gets filled on initialize()
|
|||||||
map_element.goods_purchased++
|
map_element.goods_purchased++
|
||||||
map_element.credits_spent += price
|
map_element.credits_spent += price
|
||||||
|
|
||||||
/area/vault/supermarket/shop/proc/item_destroyed(list/params)
|
/area/vault/supermarket/shop/proc/item_destroyed(datum/thing)
|
||||||
var/atom/destroyed = params["atom"]
|
var/atom/destroyed = thing
|
||||||
|
|
||||||
if(istype(destroyed, /obj/item))
|
if(istype(destroyed, /obj/item))
|
||||||
if(items.Find(destroyed))
|
if(items.Find(destroyed))
|
||||||
@@ -738,7 +723,7 @@ var/list/clothing_prices = list() //gets filled on initialize()
|
|||||||
var/price = to_spawn[new_item_type]
|
var/price = to_spawn[new_item_type]
|
||||||
|
|
||||||
I.name = "[I.name] ($[price])"
|
I.name = "[I.name] ($[price])"
|
||||||
I.on_destroyed.Add(S, "item_destroyed") //Only trigger alarm when an item for sale is destroyed
|
I.lazy_register_event(/lazy_event/on_destroyed, S, /area/vault/supermarket/shop/proc/item_destroyed) //Only trigger alarm when an item for sale is destroyed
|
||||||
|
|
||||||
S.items[I] = price
|
S.items[I] = price
|
||||||
|
|
||||||
@@ -777,4 +762,4 @@ var/list/clothing_prices = list() //gets filled on initialize()
|
|||||||
destination = /obj/docking_port/destination/vault/supermarket
|
destination = /obj/docking_port/destination/vault/supermarket
|
||||||
|
|
||||||
/obj/docking_port/destination/vault/supermarket
|
/obj/docking_port/destination/vault/supermarket
|
||||||
areaname = "Spessmart"
|
areaname = "Spessmart"
|
||||||
|
|||||||
Reference in New Issue
Block a user