Port research disks from nyano (#9081)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -16,11 +16,13 @@ using Robust.Shared.Player;
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Content.Shared.Tools.Components;
|
using Content.Shared.Tools.Components;
|
||||||
|
using Content.Server.Station.Systems;
|
||||||
|
|
||||||
namespace Content.Server.Disease
|
namespace Content.Server.Disease
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
/// Everything that's about disease diangosis and machines is in here
|
/// Everything that's about disease diangosis and machines is in here
|
||||||
|
/// </summary>
|
||||||
public sealed class DiseaseDiagnosisSystem : EntitySystem
|
public sealed class DiseaseDiagnosisSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||||
@@ -29,6 +31,8 @@ namespace Content.Server.Disease
|
|||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||||
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
||||||
|
|
||||||
|
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -36,9 +40,9 @@ namespace Content.Server.Disease
|
|||||||
SubscribeLocalEvent<DiseaseSwabComponent, ExaminedEvent>(OnExamined);
|
SubscribeLocalEvent<DiseaseSwabComponent, ExaminedEvent>(OnExamined);
|
||||||
SubscribeLocalEvent<DiseaseDiagnoserComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
SubscribeLocalEvent<DiseaseDiagnoserComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
||||||
SubscribeLocalEvent<DiseaseVaccineCreatorComponent, AfterInteractUsingEvent>(OnAfterInteractUsingVaccine);
|
SubscribeLocalEvent<DiseaseVaccineCreatorComponent, AfterInteractUsingEvent>(OnAfterInteractUsingVaccine);
|
||||||
/// Visuals
|
// Visuals
|
||||||
SubscribeLocalEvent<DiseaseMachineComponent, PowerChangedEvent>(OnPowerChanged);
|
SubscribeLocalEvent<DiseaseMachineComponent, PowerChangedEvent>(OnPowerChanged);
|
||||||
/// Private Events
|
// Private Events
|
||||||
SubscribeLocalEvent<DiseaseDiagnoserComponent, DiseaseMachineFinishedEvent>(OnDiagnoserFinished);
|
SubscribeLocalEvent<DiseaseDiagnoserComponent, DiseaseMachineFinishedEvent>(OnDiagnoserFinished);
|
||||||
SubscribeLocalEvent<DiseaseVaccineCreatorComponent, DiseaseMachineFinishedEvent>(OnVaccinatorFinished);
|
SubscribeLocalEvent<DiseaseVaccineCreatorComponent, DiseaseMachineFinishedEvent>(OnVaccinatorFinished);
|
||||||
SubscribeLocalEvent<TargetSwabSuccessfulEvent>(OnTargetSwabSuccessful);
|
SubscribeLocalEvent<TargetSwabSuccessfulEvent>(OnTargetSwabSuccessful);
|
||||||
@@ -55,26 +59,29 @@ namespace Content.Server.Disease
|
|||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
foreach (var uid in AddQueue)
|
foreach (var uid in AddQueue)
|
||||||
|
{
|
||||||
EnsureComp<DiseaseMachineRunningComponent>(uid);
|
EnsureComp<DiseaseMachineRunningComponent>(uid);
|
||||||
|
}
|
||||||
|
|
||||||
AddQueue.Clear();
|
AddQueue.Clear();
|
||||||
foreach (var uid in RemoveQueue)
|
foreach (var uid in RemoveQueue)
|
||||||
|
{
|
||||||
RemComp<DiseaseMachineRunningComponent>(uid);
|
RemComp<DiseaseMachineRunningComponent>(uid);
|
||||||
|
}
|
||||||
|
|
||||||
RemoveQueue.Clear();
|
RemoveQueue.Clear();
|
||||||
|
|
||||||
foreach (var (runningComp, diseaseMachine) in EntityQuery<DiseaseMachineRunningComponent, DiseaseMachineComponent>(false))
|
foreach (var (_, diseaseMachine) in EntityQuery<DiseaseMachineRunningComponent, DiseaseMachineComponent>())
|
||||||
{
|
{
|
||||||
if (diseaseMachine.Accumulator < diseaseMachine.Delay)
|
diseaseMachine.Accumulator += frameTime;
|
||||||
{
|
|
||||||
diseaseMachine.Accumulator += frameTime;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
diseaseMachine.Accumulator = 0;
|
while (diseaseMachine.Accumulator < diseaseMachine.Delay)
|
||||||
var ev = new DiseaseMachineFinishedEvent(diseaseMachine);
|
{
|
||||||
RaiseLocalEvent(diseaseMachine.Owner, ev, false);
|
diseaseMachine.Accumulator -= diseaseMachine.Delay;
|
||||||
RemoveQueue.Enqueue(diseaseMachine.Owner);
|
var ev = new DiseaseMachineFinishedEvent(diseaseMachine);
|
||||||
|
RaiseLocalEvent(diseaseMachine.Owner, ev);
|
||||||
|
RemoveQueue.Enqueue(diseaseMachine.Owner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +252,7 @@ namespace Content.Server.Disease
|
|||||||
report.AddMarkup(cureResistLine);
|
report.AddMarkup(cureResistLine);
|
||||||
report.PushNewline();
|
report.PushNewline();
|
||||||
|
|
||||||
/// Add Cures
|
// Add Cures
|
||||||
if (disease.Cures.Count == 0)
|
if (disease.Cures.Count == 0)
|
||||||
{
|
{
|
||||||
report.AddMarkup(Loc.GetString("diagnoser-no-cures"));
|
report.AddMarkup(Loc.GetString("diagnoser-no-cures"));
|
||||||
@@ -265,6 +272,17 @@ namespace Content.Server.Disease
|
|||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ServerHasDisease(DiseaseServerComponent server, DiseasePrototype disease)
|
||||||
|
{
|
||||||
|
bool has = false;
|
||||||
|
foreach (var serverDisease in server.Diseases)
|
||||||
|
{
|
||||||
|
if (serverDisease.ID == disease.ID)
|
||||||
|
has = true;
|
||||||
|
}
|
||||||
|
return has;
|
||||||
|
}
|
||||||
///
|
///
|
||||||
/// Appearance stuff
|
/// Appearance stuff
|
||||||
///
|
///
|
||||||
@@ -327,18 +345,41 @@ namespace Content.Server.Disease
|
|||||||
var isPowered = this.IsPowered(uid, EntityManager);
|
var isPowered = this.IsPowered(uid, EntityManager);
|
||||||
UpdateAppearance(uid, isPowered, false);
|
UpdateAppearance(uid, isPowered, false);
|
||||||
// spawn a piece of paper.
|
// spawn a piece of paper.
|
||||||
var printed = EntityManager.SpawnEntity(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
var printed = Spawn(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
||||||
|
|
||||||
if (!TryComp<PaperComponent>(printed, out var paper))
|
if (!TryComp<PaperComponent>(printed, out var paper))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var reportTitle = string.Empty;
|
string reportTitle;
|
||||||
FormattedMessage contents = new();
|
FormattedMessage contents = new();
|
||||||
if (args.Machine.Disease != null)
|
if (args.Machine.Disease != null)
|
||||||
{
|
{
|
||||||
reportTitle = Loc.GetString("diagnoser-disease-report", ("disease", args.Machine.Disease.Name));
|
reportTitle = Loc.GetString("diagnoser-disease-report", ("disease", args.Machine.Disease.Name));
|
||||||
contents = AssembleDiseaseReport(args.Machine.Disease);
|
contents = AssembleDiseaseReport(args.Machine.Disease);
|
||||||
} else
|
|
||||||
|
var known = false;
|
||||||
|
|
||||||
|
foreach (var server in EntityQuery<DiseaseServerComponent>(true))
|
||||||
|
{
|
||||||
|
if (_stationSystem.GetOwningStation(server.Owner) != _stationSystem.GetOwningStation(uid))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (ServerHasDisease(server, args.Machine.Disease))
|
||||||
|
{
|
||||||
|
known = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
server.Diseases.Add(args.Machine.Disease);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!known)
|
||||||
|
{
|
||||||
|
Spawn("ResearchDisk5000", Transform(uid).Coordinates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
reportTitle = Loc.GetString("diagnoser-disease-report-none");
|
reportTitle = Loc.GetString("diagnoser-disease-report-none");
|
||||||
contents.AddMarkup(Loc.GetString("diagnoser-disease-report-none-contents"));
|
contents.AddMarkup(Loc.GetString("diagnoser-disease-report-none-contents"));
|
||||||
@@ -351,13 +392,13 @@ namespace Content.Server.Disease
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prints a vaccine that will vaccinate
|
/// Prints a vaccine that will vaccinate
|
||||||
/// against the disease on the inserted swab.
|
/// against the disease on the inserted swab.
|
||||||
/// <summary>
|
/// </summary>
|
||||||
private void OnVaccinatorFinished(EntityUid uid, DiseaseVaccineCreatorComponent component, DiseaseMachineFinishedEvent args)
|
private void OnVaccinatorFinished(EntityUid uid, DiseaseVaccineCreatorComponent component, DiseaseMachineFinishedEvent args)
|
||||||
{
|
{
|
||||||
UpdateAppearance(uid, this.IsPowered(uid, EntityManager), false);
|
UpdateAppearance(uid, this.IsPowered(uid, EntityManager), false);
|
||||||
|
|
||||||
// spawn a vaccine
|
// spawn a vaccine
|
||||||
var vaxx = EntityManager.SpawnEntity(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
var vaxx = Spawn(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
||||||
|
|
||||||
if (!TryComp<DiseaseVaccineComponent>(vaxx, out var vaxxComp))
|
if (!TryComp<DiseaseVaccineComponent>(vaxx, out var vaxxComp))
|
||||||
return;
|
return;
|
||||||
|
|||||||
15
Content.Server/Disease/Server/DiseaseServerComponent.cs
Normal file
15
Content.Server/Disease/Server/DiseaseServerComponent.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Content.Shared.Disease;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Content.Server.Disease.Components
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class DiseaseServerComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Which diseases this server has information on.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public List<DiseasePrototype> Diseases = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Content.Server/Research/Disk/ResearchDiskComponent.cs
Normal file
9
Content.Server/Research/Disk/ResearchDiskComponent.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Content.Server.Research.Disk
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class ResearchDiskComponent : Component
|
||||||
|
{
|
||||||
|
[DataField("points")]
|
||||||
|
public int Points = 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
30
Content.Server/Research/Disk/ResearchDiskSystem.cs
Normal file
30
Content.Server/Research/Disk/ResearchDiskSystem.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Server.Research.Components;
|
||||||
|
using Content.Server.Popups;
|
||||||
|
using Robust.Shared.Player;
|
||||||
|
|
||||||
|
namespace Content.Server.Research.Disk
|
||||||
|
{
|
||||||
|
public sealed class ResearchDiskSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<ResearchDiskComponent, AfterInteractEvent>(OnAfterInteract);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAfterInteract(EntityUid uid, ResearchDiskComponent component, AfterInteractEvent args)
|
||||||
|
{
|
||||||
|
if (!args.CanReach)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!TryComp<ResearchServerComponent>(args.Target, out var server))
|
||||||
|
return;
|
||||||
|
|
||||||
|
server.Points += component.Points;
|
||||||
|
_popupSystem.PopupEntity(Loc.GetString("research-disk-inserted", ("points", component.Points)), args.Target.Value, Filter.Entities(args.User));
|
||||||
|
EntityManager.QueueDeleteEntity(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
research-disk-inserted = You insert the disk, adding {$points} points to the server.
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
prob: 0.1
|
prob: 0.1
|
||||||
- id: WelderIndustrialAdvanced
|
- id: WelderIndustrialAdvanced
|
||||||
prob: 0.1
|
prob: 0.1
|
||||||
|
- id: ResearchDisk
|
||||||
|
prob: 0.1
|
||||||
# - Service
|
# - Service
|
||||||
- id: CrayonBox
|
- id: CrayonBox
|
||||||
prob: 0.1
|
prob: 0.1
|
||||||
@@ -64,6 +66,8 @@
|
|||||||
# - Ammo
|
# - Ammo
|
||||||
- id: MagazineBoxMagnum
|
- id: MagazineBoxMagnum
|
||||||
prob: 0.01
|
prob: 0.01
|
||||||
|
- id: ResearchDisk5000
|
||||||
|
prob: 0.01
|
||||||
# Just no (0.1%)
|
# Just no (0.1%)
|
||||||
# - Working guns
|
# - Working guns
|
||||||
- id: WeaponRevolverDeckard
|
- id: WeaponRevolverDeckard
|
||||||
@@ -73,6 +77,8 @@
|
|||||||
# - Skub
|
# - Skub
|
||||||
- id: Skub
|
- id: Skub
|
||||||
prob: 0.001
|
prob: 0.001
|
||||||
|
- id: ResearchDisk10000
|
||||||
|
prob: 0.001
|
||||||
- id: ClothingHeadHatCatEars
|
- id: ClothingHeadHatCatEars
|
||||||
prob: 0.01
|
prob: 0.01
|
||||||
# TRAITOR EQUIPMENT (0.01%)
|
# TRAITOR EQUIPMENT (0.01%)
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
- WeaponFlareGun
|
- WeaponFlareGun
|
||||||
- SheetSteel
|
- SheetSteel
|
||||||
- SheetPlastic
|
- SheetPlastic
|
||||||
|
- ResearchDisk
|
||||||
chance: 0.6
|
chance: 0.6
|
||||||
offset: 0.0
|
offset: 0.0
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
- type: entity
|
||||||
|
parent: BaseItem
|
||||||
|
id: ResearchDisk
|
||||||
|
name: research point disk (1000)
|
||||||
|
description: A disk for the R&D server containing 1000 points.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Specific/Research/researchdisk.rsi
|
||||||
|
state: icon
|
||||||
|
- type: ResearchDisk
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: ResearchDisk
|
||||||
|
id: ResearchDisk5000
|
||||||
|
name: research point disk (5000)
|
||||||
|
description: A disk for the R&D server containing 5000 points.
|
||||||
|
components:
|
||||||
|
- type: ResearchDisk
|
||||||
|
points: 5000
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: ResearchDisk
|
||||||
|
id: ResearchDisk10000
|
||||||
|
name: research point disk (10000)
|
||||||
|
description: A disk for the R&D server containing 10000 points.
|
||||||
|
components:
|
||||||
|
- type: ResearchDisk
|
||||||
|
points: 10000
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
SheetSteel1:
|
SheetSteel1:
|
||||||
min: 1
|
min: 1
|
||||||
max: 2
|
max: 2
|
||||||
|
- type: DiseaseServer
|
||||||
- type: AmbientSound
|
- type: AmbientSound
|
||||||
volume: -9
|
volume: -9
|
||||||
range: 5
|
range: 5
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 455 B |
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-SA-3.0",
|
||||||
|
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/f8f4aeda930fcd0805ca4cc76d9bc9412a5b3428",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "icon"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user