From b76a29675c184d7fc8308de613069b0bd11a2ff0 Mon Sep 17 00:00:00 2001 From: Kylerace Date: Thu, 20 May 2021 02:53:12 -0700 Subject: [PATCH] makes LoadComponent() a macro like AddComponent() is so it supports named arguments (#59185) --- code/__DEFINES/dcs/helpers.dm | 3 +++ code/datums/components/_component.dm | 6 +++--- code/datums/materials/basemats.dm | 2 +- code/modules/clothing/shoes/miscellaneous.dm | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/dcs/helpers.dm b/code/__DEFINES/dcs/helpers.dm index ba2b9a704a3..a0080d7266e 100644 --- a/code/__DEFINES/dcs/helpers.dm +++ b/code/__DEFINES/dcs/helpers.dm @@ -21,3 +21,6 @@ /// A wrapper for _AddComponent that allows us to pretend we're using normal named arguments #define AddComponent(arguments...) _AddComponent(list(##arguments)) + +/// A wrapper for _LoadComponent that allows us to pretend we're using normal named arguments +#define LoadComponent(arguments...) _LoadComponent(list(##arguments)) diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 39889a16957..91e8a0cc349 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -471,10 +471,10 @@ * * component_type The typepath of the component to create or return * * ... additional arguments to be passed when creating the component if it does not exist */ -/datum/proc/LoadComponent(component_type, ...) - . = GetComponent(component_type) +/datum/proc/_LoadComponent(list/arguments) + . = GetComponent(arguments[1]) if(!.) - return _AddComponent(args) + return _AddComponent(arguments) /** * Removes the component from parent, ends up with a null parent diff --git a/code/datums/materials/basemats.dm b/code/datums/materials/basemats.dm index bf6c3f5f548..b4490c66843 100644 --- a/code/datums/materials/basemats.dm +++ b/code/datums/materials/basemats.dm @@ -161,7 +161,7 @@ Unless you know what you're doing, only use the first three numbers. They're in /datum/material/bananium/on_applied(atom/source, amount, material_flags) . = ..() - source.LoadComponent(/datum/component/squeak, list('sound/items/bikehorn.ogg'=1), 50, 0, 0, 0, 0, 20, 0) + source.LoadComponent(/datum/component/squeak, list('sound/items/bikehorn.ogg'=1), 50, falloff_exponent = 20) source.AddComponent(/datum/component/slippery, min(amount / 10, 80)) /datum/material/bananium/on_removed(atom/source, amount, material_flags) diff --git a/code/modules/clothing/shoes/miscellaneous.dm b/code/modules/clothing/shoes/miscellaneous.dm index 94f9f1b0312..21f84901b0e 100644 --- a/code/modules/clothing/shoes/miscellaneous.dm +++ b/code/modules/clothing/shoes/miscellaneous.dm @@ -104,7 +104,7 @@ /obj/item/clothing/shoes/clown_shoes/Initialize() . = ..() - LoadComponent(/datum/component/squeak, list('sound/effects/clownstep1.ogg'=1,'sound/effects/clownstep2.ogg'=1), 50, 0, 0, 0, 0, 20, 0) //die off quick please + LoadComponent(/datum/component/squeak, list('sound/effects/clownstep1.ogg'=1,'sound/effects/clownstep2.ogg'=1), 50, falloff_exponent = 20) //die off quick please AddElement(/datum/element/swabable, CELL_LINE_TABLE_CLOWN, CELL_VIRUS_TABLE_GENERIC, rand(2,3), 0) /obj/item/clothing/shoes/clown_shoes/equipped(mob/user, slot)