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

return machine upgrade system #9

Closed
wants to merge 7 commits into from
Closed
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
10 changes: 8 additions & 2 deletions Content.Client/Lathe/UI/LatheMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Client.Materials;
using Content.Shared.Lathe;
using Content.Shared.Lathe.Prototypes;
using Content.Shared.Materials; // Corvax-Next
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -137,10 +138,15 @@ private string GenerateTooltipText(LatheRecipePrototype prototype)

foreach (var (id, amount) in prototype.Materials)
{
if (!_prototypeManager.TryIndex(id, out var proto))
if (!_prototypeManager.TryIndex<MaterialPrototype>(id, out var proto)) // Corvax-Next
continue;

var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, multiplier);
if (_entityManager.TryGetComponent<LatheComponent>(Entity, out var latheComp)) // Corvax-Next
{
float finalmaterial = latheComp.FinalMaterialUseMultiplier;
}

var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, _entityManager.GetComponent<LatheComponent>(Entity).FinalMaterialUseMultiplier); // Corvax-Next: MaterialUseMultiplier<FinalMaterialUseMultiplier
var sheetVolume = _materialStorage.GetSheetVolume(proto);

var unit = Loc.GetString(proto.Unit);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Binary.Components;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Construction; // Corvax-Next
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes;
Expand Down Expand Up @@ -28,6 +29,8 @@ public override void Initialize()
SubscribeLocalEvent<GasRecyclerComponent, AtmosDeviceUpdateEvent>(OnUpdate);
SubscribeLocalEvent<GasRecyclerComponent, AtmosDeviceDisabledEvent>(OnDisabled);
SubscribeLocalEvent<GasRecyclerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<GasRecyclerComponent, RefreshPartsEvent>(OnRefreshParts); // Corvax-Next
SubscribeLocalEvent<GasRecyclerComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Corvax-Next
}

private void OnEnabled(EntityUid uid, GasRecyclerComponent comp, ref AtmosDeviceEnabledEvent args)
Expand Down Expand Up @@ -116,5 +119,26 @@ private void UpdateAppearance(EntityUid uid, GasRecyclerComponent? comp = null)

_appearance.SetData(uid, PumpVisuals.Enabled, comp.Reacting);
}

// Corvax-Next
private void OnRefreshParts(EntityUid uid, GasRecyclerComponent component, RefreshPartsEvent args)
{
var ratingTemp = args.PartRatings["Capacitor"];
var ratingPressure = args.PartRatings["Manipulator"];

var copy = new GasRecyclerComponent();

component.MinTemp = copy.MinTemp * MathF.Pow(0.95f, ratingTemp - 1);
component.MinPressure = copy.MinPressure * MathF.Pow(0.8f, ratingPressure - 1);
}

private void OnUpgradeExamine(EntityUid uid, GasRecyclerComponent component, UpgradeExamineEvent args)
{
var copy = new GasRecyclerComponent();

args.AddPercentageUpgrade("gas-recycler-upgrade-min-temp", component.MinTemp / copy.MinTemp);
args.AddPercentageUpgrade("gas-recycler-upgrade-min-pressure", component.MinPressure / copy.MinPressure);
}
// End Corvax-Next
}
}
24 changes: 24 additions & 0 deletions Content.Server/Atmos/Portable/PortableScrubberSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Destructible;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Construction; // Corvax-Next
using Content.Server.Power.Components;
using Content.Server.NodeContainer;
using Robust.Server.GameObjects;
Expand Down Expand Up @@ -40,6 +41,8 @@ public override void Initialize()
SubscribeLocalEvent<PortableScrubberComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<PortableScrubberComponent, DestructionEventArgs>(OnDestroyed);
SubscribeLocalEvent<PortableScrubberComponent, GasAnalyzerScanEvent>(OnScrubberAnalyzed);
SubscribeLocalEvent<PortableScrubberComponent, RefreshPartsEvent>(OnRefreshParts); // Corvax-Next
SubscribeLocalEvent<PortableScrubberComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Corvax-Next
}

private bool IsFull(PortableScrubberComponent component)
Expand Down Expand Up @@ -156,5 +159,26 @@ private void OnScrubberAnalyzed(EntityUid uid, PortableScrubberComponent compone
args.GasMixtures ??= new List<(string, GasMixture?)>();
args.GasMixtures.Add((Name(uid), component.Air));
}

// Corvax-Next
private void OnRefreshParts(EntityUid uid, PortableScrubberComponent component, RefreshPartsEvent args)
{
var pressureRating = args.PartRatings["MatterBin"];
var transferRating = args.PartRatings["Manipulator"];

var copy = new PortableScrubberComponent();

component.MaxPressure = copy.MaxPressure * MathF.Pow(1.5f, pressureRating - 1);
component.TransferRate = copy.TransferRate * MathF.Pow(1.4f, transferRating - 1);
}

private void OnUpgradeExamine(EntityUid uid, PortableScrubberComponent component, UpgradeExamineEvent args)
{
var copy = new PortableScrubberComponent();

args.AddPercentageUpgrade("portable-scrubber-component-upgrade-max-pressure", component.MaxPressure / copy.MaxPressure);
args.AddPercentageUpgrade("portable-scrubber-component-upgrade-transfer-rate", component.TransferRate / copy.TransferRate);
}
// End Corvax-Next
}
}
23 changes: 23 additions & 0 deletions Content.Server/Bed/BedSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Content.Server.Actions;
using Content.Server.Construction; // Corvax-Next
using Content.Shared.Emag.Components; // Corvax-Next
using Content.Server.Bed.Components;
using Content.Server.Body.Systems;
using Content.Server.Power.Components;
Expand Down Expand Up @@ -34,6 +36,8 @@ public override void Initialize()
SubscribeLocalEvent<StasisBedComponent, UnstrappedEvent>(OnStasisUnstrapped);
SubscribeLocalEvent<StasisBedComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<StasisBedComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<StasisBedComponent, RefreshPartsEvent>(OnRefreshParts); // Corvax-Next
SubscribeLocalEvent<StasisBedComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Corvax-Next
}

private void OnStrapped(Entity<HealOnBuckleComponent> bed, ref StrappedEvent args)
Expand Down Expand Up @@ -133,5 +137,24 @@ private void UpdateMetabolisms(EntityUid uid, StasisBedComponent component, bool
RaiseLocalEvent(buckledEntity, ref metabolicEvent);
}
}

// Corvax-Next
private void OnRefreshParts(EntityUid uid, StasisBedComponent component, RefreshPartsEvent args)
{
var metabolismRating = args.PartRatings["Capacitor"];
StasisBedComponent copy = new StasisBedComponent();

component.Multiplier = copy.Multiplier * metabolismRating; //linear scaling so it's not OP
if (HasComp<EmaggedComponent>(uid))
component.Multiplier = 1f / component.Multiplier;
}

private void OnUpgradeExamine(EntityUid uid, StasisBedComponent component, UpgradeExamineEvent args)
{
StasisBedComponent copy = new StasisBedComponent();

args.AddPercentageUpgrade("stasis-bed-component-upgrade-stasis", component.Multiplier / copy.Multiplier);
}
// End Corvax-Next
}
}
17 changes: 17 additions & 0 deletions Content.Server/Botany/Systems/SeedExtractorSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Botany.Components;
using Content.Server.Construction; // Corvax-Next
using Content.Server.Popups;
using Content.Server.Power.EntitySystems;
using Content.Shared.Interaction;
Expand All @@ -18,6 +19,8 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<SeedExtractorComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<SeedExtractorComponent, RefreshPartsEvent>(OnRefreshParts); // Corvax-Next
SubscribeLocalEvent<SeedExtractorComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Corvax-Next
}

private void OnInteractUsing(EntityUid uid, SeedExtractorComponent seedExtractor, InteractUsingEvent args)
Expand Down Expand Up @@ -51,4 +54,18 @@ private void OnInteractUsing(EntityUid uid, SeedExtractorComponent seedExtractor
_botanySystem.SpawnSeedPacket(packetSeed, coords, args.User);
}
}

// Corvax-Next
private void OnRefreshParts(EntityUid uid, SeedExtractorComponent seedExtractor, RefreshPartsEvent args)
{
var manipulatorQuality = args.PartRatings["Manipulator"];

seedExtractor.BaseMaxSeeds = (int)MathF.Pow(new SeedExtractorComponent().BaseMaxSeeds, manipulatorQuality - 1);
}

private void OnUpgradeExamine(EntityUid uid, SeedExtractorComponent seedExtractor, UpgradeExamineEvent args)
{
args.AddPercentageUpgrade("seed-extractor-component-upgrade-seed-yield", seedExtractor.BaseMaxSeeds);
}
// End Corvax-Next
}
17 changes: 17 additions & 0 deletions Content.Server/Cargo/Systems/CargoSystem.Telepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Station.Components;
using Content.Server.Construction; // Corvax-Next
using Content.Shared.Cargo;
using Content.Shared.Cargo.Components;
using Content.Shared.DeviceLinking;
Expand All @@ -23,6 +24,8 @@ private void InitializeTelepad()
// Shouldn't need re-anchored event
SubscribeLocalEvent<CargoTelepadComponent, AnchorStateChangedEvent>(OnTelepadAnchorChange);
SubscribeLocalEvent<FulfillCargoOrderEvent>(OnTelepadFulfillCargoOrder);
SubscribeLocalEvent<CargoTelepadComponent, RefreshPartsEvent>(OnRefreshParts); // Corvax-Next
SubscribeLocalEvent<CargoTelepadComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Corvax-Next
}

private void OnTelepadFulfillCargoOrder(ref FulfillCargoOrderEvent args)
Expand Down Expand Up @@ -161,4 +164,18 @@ private void OnTelepadAnchorChange(EntityUid uid, CargoTelepadComponent componen
{
SetEnabled(uid, component);
}

// Corvax-Next
private void OnRefreshParts(EntityUid uid, CargoTelepadComponent component, RefreshPartsEvent args)
{
var rating = args.PartRatings["Capacitor"] - 1;

component.Delay = new CargoTelepadComponent().Delay * MathF.Pow(0.8f, rating);
}

private void OnUpgradeExamine(EntityUid uid, CargoTelepadComponent component, UpgradeExamineEvent args)
{
args.AddPercentageUpgrade("cargo-telepad-delay-upgrade", component.Delay / new CargoTelepadComponent().Delay);
}
// End Corvax-Next
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ public sealed partial class SolutionHeaterComponent : Component
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float HeatPerSecond;

// Corvax-Next
/// <summary>
/// How much heat is added per second to the solution, with no upgrades.
/// </summary>
[DataField("baseHeatPerSecond")]
public float BaseHeatPerSecond = 120;
// End Corvax-Next
}
17 changes: 17 additions & 0 deletions Content.Server/Chemistry/EntitySystems/SolutionHeaterSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Chemistry.Components;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Construction; // Corvax-Next
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components.SolutionManager;
Expand All @@ -23,6 +24,8 @@ public override void Initialize()
SubscribeLocalEvent<SolutionHeaterComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<SolutionHeaterComponent, ItemPlacedEvent>(OnItemPlaced);
SubscribeLocalEvent<SolutionHeaterComponent, ItemRemovedEvent>(OnItemRemoved);
SubscribeLocalEvent<SolutionHeaterComponent, RefreshPartsEvent>(OnRefreshParts); // Corvax-Next
SubscribeLocalEvent<SolutionHeaterComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Corvax-Next
}

private void TurnOn(EntityUid uid)
Expand Down Expand Up @@ -62,6 +65,20 @@ private void OnPowerChanged(Entity<SolutionHeaterComponent> entity, ref PowerCha
}
}

// Corvax-Next
private void OnRefreshParts(Entity<SolutionHeaterComponent> entity, ref RefreshPartsEvent args)
{
var heatRating = args.PartRatings["Capacitor"] - 1;

entity.Comp.HeatPerSecond = entity.Comp.BaseHeatPerSecond * MathF.Pow(1.5f, heatRating);
}

private void OnUpgradeExamine(Entity<SolutionHeaterComponent> entity, ref UpgradeExamineEvent args)
{
args.AddPercentageUpgrade("solution-heater-upgrade-heat", entity.Comp.HeatPerSecond / entity.Comp.BaseHeatPerSecond);
}
// End Corvax-Next

private void OnItemPlaced(Entity<SolutionHeaterComponent> entity, ref ItemPlacedEvent args)
{
TryTurnOn(entity);
Expand Down
24 changes: 24 additions & 0 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Chat.Systems;
using Content.Server.Cloning.Components;
using Content.Server.DeviceLinking.Systems;
using Content.Server.Construction; // Corvax-Next
using Content.Server.EUI;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Humanoid;
Expand Down Expand Up @@ -75,6 +76,8 @@ public override void Initialize()
SubscribeLocalEvent<CloningPodComponent, AnchorStateChangedEvent>(OnAnchor);
SubscribeLocalEvent<CloningPodComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<CloningPodComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<CloningPodComponent, RefreshPartsEvent>(OnPartsRefreshed); // Corvax-Next
SubscribeLocalEvent<CloningPodComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Corvax-Next
}

private void OnComponentInit(EntityUid uid, CloningPodComponent clonePod, ComponentInit args)
Expand Down Expand Up @@ -340,5 +343,26 @@ public void Reset(RoundRestartCleanupEvent ev)
{
ClonesWaitingForMind.Clear();
}

// Corvax-Next
private void OnPartsRefreshed(EntityUid uid, CloningPodComponent component, RefreshPartsEvent args)
{
var materialRating = args.PartRatings["MatterBin"];
var speedRating = args.PartRatings["Manipulator"];

var copy = new CloningPodComponent();

component.UsedBiomass = (int)(copy.UsedBiomass * MathF.Pow(0.85f, materialRating - 1));
component.CloningTime = copy.CloningTime * MathF.Pow(0.75f, speedRating - 1);
}

private void OnUpgradeExamine(EntityUid uid, CloningPodComponent component, UpgradeExamineEvent args)
{
var copy = new CloningPodComponent();

args.AddPercentageUpgrade("cloning-pod-component-upgrade-speed", copy.CloningTime / component.CloningTime);
args.AddPercentageUpgrade("cloning-pod-component-upgrade-biomass-requirement", copy.UsedBiomass / component.UsedBiomass);
}
// End Corvax-Next
}
}
13 changes: 12 additions & 1 deletion Content.Server/Construction/Components/MachineComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Construction.Components;
using Content.Shared.Construction.Components;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;

Expand All @@ -15,3 +15,14 @@ public sealed partial class MachineComponent : Component
[ViewVariables]
public Container PartContainer = default!;
}

// Corvax-Next: maintain upgradeable machine parts
/// <summary>
/// The different types of scaling that are available for machine upgrades
/// </summary>
public enum MachineUpgradeScalingType : byte
{
Linear,
Exponential
}
// End Corvax-Next
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Construction.Components;
using Content.Shared.Construction.Components;
using Content.Shared.Construction.Prototypes; // Corvax-Next: upgradeable machine parts
using Content.Shared.Stacks;
using Content.Shared.Tag;
using Robust.Shared.Containers;
Expand All @@ -15,6 +16,9 @@ public sealed partial class MachineFrameComponent : Component
[ViewVariables]
public bool HasBoard => BoardContainer?.ContainedEntities.Count != 0;

[ViewVariables] // Corvax-Next: upgradeable machine parts
public Dictionary<ProtoId<MachinePartPrototype>, int> Progress = new(); // Corvax-Next: upgradeable machine parts

[ViewVariables]
public readonly Dictionary<ProtoId<StackPrototype>, int> MaterialProgress = new();

Expand All @@ -24,6 +28,9 @@ public sealed partial class MachineFrameComponent : Component
[ViewVariables]
public readonly Dictionary<ProtoId<TagPrototype>, int> TagProgress = new();

[ViewVariables] // Corvax-Next: upgradeable machine parts
public Dictionary<ProtoId<MachinePartPrototype>, int> Requirements = new(); // Corvax-Next: upgradeable machine parts

[ViewVariables]
public Dictionary<ProtoId<StackPrototype>, int> MaterialRequirements = new();

Expand Down
15 changes: 15 additions & 0 deletions Content.Server/Construction/Conditions/MachineFrameComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ public bool DoExamine(ExaminedEvent args)
+ "\n");
}

// Frontier: restore upgradeable parts
foreach (var (part, required) in machineFrame.Requirements)
{
var amount = required - machineFrame.Progress[part];

if (amount == 0)
continue;
var stockPart = protoManager.Index(part);

args.PushMarkup(Loc.GetString("construction-condition-machine-frame-required-element-entry",
("amount", amount),
("elementName", Loc.GetString(stockPart.Name))));
}
// End Frontier

return true;
}

Expand Down
Loading
Loading