Files
Joshua Kidder 7a3ad79506 All camelCase (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use snake_case. UNDERSCORES RULE! (#94111)
## About The Pull Request
It's just a partial cleanup of
anti-[STYLE](https://github.com/tgstation/tgstation/blob/master/.github/guides/STYLE.md)
code from /tg/'s ancient history. I compiled & tested with my helpful
assistant and damage is still working.

<img width="1920" height="1040" alt="image"
src="https://github.com/user-attachments/assets/26dabc17-088f-4008-b299-3ff4c27142c3"
/>


I'll upload the .cs script I used to do it shortly.

## Why It's Good For The Game
Just minor code cleanup.

Script used is located at https://metek.tech/camelTo-Snake.7z

EDIT 11/23/25: Updated the script to use multithreading and sequential
scan so it works a hell of a lot faster
```
/*
//
Copyright 2025 Joshua 'Joan Metekillot' Kidder

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
//
*/
using System.Text.RegularExpressions;
class Program
{
    static async Task Main(string[] args)
    {
        var readFile = new FileStreamOptions
        {
            Access = FileAccess.Read,
            Share = FileShare.ReadWrite,
            Options = FileOptions.Asynchronous | FileOptions.SequentialScan
        };
        FileStreamOptions writeFile = new FileStreamOptions
        {
            Share = FileShare.ReadWrite,
            Access = FileAccess.ReadWrite,
            Mode = FileMode.Truncate,
            Options = FileOptions.Asynchronous
        };
        RegexOptions regexOptions = RegexOptions.Multiline | RegexOptions.Compiled;
        Dictionary<string, int> changedProcs = new();
        string regexPattern = @"(?<=\P{L})([a-z]+)([A-Z]{1,2}[a-z]+)*(Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss)([A-Z]{1,2}[a-z]+)*";
        Regex camelCaseProcRegex = new(regexPattern, regexOptions);

        string snakeify(Match matchingRegex)
        {
            var vals =
            matchingRegex.Groups.Cast<Group>().SelectMany(_ => _.Captures).Select(_ => _.Value).ToArray();
            var newVal = string.Join("_", vals.Skip(1).ToArray()).ToLower();
            string logString = $"{vals[0]} => {newVal}";
            if (changedProcs.TryGetValue(logString, out int value))
            {
                changedProcs[logString] = value + 1;
            }
            else
            {
                changedProcs.Add(logString, 1);
            }
            return newVal;
        }
        var dmFiles = Directory.EnumerateFiles(".", "*.dm", SearchOption.AllDirectories).ToAsyncEnumerable<string>();

        // uses default ParallelOptions
        // https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.paralleloptions?view=net-10.0#main
        await Parallel.ForEachAsync(dmFiles, async (filePath, UnusedCancellationToken) =>
        {
            var reader = new StreamReader(filePath, readFile);
            string oldContent = await reader.ReadToEndAsync();
            string newContent = camelCaseProcRegex.Replace(oldContent, new MatchEvaluator((Func<Match, string>)snakeify));
            if (oldContent != newContent)
            {
                var writer = new StreamWriter(filePath, writeFile);
                await writer.WriteAsync(newContent);
                await writer.DisposeAsync();
            }
            reader.Dispose();
        });
        var logToList = changedProcs.Cast<KeyValuePair<string, int>>().ToList();
        foreach (var pair in logToList)
        {
            Console.WriteLine($"{pair.Key}: {pair.Value} locations");
        }
    }
}

```

## Changelog
🆑 Bisar
code: All (Brute|Burn|Fire|Tox|Oxy|Organ|Stamina)(Loss) procs now use
snake_case, in-line with the STYLE guide. Underscores rule!
/🆑
2025-11-27 15:50:23 -05:00

169 lines
5.4 KiB
Plaintext

#define HEAL_EFFECT_COOLDOWN (1 SECONDS)
/// Applies healing to those in the area.
/// Will provide them with an alert while they're in range, as well as
/// give them a healing particle.
/// Can be applied to those only with a trait conditionally.
/datum/component/aura_healing
/// The range of which to heal
var/range = 5
/// Whether or not you must be a visible object of the parent
var/requires_visibility = TRUE
/// Brute damage to heal over a second
var/brute_heal = 0
/// Burn damage to heal over a second
var/burn_heal = 0
/// Toxin damage to heal over a second
var/toxin_heal = 0
/// Suffocation damage to heal over a second
var/suffocation_heal = 0
/// Stamina damage to heal over a second
var/stamina_heal = 0
/// Amount of blood to heal over a second
var/blood_heal = 0
/// Amount of bleed/pierce wound lowering per second.
var/wound_clotting = 0
/// Map of organ (such as ORGAN_SLOT_BRAIN) to damage heal over a second
var/list/organ_healing = null
/// Amount of damage to heal on simple mobs over a second
var/simple_heal = 0
/// Trait to limit healing to, if set
var/limit_to_trait = null
/// The color to give the healing visual
var/healing_color = COLOR_GREEN
/// If the aura also heals the owner of the component
var/self_heal = TRUE
/// A list of being healed to active alerts
var/list/mob/living/current_alerts = list()
/// Cooldown between showing the heal effect
COOLDOWN_DECLARE(last_heal_effect_time)
/datum/component/aura_healing/Initialize(
range = 5,
requires_visibility = TRUE,
brute_heal = 0,
burn_heal = 0,
toxin_heal = 0,
suffocation_heal = 0,
stamina_heal = 0,
blood_heal = 0,
wound_clotting = 0,
organ_healing = null,
simple_heal = 0,
limit_to_trait = null,
healing_color = COLOR_GREEN,
self_heal = TRUE,
)
if (!isatom(parent))
return COMPONENT_INCOMPATIBLE
START_PROCESSING(SSaura, src)
src.range = range
src.requires_visibility = requires_visibility
src.brute_heal = brute_heal
src.burn_heal = burn_heal
src.toxin_heal = toxin_heal
src.suffocation_heal = suffocation_heal
src.stamina_heal = stamina_heal
src.blood_heal = blood_heal
src.wound_clotting = wound_clotting
src.organ_healing = organ_healing
src.simple_heal = simple_heal
src.limit_to_trait = limit_to_trait
src.healing_color = healing_color
src.self_heal = self_heal
/datum/component/aura_healing/Destroy(force)
STOP_PROCESSING(SSaura, src)
var/alert_category = "aura_healing_[REF(src)]"
for(var/mob/living/alert_holder as anything in current_alerts)
alert_holder.clear_alert(alert_category)
current_alerts.Cut()
return ..()
/datum/component/aura_healing/process(seconds_per_tick)
var/should_show_effect = COOLDOWN_FINISHED(src, last_heal_effect_time)
if (should_show_effect)
COOLDOWN_START(src, last_heal_effect_time, HEAL_EFFECT_COOLDOWN)
var/list/to_heal = list()
var/alert_category = "aura_healing_[REF(src)]"
if(requires_visibility)
for(var/mob/living/candidate in view(range, parent))
if (!isnull(limit_to_trait) && !HAS_TRAIT(candidate, limit_to_trait))
continue
to_heal[candidate] = TRUE
else
for(var/mob/living/candidate in range(range, parent))
if (!isnull(limit_to_trait) && !HAS_TRAIT(candidate, limit_to_trait))
continue
to_heal[candidate] = TRUE
for (var/mob/living/candidate as anything in to_heal)
if (!current_alerts[candidate])
var/atom/movable/screen/alert/aura_healing/alert = candidate.throw_alert(alert_category, /atom/movable/screen/alert/aura_healing, new_master = parent)
alert.desc = "You are being healed by [parent]."
current_alerts[candidate] = TRUE
if (should_show_effect && candidate.health < candidate.maxHealth)
new /obj/effect/temp_visual/heal(get_turf(candidate), healing_color)
if (iscarbon(candidate) || issilicon(candidate) || isbasicmob(candidate))
candidate.adjust_brute_loss(-brute_heal * seconds_per_tick, updating_health = FALSE)
candidate.adjust_fire_loss(-burn_heal * seconds_per_tick, updating_health = FALSE)
if (iscarbon(candidate))
// Toxin healing is forced for slime people
candidate.adjust_tox_loss(-toxin_heal * seconds_per_tick, updating_health = FALSE, forced = TRUE)
candidate.adjust_oxy_loss(-suffocation_heal * seconds_per_tick, updating_health = FALSE)
candidate.adjust_stamina_loss(-stamina_heal * seconds_per_tick, updating_stamina = FALSE)
for (var/organ in organ_healing)
candidate.adjust_organ_loss(organ, -organ_healing[organ] * seconds_per_tick)
var/mob/living/carbon/carbidate = candidate
for(var/datum/wound/iter_wound as anything in carbidate.all_wounds)
iter_wound.adjust_blood_flow(-wound_clotting * seconds_per_tick)
else if (isanimal(candidate))
var/mob/living/simple_animal/animal_candidate = candidate
animal_candidate.adjustHealth(-simple_heal * seconds_per_tick, updating_health = FALSE)
else if (isbasicmob(candidate))
var/mob/living/basic/basic_candidate = candidate
basic_candidate.adjust_health(-simple_heal * seconds_per_tick, updating_health = FALSE)
candidate.adjust_blood_volume(blood_heal * seconds_per_tick, maximum = BLOOD_VOLUME_NORMAL)
candidate.updatehealth()
for (var/mob/living/remove_alert_from as anything in current_alerts - to_heal)
remove_alert_from.clear_alert(alert_category)
current_alerts -= remove_alert_from
/atom/movable/screen/alert/aura_healing
name = "Aura Healing"
icon_state = "template"
use_user_hud_icon = TRUE
clickable_glow = TRUE
#undef HEAL_EFFECT_COOLDOWN