Fixed typos and improved code readability

This commit is contained in:
Chomp
2025-06-14 12:42:19 +01:00
parent 90568b9841
commit 4e89fbbfd8
2 changed files with 28 additions and 19 deletions
@@ -175,7 +175,7 @@ public class HealthHelper(
TransferPostRaidLimbEffectsToProfile(postRaidHealth.BodyParts, pmcData);
// Adjust hydration/energy/temp and limb hp using temp storage hydated above
// Adjust hydration/energy/temp and limb hp using temp storage hydrated above
SaveHealth(pmcData, sessionID);
// Reset temp storage
@@ -189,11 +189,11 @@ public class HealthHelper(
SptProfile fullProfile,
double hydration,
double energy,
double temprature)
double temperature)
{
fullProfile.VitalityData.Hydration = hydration;
fullProfile.VitalityData.Energy = energy;
fullProfile.VitalityData.Temperature = temprature;
fullProfile.VitalityData.Temperature = temperature;
}
/// <summary>
@@ -209,27 +209,25 @@ public class HealthHelper(
{
// Get effects on body part from profile
var bodyPartEffects = postRaidBodyParts[bodyPartId.Key].Effects;
foreach (var effect in bodyPartEffects)
foreach (var(key, effectDetails) in bodyPartEffects)
{
var effectDetails = bodyPartEffects[effect.Key];
// Null guard
profileData.Health.BodyParts[bodyPartId.Key].Effects ??= new Dictionary<string, BodyPartEffectProperties>();
// Effect already exists on limb in server profile, skip
var profileBodyPartEffects = profileData.Health.BodyParts[bodyPartId.Key].Effects;
if (profileBodyPartEffects.TryGetValue(effect.Key, out _))
if (profileBodyPartEffects.ContainsKey(key))
{
if (effectsToIgnore.Contains(effect.Key))
if (effectsToIgnore.Contains(key))
// Get rid of certain effects we don't want to persist out of raid
{
profileBodyPartEffects[effect.Key] = null;
profileBodyPartEffects[key] = null;
}
continue;
}
if (effectsToIgnore.Contains(effect.Key))
if (effectsToIgnore.Contains(key))
// Do not pass some effects to out of raid profile
{
continue;
@@ -240,9 +238,9 @@ public class HealthHelper(
Time = effectDetails.Time ?? -1
};
// Add effect to server profile
if (profileBodyPartEffects.TryAdd(effect.Key, effectToAdd))
if (profileBodyPartEffects.TryAdd(key, effectToAdd))
{
profileBodyPartEffects[effect.Key] = effectToAdd;
profileBodyPartEffects[key] = effectToAdd;
}
}
}
@@ -454,7 +454,15 @@ public class LocationLifecycleService
if (!isPmc)
{
HandlePostRaidPlayerScav(sessionId, pmcProfile, scavProfile, isDead, isTransfer, isSurvived, request);
HandlePostRaidPlayerScav(
sessionId,
pmcProfile,
scavProfile,
isDead,
isTransfer,
isSurvived,
request);
return;
}
@@ -487,21 +495,24 @@ public class LocationLifecycleService
}
}
private void SendCoopTakenFenceMessage(string sessionId)
/// <summary>
/// After taking a COOP extract, send player a gift via mail
/// </summary>
/// <param name="sessionId">Player/Session id</param>
protected void SendCoopTakenFenceMessage(string sessionId)
{
// Generate reward for taking coop extract
// Generate randomised reward for taking coop extract
var loot = _lootGenerator.CreateRandomLoot(_traderConfig.Fence.CoopExtractGift);
var mailableLoot = new List<Item>();
var parentId = _hashUtil.Generate();
foreach (var itemAndChildren in loot)
{
// Set all root items parent to new id
itemAndChildren[0].ParentId = parentId;
itemAndChildren.FirstOrDefault().ParentId = parentId;
}
// Flatten
mailableLoot.AddRange(loot.SelectMany(x => x));
List<Item> mailableLoot = [..loot.SelectMany(x => x)];
// Send message from fence giving player reward generated above
_mailSendService.SendLocalisedNpcMessageToPlayer(
@@ -522,7 +533,7 @@ public class LocationLifecycleService
protected bool ExtractWasViaCar(string extractName)
{
// exit name is undefined on death
if (extractName is null)
if (string.IsNullOrEmpty(extractName))
{
return false;
}