Construct and upgrade mini gravity generator (#18568)
* Construct and upgrade mini gravity generator Now the mini gravity generator can be assembled/disassembled, the necessary machine board has been added to ShuttleCraft technology. Now it is possible to destroy the mini gravity generator and improve its components, thereby increasing the maximum charge of the generator. * Test with empty OnRefreshParts Perhaps this will help to get rid of the error during the test... * Revert "Test with empty OnRefreshParts" This reverts commit 5f32e15d66a4cb0d8df7578593867062be7872d8. * Test without OnRefreshParts Let's check if the problem is multiple inheritance. * Revert "Test without OnRefreshParts" This reverts commit d319757aa15a8ebec1237e552213e80eb8042790. * Enabled by default Maybe this will solve the problem, and maybe not... * Swapped the components ApcPowerReciver and GravityGenerator The previous "solution" did not give results, perhaps this time it will work.... * Revert "Swapped the components ApcPowerReciver and GravityGenerator" This reverts commit 38759ca5a3465908b97d1d7e6ca583f8e9a97afb. * Brought everything back to the beginning * One parent in generator prototype, test * Revert "One parent in generator prototype, test" This reverts commit f7275b5d53234d9f66e8b4df0692596e14d82c95. * Test without switchedOn and charge * Revert "Test without switchedOn and charge" This reverts commit 3916de8cc68e488098e6adc1e6b13e00d3f0e1a1. * Revert "Revert "Test without switchedOn and charge"" This reverts commit 3d95efbfd4cb358b5c04a2302a377d51eb5f34cc. * Update Resources/Prototypes/Entities/Structures/Machines/gravity_generator.yml --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
@@ -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<MachinePartPrototype>))]
|
||||
public string MachinePartMaxChargeMultiplier = "Capacitor";
|
||||
|
||||
/// <summary>
|
||||
/// Is the gravity generator currently "producing" gravity?
|
||||
/// </summary>
|
||||
|
||||
@@ -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<GravityGeneratorComponent, ComponentShutdown>(OnComponentShutdown);
|
||||
SubscribeLocalEvent<GravityGeneratorComponent, EntParentChangedMessage>(OnParentChanged); // Or just anchor changed?
|
||||
SubscribeLocalEvent<GravityGeneratorComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<GravityGeneratorComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
SubscribeLocalEvent<GravityGeneratorComponent, SharedGravityGeneratorComponent.SwitchGeneratorMessage>(
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -347,6 +347,7 @@
|
||||
- EmitterCircuitboard
|
||||
- ThrusterMachineCircuitboard
|
||||
- GyroscopeMachineCircuitboard
|
||||
- MiniGravityGeneratorCircuitboard
|
||||
- GasRecyclerMachineCircuitboard
|
||||
- SeedExtractorMachineCircuitboard
|
||||
- AnalysisComputerCircuitboard
|
||||
|
||||
@@ -661,3 +661,12 @@
|
||||
materials:
|
||||
Steel: 100
|
||||
Glass: 900
|
||||
|
||||
- type: latheRecipe
|
||||
id: MiniGravityGeneratorCircuitboard
|
||||
result: MiniGravityGeneratorCircuitboard
|
||||
completetime: 6
|
||||
materials:
|
||||
Steel: 100
|
||||
Glass: 900
|
||||
Gold: 100
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
- RadarConsoleCircuitboard
|
||||
- ThrusterMachineCircuitboard
|
||||
- GyroscopeMachineCircuitboard
|
||||
- MiniGravityGeneratorCircuitboard
|
||||
|
||||
- type: technology
|
||||
id: RipleyAPLU
|
||||
|
||||
Reference in New Issue
Block a user