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")