[Sci] Non-destructive XenoArch Research (#15398)

* Non-destructive XenoArch research

* nerf the price

* Points -> Extract
This commit is contained in:
Nemanja
2023-04-17 01:57:21 -04:00
committed by GitHub
parent adb6b168b7
commit 2a83a9bc17
11 changed files with 89 additions and 167 deletions

View File

@@ -35,7 +35,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambienntSound = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSound = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly ArtifactSystem _artifact = default!;
@@ -199,6 +199,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
var totalTime = TimeSpan.Zero;
var canScan = false;
var canPrint = false;
var points = 0;
if (component.AnalyzerEntity != null && TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity, out var analyzer))
{
artifact = analyzer.LastAnalyzedArtifact;
@@ -206,6 +207,10 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
totalTime = analyzer.AnalysisDuration * analyzer.AnalysisDurationMulitplier;
canScan = analyzer.Contacts.Any();
canPrint = analyzer.ReadyToPrint;
// the artifact that's actually on the scanner right now.
if (GetArtifactForAnalysis(component.AnalyzerEntity, analyzer) is { } current)
points = _artifact.GetResearchPointValue(current);
}
var analyzerConnected = component.AnalyzerEntity != null;
var serverConnected = TryComp<ResearchClientComponent>(uid, out var client) && client.ConnectedToServer;
@@ -214,7 +219,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
var remaining = active != null ? _timing.CurTime - active.StartTime : TimeSpan.Zero;
var state = new AnalysisConsoleScanUpdateState(artifact, analyzerConnected, serverConnected,
canScan, canPrint, msg, scanning, remaining, totalTime);
canScan, canPrint, msg, scanning, remaining, totalTime, points);
var bui = _ui.GetUi(uid, ArtifactAnalzyerUiKey.Key);
_ui.SetUiState(bui, state);
@@ -347,22 +352,21 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
if (!_research.TryGetClientServer(uid, out var server, out var serverComponent))
return;
var entToDestroy = GetArtifactForAnalysis(component.AnalyzerEntity);
if (entToDestroy == null)
var artifact = GetArtifactForAnalysis(component.AnalyzerEntity);
if (artifact == null)
return;
if (TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity.Value, out var analyzer) &&
analyzer.LastAnalyzedArtifact == entToDestroy)
{
ResetAnalyzer(component.AnalyzerEntity.Value);
}
var pointValue = _artifact.GetResearchPointValue(artifact.Value);
_research.AddPointsToServer(server.Value, _artifact.GetResearchPointValue(entToDestroy.Value), serverComponent);
EntityManager.DeleteEntity(entToDestroy.Value);
if (pointValue == 0)
return;
_research.AddPointsToServer(server.Value, pointValue, serverComponent);
_artifact.AdjustConsumedPoints(artifact.Value, pointValue);
_audio.PlayPvs(component.DestroySound, component.AnalyzerEntity.Value, AudioParams.Default.WithVolume(2f));
_popup.PopupEntity(Loc.GetString("analyzer-artifact-destroy-popup"),
_popup.PopupEntity(Loc.GetString("analyzer-artifact-extract-popup"),
component.AnalyzerEntity.Value, PopupType.Large);
UpdateUserInterface(uid, component);
@@ -371,9 +375,6 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
/// <summary>
/// Cancels scans if the artifact changes nodes (is activated) during the scan.
/// </summary>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <param name="args"></param>
private void OnArtifactActivated(EntityUid uid, ActiveScannedArtifactComponent component, ArtifactActivatedEvent args)
{
CancelScan(uid);
@@ -382,9 +383,6 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
/// <summary>
/// Checks to make sure that the currently scanned artifact isn't moved off of the scanner
/// </summary>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <param name="args"></param>
private void OnScannedMoved(EntityUid uid, ActiveScannedArtifactComponent component, ref MoveEvent args)
{
if (!TryComp<ArtifactAnalyzerComponent>(component.Scanner, out var analyzer))
@@ -399,9 +397,6 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
/// <summary>
/// Stops the current scan
/// </summary>
/// <param name="artifact">The artifact being scanned</param>
/// <param name="component"></param>
/// <param name="analyzer">The artifact analyzer component</param>
[PublicAPI]
public void CancelScan(EntityUid artifact, ActiveScannedArtifactComponent? component = null, ArtifactAnalyzerComponent? analyzer = null)
{
@@ -423,9 +418,6 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
/// <summary>
/// Finishes the current scan.
/// </summary>
/// <param name="uid">The analyzer that is scanning</param>
/// <param name="component"></param>
/// <param name="active"></param>
[PublicAPI]
public void FinishScan(EntityUid uid, ArtifactAnalyzerComponent? component = null, ActiveArtifactAnalyzerComponent? active = null)
{
@@ -485,7 +477,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var powa))
powa.NeedsPower = true;
_ambienntSound.SetAmbience(uid, true);
_ambientSound.SetAmbience(uid, true);
}
private void OnAnalyzeEnd(EntityUid uid, ActiveArtifactAnalyzerComponent component, ComponentShutdown args)
@@ -493,7 +485,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var powa))
powa.NeedsPower = false;
_ambienntSound.SetAmbience(uid, false);
_ambientSound.SetAmbience(uid, false);
}
private void OnPowerChanged(EntityUid uid, ActiveArtifactAnalyzerComponent component, ref PowerChangedEvent args)

View File

@@ -6,6 +6,8 @@ namespace Content.Server.Xenoarchaeology.Equipment.Systems;
public sealed class SuppressArtifactContainerSystem : EntitySystem
{
[Dependency] private readonly ArtifactSystem _artifact = default!;
public override void Initialize()
{
base.Initialize();
@@ -15,17 +17,17 @@ public sealed class SuppressArtifactContainerSystem : EntitySystem
private void OnInserted(EntityUid uid, SuppressArtifactContainerComponent component, EntInsertedIntoContainerMessage args)
{
if (!TryComp(args.Entity, out ArtifactComponent? artifact))
if (!TryComp<ArtifactComponent>(args.Entity, out var artifact))
return;
artifact.IsSuppressed = true;
_artifact.SetIsSuppressed(args.Entity, true, artifact);
}
private void OnRemoved(EntityUid uid, SuppressArtifactContainerComponent component, EntRemovedFromContainerMessage args)
{
if (!TryComp(args.Entity, out ArtifactComponent? artifact))
if (!TryComp<ArtifactComponent>(args.Entity, out var artifact))
return;
artifact.IsSuppressed = false;
_artifact.SetIsSuppressed(args.Entity, false, artifact);
}
}