medibot fixes and refactoring (#21852)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Mobs;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Silicons.Bots;
|
||||
|
||||
@@ -13,30 +15,56 @@ namespace Content.Shared.Silicons.Bots;
|
||||
public sealed partial class MedibotComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Med the bot will inject when UNDER the standard med damage threshold.
|
||||
/// Treatments the bot will apply for each mob state.
|
||||
/// </summary>
|
||||
[DataField("standardMed", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
public string StandardMed = "Tricordrazine";
|
||||
|
||||
[DataField("standardMedAmount")]
|
||||
public float StandardMedAmount = 30f;
|
||||
|
||||
/// <summary>
|
||||
/// Med the bot will inject when OVER the emergency med damage threshold.
|
||||
/// </summary>
|
||||
[DataField("emergencyMed", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
public string EmergencyMed = "Inaprovaline";
|
||||
|
||||
[DataField("emergencyMedAmount")]
|
||||
public float EmergencyMedAmount = 15f;
|
||||
[DataField(required: true)]
|
||||
public Dictionary<MobState, MedibotTreatment> Treatments = new();
|
||||
|
||||
/// <summary>
|
||||
/// Sound played after injecting a patient.
|
||||
/// </summary>
|
||||
[DataField("injectSound")]
|
||||
public SoundSpecifier InjectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg");
|
||||
|
||||
public const float StandardMedDamageThreshold = 0f;
|
||||
public const float StandardMedDamageThresholdStop = 50f;
|
||||
public const float EmergencyMedDamageThreshold = 100f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An injection to treat the patient with.
|
||||
/// </summary>
|
||||
[DataDefinition]
|
||||
public sealed partial class MedibotTreatment
|
||||
{
|
||||
/// <summary>
|
||||
/// Reagent to inject into the patient.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public ProtoId<ReagentPrototype> Reagent = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// How much of the reagent to inject.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public FixedPoint2 Quantity;
|
||||
|
||||
/// <summary>
|
||||
/// Do nothing when the patient is at or below this total damage.
|
||||
/// When null this will inject meds into completely healthy patients.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public FixedPoint2? MinDamage;
|
||||
|
||||
/// <summary>
|
||||
/// Do nothing when the patient is at or above this total damage.
|
||||
/// Useful for tricordrazine which does nothing above 50 damage.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public FixedPoint2? MaxDamage;
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the treatment will probably work for an amount of damage.
|
||||
/// Doesn't account for specific damage types only total amount.
|
||||
/// </summary>
|
||||
public bool IsValid(FixedPoint2 damage)
|
||||
{
|
||||
return (MaxDamage == null || damage < MaxDamage) && (MinDamage == null || damage > MinDamage);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user