Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Apr 8, 2024
1 parent 7a8f32f commit 56f1e37
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Content.Server/Backmen/Disease/Cures/DiseaseCureSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.Backmen.Disease;
using Content.Shared.Bed.Sleep;
using Content.Shared.Buckle.Components;
using Content.Shared.Mobs.Components;

namespace Content.Server.Backmen.Disease.Cures;

Expand All @@ -15,6 +16,7 @@ public sealed partial class DiseaseCureSystem : EntitySystem
private EntityQuery<SleepingComponent> _sleepingComponentQuery;
private EntityQuery<BloodstreamComponent> _bloodstreamQuery;
private EntityQuery<TemperatureComponent> _temperatureQuery;
private EntityQuery<MobStateComponent> _mobStateQuery;

public override void Initialize()
{
Expand All @@ -24,11 +26,13 @@ public override void Initialize()
SubscribeLocalEvent<DiseaseCarrierComponent, DiseaseCureArgs<DiseaseBodyTemperatureCure>>(DiseaseBodyTemperatureCure);
SubscribeLocalEvent<DiseaseCarrierComponent, DiseaseCureArgs<DiseaseJustWaitCure>>(DiseaseJustWaitCure);
SubscribeLocalEvent<DiseaseCarrierComponent, DiseaseCureArgs<DiseaseReagentCure>>(DiseaseReagentCure);
SubscribeLocalEvent<DiseaseCarrierComponent, DiseaseCureArgs<DiseaseDeathCure>>(DiseaseDeathCure);

_buckleQuery = GetEntityQuery<BuckleComponent>();
_healOnBuckleQuery = GetEntityQuery<HealOnBuckleComponent>();
_sleepingComponentQuery = GetEntityQuery<SleepingComponent>();
_bloodstreamQuery = GetEntityQuery<BloodstreamComponent>();
_temperatureQuery = GetEntityQuery<TemperatureComponent>();
_mobStateQuery = GetEntityQuery<MobStateComponent>();
}
}
40 changes: 40 additions & 0 deletions Content.Server/Backmen/Disease/Cures/DiseaseDeathCure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Content.Shared.Backmen.Disease;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Prototypes;

namespace Content.Server.Backmen.Disease.Cures;

public sealed partial class DiseaseDeathCure : DiseaseCure
{
public override string CureText()
{
return Loc.GetString("diagnoser-cure-death");
}

public override object GenerateEvent(Entity<DiseaseCarrierComponent> ent, ProtoId<DiseasePrototype> disease)
{
return new DiseaseCureArgs<DiseaseDeathCure>(ent, disease, this);
}
}

public sealed partial class DiseaseCureSystem
{
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;

private void DiseaseDeathCure(Entity<DiseaseCarrierComponent> ent, ref DiseaseCureArgs<DiseaseDeathCure> args)
{
if(args.Handled)
return;

args.Handled = true;

if (!_mobStateQuery.TryGetComponent(ent, out var mobStateComponent))
return;

if (_mobStateSystem.IsIncapacitated(ent, mobStateComponent))
{
_disease.CureDisease(args.DiseasedEntity, args.Disease);
}
}
}
9 changes: 6 additions & 3 deletions Content.Server/Backmen/Disease/DiseaseSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ public override void Update(float frameTime)

foreach (var (carrier, disease) in _cureQueue)
{
if (carrier.Comp.Diseases.Count > 0) //This is reliable unlike testing Count == 0 right after removal for reasons I don't quite get
RemCompDeferred<DiseasedComponent>(carrier);
carrier.Comp.PastDiseases.Add(disease);
var d = carrier.Comp.Diseases.FirstOrDefault(x => x.ID == disease);
if (d != null)
{
carrier.Comp.Diseases.Remove(d);
if (d.Infectious)
{
carrier.Comp.PastDiseases.Add(disease);
}
}
if (carrier.Comp.Diseases.Count == 0) //This is reliable unlike testing Count == 0 right after removal for reasons I don't quite get
RemCompDeferred<DiseasedComponent>(carrier);
}
_cureQueue.Clear();

Expand Down
12 changes: 8 additions & 4 deletions Content.Server/Backmen/Disease/VaccineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public sealed class VaccineSystem : EntitySystem
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;

public override void Initialize()
Expand Down Expand Up @@ -258,14 +256,20 @@ private void OnExamined(EntityUid uid, DiseaseVaccineComponent vaxx, ExaminedEve
/// past diseases to give them immunity
/// IF they don't already have the disease.
/// </summary>
public void Vaccinate(DiseaseCarrierComponent carrier, DiseasePrototype disease)
public bool Vaccinate(DiseaseCarrierComponent carrier, DiseasePrototype disease)
{
foreach (var currentDisease in carrier.Diseases)
{
if (currentDisease.ID == disease.ID) //ID because of the way protoypes work
return;
return false;
}

if (!disease.Infectious)
{
return false;
}
carrier.PastDiseases.Add(disease.ID);
return true;
}

private void OnDoAfter(EntityUid uid, DiseaseVaccineComponent component, VaccineDoAfterEvent args)
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Medical/DefibrillatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorCo
{
_euiManager.OpenEui(new ReturnToBodyEui(mind, _mind), session);
}

// start-backmen: revenant
if (TryComp<Server.Revenant.Components.EssenceComponent>(target, out var essenceComponent))
{
essenceComponent.Harvested = false;
}
// end-backmen: revenant
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Backmen/Disease/DiseaseCarrierComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public sealed partial class DiseaseCarrierComponent : Component
/// Diseases the carrier has had, used for immunity.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public List<ProtoId<DiseasePrototype>> PastDiseases = new();
public HashSet<ProtoId<DiseasePrototype>> PastDiseases = new();

/// <summary>
/// All the diseases the carrier has or has had.
Expand All @@ -55,5 +55,5 @@ public sealed partial class DiseaseCarrierComponent : Component
/// rendering them immune.
/// </summary>
[DataField("naturalImmunities")]
public List<ProtoId<DiseasePrototype>>? NaturalImmunities;
public HashSet<ProtoId<DiseasePrototype>>? NaturalImmunities;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,22 @@
reagents:
- ReagentId: LotophagoiOil
Quantity: 100


- type: entity
parent: SmokeGrenade
id: XenoGrenade
name: xeno virus grenade
components:
- type: Sprite
sprite: Objects/Weapons/Grenades/tear_gas.rsi
- type: SmokeOnTrigger
duration: 5
spreadAmount: 20
solution:
reagents:
- ReagentId: FluorosulfuricAcid
Quantity: 20

- type: entity
parent: SmokeGrenade
id: AntiPsiGrenade
Expand All @@ -44,4 +59,4 @@
solution:
reagents:
- ReagentId: MindbreakerToxin
Quantity: 75
Quantity: 75

0 comments on commit 56f1e37

Please sign in to comment.