Files
tbd-station-14/Content.Server/Medical/VomitSystem.cs
faint 8b6996cbae DNA basics (#14724)
* DNA component

* Commit numba 2

* Added DNA into Station Records Computer

* commit numba 3

* commit numba 4

* Vomit also contain DNA component now

* fixed DNA field not clearing after scanning another item

* commit numba 10
Drinking leaves DNA on an object. Breaking glasses, bottles and beakers leave DNA and leave fingerprints/fibers with 40% chance on glass shards. + lotta fixes

* 11

* 12

* 14

* Added DNA guide entry

* FIX
2023-03-30 22:49:25 -06:00

80 lines
3.5 KiB
C#

using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Fluids.Components;
using Content.Server.Forensics;
using Content.Server.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Server.Popups;
using Content.Server.Stunnable;
using Content.Shared.Audio;
using Content.Shared.IdentityManagement;
using Content.Shared.StatusEffect;
using Robust.Shared.Audio;
using Robust.Shared.Player;
namespace Content.Server.Medical
{
public sealed class VomitSystem : EntitySystem
{
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly SolutionContainerSystem _solutionSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly ThirstSystem _thirstSystem = default!;
/// <summary>
/// Make an entity vomit, if they have a stomach.
/// </summary>
public void Vomit(EntityUid uid, float thirstAdded = -40f, float hungerAdded = -40f)
{
// Main requirement: You have a stomach
var stomachList = _bodySystem.GetBodyOrganComponents<StomachComponent>(uid);
if (stomachList.Count == 0)
{
return;
}
// Vomiting makes you hungrier and thirstier
if (TryComp<HungerComponent>(uid, out var hunger))
hunger.UpdateFood(hungerAdded);
if (TryComp<ThirstComponent>(uid, out var thirst))
_thirstSystem.UpdateThirst(thirst, thirstAdded);
// It fully empties the stomach, this amount from the chem stream is relatively small
float solutionSize = (Math.Abs(thirstAdded) + Math.Abs(hungerAdded)) / 6;
// Apply a bit of slowdown
if (TryComp<StatusEffectsComponent>(uid, out var status))
_stunSystem.TrySlowdown(uid, TimeSpan.FromSeconds(solutionSize), true, 0.5f, 0.5f, status);
var puddle = EntityManager.SpawnEntity("PuddleVomit", Transform(uid).Coordinates);
var forensics = EnsureComp<ForensicsComponent>(puddle);
if (TryComp<DnaComponent>(uid, out var dna))
forensics.DNAs.Add(dna.DNA);
var puddleComp = Comp<PuddleComponent>(puddle);
SoundSystem.Play("/Audio/Effects/Fluids/splat.ogg", Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.2f).WithVolume(-4f));
_popupSystem.PopupEntity(Loc.GetString("disease-vomit", ("person", Identity.Entity(uid, EntityManager))), uid);
// Get the solution of the puddle we spawned
if (!_solutionSystem.TryGetSolution(puddle, puddleComp.SolutionName, out var puddleSolution))
return;
// Empty the stomach out into it
foreach (var stomach in stomachList)
{
if (_solutionSystem.TryGetSolution(stomach.Comp.Owner, StomachSystem.DefaultSolutionName, out var sol))
_solutionSystem.TryAddSolution(puddle, puddleSolution, sol);
}
// And the small bit of the chem stream from earlier
if (TryComp<BloodstreamComponent>(uid, out var bloodStream))
{
var temp = bloodStream.ChemicalSolution.SplitSolution(solutionSize);
_solutionSystem.TryAddSolution(puddle, puddleSolution, temp);
}
}
}
}