From 17e80ffd6329e4ddc009261decaa79cd738ec94d Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Sun, 3 Dec 2023 11:43:07 +0100
Subject: [PATCH] [MIRROR] Retools `IS_SPINNING_1` into a trait [MDB IGNORE]
 (#25399)

* Retools `IS_SPINNING_1` into a trait

* Modular

---------

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
---
 code/__DEFINES/_flags.dm                      | 22 +++++++++++++++++++
 code/__DEFINES/traits/declarations.dm         |  2 ++
 code/_globalvars/bitfields.dm                 |  6 +++++
 code/_globalvars/traits/_traits.dm            |  1 +
 .../dna_infuser/organ_sets/roach_organs.dm    |  2 +-
 .../heretic/knowledge/blade_lore.dm           |  2 +-
 code/modules/assembly/flash.dm                |  2 +-
 code/modules/basketball/basketball.dm         |  4 ++--
 code/modules/basketball/hoop.dm               |  2 +-
 code/modules/mob/mob.dm                       |  8 +++++--
 10 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/code/__DEFINES/_flags.dm b/code/__DEFINES/_flags.dm
index f5fc50004cd..36c62e13df6 100644
--- a/code/__DEFINES/_flags.dm
+++ b/code/__DEFINES/_flags.dm
@@ -38,6 +38,7 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
 /// Should this object be paintable with very dark colors?
 #define ALLOW_DARK_PAINTS_1 (1<<10)
 /// Should this object be unpaintable?
+<<<<<<< HEAD
 #define UNPAINTABLE_1 (1<<11)
 /// Is the thing currently spinning?
 #define IS_SPINNING_1 (1<<12)
@@ -55,11 +56,32 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
 #define HAS_CONTEXTUAL_SCREENTIPS_1 (1<<18)
 /// Whether or not this atom is storing contents for a disassociated storage object
 #define HAS_DISASSOCIATED_STORAGE_1 (1<<19)
+=======
+#define UNPAINTABLE_1 (1<<10)
+/// Is this atom on top of another atom, and as such has click priority?
+#define IS_ONTOP_1 (1<<11)
+/// Is this atom immune to being dusted by the supermatter?
+#define SUPERMATTER_IGNORES_1 (1<<12)
+/// If a turf can be made dirty at roundstart. This is also used in areas.
+#define CAN_BE_DIRTY_1 (1<<13)
+/// Should we use the initial icon for display? Mostly used by overlay only objects
+#define HTML_USE_INITAL_ICON_1 (1<<14)
+/// Can players recolor this in-game via vendors (and maybe more if support is added)?
+#define IS_PLAYER_COLORABLE_1 (1<<15)
+/// Whether or not this atom has contextual screentips when hovered OVER
+#define HAS_CONTEXTUAL_SCREENTIPS_1 (1<<16)
+/// Whether or not this atom is storing contents for a disassociated storage object
+#define HAS_DISASSOCIATED_STORAGE_1 (1<<17)
+>>>>>>> 9b146e388 ([MIRROR] Retools `IS_SPINNING_1` into a trait [MDB IGNORE] (#25399))
 /// If this atom has experienced a decal element "init finished" sourced appearance update
 /// We use this to ensure stacked decals don't double up appearance updates for no rasin
 /// Flag as an optimization, don't make this a trait without profiling
 /// Yes I know this is a stupid flag, no you can't take him from me
+<<<<<<< HEAD
 #define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<20)
+=======
+#define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<18)
+>>>>>>> 9b146e388 ([MIRROR] Retools `IS_SPINNING_1` into a trait [MDB IGNORE] (#25399))
 
 // Update flags for [/atom/proc/update_appearance]
 /// Update the atom's name
diff --git a/code/__DEFINES/traits/declarations.dm b/code/__DEFINES/traits/declarations.dm
index 4aa6f4a74a4..2ac5ccf48e9 100644
--- a/code/__DEFINES/traits/declarations.dm
+++ b/code/__DEFINES/traits/declarations.dm
@@ -889,6 +889,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
 #define STATION_TRAIT_UNNATURAL_ATMOSPHERE "station_trait_unnatural_atmosphere"
 #define STATION_TRAIT_VENDING_SHORTAGE "station_trait_vending_shortage"
 
+/// This atom is currently spinning.
+#define TRAIT_SPINNING "spinning"
 
 /// Denotes that this id card was given via the job outfit, aka the first ID this player got.
 #define TRAIT_JOB_FIRST_ID_CARD "job_first_id_card"
diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm
index 796def0de16..6e1e3e9f4dd 100644
--- a/code/_globalvars/bitfields.dm
+++ b/code/_globalvars/bitfields.dm
@@ -126,7 +126,13 @@ DEFINE_BITFIELD(flags_1, list(
 	"INITIALIZED_1" = INITIALIZED_1,
 	"IS_ONTOP_1" = IS_ONTOP_1,
 	"IS_PLAYER_COLORABLE_1" = IS_PLAYER_COLORABLE_1,
+<<<<<<< HEAD
 	"IS_SPINNING_1" = IS_SPINNING_1,
+=======
+	"NO_SCREENTIPS_1" = NO_SCREENTIPS_1,
+	"NODECONSTRUCT_1" = NODECONSTRUCT_1,
+	"NO_SCREENTIPS_1" = NO_SCREENTIPS_1,
+>>>>>>> 9b146e388 ([MIRROR] Retools `IS_SPINNING_1` into a trait [MDB IGNORE] (#25399))
 	"NODECONSTRUCT_1" = NODECONSTRUCT_1,
 	"NO_SCREENTIPS_1" = NO_SCREENTIPS_1,
 	"ON_BORDER_1" = ON_BORDER_1,
diff --git a/code/_globalvars/traits/_traits.dm b/code/_globalvars/traits/_traits.dm
index 79facdd304c..d7ab26f2c62 100644
--- a/code/_globalvars/traits/_traits.dm
+++ b/code/_globalvars/traits/_traits.dm
@@ -25,6 +25,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
 		"TRAIT_MAT_TRANSMUTED" = TRAIT_MAT_TRANSMUTED,
 		"TRAIT_RECENTLY_COINED" = TRAIT_RECENTLY_COINED,
 		"TRAIT_RUSTY" = TRAIT_RUSTY,
+		"TRAIT_SPINNING" = TRAIT_SPINNING,
 		"TRAIT_STICKERED" = TRAIT_STICKERED,
 	),
 	/atom/movable = list(
diff --git a/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm b/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm
index 3c2d461e08c..f10c9b039f2 100644
--- a/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm
+++ b/code/game/machinery/dna_infuser/organ_sets/roach_organs.dm
@@ -137,7 +137,7 @@
 	if(!ishuman(blocker) || blocker.stat >= UNCONSCIOUS)
 		return FALSE
 	// No tactical spinning
-	if(blocker.flags_1 & IS_SPINNING_1)
+	if(HAS_TRAIT(blocker, TRAIT_SPINNING))
 		return FALSE
 	if(blocker.body_position == LYING_DOWN || (blocker.dir & attack_direction))
 		return TRUE
diff --git a/code/modules/antagonists/heretic/knowledge/blade_lore.dm b/code/modules/antagonists/heretic/knowledge/blade_lore.dm
index eae5b856318..03b9a716d53 100644
--- a/code/modules/antagonists/heretic/knowledge/blade_lore.dm
+++ b/code/modules/antagonists/heretic/knowledge/blade_lore.dm
@@ -70,7 +70,7 @@
 
 	var/are_we_behind = FALSE
 	// No tactical spinning allowed
-	if(target.flags_1 & IS_SPINNING_1)
+	if(HAS_TRAIT(target, TRAIT_SPINNING))
 		are_we_behind = TRUE
 
 	// We'll take "same tile" as "behind" for ease
diff --git a/code/modules/assembly/flash.dm b/code/modules/assembly/flash.dm
index 382aca8e3f3..2f8569d8780 100644
--- a/code/modules/assembly/flash.dm
+++ b/code/modules/assembly/flash.dm
@@ -193,7 +193,7 @@
 	// Tactical combat emote-spinning should not counter intended gameplay mechanics.
 	// This trumps same-loc checks to discourage floor spinning in general to counter flashes.
 	// In short, combat spinning is silly and you should feel silly for doing it.
-	if(victim.flags_1 & IS_SPINNING_1)
+	if(HAS_TRAIT(victim, TRAIT_SPINNING))
 		return DEVIATION_NONE
 
 	if(iscarbon(victim))
diff --git a/code/modules/basketball/basketball.dm b/code/modules/basketball/basketball.dm
index 232b65d8e1c..9fe176715db 100644
--- a/code/modules/basketball/basketball.dm
+++ b/code/modules/basketball/basketball.dm
@@ -106,7 +106,7 @@
 		return
 
 	// spinning gives you a lower disarm chance but it drains stamina
-	var/disarm_chance = baller.flags_1 & IS_SPINNING_1 ? 35 : 50
+	var/disarm_chance = HAS_TRAIT(baller, TRAIT_SPINNING) ? 35 : 50
 	// ballers stamina results in lower disarm, stealer stamina results in higher disarm
 	disarm_chance += (baller.getStaminaLoss() - stealer.getStaminaLoss()) / 2
 	// the lowest chance for disarm is 25% and the highest is 75%
@@ -169,7 +169,7 @@
 		return
 
 	// need a free hand and can't be spinning
-	if(!user.put_in_inactive_hand(src) || user.flags_1 & IS_SPINNING_1)
+	if(!user.put_in_inactive_hand(src) || HAS_TRAIT(user, TRAIT_SPINNING))
 		return
 
 	last_use = world.time
diff --git a/code/modules/basketball/hoop.dm b/code/modules/basketball/hoop.dm
index 5de263c4786..dd0585e0742 100644
--- a/code/modules/basketball/hoop.dm
+++ b/code/modules/basketball/hoop.dm
@@ -164,7 +164,7 @@
 		score_chance *= 0.5
 
 	// aim penalty for spinning while shooting
-	if(istype(thrower) && thrower.flags_1 & IS_SPINNING_1)
+	if(istype(thrower) && HAS_TRAIT(thrower, TRAIT_SPINNING))
 		score_chance *= 0.5
 
 	if(prob(score_chance))
diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm
index 30027e5ba4b..9b81e2e01ab 100644
--- a/code/modules/mob/mob.dm
+++ b/code/modules/mob/mob.dm
@@ -744,6 +744,8 @@
 /mob/proc/can_resist()
 	return FALSE //overridden in living.dm
 
+#define SPIN_PROC_TRAIT "trait_from_spin()"
+
 ///Spin this mob around it's central axis
 /mob/proc/spin(spintime, speed)
 	set waitfor = 0
@@ -751,7 +753,7 @@
 	if((spintime < 1) || (speed < 1) || !spintime || !speed)
 		return
 
-	flags_1 |= IS_SPINNING_1
+	ADD_TRAIT(src, TRAIT_SPINNING, SPIN_PROC_TRAIT)
 	while(spintime >= speed)
 		sleep(speed)
 		switch(D)
@@ -765,7 +767,9 @@
 				D = NORTH
 		setDir(D)
 		spintime -= speed
-	flags_1 &= ~IS_SPINNING_1
+	REMOVE_TRAIT(src, TRAIT_SPINNING, SPIN_PROC_TRAIT)
+
+#undef SPIN_PROC_TRAIT
 
 ///Update the pulling hud icon
 /mob/proc/update_pull_hud_icon()