Build 0.21.6.0

This commit is contained in:
Markus Isberg
2023-01-31 18:01:29 +02:00
parent 697ec52120
commit 25fa5a9552
145 changed files with 2317 additions and 1145 deletions
@@ -14,6 +14,13 @@ namespace Barotrauma
/// </summary>
public bool Discarded;
public void ApplyDeathEffects()
{
RespawnManager.ReduceCharacterSkills(this);
RemoveSavedStatValuesOnDeath();
CauseOfDeath = null;
}
partial void OnSkillChanged(Identifier skillIdentifier, float prevLevel, float newLevel)
{
if (Character == null || Character.Removed) { return; }
@@ -0,0 +1,51 @@
#nullable enable
using System;
using System.Collections.Generic;
using Barotrauma.Networking;
namespace Barotrauma
{
internal static class HealingCooldown
{
private static readonly Dictionary<Client, DateTimeOffset> HealingCooldowns = new();
// Little bit less than client's 0.5 second cooldown to account for latency
private const float CooldownDuration = 0.4f;
public static bool IsOnCooldown(Client client)
{
RemoveExpiredCooldowns();
return HealingCooldowns.ContainsKey(client);
}
public static void SetCooldown(Client client)
{
RemoveExpiredCooldowns();
DateTimeOffset newCooldown = DateTimeOffset.UtcNow.AddSeconds(CooldownDuration);
HealingCooldowns[client] = newCooldown;
}
private static void RemoveExpiredCooldowns()
{
HashSet<Client>? expiredCooldowns = null;
DateTimeOffset now = DateTimeOffset.UtcNow;
foreach (var (client, cooldown) in HealingCooldowns)
{
if (now < cooldown) { continue; }
expiredCooldowns ??= new HashSet<Client>();
expiredCooldowns.Add(client);
}
if (expiredCooldowns is null) { return; }
foreach (Client expiredCooldown in expiredCooldowns)
{
HealingCooldowns.Remove(expiredCooldown);
}
}
}
}