Basic bleeding mechanics (#6710)
This commit is contained in:
@@ -1,28 +1,136 @@
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Body.Components
|
||||
{
|
||||
[RegisterComponent, Friend(typeof(BloodstreamSystem))]
|
||||
public sealed class BloodstreamComponent : Component
|
||||
{
|
||||
public static string DefaultChemicalsSolutionName = "chemicals";
|
||||
public static string DefaultBloodSolutionName = "bloodstream";
|
||||
public static string DefaultBloodTemporarySolutionName = "bloodstreamTemporary";
|
||||
|
||||
public float AccumulatedFrametime = 0.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Max volume of internal solution storage
|
||||
/// How much is this entity currently bleeding?
|
||||
/// Higher numbers mean more blood lost every tick.
|
||||
///
|
||||
/// Goes down slowly over time, and items like bandages
|
||||
/// or clotting reagents can lower bleeding.
|
||||
/// </summary>
|
||||
[DataField("maxVolume")]
|
||||
public FixedPoint2 InitialMaxVolume = FixedPoint2.New(250);
|
||||
/// <remarks>
|
||||
/// This generally corresponds to an amount of damage and can't go above 100.
|
||||
/// </remarks>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float BleedAmount;
|
||||
|
||||
/// <summary>
|
||||
/// How much should bleeding should be reduced every update interval?
|
||||
/// </summary>
|
||||
[DataField("bleedReductionAmount")]
|
||||
public float BleedReductionAmount = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// What percentage of current blood is necessary to avoid dealing blood loss damage?
|
||||
/// </summary>
|
||||
[DataField("bloodlossThreshold")]
|
||||
public float BloodlossThreshold = 0.9f;
|
||||
|
||||
/// <summary>
|
||||
/// The base bloodloss damage to be incurred if below <see cref="BloodlossThreshold"/>
|
||||
/// </summary>
|
||||
[DataField("bloodlossDamage", required: true)]
|
||||
public DamageSpecifier BloodlossDamage = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The base bloodloss damage to be healed if above <see cref="BloodlossThreshold"/>
|
||||
/// </summary>
|
||||
[DataField("bloodlossHealDamage", required: true)]
|
||||
public DamageSpecifier BloodlossHealDamage = default!;
|
||||
|
||||
/// <summary>
|
||||
/// How frequently should this bloodstream update, in seconds?
|
||||
/// </summary>
|
||||
[DataField("updateInterval")]
|
||||
public float UpdateInterval = 5.0f;
|
||||
|
||||
// TODO shouldn't be hardcoded, should just use some organ simulation like bone marrow or smth.
|
||||
/// <summary>
|
||||
/// How much reagent of blood should be restored each update interval?
|
||||
/// </summary>
|
||||
[DataField("bloodRefreshAmount")]
|
||||
public float BloodRefreshAmount = 0.2f;
|
||||
|
||||
/// <summary>
|
||||
/// How much blood needs to be in the temporary solution in order to create a puddle?
|
||||
/// </summary>
|
||||
[DataField("bleedPuddleThreshold")]
|
||||
public FixedPoint2 BleedPuddleThreshold = 10.0f;
|
||||
|
||||
/// <summary>
|
||||
/// A modifier set prototype ID corresponding to how damage should be modified
|
||||
/// before taking it into account for bloodloss.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For example, piercing damage is increased while poison damage is nullified entirely.
|
||||
/// </remarks>
|
||||
[DataField("damageBleedModifiers", customTypeSerializer:typeof(PrototypeIdSerializer<DamageModifierSetPrototype>))]
|
||||
public string DamageBleedModifiers = "BloodlossHuman";
|
||||
|
||||
/// <summary>
|
||||
/// The sound to be played when a weapon instantly deals blood loss damage.
|
||||
/// </summary>
|
||||
[DataField("instantBloodSound")]
|
||||
public SoundSpecifier InstantBloodSound = new SoundCollectionSpecifier("blood");
|
||||
|
||||
// TODO probably damage bleed thresholds.
|
||||
|
||||
/// <summary>
|
||||
/// Max volume of internal chemical solution storage
|
||||
/// </summary>
|
||||
[DataField("chemicalMaxVolume")]
|
||||
public FixedPoint2 ChemicalMaxVolume = FixedPoint2.New(250);
|
||||
|
||||
/// <summary>
|
||||
/// Max volume of internal blood storage,
|
||||
/// and starting level of blood.
|
||||
/// </summary>
|
||||
[DataField("bloodMaxVolume")]
|
||||
public FixedPoint2 BloodMaxVolume = FixedPoint2.New(300);
|
||||
|
||||
/// <summary>
|
||||
/// Which reagent is considered this entities 'blood'?
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Slime-people might use slime as their blood or something like that.
|
||||
/// </remarks>
|
||||
[DataField("bloodReagent")]
|
||||
public string BloodReagent = "Blood";
|
||||
|
||||
/// <summary>
|
||||
/// Internal solution for reagent storage
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Solution Solution = default!;
|
||||
public Solution ChemicalSolution = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Internal solution for blood storage
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Solution BloodSolution = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Temporary blood solution.
|
||||
/// When blood is lost, it goes to this solution, and when this
|
||||
/// solution hits a certain cap, the blood is actually spilled as a puddle.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Solution BloodTemporarySolution = default!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Body.Components
|
||||
/// From which solution will this metabolizer attempt to metabolize chemicals
|
||||
/// </summary>
|
||||
[DataField("solution")]
|
||||
public string SolutionName { get; set; } = BloodstreamSystem.DefaultSolutionName;
|
||||
public string SolutionName { get; set; } = BloodstreamComponent.DefaultChemicalsSolutionName;
|
||||
|
||||
/// <summary>
|
||||
/// Does this component use a solution on it's parent entity (the body) or itself
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Server.Body.Components
|
||||
/// What solution should this stomach push reagents into, on the body?
|
||||
/// </summary>
|
||||
[DataField("bodySolutionName")]
|
||||
public string BodySolutionName = BloodstreamSystem.DefaultSolutionName;
|
||||
public string BodySolutionName = BloodstreamComponent.DefaultChemicalsSolutionName;
|
||||
|
||||
/// <summary>
|
||||
/// Initial internal solution storage volume
|
||||
|
||||
Reference in New Issue
Block a user