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

ChemMaster: limit buffer, upgradable buffer size & maximum pill dosage #2551

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ private void UpdatePanelInfo(ChemMasterBoundUserInterfaceState state)
bufferHBox.AddChild(bufferLabel);
var bufferVol = new Label
{
Text = $"{state.BufferCurrentVolume}u",
//Text = $"{state.BufferCurrentVolume}u", // Frontier
Text = state.BufferMaxVolume != null ? $"{state.BufferCurrentVolume}/{state.BufferMaxVolume}" : $"{state.BufferCurrentVolume}u", // Frontier
StyleClasses = {StyleNano.StyleClassLabelSecondaryColor}
};
bufferHBox.AddChild(bufferVol);
Expand Down
19 changes: 19 additions & 0 deletions Content.Server/Chemistry/Components/ChemMasterComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Content.Server.Chemistry.EntitySystems;
using Content.Shared.Chemistry;
using Content.Shared.Construction.Prototypes;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;

namespace Content.Server.Chemistry.Components
{
Expand All @@ -23,5 +25,22 @@ public sealed partial class ChemMasterComponent : Component

[DataField("clickSound"), ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier ClickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");

// Frontier: upgrade fields
[DataField]
public uint[] PillDosageLimitPerTier;

[DataField]
public ProtoId<MachinePartPrototype> PillDosageMachinePart = "Manipulator";

[ViewVariables]
public uint MaxVolume;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (non-blocker): by storing the max volume here and on the solution, is there any risk of them divering? I.e., are there any places where we might forget to update one of them? Might it be possible to rely entirely on the solution max volume? Maybe that's not available everywhere we need it.


[DataField]
public uint[] MaxVolumePerTier;

[DataField]
public ProtoId<MachinePartPrototype> MaxVolumeMachinePart = "MatterBin";
// End Frontier
}
}
37 changes: 36 additions & 1 deletion Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Robust.Shared.Prototypes;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Construction; // Frontier

namespace Content.Server.Chemistry.EntitySystems
{
Expand Down Expand Up @@ -57,6 +58,9 @@ public override void Initialize()
SubscribeLocalEvent<ChemMasterComponent, ChemMasterReagentAmountButtonMessage>(OnReagentButtonMessage);
SubscribeLocalEvent<ChemMasterComponent, ChemMasterCreatePillsMessage>(OnCreatePillsMessage);
SubscribeLocalEvent<ChemMasterComponent, ChemMasterOutputToBottleMessage>(OnOutputToBottleMessage);

SubscribeLocalEvent<ChemMasterComponent, RefreshPartsEvent>(OnRefreshParts); // Frontier
SubscribeLocalEvent<ChemMasterComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Frontier
}

private void SubscribeUpdateUiState<T>(Entity<ChemMasterComponent> ent, ref T ev)
Expand All @@ -77,7 +81,7 @@ private void UpdateUiState(Entity<ChemMasterComponent> ent, bool updateLabel = f

var state = new ChemMasterBoundUserInterfaceState(
chemMaster.Mode, BuildInputContainerInfo(inputContainer), BuildOutputContainerInfo(outputContainer),
bufferReagents, bufferCurrentVolume, chemMaster.PillType, chemMaster.PillDosageLimit, updateLabel);
bufferReagents, bufferCurrentVolume, chemMaster.MaxVolume, chemMaster.PillType, chemMaster.PillDosageLimit, updateLabel); // Frontier: add chemMaster.MaxVolume

_userInterfaceSystem.SetUiState(owner, ChemMasterUiKey.Key, state);
}
Expand Down Expand Up @@ -348,5 +352,36 @@ private static ContainerInfo BuildContainerInfo(string name, Solution solution)
Reagents = solution.Contents
};
}

// Frontier: upgradeable parts
private void OnRefreshParts(EntityUid uid, ChemMasterComponent component, ref RefreshPartsEvent args)
{
if (!args.PartRatings.TryGetValue(component.PillDosageMachinePart, out var pillDosageRating))
pillDosageRating = 1.0f;

if (!args.PartRatings.TryGetValue(component.MaxVolumeMachinePart, out var maxVolumeRating))
maxVolumeRating = 1.0f;

if (component.MaxVolumePerTier.Length > 0)
{
component.MaxVolume = component.MaxVolumePerTier[int.Clamp((int)(maxVolumeRating - 1.0f), 0, component.MaxVolumePerTier.Length - 1)];
if (_solutionContainerSystem.TryGetSolution(uid, SharedChemMaster.BufferSolutionName, out _, out var bufferSolution))
bufferSolution.MaxVolume = component.MaxVolume;
}
if (component.PillDosageLimitPerTier.Length > 0)
{
component.PillDosageLimit = component.PillDosageLimitPerTier[int.Clamp((int)(pillDosageRating - 1.0f), 0, component.PillDosageLimitPerTier.Length - 1)];
}
UpdateUiState((uid, component));
}

private void OnUpgradeExamine(EntityUid uid, ChemMasterComponent component, ref UpgradeExamineEvent args)
{
var volumeIncrease = component.MaxVolumePerTier.Length > 0 ? component.MaxVolume - component.MaxVolumePerTier[0] : 0;
var dosageIncrease = component.PillDosageLimitPerTier.Length > 0 ? component.PillDosageLimit - component.PillDosageLimitPerTier[0] : 0;
args.AddNumberUpgrade("chem-master-component-examine-maximum-volume", (int)volumeIncrease);
args.AddNumberUpgrade("chem-master-component-examine-maximum-pill-dosage", (int)dosageIncrease);
}
// End Frontier
}
}
4 changes: 3 additions & 1 deletion Content.Shared/Chemistry/SharedChemMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public sealed class ChemMasterBoundUserInterfaceState : BoundUserInterfaceState
public readonly ChemMasterMode Mode;

public readonly FixedPoint2? BufferCurrentVolume;
public readonly FixedPoint2? BufferMaxVolume; // Frontier
public readonly uint SelectedPillType;

public readonly uint PillDosageLimit;
Expand All @@ -169,14 +170,15 @@ public sealed class ChemMasterBoundUserInterfaceState : BoundUserInterfaceState

public ChemMasterBoundUserInterfaceState(
ChemMasterMode mode, ContainerInfo? inputContainerInfo, ContainerInfo? outputContainerInfo,
IReadOnlyList<ReagentQuantity> bufferReagents, FixedPoint2 bufferCurrentVolume,
IReadOnlyList<ReagentQuantity> bufferReagents, FixedPoint2 bufferCurrentVolume, FixedPoint2 bufferMaxVolume, // Frontier: add bufferMaxVolume
uint selectedPillType, uint pillDosageLimit, bool updateLabel)
{
InputContainerInfo = inputContainerInfo;
OutputContainerInfo = outputContainerInfo;
BufferReagents = bufferReagents;
Mode = mode;
BufferCurrentVolume = bufferCurrentVolume;
BufferMaxVolume = bufferMaxVolume; // Frontier
SelectedPillType = selectedPillType;
PillDosageLimit = pillDosageLimit;
UpdateLabel = updateLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
chem-master-component-activate-no-hands = You have no hands.
chem-master-component-cannot-put-entity-message = You can't put this in the ChemMaster!

# Frontier
chem-master-component-examine-maximum-volume = Maximum volume
chem-master-component-examine-maximum-pill-dosage = Maximum pill dosage

## Bound UI
chem-master-bound-user-interface-title = ChemMaster 4000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,10 @@
state: medical
- type: MachineBoard
prototype: ChemMaster
requirements: # Frontier
Capacitor: 1 # Frontier stackRequirements<requirements
requirements: # Frontier: stackRequirements<requirements
# Capacitor: 1 # Frontier
Manipulator: 2 # Frontier
MatterBin: 2 # Frontier
stackRequirements:
Glass: 1
Cable: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
state: mixer_loaded
- type: ChemMaster
pillDosageLimit: 20
pillDosageLimitPerTier: [ 20, 22, 25, 30 ] # Frontier
maxVolumePerTier: [ 2000, 2250, 2500, 3000 ] # Frontier
- type: Physics
bodyType: Static
- type: Fixtures
Expand Down Expand Up @@ -85,10 +87,11 @@
- PillCanister
- type: SolutionContainerManager
solutions:
buffer: {}
buffer: # Frontier: remove {}
maxVol: 1000 # Frontier
- type: DumpableSolution
solution: buffer
unlimited: true
unlimited: false # Frontier: true<false
- type: GuideHelp
guides:
- Chemicals
Expand Down
Loading