Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Разумная болезнь опять #157

Merged
merged 16 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Content.Client/_Sunrise/Disease/DiseaseRoleSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Content.Shared.Humanoid;
using Content.Shared._Sunrise.Disease;
namespace Content.Client._Sunrise.Disease;

public sealed class DiseaseRoleSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<ClientInfectEvent>(OnInfect);
}



private void OnInfect(ClientInfectEvent ev)
{

var target = GetEntity(ev.Infected);
var performer = GetEntity(ev.Owner);

if (!TryComp<HumanoidAppearanceComponent>(target, out var body))
return;

var sick = EnsureComp<SickComponent>(target);
sick.owner = performer;
sick.Inited = true;
if (TryComp<DiseaseRoleComponent>(performer, out var comp))
{
comp.Infected.Add(target);
}
}

}
49 changes: 49 additions & 0 deletions Content.Client/_Sunrise/Disease/SickSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.NPC;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Client.Player;
using Robust.Shared.Prototypes;
using Content.Shared._Sunrise.Disease;
using Content.Shared.Ghost;
namespace Content.Client._Sunrise.Disease;
public sealed class SickSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SickComponent, GetStatusIconsEvent>(OnGetStatusIcon);
SubscribeNetworkEvent<UpdateInfectionsEvent>(OnUpdateInfect);
}

private void OnUpdateInfect(UpdateInfectionsEvent args)
{
EnsureComp<SickComponent>(GetEntity(args.Uid)).Inited = true;
}

private void OnGetStatusIcon(EntityUid uid, SickComponent component, ref GetStatusIconsEvent args)
{
if (component.Inited)
{
if (_playerManager.LocalEntity != null)
{
if (HasComp<DiseaseRoleComponent>(_playerManager.LocalEntity.Value) || HasComp<GhostComponent>(_playerManager.LocalEntity.Value))
{
if (!_mobState.IsDead(uid) &&
!HasComp<ActiveNPCComponent>(uid) &&
TryComp<MindContainerComponent>(uid, out var mindContainer) &&
mindContainer.ShowExamineInfo)
{
args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(component.Icon));
}
}
}
}
}
}
10 changes: 10 additions & 0 deletions Content.Client/_Sunrise/Disease/VaccinatorSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using Content.Shared.Chemistry.EntitySystems;

namespace Content.Client.Chemistry.EntitySystems;

/// <inheritdoc/>
public sealed class VaccinatorSystem : SharedVaccinatorSystem
{

}
6 changes: 3 additions & 3 deletions Content.Server/Traits/Assorted/NarcolepsyComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;

namespace Content.Server.Traits.Assorted;

Expand All @@ -12,13 +12,13 @@ public sealed partial class NarcolepsyComponent : Component
/// The random time between incidents, (min, max).
/// </summary>
[DataField("timeBetweenIncidents", required: true)]
public Vector2 TimeBetweenIncidents { get; set; } // Sunrise-Edit
public Vector2 TimeBetweenIncidents = new Vector2(300, 600);

/// <summary>
/// The duration of incidents, (min, max).
/// </summary>
[DataField("durationOfIncident", required: true)]
public Vector2 DurationOfIncident { get; set; } // Sunrise-Edit
public Vector2 DurationOfIncident = new Vector2(10, 30);

public float NextIncidentTime;
}
9 changes: 9 additions & 0 deletions Content.Server/Traits/Assorted/NarcolepsySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Bed.Sleep;
using Content.Shared.StatusEffect;
using Robust.Shared.Random;
using System.Numerics;

namespace Content.Server.Traits.Assorted;

Expand Down Expand Up @@ -36,6 +37,14 @@ public void AdjustNarcolepsyTimer(EntityUid uid, int TimerReset, NarcolepsyCompo
narcolepsy.NextIncidentTime = TimerReset;
}

public void SetNarcolepsy(EntityUid uid, Vector2 timeBetweenIncidents, Vector2 durationOfIncident, NarcolepsyComponent? narcolepsy = null)
{
if (!Resolve(uid, ref narcolepsy, false))
return;
narcolepsy.DurationOfIncident = durationOfIncident;
narcolepsy.TimeBetweenIncidents = timeBetweenIncidents;
}

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand Down
33 changes: 33 additions & 0 deletions Content.Server/_Sunrise/Disease/CureDiseaseInfection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
using Content.Shared._Sunrise.Disease;
using Content.Shared.EntityEffects;
public sealed partial class CureDiseaseInfection : EntityEffect
{
[DataField]
public bool Innoculate;

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
{
if (Innoculate)
return "ок";

return "окей";
}

public override void Effect(EntityEffectBaseArgs args)
{
var entityManager = args.EntityManager;
if (!entityManager.HasComponent<SickComponent>(args.TargetEntity)) return;
if (entityManager.TryGetComponent<SickComponent>(args.TargetEntity, out var sick))
{
if (entityManager.TryGetComponent<DiseaseRoleComponent>(sick.owner, out var disease))
{
var comp = entityManager.EnsureComponent<DiseaseVaccineTimerComponent>(args.TargetEntity);
comp.Immune = Innoculate;
comp.Delay = TimeSpan.FromMinutes(2) + TimeSpan.FromSeconds(disease.Shield * 30);
}
}
}
}
59 changes: 59 additions & 0 deletions Content.Server/_Sunrise/Disease/DiseaseImmuneClothingSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory.Events;
using Content.Shared._Sunrise.Disease;
using Content.Shared.Examine;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
namespace Content.Server._Sunrise.Disease;

public sealed class DiseaseImmuneClothingSystem : EntitySystem
{
[Dependency] private readonly ExamineSystemShared _examine = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DiseaseImmuneClothingComponent, GotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<DiseaseImmuneClothingComponent, GotUnequippedEvent>(OnGotUnequipped);
SubscribeLocalEvent<DiseaseImmuneClothingComponent, GetVerbsEvent<ExamineVerb>>(OnArmorVerbExamine);
}

private void OnGotEquipped(EntityUid uid, DiseaseImmuneClothingComponent component, GotEquippedEvent args)
{
if (!TryComp(uid, out ClothingComponent? clothing))
return;
var isCorrectSlot = clothing.Slots.HasFlag(args.SlotFlags);
if (!isCorrectSlot)
return;

EnsureComp<DiseaseTempImmuneComponent>(args.Equipee).Prob += component.Prob;
if (Comp<DiseaseTempImmuneComponent>(args.Equipee).Prob > 1) Comp<DiseaseTempImmuneComponent>(args.Equipee).Prob = 1;

component.IsActive = true;
}

private void OnGotUnequipped(EntityUid uid, DiseaseImmuneClothingComponent component, GotUnequippedEvent args)
{
if (!component.IsActive)
return;

EnsureComp<DiseaseTempImmuneComponent>(args.Equipee).Prob -= component.Prob;
if (Comp<DiseaseTempImmuneComponent>(args.Equipee).Prob < 0) Comp<DiseaseTempImmuneComponent>(args.Equipee).Prob = 0;

component.IsActive = false;
}

private void OnArmorVerbExamine(EntityUid uid, DiseaseImmuneClothingComponent component, GetVerbsEvent<ExamineVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
return;

var examineMarkup = new FormattedMessage();
examineMarkup.TryAddMarkup($"Защищает от заражения на {Convert.ToInt32(component.Prob * 100)}%", out var _);

_examine.AddDetailedExamineVerb(args, component, examineMarkup,
"Стерильность", "/Textures/Interface/VerbIcons/dot.svg.192dpi.png",
"Изучить показатели стерильности.");
}

}
Loading
Loading