Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</ScrollContainer>
<Control MinHeight="5"/>
<RichTextLabel Name="ExtractionSumLabel" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
<RichTextLabel Name="GlimmerSumLabel" VerticalAlignment="Bottom" HorizontalAlignment="Left"/> <!-- DeltaV - Glimmer/Artifact Interactions -->
</BoxContainer>
</PanelContainer>
</BoxContainer>
Expand Down
14 changes: 13 additions & 1 deletion Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Content.Client.UserInterface.Controls;
using Content.Client.Xenoarchaeology.Artifact;
using Content.Client.Xenoarchaeology.Equipment;
using Content.Shared._DVA.Research.Systems; // DeltaV - Glimmer/Artifact interactions
using Content.Shared.Research.Systems; // DeltaV - Glimmer/Artifact interactions
using Content.Shared.Xenoarchaeology.Artifact.Components;
using Content.Shared.Xenoarchaeology.Equipment.Components;
using Robust.Client.Audio;
Expand All @@ -21,7 +23,7 @@ namespace Content.Client.Xenoarchaeology.Ui;
[GenerateTypedNameReferences]
public sealed partial class AnalysisConsoleMenu : FancyWindow
{
private static readonly TimeSpan ExtractInfoDisplayForDuration = TimeSpan.FromSeconds(3);
private static readonly TimeSpan ExtractInfoDisplayForDuration = TimeSpan.FromSeconds(5); // DeltaV

[Dependency] private IEntityManager _ent = default!;
[Dependency] private IResourceCache _resCache = default!;
Expand Down Expand Up @@ -111,6 +113,7 @@ private void StartExtract(BaseButton.ButtonEventArgs obj)
var text = Loc.GetString("analysis-console-extract-value", ("id", nodeId), ("value", pointValue));
extractionMessage.AddMarkupOrThrow(text);
extractionMessage.PushNewline();
_extractionSum += pointValue; // DeltaV - Actually update the extraction sum
}

if (count == 0)
Expand All @@ -122,6 +125,15 @@ private void StartExtract(BaseButton.ButtonEventArgs obj)

ExtractionSumLabel.SetMarkup(Loc.GetString("analysis-console-extract-sum", ("value", _extractionSum)));

// BEGIN DeltaV - Glimmer/Artifact interactions
var ev = new GetGlimmerModifiedResearchEvent(_extractionSum, updateGlimmer: false);
_ent.EventBus.RaiseLocalEvent(_owner, ref ev);

ExtractionSumLabel.SetMarkup(Loc.GetString("dv-analysis-console-extract-sum",
("value", _extractionSum + ev.BonusResearch), ("bonus", ev.BonusResearch)));
GlimmerSumLabel.SetMarkup(Loc.GetString("dv-analysis-console-extract-sum-glimmer", ("value", ev.GeneratedGlimmer)));
// End DeltaV - Glimmer/Artifact interactions

_audio.PlayGlobal(_owner.Comp.ScanFinishedSound, _owner, AudioParams.Default.WithVolume(1f));
OnExtractButtonPressed?.Invoke();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Content.Server.Research.Systems;
using Content.Server.Xenoarchaeology.Artifact;
using Content.Shared._DVA.Research.Systems; // DeltaV - glimmer/artifact interaction
using Content.Shared.Popups;
using Content.Shared.Research.Systems; // DeltaV - glimmer/artifact interaction
using Content.Shared.Xenoarchaeology.Equipment;
using Content.Shared.Xenoarchaeology.Equipment.Components;
using Robust.Shared.Audio.Systems;
Expand Down Expand Up @@ -43,6 +45,12 @@ private void OnExtractButtonPressed(Entity<AnalysisConsoleComponent> ent, ref An
if (sumResearch <= 0)
return;

// BEGIN DeltaV - Glimmer/Artifact interactions
var ev = new GetGlimmerModifiedResearchEvent(sumResearch, updateGlimmer: true);
RaiseLocalEvent(ent, ref ev);
sumResearch += ev.BonusResearch;
// END DeltaV - Glimmer/Artifact interactions

_research.ModifyServerPoints(server.Value, sumResearch, serverComponent);
_audio.PlayPvs(ent.Comp.ExtractSound, artifact.Value);
_popup.PopupEntity(Loc.GetString("analyzer-artifact-extract-popup"), artifact.Value, PopupType.Large);
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/_DVA/Glimmer/DVGlimmerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ public int Glimmer
}
}

/// <summary>
/// The maximum glimmer possible.
/// </summary>
[PublicAPI]
public int MaxGlimmer
{
get => Entity?.Comp.MaxGlimmer ?? 0;
}

/// <summary>
/// The current glimmer tier of the round.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Content.Shared._DVA.Research.Systems;

namespace Content.Shared._DVA.Research.Components;

/// <summary>
/// Component for handling multipliers and Glimmer production when players generate
/// research via an analysis console.
/// </summary>
[RegisterComponent, Access(typeof(SharedGlimmerResearchSystem))]
public sealed partial class DVAnalysisConsoleGlimmerComponent : Component
{
/// <summary>
/// How much research is required to generate a single point of Glimmer.
/// </summary>
[DataField]
public float ResearchPerGlimmer = 1250;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

using Content.Shared._DVA.Research.Components;
using Content.Shared._DVA.Glimmer;

namespace Content.Shared._DVA.Research.Systems;

/// <summary>
/// Handling for Glimmer changes due to research and artifacts.
/// </summary>
public sealed partial class SharedGlimmerResearchSystem : EntitySystem
{
[Dependency] private DVGlimmerSystem _glimmer = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DVAnalysisConsoleGlimmerComponent, GetGlimmerModifiedResearchEvent>(OnGetGlimmerResearch);
}

/// <summary>
/// Handles when an Analysis console generates research and allows for additional points due to Glimmer.
/// Optionally allows Glimmer to be increased based on the amount of research generated.
/// </summary>
/// <param name="console">The console used for generating the Research points.</param>
/// <param name="arg">Args for the event.</param>
private void OnGetGlimmerResearch(Entity<DVAnalysisConsoleGlimmerComponent> console, ref GetGlimmerModifiedResearchEvent arg)
{
var normalizedGlimmer = Math.Clamp(_glimmer.Glimmer / (float)_glimmer.MaxGlimmer, 0f, 1f); // Coearce to floating point
var researchMultiplier = .5f + Math.Clamp(Math.Pow(normalizedGlimmer, 0.5f) + 1.5f * Math.Pow(normalizedGlimmer, 10f), 0f, 2.5f);

// Any fractional research or glimmer is truncated here
arg.BonusResearch = (int)(arg.ResearchPoints * researchMultiplier);
arg.GeneratedGlimmer = (int)(arg.ResearchPoints / console.Comp.ResearchPerGlimmer);

if (arg.ShouldUpdateGlimmer)
_glimmer.Glimmer += arg.GeneratedGlimmer;
}
}

/// <summary>
/// Raised by systems to determine how much bonus research and glimmer is generated
/// when extracting from an artifact.
/// </summary>
/// <param name="researchPoints">The incoming number of points.</param>
/// <param name="updateGlimmer">Whether to update the glimmer from this event.</param>
[ByRefEvent]
public struct GetGlimmerModifiedResearchEvent(int researchPoints, bool updateGlimmer = false)
{
/// <summary>
/// Whether to update glimmer as a result of this event.
/// </summary>
public readonly bool ShouldUpdateGlimmer = updateGlimmer;

/// <summary>
/// How many research points have been generated by some event.
/// This is untouched by the event.
/// </summary>
public readonly int ResearchPoints = researchPoints;

/// <summary>
/// How many research points are generated after being altered by Glimmer.
/// This is set by the event handlers.
/// </summary>
public int BonusResearch = 0;

/// <summary>
/// How many glimmer points would be added if glimmer is updated.
/// </summary>
public int GeneratedGlimmer = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dv-analysis-console-extract-sum = [font="Monospace" size=11][color=orange]Total Research: {$value} (+{$bonus})[/color][/font]
dv-analysis-console-extract-sum-glimmer = [font="Monospace" size=11][color=orange]Total Glimmer: {$value}[/color][/font]
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@
state: generic_panel_open
- type: ResearchClient
- type: AnalysisConsole
- type: DVAnalysisConsoleGlimmer # DeltaV - xenoarchaeology glimmer
- type: DeviceList
- type: DeviceNetwork
deviceNetId: Wired
Expand Down
Loading