* initial commit * reapply 38126 * fix rootable * someone missed an important minus sign here * try this * fix * fix * reenable crit hits * cleanup * fix status time dirtying * fix * camelCase
59 lines
2.6 KiB
C#
59 lines
2.6 KiB
C#
using Content.Shared.Body.Components;
|
|
using Content.Shared.Body.Systems;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.Forensics;
|
|
|
|
namespace Content.Server.Body.Systems;
|
|
|
|
public sealed class BloodstreamSystem : SharedBloodstreamSystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<BloodstreamComponent, ComponentInit>(OnComponentInit);
|
|
SubscribeLocalEvent<BloodstreamComponent, GenerateDnaEvent>(OnDnaGenerated);
|
|
}
|
|
|
|
// not sure if we can move this to shared or not
|
|
// it would certainly help if SolutionContainer was documented
|
|
// but since we usually don't add the component dynamically to entities we can keep this unpredicted for now
|
|
private void OnComponentInit(Entity<BloodstreamComponent> entity, ref ComponentInit args)
|
|
{
|
|
if (!SolutionContainer.EnsureSolution(entity.Owner,
|
|
entity.Comp.ChemicalSolutionName,
|
|
out var chemicalSolution) ||
|
|
!SolutionContainer.EnsureSolution(entity.Owner,
|
|
entity.Comp.BloodSolutionName,
|
|
out var bloodSolution) ||
|
|
!SolutionContainer.EnsureSolution(entity.Owner,
|
|
entity.Comp.BloodTemporarySolutionName,
|
|
out var tempSolution))
|
|
return;
|
|
|
|
chemicalSolution.MaxVolume = entity.Comp.ChemicalMaxVolume;
|
|
bloodSolution.MaxVolume = entity.Comp.BloodMaxVolume;
|
|
tempSolution.MaxVolume = entity.Comp.BleedPuddleThreshold * 4; // give some leeway, for chemstream as well
|
|
|
|
// Fill blood solution with BLOOD
|
|
// The DNA string might not be initialized yet, but the reagent data gets updated in the GenerateDnaEvent subscription
|
|
bloodSolution.AddReagent(new ReagentId(entity.Comp.BloodReagent, GetEntityBloodData(entity.Owner)), entity.Comp.BloodMaxVolume - bloodSolution.Volume);
|
|
}
|
|
|
|
// forensics is not predicted yet
|
|
private void OnDnaGenerated(Entity<BloodstreamComponent> entity, ref GenerateDnaEvent args)
|
|
{
|
|
if (SolutionContainer.ResolveSolution(entity.Owner, entity.Comp.BloodSolutionName, ref entity.Comp.BloodSolution, out var bloodSolution))
|
|
{
|
|
foreach (var reagent in bloodSolution.Contents)
|
|
{
|
|
List<ReagentData> reagentData = reagent.Reagent.EnsureReagentData();
|
|
reagentData.RemoveAll(x => x is DnaData);
|
|
reagentData.AddRange(GetEntityBloodData(entity.Owner));
|
|
}
|
|
}
|
|
else
|
|
Log.Error("Unable to set bloodstream DNA, solution entity could not be resolved");
|
|
}
|
|
}
|