medical scanner machine upgrading (#12487)

This commit is contained in:
Nemanja
2022-11-16 16:02:36 -05:00
committed by GitHub
parent 7173fb856f
commit 7895ddebe3
8 changed files with 45 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
using Content.Shared.Construction.Prototypes;
using Content.Shared.DragDrop;
using Content.Shared.MedicalScanner;
using Robust.Shared.Containers;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Medical.Components
{
@@ -11,6 +13,15 @@ namespace Content.Server.Medical.Components
public ContainerSlot BodyContainer = default!;
public EntityUid? ConnectedConsole;
[ViewVariables(VVAccess.ReadWrite)]
public float CloningFailChanceMultiplier = 1f;
[DataField("machinePartCloningFailChance", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string MachinePartCloningFailChance = "ScanningModule";
[DataField("partRatingCloningFailChanceMultiplier")]
public float PartRatingFailMultiplier = 0.75f;
// ECS this out!, when DragDropSystem and InteractionSystem refactored
public override bool DragDropOn(DragDropEvent eventArgs)
{

View File

@@ -1,4 +1,5 @@
using Content.Server.Climbing;
using Content.Server.Cloning;
using Content.Server.Medical.Components;
using Content.Server.Power.Components;
using Content.Shared.Destructible;
@@ -10,8 +11,8 @@ using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.Cloning.Systems;
using Content.Server.Cloning.Components;
using Content.Server.Construction;
using Content.Server.MobState;
using Robust.Server.Containers;
@@ -43,6 +44,8 @@ namespace Content.Server.Medical
SubscribeLocalEvent<MedicalScannerComponent, DragDropEvent>(HandleDragDropOn);
SubscribeLocalEvent<MedicalScannerComponent, PortDisconnectedEvent>(OnPortDisconnected);
SubscribeLocalEvent<MedicalScannerComponent, AnchorStateChangedEvent>(OnAnchorChanged);
SubscribeLocalEvent<MedicalScannerComponent, RefreshPartsEvent>(OnRefreshParts);
SubscribeLocalEvent<MedicalScannerComponent, UpgradeExamineEvent>(OnUpgradeExamine);
}
private void OnComponentInit(EntityUid uid, MedicalScannerComponent scannerComponent, ComponentInit args)
@@ -224,5 +227,17 @@ namespace Content.Server.Medical
_climbSystem.ForciblySetClimbing(contained, uid);
UpdateAppearance(scannerComponent.Owner, scannerComponent);
}
private void OnRefreshParts(EntityUid uid, MedicalScannerComponent component, RefreshPartsEvent args)
{
var ratingFail = args.PartRatings[component.MachinePartCloningFailChance];
component.CloningFailChanceMultiplier = MathF.Pow(component.PartRatingFailMultiplier, ratingFail - 1);
}
private void OnUpgradeExamine(EntityUid uid, MedicalScannerComponent component, UpgradeExamineEvent args)
{
args.AddPercentageUpgrade("medical-scanner-upgrade-cloning", component.CloningFailChanceMultiplier);
}
}
}