Adds Source Count Macro (#77519)

## About The Pull Request

I prefer this to having people manually read the list, plus it seems
like reasonable information to expose, especially if we're gonna start
using it in this pattern.

## Why It's Good For The Game

Less futzing with internals
This commit is contained in:
LemonInTheDark
2023-08-11 20:40:15 +02:00
committed by GitHub
parent ddca8c5cf0
commit a803b21a6c
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -115,7 +115,9 @@
#define HAS_TRAIT_NOT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (length(target._status_traits[trait] - source) > 0))
/// Returns a list of trait sources for this trait. Only useful for wacko cases and internal futzing
/// You should not be using this
#define GET_TRAIT_SOURCES(target, trait) target._status_traits?[trait] || list()
#define GET_TRAIT_SOURCES(target, trait) (target._status_traits?[trait] || list())
/// Returns the amount of sources for a trait. useful if you don't want to have a "thing counter" stuck around all the time
#define COUNT_TRAIT_SOURCES(target, trait) length(GET_TRAIT_SOURCES(target, trait))
/// A simple helper for checking traits in a mob's mind
#define HAS_MIND_TRAIT(target, trait) (HAS_TRAIT(target, trait) || (target.mind ? HAS_TRAIT(target.mind, trait) : FALSE))
+1 -1
View File
@@ -39,7 +39,7 @@
///Add our stick_type to the target with px and py as pixel x and pixel y respectively
/datum/element/sticker/proc/do_stick(obj/item/source, atom/target, mob/living/user, px, py)
if(length(GET_TRAIT_SOURCES(target, TRAIT_STICKERED)) >= MAX_ALLOWED_STICKERS)
if(COUNT_TRAIT_SOURCES(target, TRAIT_STICKERED) >= MAX_ALLOWED_STICKERS)
source.balloon_alert_to_viewers("sticker won't stick!")
return FALSE
target.AddComponent(stick_type, px, py, source, user, washable)