Port research disks from nyano (#9081)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
parent
793f0e1281
commit
e86e6a5cce
|
|
@ -16,11 +16,13 @@ using Robust.Shared.Player;
|
|||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
|
||||
namespace Content.Server.Disease
|
||||
{
|
||||
/// <summary>
|
||||
/// Everything that's about disease diangosis and machines is in here
|
||||
|
||||
/// </summary>
|
||||
public sealed class DiseaseDiagnosisSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||
|
|
@ -29,6 +31,8 @@ namespace Content.Server.Disease
|
|||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||
[Dependency] private readonly PaperSystem _paperSystem = default!;
|
||||
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
|
@ -36,9 +40,9 @@ namespace Content.Server.Disease
|
|||
SubscribeLocalEvent<DiseaseSwabComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<DiseaseDiagnoserComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
||||
SubscribeLocalEvent<DiseaseVaccineCreatorComponent, AfterInteractUsingEvent>(OnAfterInteractUsingVaccine);
|
||||
/// Visuals
|
||||
// Visuals
|
||||
SubscribeLocalEvent<DiseaseMachineComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
/// Private Events
|
||||
// Private Events
|
||||
SubscribeLocalEvent<DiseaseDiagnoserComponent, DiseaseMachineFinishedEvent>(OnDiagnoserFinished);
|
||||
SubscribeLocalEvent<DiseaseVaccineCreatorComponent, DiseaseMachineFinishedEvent>(OnVaccinatorFinished);
|
||||
SubscribeLocalEvent<TargetSwabSuccessfulEvent>(OnTargetSwabSuccessful);
|
||||
|
|
@ -55,26 +59,29 @@ namespace Content.Server.Disease
|
|||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var uid in AddQueue)
|
||||
{
|
||||
EnsureComp<DiseaseMachineRunningComponent>(uid);
|
||||
}
|
||||
|
||||
AddQueue.Clear();
|
||||
foreach (var uid in RemoveQueue)
|
||||
{
|
||||
RemComp<DiseaseMachineRunningComponent>(uid);
|
||||
}
|
||||
|
||||
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;
|
||||
return;
|
||||
}
|
||||
diseaseMachine.Accumulator += frameTime;
|
||||
|
||||
diseaseMachine.Accumulator = 0;
|
||||
var ev = new DiseaseMachineFinishedEvent(diseaseMachine);
|
||||
RaiseLocalEvent(diseaseMachine.Owner, ev, false);
|
||||
RemoveQueue.Enqueue(diseaseMachine.Owner);
|
||||
while (diseaseMachine.Accumulator < diseaseMachine.Delay)
|
||||
{
|
||||
diseaseMachine.Accumulator -= diseaseMachine.Delay;
|
||||
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.PushNewline();
|
||||
|
||||
/// Add Cures
|
||||
// Add Cures
|
||||
if (disease.Cures.Count == 0)
|
||||
{
|
||||
report.AddMarkup(Loc.GetString("diagnoser-no-cures"));
|
||||
|
|
@ -265,6 +272,17 @@ namespace Content.Server.Disease
|
|||
|
||||
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
|
||||
///
|
||||
|
|
@ -327,18 +345,41 @@ namespace Content.Server.Disease
|
|||
var isPowered = this.IsPowered(uid, EntityManager);
|
||||
UpdateAppearance(uid, isPowered, false);
|
||||
// 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))
|
||||
return;
|
||||
|
||||
var reportTitle = string.Empty;
|
||||
string reportTitle;
|
||||
FormattedMessage contents = new();
|
||||
if (args.Machine.Disease != null)
|
||||
{
|
||||
reportTitle = Loc.GetString("diagnoser-disease-report", ("disease", args.Machine.Disease.Name));
|
||||
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");
|
||||
contents.AddMarkup(Loc.GetString("diagnoser-disease-report-none-contents"));
|
||||
|
|
@ -351,13 +392,13 @@ namespace Content.Server.Disease
|
|||
/// <summary>
|
||||
/// Prints a vaccine that will vaccinate
|
||||
/// against the disease on the inserted swab.
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
private void OnVaccinatorFinished(EntityUid uid, DiseaseVaccineCreatorComponent component, DiseaseMachineFinishedEvent args)
|
||||
{
|
||||
UpdateAppearance(uid, this.IsPowered(uid, EntityManager), false);
|
||||
|
||||
// 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))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
namespace Content.Server.Research.Disk
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class ResearchDiskComponent : Component
|
||||
{
|
||||
[DataField("points")]
|
||||
public int Points = 1000;
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
- id: WelderIndustrialAdvanced
|
||||
prob: 0.1
|
||||
- id: ResearchDisk
|
||||
prob: 0.1
|
||||
# - Service
|
||||
- id: CrayonBox
|
||||
prob: 0.1
|
||||
|
|
@ -64,6 +66,8 @@
|
|||
# - Ammo
|
||||
- id: MagazineBoxMagnum
|
||||
prob: 0.01
|
||||
- id: ResearchDisk5000
|
||||
prob: 0.01
|
||||
# Just no (0.1%)
|
||||
# - Working guns
|
||||
- id: WeaponRevolverDeckard
|
||||
|
|
@ -73,6 +77,8 @@
|
|||
# - Skub
|
||||
- id: Skub
|
||||
prob: 0.001
|
||||
- id: ResearchDisk10000
|
||||
prob: 0.001
|
||||
- id: ClothingHeadHatCatEars
|
||||
prob: 0.01
|
||||
# TRAITOR EQUIPMENT (0.01%)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
- WeaponFlareGun
|
||||
- SheetSteel
|
||||
- SheetPlastic
|
||||
- ResearchDisk
|
||||
chance: 0.6
|
||||
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:
|
||||
min: 1
|
||||
max: 2
|
||||
- type: DiseaseServer
|
||||
- type: AmbientSound
|
||||
volume: -9
|
||||
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"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue