Skip to content

Commit

Permalink
rename and unify return values for digging
Browse files Browse the repository at this point in the history
  • Loading branch information
warriorstar-orion committed Oct 21, 2024
1 parent 171aa2f commit e25cc5f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
/// Returns a list of around us
#define TURF_NEIGHBORS(turf) (CORNER_BLOCK_OFFSET(turf, 3, 3, -1, -1) - turf)

#define ORE_PREVENT_DIG 0 //! A turf with ore in it should not be changed when mined.
#define ORE_ALLOW_DIG 1 //! A turf with ore in it should be dug out when mined.
#define MINERAL_PREVENT_DIG 0 //! A mineral turf should not be changed when mined.
#define MINERAL_ALLOW_DIG 1 //! A mineral turf should be dug out when mined.
19 changes: 12 additions & 7 deletions code/datums/ores.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
/// The icon state of the ore used for mining scanner overlays.
var/scan_icon_state = ""

/// Called when the containing turf is "mined", such as with a pickaxe or other digging implement.
/// Returns [ORE_ALLOW_DIG] if the containing turf should be changed to its "dug" state, [ORE_PREVENT_DIG] if it should remain as is.
/**
* Called when the containing turf is "mined", such as with a pickaxe or other
* digging implement.
*
* Returns [MINERAL_ALLOW_DIG] if the containing turf should be changed to its
* "dug" state, [MINERAL_PREVENT_DIG] if it should remain as is.
*/
/datum/ore/proc/on_mine(turf/source, mob/user, triggered_by_explosion = FALSE)
var/amount = rand(drop_min, drop_max)

Expand All @@ -22,7 +27,7 @@
else
stack_trace("[source.type] [COORD(source)] had non-ore stack [drop_type]")

return ORE_ALLOW_DIG
return MINERAL_ALLOW_DIG

/datum/ore/iron
drop_type = /obj/item/stack/ore/iron
Expand Down Expand Up @@ -137,11 +142,11 @@
if(GIBTONITE_UNSTRUCK)
playsound(src,'sound/effects/hit_on_shattered_glass.ogg', 50, TRUE)
explosive_reaction(source, user, triggered_by_explosion)
return ORE_PREVENT_DIG
return MINERAL_PREVENT_DIG
if(GIBTONITE_ACTIVE)
detonate(source)

return ORE_ALLOW_DIG
return MINERAL_ALLOW_DIG
if(GIBTONITE_STABLE)
var/obj/item/gibtonite/gibtonite = new(source)
if(remaining_time <= 0)
Expand All @@ -151,9 +156,9 @@
gibtonite.quality = 2
gibtonite.icon_state = "Gibtonite ore 2"

return ORE_ALLOW_DIG
return MINERAL_ALLOW_DIG

return ORE_PREVENT_DIG
return MINERAL_PREVENT_DIG

/datum/ore/gibtonite/proc/on_parent_attackby(turf/source, obj/item/attacker, mob/user)
SIGNAL_HANDLER // COMSIG_PARENT_ATTACKBY
Expand Down
4 changes: 2 additions & 2 deletions code/game/turfs/simulated/minerals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@

/turf/simulated/mineral/proc/mine_ore(mob/user, triggered_by_explosion)
if(!ore)
return TRUE
return MINERAL_ALLOW_DIG

for(var/obj/effect/temp_visual/mining_overlay/M in src)
qdel(M)

return ore.on_mine(src, user, triggered_by_explosion)

/turf/simulated/mineral/proc/gets_drilled(mob/user, triggered_by_explosion = FALSE)
if(mine_ore(user, triggered_by_explosion) == ORE_PREVENT_DIG)
if(mine_ore(user, triggered_by_explosion) == MINERAL_PREVENT_DIG)
return

ChangeTurf(turf_type, defer_change)
Expand Down

0 comments on commit e25cc5f

Please sign in to comment.