Skip to content

Commit

Permalink
re-implement more machine upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheackraze committed Feb 2, 2024
1 parent b55fa9e commit 70f514a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Content.Server/Lathe/LatheSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.Administration.Logs;
using Content.Server.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Construction;
using Content.Server.Lathe.Components;
using Content.Server.Materials;
using Content.Server.Power.Components;
Expand Down Expand Up @@ -59,6 +60,10 @@ public override void Initialize()
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheGetRecipesEvent>(OnGetRecipes);
SubscribeLocalEvent<EmagLatheRecipesComponent, LatheGetRecipesEvent>(GetEmagLatheRecipes);
SubscribeLocalEvent<LatheHeatProducingComponent, LatheStartPrintingEvent>(OnHeatStartPrinting);

//Frontier Upgrade Code Restore
SubscribeLocalEvent<LatheComponent, RefreshPartsEvent>(OnPartsRefresh);
SubscribeLocalEvent<LatheComponent, UpgradeExamineEvent>(OnUpgradeExamine);
}

public override void Update(float frameTime)
Expand Down Expand Up @@ -348,5 +353,22 @@ private void OnLatheSyncRequestMessage(EntityUid uid, LatheComponent component,
UpdateUserInterfaceState(uid, component);
}
#endregion

//Frontier Upgrade Code Restore
private void OnPartsRefresh(EntityUid uid, LatheComponent component, RefreshPartsEvent args)
{
var printTimeRating = args.PartRatings[component.MachinePartPrintSpeed];
var materialUseRating = args.PartRatings[component.MachinePartMaterialUse];

component.TimeMultiplier = MathF.Pow(component.PartRatingPrintTimeMultiplier, printTimeRating - 1);
component.MaterialUseMultiplier = MathF.Pow(component.PartRatingMaterialUseMultiplier, materialUseRating - 1);
Dirty(component);
}

private void OnUpgradeExamine(EntityUid uid, LatheComponent component, UpgradeExamineEvent args)
{
args.AddPercentageUpgrade("lathe-component-upgrade-speed", 1 / component.TimeMultiplier);
args.AddPercentageUpgrade("lathe-component-upgrade-material-use", component.MaterialUseMultiplier);
}
}
}
25 changes: 25 additions & 0 deletions Content.Shared/Lathe/LatheComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ public sealed partial class LatheComponent : Component

public const float DefaultPartRatingMaterialUseMultiplier = 0.85f;
#endregion

//Frontier Upgrade Code Restore
/// <summary>
/// The machine part that reduces how long it takes to print a recipe.
/// </summary>
[DataField]
public ProtoId<MachinePartPrototype> MachinePartPrintSpeed = "Manipulator";

/// <summary>
/// The value that is used to calculate the modified <see cref="TimeMultiplier"/>
/// </summary>
[DataField]
public float PartRatingPrintTimeMultiplier = 0.5f;

/// <summary>
/// The machine part that reduces how much material it takes to print a recipe.
/// </summary>
[DataField]
public ProtoId<MachinePartPrototype> MachinePartMaterialUse = "MatterBin";

/// <summary>
/// The value that is used to calculate the modifier <see cref="MaterialUseMultiplier"/>
/// </summary>
[DataField]
public float PartRatingMaterialUseMultiplier = DefaultPartRatingMaterialUseMultiplier;
}

public sealed class LatheGetRecipesEvent : EntityEventArgs
Expand Down

0 comments on commit 70f514a

Please sign in to comment.