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(OnComponentInit); SubscribeLocalEvent(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 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 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 = 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"); } }