using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Rejuvenate;
+using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
-
+ [Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedDrunkSystem _drunkSystem = default!;
- // TODO here
- // Update over time. Modify bloodloss damage in accordance with (amount of blood / max blood level), and reduce bleeding over time
- // Sub to damage changed event and modify bloodloss if incurring large hits of slashing/piercing
-
public override void Initialize()
{
base.Initialize();
{
base.Update(frameTime);
- foreach (var bloodstream in EntityManager.EntityQuery<BloodstreamComponent>())
+ var query = new EntityQueryEnumerator<BloodstreamComponent>();
+ while (query.MoveNext(out var uid, out var bloodstream))
{
bloodstream.AccumulatedFrametime += frameTime;
bloodstream.AccumulatedFrametime -= bloodstream.UpdateInterval;
- var uid = bloodstream.Owner;
if (TryComp<MobStateComponent>(uid, out var state) && _mobStateSystem.IsDead(uid, state))
continue;
// as well as stop their bleeding to a certain extent.
if (bloodstream.BleedAmount > 0)
{
- TryModifyBloodLevel(uid, (-bloodstream.BleedAmount) / 20, bloodstream);
+ TryModifyBloodLevel(uid, (-bloodstream.BleedAmount) / 10, bloodstream);
TryModifyBleedAmount(uid, -bloodstream.BleedReductionAmount, bloodstream);
}
if (args.DamageDelta is null)
return;
+ // definitely don't make them bleed if they got healed
+ if (!args.DamageIncreased)
+ return;
+
// TODO probably cache this or something. humans get hurt a lot
if (!_prototypeManager.TryIndex<DamageModifierSetPrototype>(component.DamageBleedModifiers, out var modifiers))
return;
if (totalFloat > 0 && _robustRandom.Prob(prob))
{
TryModifyBloodLevel(uid, (-total) / 5, component);
- SoundSystem.Play(component.InstantBloodSound.GetSound(), Filter.Pvs(uid), uid, AudioParams.Default);
+ _audio.PlayPvs(component.InstantBloodSound, uid);
}
else if (totalFloat < 0 && oldBleedAmount > 0 && _robustRandom.Prob(healPopupProb))
{
// because it's burn damage that cauterized their wounds.
// We'll play a special sound and popup for feedback.
- SoundSystem.Play(component.BloodHealedSound.GetSound(), Filter.Pvs(uid), uid, AudioParams.Default);
+ _audio.PlayPvs(component.BloodHealedSound, uid);
_popupSystem.PopupEntity(Loc.GetString("bloodstream-component-wounds-cauterized"), uid,
uid, PopupType.Medium);
}