mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-13 03:02:38 +00:00
[MIRROR] Moves /datum/var/signal_enabled to datum flags (#3171)
* Moves /datum/var/signal_enabled to datum flags (#56372) * Moves /datum/var/signal_enabled to datum flags `signal_enabled` is a variable on /datum, so present almost every object in the game. Folding it into the existing `datum_flags` variable will save allocating a variable on every datum in the game. - Clown weaponry was using the `signal_enabled` variable to turn their attached slippery component on and off when the shield/sword was toggled. They now just remove/add the component, rather than touching deep datum internals. * Moves /datum/var/signal_enabled to datum flags Co-authored-by: coiax <yellowbounder@gmail.com>
This commit is contained in:
@@ -11,9 +11,14 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
|
|||||||
#define ALL_CARDINALS (NORTH|SOUTH|EAST|WEST)
|
#define ALL_CARDINALS (NORTH|SOUTH|EAST|WEST)
|
||||||
|
|
||||||
// for /datum/var/datum_flags
|
// for /datum/var/datum_flags
|
||||||
#define DF_USE_TAG (1<<0)
|
#define DF_USE_TAG (1<<0)
|
||||||
#define DF_VAR_EDITED (1<<1)
|
#define DF_VAR_EDITED (1<<1)
|
||||||
#define DF_ISPROCESSING (1<<2)
|
#define DF_ISPROCESSING (1<<2)
|
||||||
|
/**
|
||||||
|
* Is this datum capable of sending signals?
|
||||||
|
* Set when a signal has been registered.
|
||||||
|
*/
|
||||||
|
#define DF_SIGNAL_ENABLED (1<<3)
|
||||||
|
|
||||||
//FLAGS BITMASK
|
//FLAGS BITMASK
|
||||||
// scroll down before changing the numbers on these
|
// scroll down before changing the numbers on these
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ DEFINE_BITFIELD(datum_flags, list(
|
|||||||
"DF_ISPROCESSING" = DF_ISPROCESSING,
|
"DF_ISPROCESSING" = DF_ISPROCESSING,
|
||||||
"DF_VAR_EDITED" = DF_VAR_EDITED,
|
"DF_VAR_EDITED" = DF_VAR_EDITED,
|
||||||
"DF_USE_TAG" = DF_USE_TAG,
|
"DF_USE_TAG" = DF_USE_TAG,
|
||||||
|
"DF_SIGNAL_ENABLED" = DF_SIGNAL_ENABLED,
|
||||||
))
|
))
|
||||||
|
|
||||||
DEFINE_BITFIELD(disease_flags, list(
|
DEFINE_BITFIELD(disease_flags, list(
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
else // Many other things have registered here
|
else // Many other things have registered here
|
||||||
lookup[sig_type][src] = TRUE
|
lookup[sig_type][src] = TRUE
|
||||||
|
|
||||||
signal_enabled = TRUE
|
datum_flags |= DF_SIGNAL_ENABLED
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop listening to a given signal from target
|
* Stop listening to a given signal from target
|
||||||
@@ -311,14 +311,14 @@
|
|||||||
var/target = comp_lookup[sigtype]
|
var/target = comp_lookup[sigtype]
|
||||||
if(!length(target))
|
if(!length(target))
|
||||||
var/datum/C = target
|
var/datum/C = target
|
||||||
if(!C.signal_enabled)
|
if(!(C.datum_flags & DF_SIGNAL_ENABLED))
|
||||||
return NONE
|
return NONE
|
||||||
var/proctype = C.signal_procs[src][sigtype]
|
var/proctype = C.signal_procs[src][sigtype]
|
||||||
return NONE | CallAsync(C, proctype, arguments)
|
return NONE | CallAsync(C, proctype, arguments)
|
||||||
. = NONE
|
. = NONE
|
||||||
for(var/I in target)
|
for(var/I in target)
|
||||||
var/datum/C = I
|
var/datum/C = I
|
||||||
if(!C.signal_enabled)
|
if(!(C.datum_flags & DF_SIGNAL_ENABLED))
|
||||||
continue
|
continue
|
||||||
var/proctype = C.signal_procs[src][sigtype]
|
var/proctype = C.signal_procs[src][sigtype]
|
||||||
. |= CallAsync(C, proctype, arguments)
|
. |= CallAsync(C, proctype, arguments)
|
||||||
|
|||||||
@@ -36,12 +36,6 @@
|
|||||||
var/list/comp_lookup
|
var/list/comp_lookup
|
||||||
/// Lazy associated list in the structure of `signals:proctype` that are run when the datum receives that signal
|
/// Lazy associated list in the structure of `signals:proctype` that are run when the datum receives that signal
|
||||||
var/list/list/datum/callback/signal_procs
|
var/list/list/datum/callback/signal_procs
|
||||||
/**
|
|
||||||
* Is this datum capable of sending signals?
|
|
||||||
*
|
|
||||||
* Set to true when a signal has been registered
|
|
||||||
*/
|
|
||||||
var/signal_enabled = FALSE
|
|
||||||
|
|
||||||
/// Datum level flags
|
/// Datum level flags
|
||||||
var/datum_flags = NONE
|
var/datum_flags = NONE
|
||||||
@@ -106,7 +100,7 @@
|
|||||||
qdel(timer)
|
qdel(timer)
|
||||||
|
|
||||||
//BEGIN: ECS SHIT
|
//BEGIN: ECS SHIT
|
||||||
signal_enabled = FALSE
|
datum_flags &= ~DF_SIGNAL_ENABLED
|
||||||
|
|
||||||
var/list/dc = datum_components
|
var/list/dc = datum_components
|
||||||
if(dc)
|
if(dc)
|
||||||
|
|||||||
@@ -75,11 +75,18 @@
|
|||||||
light_color = COLOR_YELLOW
|
light_color = COLOR_YELLOW
|
||||||
var/next_trombone_allowed = 0
|
var/next_trombone_allowed = 0
|
||||||
|
|
||||||
/obj/item/melee/transforming/energy/sword/bananium/ComponentInitialize()
|
/obj/item/melee/transforming/energy/sword/bananium/Initialize()
|
||||||
. = ..()
|
. = ..()
|
||||||
AddComponent(/datum/component/slippery, 60, GALOSHES_DONT_HELP)
|
adjust_slipperiness()
|
||||||
var/datum/component/slippery/slipper = GetComponent(/datum/component/slippery)
|
|
||||||
slipper.signal_enabled = active
|
/* Adds or removes a slippery component, depending on whether the sword
|
||||||
|
* is active or not.
|
||||||
|
*/
|
||||||
|
/obj/item/melee/transforming/energy/sword/proc/adjust_slipperiness()
|
||||||
|
if(active)
|
||||||
|
AddComponent(/datum/component/slippery, 60, GALOSHES_DONT_HELP)
|
||||||
|
else
|
||||||
|
qdel(GetComponent(/datum/component/slippery))
|
||||||
|
|
||||||
/obj/item/melee/transforming/energy/sword/bananium/attack(mob/living/M, mob/living/user)
|
/obj/item/melee/transforming/energy/sword/bananium/attack(mob/living/M, mob/living/user)
|
||||||
..()
|
..()
|
||||||
@@ -102,9 +109,8 @@
|
|||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/obj/item/melee/transforming/energy/sword/bananium/transform_weapon(mob/living/user, supress_message_text)
|
/obj/item/melee/transforming/energy/sword/bananium/transform_weapon(mob/living/user, supress_message_text)
|
||||||
..()
|
. = ..()
|
||||||
var/datum/component/slippery/slipper = GetComponent(/datum/component/slippery)
|
adjust_slipperiness()
|
||||||
slipper.signal_enabled = active
|
|
||||||
|
|
||||||
/obj/item/melee/transforming/energy/sword/bananium/ignition_effect(atom/A, mob/user)
|
/obj/item/melee/transforming/energy/sword/bananium/ignition_effect(atom/A, mob/user)
|
||||||
return ""
|
return ""
|
||||||
@@ -132,16 +138,22 @@
|
|||||||
on_throwforce = 0
|
on_throwforce = 0
|
||||||
on_throw_speed = 1
|
on_throw_speed = 1
|
||||||
|
|
||||||
/obj/item/shield/energy/bananium/ComponentInitialize()
|
/obj/item/shield/energy/bananium/Initialize()
|
||||||
. = ..()
|
. = ..()
|
||||||
AddComponent(/datum/component/slippery, 60, GALOSHES_DONT_HELP)
|
adjust_slipperiness()
|
||||||
var/datum/component/slippery/slipper = GetComponent(/datum/component/slippery)
|
|
||||||
slipper.signal_enabled = active
|
/* Adds or removes a slippery component, depending on whether the shield
|
||||||
|
* is active or not.
|
||||||
|
*/
|
||||||
|
/obj/item/shield/energy/bananium/proc/adjust_slipperiness()
|
||||||
|
if(active)
|
||||||
|
AddComponent(/datum/component/slippery, 60, GALOSHES_DONT_HELP)
|
||||||
|
else
|
||||||
|
qdel(GetComponent(/datum/component/slippery))
|
||||||
|
|
||||||
/obj/item/shield/energy/bananium/attack_self(mob/living/carbon/human/user)
|
/obj/item/shield/energy/bananium/attack_self(mob/living/carbon/human/user)
|
||||||
..()
|
. = ..()
|
||||||
var/datum/component/slippery/slipper = GetComponent(/datum/component/slippery)
|
adjust_slipperiness()
|
||||||
slipper.signal_enabled = active
|
|
||||||
|
|
||||||
/obj/item/shield/energy/bananium/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, gentle = FALSE, quickstart = TRUE)
|
/obj/item/shield/energy/bananium/throw_at(atom/target, range, speed, mob/thrower, spin=1, diagonals_first = 0, datum/callback/callback, force, gentle = FALSE, quickstart = TRUE)
|
||||||
if(active)
|
if(active)
|
||||||
|
|||||||
Reference in New Issue
Block a user