diff --git a/Content.Server/Gravity/GravityGeneratorComponent.cs b/Content.Server/Gravity/GravityGeneratorComponent.cs index 2ed325e52c..511fd49bdd 100644 --- a/Content.Server/Gravity/GravityGeneratorComponent.cs +++ b/Content.Server/Gravity/GravityGeneratorComponent.cs @@ -1,4 +1,6 @@ -using Content.Shared.Gravity; +using Content.Shared.Gravity; +using Content.Shared.Construction.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.Gravity { @@ -29,9 +31,15 @@ namespace Content.Server.Gravity [DataField("intact")] public bool Intact { get; set; } = true; + [DataField("maxCharge")] + public float MaxCharge { get; set; } = 1; + // 0 -> 1 [ViewVariables(VVAccess.ReadWrite)] [DataField("charge")] public float Charge { get; set; } = 1; + [DataField("machinePartMaxChargeMultiplier", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string MachinePartMaxChargeMultiplier = "Capacitor"; + /// /// Is the gravity generator currently "producing" gravity? /// diff --git a/Content.Server/Gravity/GravityGeneratorSystem.cs b/Content.Server/Gravity/GravityGeneratorSystem.cs index 930f2a8d4c..ad745ffa5d 100644 --- a/Content.Server/Gravity/GravityGeneratorSystem.cs +++ b/Content.Server/Gravity/GravityGeneratorSystem.cs @@ -7,6 +7,7 @@ using Content.Shared.Interaction; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Players; +using Content.Server.Construction; namespace Content.Server.Gravity { @@ -26,6 +27,7 @@ namespace Content.Server.Gravity SubscribeLocalEvent(OnComponentShutdown); SubscribeLocalEvent(OnParentChanged); // Or just anchor changed? SubscribeLocalEvent(OnInteractHand); + SubscribeLocalEvent(OnRefreshParts); SubscribeLocalEvent( OnSwitchGenerator); } @@ -84,11 +86,11 @@ namespace Content.Server.Gravity var active = gravGen.GravityActive; var lastCharge = gravGen.Charge; - gravGen.Charge = Math.Clamp(gravGen.Charge + frameTime * chargeRate, 0, 1); + gravGen.Charge = Math.Clamp(gravGen.Charge + frameTime * chargeRate, 0, gravGen.MaxCharge); if (chargeRate > 0) { // Charging. - if (MathHelper.CloseTo(gravGen.Charge, 1) && !gravGen.GravityActive) + if (MathHelper.CloseTo(gravGen.Charge, gravGen.MaxCharge) && !gravGen.GravityActive) { gravGen.GravityActive = true; } @@ -158,7 +160,7 @@ namespace Content.Server.Gravity if (!_uiSystem.IsUiOpen(component.Owner, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key)) return; - var chargeTarget = chargeRate < 0 ? 0 : 1; + var chargeTarget = chargeRate < 0 ? 0 : component.MaxCharge; short chargeEta; var atTarget = false; if (MathHelper.CloseTo(component.Charge, chargeTarget)) @@ -255,6 +257,12 @@ namespace Content.Server.Gravity } } + private void OnRefreshParts(EntityUid uid, GravityGeneratorComponent component, RefreshPartsEvent args) + { + var maxChargeMultipler = args.PartRatings[component.MachinePartMaxChargeMultiplier]; + component.MaxCharge = maxChargeMultipler * 1; + } + private void MakeBroken(EntityUid uid, GravityGeneratorComponent component, AppearanceComponent? appearance) { _ambientSoundSystem.SetAmbience(component.Owner, false); diff --git a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml index 5f4fced02f..defb13df04 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml @@ -941,3 +941,19 @@ Steel: 5 CableHV: 5 Cable: 2 + +- type: entity + parent: BaseMachineCircuitboard + id: MiniGravityGeneratorCircuitboard + name: mini gravity generator machine board + description: A machine printed circuit board for a mini gravity generator. + components: + - type: MachineBoard + prototype: GravityGeneratorMini + requirements: + Capacitor: 4 + MatterBin: 3 + materialRequirements: + Steel: 5 + CableHV: 5 + Uranium: 2 \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Structures/Machines/gravity_generator.yml b/Resources/Prototypes/Entities/Structures/Machines/gravity_generator.yml index 9d1bf03efc..2658f68dfe 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/gravity_generator.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/gravity_generator.yml @@ -12,7 +12,6 @@ range: 7 sound: path: /Audio/Ambience/Objects/gravity_gen_hum.ogg - - type: Sprite sprite: Structures/Machines/gravity_generator.rsi layers: @@ -77,7 +76,7 @@ - type: entity id: GravityGeneratorMini - parent: GravityGenerator + parent: [ GravityGenerator, ConstructibleMachine ] name: mini gravity generator description: It's what keeps you to the floor, now in fun size. components: @@ -104,6 +103,28 @@ - LargeMobMask layer: - WallLayer + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 500 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + MachineFrameDestroyed: + min: 1 + max: 1 + - type: WiresPanel + - type: Wires + BoardName: "MiniGravityGenerator" + LayoutId: MiniGravityGenerator + - type: Machine + board: MiniGravityGeneratorCircuitboard - type: ApcPowerReceiver powerLoad: 500 - type: GravityGenerator diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 49efcb3711..ada5159197 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -347,6 +347,7 @@ - EmitterCircuitboard - ThrusterMachineCircuitboard - GyroscopeMachineCircuitboard + - MiniGravityGeneratorCircuitboard - GasRecyclerMachineCircuitboard - SeedExtractorMachineCircuitboard - AnalysisComputerCircuitboard diff --git a/Resources/Prototypes/Recipes/Lathes/electronics.yml b/Resources/Prototypes/Recipes/Lathes/electronics.yml index 8a5a5a2996..e9dcd8f181 100644 --- a/Resources/Prototypes/Recipes/Lathes/electronics.yml +++ b/Resources/Prototypes/Recipes/Lathes/electronics.yml @@ -661,3 +661,12 @@ materials: Steel: 100 Glass: 900 + +- type: latheRecipe + id: MiniGravityGeneratorCircuitboard + result: MiniGravityGeneratorCircuitboard + completetime: 6 + materials: + Steel: 100 + Glass: 900 + Gold: 100 diff --git a/Resources/Prototypes/Research/industrial.yml b/Resources/Prototypes/Research/industrial.yml index c262b067b6..5ea36788ec 100644 --- a/Resources/Prototypes/Research/industrial.yml +++ b/Resources/Prototypes/Research/industrial.yml @@ -129,6 +129,7 @@ - RadarConsoleCircuitboard - ThrusterMachineCircuitboard - GyroscopeMachineCircuitboard + - MiniGravityGeneratorCircuitboard - type: technology id: RipleyAPLU