mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
Turns rust component into bespoke element (#60496)
This commit is contained in:
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* Adding this component to an Atom will have it automatically render an overlay.
|
||||
* The overlay can be specified in new as the first paramter; if not set it defaults to rust_overlay's rust_default
|
||||
*/
|
||||
/datum/component/rust
|
||||
dupe_mode = COMPONENT_DUPE_UNIQUE
|
||||
/// Internal variable to store the rust overlay we are using to avoid regenerating it every overlay update call
|
||||
var/mutable_appearance/rust_overlay
|
||||
|
||||
/turf/closed/wall/rust/New()
|
||||
var/atom/wall_new = new /turf/closed/wall(src)
|
||||
wall_new.AddComponent(/datum/component/rust)
|
||||
|
||||
/turf/closed/wall/r_wall/rust/New()
|
||||
var/atom/wall_new = new /turf/closed/wall/r_wall(src)
|
||||
wall_new.AddComponent(/datum/component/rust)
|
||||
|
||||
/turf/open/floor/plating/rust/New()
|
||||
var/atom/wall_new = new /turf/open/floor/plating(src)
|
||||
wall_new.AddComponent(/datum/component/rust)
|
||||
|
||||
/datum/component/rust/Initialize(mutable_appearance/overlay)
|
||||
. = ..()
|
||||
if(!isatom(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
rust_overlay = overlay || mutable_appearance('icons/effects/rust_overlay.dmi', "rust_default")
|
||||
// Unfortunately registering with parent sometimes doesn't cause an overlay update
|
||||
ADD_TRAIT(parent, TRAIT_RUSTY, src)
|
||||
var/atom/parent_atom = parent
|
||||
parent_atom.update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
/datum/component/rust/RegisterWithParent()
|
||||
RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, .proc/apply_rust_overlay)
|
||||
RegisterSignal(parent, list(COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_WELDER), COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_RUSTSCRAPER)), .proc/secondary_tool_act)
|
||||
RegisterSignal(parent, COMSIG_PARENT_PREQDELETED, .proc/parent_del)
|
||||
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/handle_examine)
|
||||
|
||||
/datum/component/rust/UnregisterFromParent()
|
||||
UnregisterSignal(parent,\
|
||||
list(COMSIG_ATOM_UPDATE_OVERLAYS, COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_WELDER), COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_RUSTSCRAPER)), COMSIG_PARENT_PREQDELETED)
|
||||
REMOVE_TRAIT(parent, TRAIT_RUSTY, src)
|
||||
var/atom/parent_atom = parent
|
||||
parent_atom.update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
/datum/component/rust/proc/handle_examine(datum/source, mob/user, list/examine_text)
|
||||
SIGNAL_HANDLER
|
||||
examine_text += span_notice("[source] is very rusty, you could probably <i>burn</i> or <i>scrape</i> it off.")
|
||||
|
||||
/datum/component/rust/proc/apply_rust_overlay(atom/parent_atom, list/overlays)
|
||||
SIGNAL_HANDLER
|
||||
overlays |= rust_overlay
|
||||
|
||||
/datum/component/rust/proc/parent_del()
|
||||
SIGNAL_HANDLER
|
||||
qdel(src)
|
||||
|
||||
/datum/component/rust/Destroy()
|
||||
rust_overlay = null
|
||||
return ..()
|
||||
|
||||
/// We call this from secondary_tool_act because we sleep with do_after
|
||||
/datum/component/rust/proc/handle_tool_use(atom/source, mob/user, obj/item/item)
|
||||
switch(item.tool_behaviour)
|
||||
if(TOOL_WELDER)
|
||||
if(item.use(5))
|
||||
user.balloon_alert(user, "burning off rust...")
|
||||
if(!do_after(user, 5 SECONDS * item.toolspeed, parent))
|
||||
return
|
||||
user.balloon_alert(user, "burned off rust")
|
||||
qdel(src)
|
||||
return
|
||||
if(TOOL_RUSTSCRAPER)
|
||||
user.balloon_alert(user, "scraping off rust...")
|
||||
if(!do_after(user, 2 SECONDS * item.toolspeed, parent))
|
||||
return
|
||||
user.balloon_alert(user, "scraped off rust")
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
/// Because do_after sleeps we register the signal here and defer via an async call
|
||||
/datum/component/rust/proc/secondary_tool_act(atom/source, mob/user, obj/item/item)
|
||||
SIGNAL_HANDLER
|
||||
INVOKE_ASYNC(src, .proc/handle_tool_use, source, user, item)
|
||||
return COMPONENT_BLOCK_TOOL_ATTACK
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Adding this element to an atom will have it automatically render an overlay.
|
||||
* The overlay can be specified in new as the first paramter; if not set it defaults to rust_overlay's rust_default
|
||||
*/
|
||||
/datum/element/rust
|
||||
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
|
||||
id_arg_index = 2
|
||||
/// The rust image itself, since the icon and icon state are only used as an argument
|
||||
var/image/rust_overlay
|
||||
|
||||
/datum/element/rust/Attach(atom/target, rust_icon = 'icons/effects/rust_overlay.dmi', rust_icon_state = "rust_default")
|
||||
. = ..()
|
||||
if(!isatom(target))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
if(!rust_overlay)
|
||||
rust_overlay = image(rust_icon, rust_icon)
|
||||
ADD_TRAIT(target, TRAIT_RUSTY, src)
|
||||
RegisterSignal(target, COMSIG_ATOM_UPDATE_OVERLAYS, .proc/apply_rust_overlay)
|
||||
RegisterSignal(target, COMSIG_PARENT_EXAMINE, .proc/handle_examine)
|
||||
RegisterSignal(target, list(COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_WELDER), COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_RUSTSCRAPER)), .proc/secondary_tool_act)
|
||||
// Unfortunately registering with parent sometimes doesn't cause an overlay update
|
||||
target.update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
/datum/element/rust/Detach(atom/source)
|
||||
. = ..()
|
||||
UnregisterSignal(source, COMSIG_ATOM_UPDATE_OVERLAYS)
|
||||
UnregisterSignal(source, COMSIG_PARENT_EXAMINE)
|
||||
UnregisterSignal(source, list(COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_WELDER), COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_RUSTSCRAPER)))
|
||||
REMOVE_TRAIT(source, TRAIT_RUSTY, src)
|
||||
source.update_icon(UPDATE_OVERLAYS)
|
||||
|
||||
/datum/element/rust/proc/handle_examine(datum/source, mob/user, list/examine_text)
|
||||
SIGNAL_HANDLER
|
||||
examine_text += span_notice("[source] is very rusty, you could probably <i>burn</i> or <i>scrape</i> it off.")
|
||||
|
||||
/datum/element/rust/proc/apply_rust_overlay(atom/parent_atom, list/overlays)
|
||||
SIGNAL_HANDLER
|
||||
overlays |= rust_overlay
|
||||
|
||||
/// Because do_after sleeps we register the signal here and defer via an async call
|
||||
/datum/element/rust/proc/secondary_tool_act(atom/source, mob/user, obj/item/item)
|
||||
SIGNAL_HANDLER
|
||||
INVOKE_ASYNC(src, .proc/handle_tool_use, source, user, item)
|
||||
return COMPONENT_BLOCK_TOOL_ATTACK
|
||||
|
||||
/// We call this from secondary_tool_act because we sleep with do_after
|
||||
/datum/element/rust/proc/handle_tool_use(atom/source, mob/user, obj/item/item)
|
||||
switch(item.tool_behaviour)
|
||||
if(TOOL_WELDER)
|
||||
if(item.use(5))
|
||||
user.balloon_alert(user, "burning off rust...")
|
||||
if(!do_after(user, 5 SECONDS * item.toolspeed, source))
|
||||
return
|
||||
user.balloon_alert(user, "burned off rust")
|
||||
qdel(src)
|
||||
return
|
||||
if(TOOL_RUSTSCRAPER)
|
||||
user.balloon_alert(user, "scraping off rust...")
|
||||
if(!do_after(user, 2 SECONDS * item.toolspeed, source))
|
||||
return
|
||||
user.balloon_alert(user, "scraped off rust")
|
||||
qdel(src)
|
||||
return
|
||||
+1
-1
@@ -1936,7 +1936,7 @@
|
||||
* Override this if you want custom behaviour in whatever gets hit by the rust
|
||||
*/
|
||||
/atom/proc/rust_heretic_act()
|
||||
AddComponent(/datum/component/rust)
|
||||
AddElement(/datum/element/rust)
|
||||
|
||||
/**
|
||||
* Used to set something as 'open' if it's being used as a supplypod
|
||||
|
||||
@@ -75,22 +75,30 @@
|
||||
bullet_sizzle = TRUE
|
||||
|
||||
/turf/closed/wall/rust
|
||||
name = "rusted wall"
|
||||
desc = "A rusted metal wall."
|
||||
icon = 'icons/turf/walls/rusty_wall.dmi'
|
||||
icon_state = "rusty_wall-0"
|
||||
base_icon_state = "rusty_wall"
|
||||
smoothing_flags = SMOOTH_BITMASK
|
||||
hardness = 45
|
||||
//SDMM supports colors, this is simply for easier mapping
|
||||
//and should be removed on initialize
|
||||
color = COLOR_ORANGE_BROWN
|
||||
|
||||
/turf/closed/wall/rust/Initialize(mapload)
|
||||
. = ..()
|
||||
color = null
|
||||
|
||||
/turf/closed/wall/rust/ComponentInitialize()
|
||||
. = ..()
|
||||
AddElement(/datum/element/rust)
|
||||
|
||||
/turf/closed/wall/r_wall/rust
|
||||
name = "rusted reinforced wall"
|
||||
desc = "A huge chunk of rusted reinforced metal."
|
||||
icon = 'icons/turf/walls/rusty_reinforced_wall.dmi'
|
||||
icon_state = "rusty_reinforced_wall-0"
|
||||
base_icon_state = "rusty_reinforced_wall"
|
||||
smoothing_flags = SMOOTH_BITMASK
|
||||
hardness = 15
|
||||
//SDMM supports colors, this is simply for easier mapping
|
||||
//and should be removed on initialize
|
||||
color = COLOR_ORANGE_BROWN
|
||||
|
||||
/turf/closed/wall/r_wall/Initialize(mapload)
|
||||
. = ..()
|
||||
color = null
|
||||
|
||||
/turf/closed/wall/r_wall/ComponentInitialize()
|
||||
. = ..()
|
||||
AddElement(/datum/element/rust)
|
||||
|
||||
/turf/closed/wall/mineral/bronze
|
||||
name = "clockwork wall"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
if(prob(70))
|
||||
new /obj/effect/temp_visual/glowing_rune(src)
|
||||
var/atom/changed_turf = ChangeTurf(/turf/open/floor/plating)
|
||||
changed_turf.AddComponent(/datum/component/rust)
|
||||
changed_turf.AddElement(/datum/element/rust)
|
||||
return ..()
|
||||
|
||||
|
||||
|
||||
@@ -200,17 +200,26 @@
|
||||
return list("eightiesred_damaged")
|
||||
|
||||
/turf/open/floor/plating/rust
|
||||
name = "rusted plating"
|
||||
desc = "Corrupted steel."
|
||||
icon_state = "plating_rust"
|
||||
//SDMM supports colors, this is simply for easier mapping
|
||||
//and should be removed on initialize
|
||||
color = COLOR_BROWN
|
||||
|
||||
/turf/open/floor/plating/rust/Initialize(mapload)
|
||||
. = ..()
|
||||
color = null
|
||||
|
||||
/turf/open/floor/plating/rust/ComponentInitialize()
|
||||
. = ..()
|
||||
AddElement(/datum/element/rust)
|
||||
|
||||
/turf/open/floor/plating/plasma
|
||||
initial_gas_mix = ATMOS_TANK_PLASMA
|
||||
|
||||
/turf/open/floor/plating/plasma/rust/Initialize(mapload)
|
||||
. = ..()
|
||||
// Because this is a fluff turf explicitly for KiloStation it doesn't make sense to ChangeTurf like usual
|
||||
// Especially since it looks like we don't even change the default icon/iconstate???
|
||||
AddComponent(/datum/component/rust)
|
||||
AddElement(/datum/element/rust)
|
||||
|
||||
/turf/open/floor/stone
|
||||
name = "stone brick floor"
|
||||
|
||||
@@ -264,10 +264,10 @@
|
||||
floor.make_plating(TRUE)
|
||||
if(T.type == /turf/closed/wall && prob(15) && !HAS_TRAIT(T, TRAIT_RUSTY))
|
||||
new /obj/effect/temp_visual/revenant(T)
|
||||
T.AddComponent(/datum/component/rust)
|
||||
T.AddElement(/datum/element/rust)
|
||||
if(T.type == /turf/closed/wall/r_wall && prob(10) && !HAS_TRAIT(T, TRAIT_RUSTY))
|
||||
new /obj/effect/temp_visual/revenant(T)
|
||||
T.AddComponent(/datum/component/rust)
|
||||
T.AddElement(/datum/element/rust)
|
||||
for(var/obj/effect/decal/cleanable/food/salt/salt in T)
|
||||
new /obj/effect/temp_visual/revenant(T)
|
||||
qdel(salt)
|
||||
|
||||
+1
-1
@@ -563,7 +563,6 @@
|
||||
#include "code\datums\components\rename.dm"
|
||||
#include "code\datums\components\rot.dm"
|
||||
#include "code\datums\components\rotation.dm"
|
||||
#include "code\datums\components\rust.dm"
|
||||
#include "code\datums\components\shell.dm"
|
||||
#include "code\datums\components\shielded.dm"
|
||||
#include "code\datums\components\shrink.dm"
|
||||
@@ -737,6 +736,7 @@
|
||||
#include "code\datums\elements\point_of_interest.dm"
|
||||
#include "code\datums\elements\rad_insulation.dm"
|
||||
#include "code\datums\elements\ridable.dm"
|
||||
#include "code\datums\elements\rust.dm"
|
||||
#include "code\datums\elements\selfknockback.dm"
|
||||
#include "code\datums\elements\series.dm"
|
||||
#include "code\datums\elements\simple_flying.dm"
|
||||
|
||||
Reference in New Issue
Block a user