Turning a few components into elements. (#12325)

* Turning a few components into elements.

* eh
This commit is contained in:
Ghom
2020-05-24 22:06:27 +02:00
committed by GitHub
parent 02f467654e
commit ce1f1bdf5e
20 changed files with 116 additions and 100 deletions

View File

@@ -1,11 +0,0 @@
/datum/component/empprotection
var/flags = NONE
/datum/component/empprotection/Initialize(_flags)
if(!istype(parent, /atom))
return COMPONENT_INCOMPATIBLE
flags = _flags
RegisterSignal(parent, list(COMSIG_ATOM_EMP_ACT), .proc/getEmpFlags)
/datum/component/empprotection/proc/getEmpFlags(datum/source, severity)
return flags

View File

@@ -9,6 +9,7 @@
var/originalName
var/list/affixes
var/list/appliedComponents
var/list/appliedElements
var/static/list/affixListing
@@ -22,6 +23,7 @@
src.affixes = affixes
appliedComponents = list()
appliedElements = list()
randomAffixes()
/datum/component/fantasy/Destroy()
@@ -118,6 +120,8 @@
affix.remove(src)
for(var/i in appliedComponents)
qdel(i)
for(var/i in appliedElements)
master._RemoveElement(i)
master.force = max(0, master.force - quality)
master.throwforce = max(0, master.throwforce - quality)

View File

@@ -45,7 +45,8 @@
/datum/fantasy_affix/tactical/apply(datum/component/fantasy/comp, newName)
var/obj/item/master = comp.parent
comp.appliedComponents += master.AddComponent(/datum/component/tactical)
master.AddElement(/datum/element/tactical)
comp.appliedElements += list(/datum/element/tactical)
return "tactical [newName]"
/datum/fantasy_affix/pyromantic

View File

@@ -1,20 +0,0 @@
/datum/component/forced_gravity
var/gravity
var/ignore_space = FALSE //If forced gravity should also work on space turfs
/datum/component/forced_gravity/Initialize(forced_value = 1)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(COMSIG_ATOM_HAS_GRAVITY, .proc/gravity_check)
if(isturf(parent))
RegisterSignal(COMSIG_TURF_HAS_GRAVITY, .proc/turf_gravity_check)
gravity = forced_value
/datum/component/forced_gravity/proc/gravity_check(datum/source, turf/location, list/gravs)
if(!ignore_space && isspaceturf(location))
return
gravs += gravity
/datum/component/forced_gravity/proc/turf_gravity_check(datum/source, atom/checker, list/gravs)
return gravity_check(parent, gravs)

View File

@@ -1,44 +0,0 @@
/datum/component/tactical
var/allowed_slot
/datum/component/tactical/Initialize(allowed_slot)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
src.allowed_slot = allowed_slot
/datum/component/tactical/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/modify)
RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/unmodify)
/datum/component/tactical/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
unmodify()
/datum/component/tactical/Destroy()
unmodify()
return ..()
/datum/component/tactical/proc/modify(obj/item/source, mob/user, slot)
if(allowed_slot && slot != allowed_slot)
unmodify()
return
var/obj/item/master = parent
var/image/I = image(icon = master.icon, icon_state = master.icon_state, loc = user)
I.copy_overlays(master)
I.override = TRUE
source.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/everyone, "sneaking_mission", I)
I.layer = ABOVE_MOB_LAYER
/datum/component/tactical/proc/unmodify(obj/item/source, mob/user)
var/obj/item/master = source || parent
if(!user)
if(!ismob(master.loc))
return
user = master.loc
user.remove_alt_appearance("sneaking_mission")

View File

@@ -0,0 +1,18 @@
/datum/element/empprotection
element_flags = ELEMENT_DETACH | ELEMENT_BESPOKE
id_arg_index = 2
var/flags = NONE
/datum/element/empprotection/Attach(datum/target, _flags)
. = ..()
if(. == ELEMENT_INCOMPATIBLE || !isatom(target))
return ELEMENT_INCOMPATIBLE
flags = _flags
RegisterSignal(target, COMSIG_ATOM_EMP_ACT, .proc/getEmpFlags)
/datum/element/empprotection/Detach(atom/target)
UnregisterSignal(target, COMSIG_ATOM_EMP_ACT)
return ..()
/datum/element/empprotection/proc/getEmpFlags(datum/source, severity)
return flags

View File

@@ -0,0 +1,30 @@
/datum/element/forced_gravity
element_flags = ELEMENT_BESPOKE
id_arg_index = 2
var/gravity
var/ignore_space
/datum/element/forced_gravity/Attach(datum/target, gravity=1, ignore_space=FALSE)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE
src.gravity = gravity
src.ignore_space = ignore_space
RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, .proc/gravity_check)
if(isturf(target))
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, .proc/turf_gravity_check)
/datum/element/forced_gravity/Detach(datum/source, force)
. = ..()
var/static/list/signals_b_gone = list(COMSIG_ATOM_HAS_GRAVITY, COMSIG_TURF_HAS_GRAVITY)
UnregisterSignal(source, signals_b_gone)
/datum/element/forced_gravity/proc/gravity_check(datum/source, turf/location, list/gravs)
if(!ignore_space && isspaceturf(location))
return
gravs += gravity
/datum/element/forced_gravity/proc/turf_gravity_check(datum/source, atom/checker, list/gravs)
return gravity_check(null, source, gravs)

View File

@@ -0,0 +1,37 @@
/datum/element/tactical
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
id_arg_index = 2
var/allowed_slot
/datum/element/tactical/Attach(datum/target, allowed_slot)
. = ..()
if(. == ELEMENT_INCOMPATIBLE || !isitem(target))
return ELEMENT_INCOMPATIBLE
src.allowed_slot = allowed_slot
RegisterSignal(target, COMSIG_ITEM_EQUIPPED, .proc/modify)
RegisterSignal(target, COMSIG_ITEM_DROPPED, .proc/unmodify)
/datum/element/tactical/Detach(datum/target)
UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
unmodify()
return ..()
/datum/element/tactical/proc/modify(obj/item/source, mob/user, slot)
if(allowed_slot && slot != allowed_slot)
unmodify()
return
var/image/I = image(icon = source.icon, icon_state = source.icon_state, loc = user)
I.copy_overlays(source)
I.override = TRUE
source.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/everyone, "sneaking_mission", I)
I.layer = ABOVE_MOB_LAYER
/datum/element/tactical/proc/unmodify(obj/item/source, mob/user)
if(!user)
if(!ismob(source.loc))
return
user = source.loc
user.remove_alt_appearance("sneaking_mission")

View File

@@ -75,7 +75,7 @@
// UPGRADE PROCS
/obj/machinery/camera/proc/upgradeEmpProof()
AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES | EMP_PROTECT_CONTENTS)
AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES | EMP_PROTECT_CONTENTS)
assembly.upgrades.Add(new /obj/item/stack/sheet/mineral/plasma(assembly))
upgrades |= CAMERA_UPGRADE_EMP_PROOF

View File

@@ -679,7 +679,7 @@
/obj/machinery/porta_turret/syndicate/ComponentInitialize()
. = ..()
AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
/obj/machinery/porta_turret/syndicate/energy
icon_state = "standard_stun"
@@ -788,7 +788,7 @@
/obj/machinery/porta_turret/centcom_shuttle/ComponentInitialize()
. = ..()
AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
/obj/machinery/porta_turret/centcom_shuttle/assess_perp(mob/living/carbon/human/perp)
return 0

View File

@@ -98,7 +98,7 @@
/obj/item/radio/ComponentInitialize()
. = ..()
AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES)
AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES)
/obj/item/radio/interact(mob/user)
if(unscrewed && !isAI(user))

View File

@@ -2,16 +2,16 @@
name = "antigravity grenade"
icon_state = "emp"
item_state = "emp"
var/range = 7
var/forced_value = 0
var/duration = 300
/obj/item/grenade/antigravity/prime()
update_mob()
for(var/turf/T in view(range,src))
var/datum/component/C = T.AddComponent(/datum/component/forced_gravity,forced_value)
QDEL_IN(C,duration)
T.AddElement(/datum/element/forced_gravity, forced_value)
addtimer(CALLBACK(T, /datum/.proc/_RemoveElement, list(forced_value)), duration)
qdel(src)

View File

@@ -26,7 +26,7 @@
/obj/item/grenade/plastic/ComponentInitialize()
. = ..()
AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES)
AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES)
/obj/item/grenade/plastic/Destroy()
qdel(nadeassembly)

View File

@@ -302,7 +302,7 @@
/obj/item/twohanded/required/kirbyplants/Initialize()
. = ..()
AddComponent(/datum/component/tactical)
AddElement(/datum/element/tactical)
/obj/item/twohanded/required/kirbyplants/random
icon = 'icons/obj/flora/_flora.dmi'

View File

@@ -2,16 +2,17 @@
name = "modified gravity zone"
setup_field_turfs = TRUE
var/gravity_value = 0
var/list/grav_components = list()
var/list/modified_turfs = list()
field_shape = FIELD_SHAPE_RADIUS_SQUARE
/datum/proximity_monitor/advanced/gravity/setup_field_turf(turf/T)
. = ..()
grav_components[T] = T.AddComponent(/datum/component/forced_gravity,gravity_value)
T.AddElement(/datum/element/forced_gravity, gravity_value)
modified_turfs[T] = gravity_value
/datum/proximity_monitor/advanced/gravity/cleanup_field_turf(turf/T)
. = ..()
var/datum/component/forced_gravity/G = grav_components[T]
grav_components -= T
if(G)
qdel(G)
if(isnull(modified_turfs[T]))
return
T.RemoveElement(/datum/element/forced_gravity, modified_turfs[T])
modified_turfs -= T

View File

@@ -14,7 +14,7 @@
spark_system.attach(src)
wires = new /datum/wires/robot(src)
AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES)
AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES)
robot_modules_background = new()
robot_modules_background.icon_state = "block"

View File

@@ -317,7 +317,7 @@
/obj/item/stock_parts/cell/emproof/ComponentInitialize()
. = ..()
AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF)
AddElement(/datum/element/empprotection, EMP_PROTECT_SELF)
/obj/item/stock_parts/cell/emproof/empty
start_charged = FALSE

View File

@@ -75,7 +75,7 @@
/obj/machinery/power/emitter/ComponentInitialize()
. = ..()
AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
/obj/machinery/power/emitter/RefreshParts()
var/max_firedelay = 120

View File

@@ -61,7 +61,7 @@ field_generator power level display
/obj/machinery/field/generator/ComponentInitialize()
. = ..()
AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES)
/obj/machinery/field/generator/process()
if(active == FG_ONLINE)

View File

@@ -399,11 +399,9 @@
#include "code\datums\components\dejavu.dm"
#include "code\datums\components\earprotection.dm"
#include "code\datums\components\edit_complainer.dm"
#include "code\datums\components\empprotection.dm"
#include "code\datums\components\explodable.dm"
#include "code\datums\components\field_of_vision.dm"
#include "code\datums\components\footstep.dm"
#include "code\datums\components\forced_gravity.dm"
#include "code\datums\components\identification.dm"
#include "code\datums\components\igniter.dm"
#include "code\datums\components\infective.dm"
@@ -438,7 +436,6 @@
#include "code\datums\components\summoning.dm"
#include "code\datums\components\swarming.dm"
#include "code\datums\components\tackle.dm"
#include "code\datums\components\tactical.dm"
#include "code\datums\components\thermite.dm"
#include "code\datums\components\uplink.dm"
#include "code\datums\components\virtual_reality.dm"
@@ -530,8 +527,10 @@
#include "code\datums\elements\dusts_on_leaving_area.dm"
#include "code\datums\elements\dwarfism.dm"
#include "code\datums\elements\earhealing.dm"
#include "code\datums\elements\empprotection.dm"
#include "code\datums\elements\firestacker.dm"
#include "code\datums\elements\flavor_text.dm"
#include "code\datums\elements\forced_gravity.dm"
#include "code\datums\elements\ghost_role_eligibility.dm"
#include "code\datums\elements\mob_holder.dm"
#include "code\datums\elements\polychromic.dm"
@@ -541,6 +540,7 @@
#include "code\datums\elements\squish.dm"
#include "code\datums\elements\swimming.dm"
#include "code\datums\elements\sword_point.dm"
#include "code\datums\elements\tactical.dm"
#include "code\datums\elements\update_icon_blocker.dm"
#include "code\datums\elements\update_icon_updates_onmob.dm"
#include "code\datums\elements\wuv.dm"