Files
Bubberstation/code/datums/components/stationstuck.dm
Emmett Gaines 9e34b3d6a1 Supports named arguments in AddComponent and AddElement (#49098)
AddComponent/AddElement now support named arguments. This requires passing around an argument list instead of using actual proc args which a bit gross but we can blame byond for forcing this.

InheritComponent uses mirrored init arguments instead of an argument list which means no more accessing it via index to get to the same arguments as in init.

As a small bonus I restructured dcs defines to be a bit more manageable. Mainly just splits them into separate files and gives them their own folder.
2020-02-17 17:57:52 +13:00

39 lines
1.1 KiB
Plaintext

//very similar to stationloving, but more made for mobs and not objects. used on derelict drones currently
/datum/component/stationstuck
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
var/murder = TRUE //teleports if not
var/stuck_zlevel
var/message = ""
/datum/component/stationstuck/Initialize(_murder = TRUE, _message = "")
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
var/mob/living/L = parent
RegisterSignal(L, list(COMSIG_MOVABLE_Z_CHANGED), .proc/punish)
murder = _murder
message = _message
stuck_zlevel = L.z
/datum/component/stationstuck/InheritComponent(datum/component/stationstuck/newc, original, _murder, _message)
if(newc)
murder = newc.murder
message = newc.message
else
murder = _murder
message = _message
/datum/component/stationstuck/proc/punish()
var/mob/living/L = parent
if(message)
var/span = murder ? "userdanger" : "danger"
to_chat(L, "<span class='[span]'>[message]</span>")
if(murder)
L.gib()
return
var/targetturf = find_safe_turf(stuck_zlevel)
if(!targetturf)
targetturf = locate(world.maxx/2,world.maxy/2,stuck_zlevel)
L.forceMove(targetturf)
return targetturf