MedibotComponent.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Content.Shared.Chemistry.Reagent;
  2. using Content.Shared.FixedPoint;
  3. using Content.Shared.Mobs;
  4. using Robust.Shared.Audio;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Shared.Silicons.Bots;
  7. /// <summary>
  8. /// Used by the server for NPC medibot injection.
  9. /// Currently no clientside prediction done, only exists in shared for emag handling.
  10. /// </summary>
  11. [RegisterComponent]
  12. [Access(typeof(MedibotSystem))]
  13. public sealed partial class MedibotComponent : Component
  14. {
  15. /// <summary>
  16. /// Treatments the bot will apply for each mob state.
  17. /// </summary>
  18. [DataField(required: true)]
  19. public Dictionary<MobState, MedibotTreatment> Treatments = new();
  20. /// <summary>
  21. /// Sound played after injecting a patient.
  22. /// </summary>
  23. [DataField("injectSound")]
  24. public SoundSpecifier InjectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg");
  25. }
  26. /// <summary>
  27. /// An injection to treat the patient with.
  28. /// </summary>
  29. [DataDefinition]
  30. public sealed partial class MedibotTreatment
  31. {
  32. /// <summary>
  33. /// Reagent to inject into the patient.
  34. /// </summary>
  35. [DataField(required: true)]
  36. public ProtoId<ReagentPrototype> Reagent = string.Empty;
  37. /// <summary>
  38. /// How much of the reagent to inject.
  39. /// </summary>
  40. [DataField(required: true)]
  41. public FixedPoint2 Quantity;
  42. /// <summary>
  43. /// Do nothing when the patient is at or below this total damage.
  44. /// When null this will inject meds into completely healthy patients.
  45. /// </summary>
  46. [DataField]
  47. public FixedPoint2? MinDamage;
  48. /// <summary>
  49. /// Do nothing when the patient is at or above this total damage.
  50. /// Useful for tricordrazine which does nothing above 50 damage.
  51. /// </summary>
  52. [DataField]
  53. public FixedPoint2? MaxDamage;
  54. /// <summary>
  55. /// Returns whether the treatment will probably work for an amount of damage.
  56. /// Doesn't account for specific damage types only total amount.
  57. /// </summary>
  58. public bool IsValid(FixedPoint2 damage)
  59. {
  60. return (MaxDamage == null || damage < MaxDamage) && (MinDamage == null || damage > MinDamage);
  61. }
  62. }