From 6c99e35bcbc2914685b0897ff7a5393a55f858ac Mon Sep 17 00:00:00 2001 From: Anri Date: Tue, 24 Dec 2024 14:46:41 +0300 Subject: [PATCH 1/8] =?UTF-8?q?=D0=A1=D1=8B=D0=BD=D0=BE=D0=BA,=20=D1=82?= =?UTF-8?q?=D1=8B=20=D1=87=D1=82=D0=BE=20=D0=BE=D0=BF=D1=8F=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=D0=B8=D0=BB=20=D0=B4=D0=BB=D1=8F=20=D1=81?= =?UTF-8?q?=D1=8114=3F=20=D0=9D=D0=B5=D1=82,=20=D0=BC=D0=B0=D0=BC=D0=B0!?= =?UTF-8?q?=20=D0=AD=D1=82=D0=BE=20=D0=B4=D1=80=D1=83=D0=B7=D1=8C=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=D0=B8=D0=BB=D0=B8,=20=D0=B0=20=D1=8F=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=81=D1=82=D0=BE=20=D1=80=D1=8F=D0=B4=D0=BE?= =?UTF-8?q?=D0=BC=20=D0=B4=D1=8B=D1=88=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ui/SuperMatterEmitterExtensionBUI.cs | 12 ++++++ .../SuperMatter/Crystal/SuperMatterSystem.cs | 7 +++- .../SuperMatterEmitterExtensionSystem.cs | 23 ++++++++--- .../Components/RadiationCollectorComponent.cs | 15 +++++++ .../EntitySystems/RadiationCollectorSystem.cs | 22 ++++++++++ .../Tesla/Components/TeslaCoilComponent.cs | 15 +++++++ .../Tesla/EntitySystem/TeslaCoilSystem.cs | 40 ++++++++++++++++++- .../Ui/SuperMatterEmitterExtensionUI.cs | 11 +++++ 8 files changed, 137 insertions(+), 8 deletions(-) diff --git a/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs b/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs index 81ab100a179bc5..eae72bb400cde1 100644 --- a/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs +++ b/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs @@ -28,4 +28,16 @@ protected override void Open() SendMessage(new SuperMatterEmitterExtensionValueMessage(powerConsumption, ratio)); }; } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + switch (state) + { + case SuperMatterEmitterExtensionUpdate update: + _menu?.SetEmitterParams(update.EnergyToMatterRatio, update.PowerConsumption); + break; + } + } } diff --git a/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.cs b/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.cs index dfa1ae137e6515..d9c11cb9894a70 100644 --- a/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.cs +++ b/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.cs @@ -22,10 +22,12 @@ public sealed partial class SuperMatterSystem : EntitySystem private const float RadiationPerEnergy = 70f; private const float IntegrityDamageICAnnounceDelay = 12f; - private const float IntegrityDamageStationAnnouncementDelay = 6f; + private const float IntegrityDamageStationAnnouncementDelay = 8f; private const float ReleasedEnergyToGasHeat = 60f; + private const float MaxRadiationIntensity = 16f; + public override void Initialize() { base.Initialize(); @@ -88,6 +90,7 @@ private void SuperMatterUpdate(Entity crystal, float frame EjectGases(decayedMatter, crystalTemperature, smState, gasMixture); crystal.Comp.Matter -= decayedMatter; + crystal.Comp.Temperature -= decayedMatter / crystal.Comp.Matter * crystalTemperature; _atmosphere.AddHeat(gasMixture, ReleasedEnergyToGasHeat * releasedEnergyPerFrame); AddIntegrityDamage(crystal.Comp, GetIntegrityDamage(crystal.Comp) * frameTime); @@ -157,7 +160,7 @@ private void ReleaseEnergy(Entity crystal) arcShooterComponent.ShootMaxInterval = MaxTimeBetweenArcs - timeDecreaseBetweenArcs; } - var radiationIntensity = smComp.AccumulatedRadiationEnergy / RadiationPerEnergy; + var radiationIntensity = MathF.Min(MaxRadiationIntensity, smComp.AccumulatedRadiationEnergy / RadiationPerEnergy); radiationSource.Intensity = radiationIntensity; } private void EjectGases(float decayedMatter, float crystalTemperature, SuperMatterPhaseState smState, GasMixture gasMixture) diff --git a/Content.Server/SS220/SuperMatter/Emitter/SuperMatterEmitterExtensionSystem.cs b/Content.Server/SS220/SuperMatter/Emitter/SuperMatterEmitterExtensionSystem.cs index 48fade3cb4463a..69f3207b667582 100644 --- a/Content.Server/SS220/SuperMatter/Emitter/SuperMatterEmitterExtensionSystem.cs +++ b/Content.Server/SS220/SuperMatter/Emitter/SuperMatterEmitterExtensionSystem.cs @@ -2,6 +2,7 @@ using Content.Shared.Singularity.Components; using Content.Shared.SS220.SuperMatter.Emitter; using Content.Shared.SS220.SuperMatter.Ui; +using Robust.Server.GameObjects; using Robust.Shared.Prototypes; namespace Content.Server.SS220.SuperMatter.Emitter; @@ -10,6 +11,8 @@ namespace Content.Server.SS220.SuperMatter.Emitter; public sealed class SuperMatterEmitterExtensionSystem : EntitySystem { [Dependency] IPrototypeManager _prototypeManager = default!; + [Dependency] UserInterfaceSystem _userInterface = default!; + public override void Initialize() { base.Initialize(); @@ -29,19 +32,29 @@ private void OnComponentInit(Entity entity } private void OnApplyMessage(Entity entity, ref SuperMatterEmitterExtensionValueMessage args) { - entity.Comp.PowerConsumption = args.PowerConsumption; - entity.Comp.EnergyToMatterRatio = args.EnergyToMatterRatio; + entity.Comp.PowerConsumption = Math.Min(16384, args.PowerConsumption); + entity.Comp.EnergyToMatterRatio = Math.Clamp(args.EnergyToMatterRatio, 0, 100); + + UpdateCorrespondingComponents(entity.Owner, entity.Comp, out var emitterComponent); - UpdateCorrespondingComponents(entity.Owner, entity.Comp); Dirty(entity); + if (emitterComponent != null) + Dirty(entity.Owner, emitterComponent); } - private void UpdateCorrespondingComponents(EntityUid uid, SuperMatterEmitterExtensionComponent comp) + private void UpdateCorrespondingComponents(EntityUid uid, SuperMatterEmitterExtensionComponent comp, out EmitterComponent? emitterComponent) { - if (!TryComp(uid, out var emitterComponent)) + if (!TryComp(uid, out emitterComponent)) { Log.Debug($"SM Emitter Extension exist in entity, but it doesnt have {nameof(EmitterComponent)}"); return; } emitterComponent.PowerUseActive = comp.PowerConsumption; } + + private void UpdateBUI(Entity entity) + { + var state = new SuperMatterEmitterExtensionUpdate(entity.Comp.PowerConsumption, entity.Comp.EnergyToMatterRatio); + + _userInterface.SetUiState(entity.Owner, SuperMatterEmitterExtensionUiKey.Key, state); + } } diff --git a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs index 7870234aab68b5..85ac57ef096869 100644 --- a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs +++ b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs @@ -34,6 +34,21 @@ public sealed partial class RadiationCollectorComponent : Component [ViewVariables] public bool Enabled; + // SS220-SM-fix-begin + /// + /// This bool ensure less usage of plasmas near SM crystal + /// + [DataField] + public bool NearSM = false; + + [DataField] + [ViewVariables(VVAccess.ReadWrite)] + public float SMNearReactionRateModifier = 0.2f; + + [DataField] + public float SMLookupRange = 3f; + // SS220-SM-fix-end + /// /// List of gases that will react to the radiation passing through the collector /// diff --git a/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs index bdd775c79273c5..8822d61a80cf40 100644 --- a/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs @@ -14,6 +14,7 @@ using Content.Shared.Timing; using Robust.Shared.Containers; using Robust.Shared.Timing; +using Content.Server.SS220.SuperMatterCrystal.Components; // SS220-SM-fix namespace Content.Server.Singularity.EntitySystems; @@ -24,12 +25,14 @@ public sealed class RadiationCollectorSystem : EntitySystem [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly UseDelaySystem _useDelay = default!; + [Dependency] private readonly EntityLookupSystem _entityLookup = default!; //SS220-fix-SM private const string GasTankContainer = "gas_tank"; public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnAnchorChange); // SS220-SM-fix SubscribeLocalEvent(OnActivate); SubscribeLocalEvent(OnRadiation); SubscribeLocalEvent(OnExamined); @@ -56,6 +59,7 @@ private bool TryGetLoadedGasTank(EntityUid uid, [NotNullWhen(true)] out GasTankC private void OnMapInit(EntityUid uid, RadiationCollectorComponent component, MapInitEvent args) { TryGetLoadedGasTank(uid, out var gasTank); + TryFindSMNear((uid, component)); // SS220-SM-fix; UpdateTankAppearance(uid, component, gasTank); } @@ -88,6 +92,11 @@ private void OnRadiation(EntityUid uid, RadiationCollectorComponent component, O float reactantMol = gasTankComponent.Air.GetMoles(gas.ReactantPrototype); float delta = args.TotalRads * reactantMol * gas.ReactantBreakdownRate; + // SS220 SM-fix-begin + var smFactor = component.NearSM ? component.SMNearReactionRateModifier : 1f; + delta *= smFactor; + // SS220 SM-fix-end + // We need to offset the huge power gains possible when using very cold gases // (they allow you to have a much higher molar concentrations of gas in the tank). // Hence power output is modified using the Michaelis-Menten equation, @@ -227,4 +236,17 @@ private void UpdateTankAppearance(EntityUid uid, RadiationCollectorComponent com UpdatePressureIndicatorAppearance(uid, component, gasTank, appearance); } + + //SS220-SM-fix-begin + private void OnAnchorChange(Entity entity, ref AnchorStateChangedEvent _) + { + TryFindSMNear(entity); + } + + private void TryFindSMNear(Entity entity) + { + var sm_queries = _entityLookup.GetEntitiesInRange(Transform(entity).Coordinates, entity.Comp.SMLookupRange); + entity.Comp.NearSM = !(sm_queries.Count == 0); + } + //SS220-SM-fix-end } diff --git a/Content.Server/Tesla/Components/TeslaCoilComponent.cs b/Content.Server/Tesla/Components/TeslaCoilComponent.cs index d9c7be6fe4d8c9..fd1a609aaaf900 100644 --- a/Content.Server/Tesla/Components/TeslaCoilComponent.cs +++ b/Content.Server/Tesla/Components/TeslaCoilComponent.cs @@ -8,6 +8,21 @@ namespace Content.Server.Tesla.Components; [RegisterComponent, Access(typeof(TeslaCoilSystem))] public sealed partial class TeslaCoilComponent : Component { + // SS220-SM-fix-begin + /// + /// This bool ensure less usage of plasmas near SM crystal + /// + [DataField] + public bool NearSM = false; + + [DataField] + [ViewVariables(VVAccess.ReadWrite)] + public float StructureDamageRecoveredNearSM = 0.8f; + + [DataField] + public float SMLookupRange = 3f; + // SS220-SM-fix-end + /// /// How much power will the coil generate from a lightning strike /// diff --git a/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs b/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs index 4fd2f9b6ed041c..d3325018a61333 100644 --- a/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs +++ b/Content.Server/Tesla/EntitySystem/TeslaCoilSystem.cs @@ -2,7 +2,10 @@ using Content.Server.Power.EntitySystems; using Content.Server.Tesla.Components; using Content.Server.Lightning; - +// SS220-SM-fix-begin +using Content.Shared.Damage; +using Content.Server.SS220.SuperMatterCrystal.Components; +// SS220-SM-fix-begin namespace Content.Server.Tesla.EntitySystems; /// @@ -11,12 +14,20 @@ namespace Content.Server.Tesla.EntitySystems; public sealed class TeslaCoilSystem : EntitySystem { [Dependency] private readonly BatterySystem _battery = default!; + //SS220-fix-SM-begin + [Dependency] private readonly EntityLookupSystem _entityLookup = default!; + [Dependency] private readonly DamageableSystem _damageable = default!; + //SS220-fix-SM-begin public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnHitByLightning); + // SS220-SM-fix-begin + SubscribeLocalEvent(OnDamage); + SubscribeLocalEvent(OnAnchorChange); + // SS220-SM-fix-begin } //When struck by lightning, charge the internal battery @@ -27,4 +38,31 @@ private void OnHitByLightning(Entity coil, ref HitByLightnin _battery.SetCharge(coil, batteryComponent.CurrentCharge + coil.Comp.ChargeFromLightning); } } + + //SS220-SM-fix-begin + private void OnAnchorChange(Entity entity, ref AnchorStateChangedEvent _) + { + TryFindSMNear(entity); + } + + private void OnDamage(Entity entity, ref DamageChangedEvent args) + { + if (!args.DamageIncreased || args.DamageDelta == null || !entity.Comp.NearSM) + return; + + if (!args.DamageDelta.DamageDict.TryGetValue("Structural", out var structuralDamage)) + return; + + DamageSpecifier damage = new(); + damage.DamageDict.Add("Structural", -1 * structuralDamage * entity.Comp.StructureDamageRecoveredNearSM); + + _damageable.TryChangeDamage(entity, damage, true); + } + + private void TryFindSMNear(Entity entity) + { + var sm_queries = _entityLookup.GetEntitiesInRange(Transform(entity).Coordinates, entity.Comp.SMLookupRange); + entity.Comp.NearSM = !(sm_queries.Count == 0); + } + //SS220-SM-fix-end } diff --git a/Content.Shared/SS220/SuperMatter/Ui/SuperMatterEmitterExtensionUI.cs b/Content.Shared/SS220/SuperMatter/Ui/SuperMatterEmitterExtensionUI.cs index e957702122753a..7659500a238764 100644 --- a/Content.Shared/SS220/SuperMatter/Ui/SuperMatterEmitterExtensionUI.cs +++ b/Content.Shared/SS220/SuperMatter/Ui/SuperMatterEmitterExtensionUI.cs @@ -9,6 +9,17 @@ public enum SuperMatterEmitterExtensionUiKey : byte Key } +/// +/// This event raise to give users information about server's component values after its flatting. +/// +[Serializable, NetSerializable] +public sealed class SuperMatterEmitterExtensionUpdate(int power, int ratio) : BoundUserInterfaceState +{ + public int PowerConsumption { get; } = power; + public int EnergyToMatterRatio { get; } = ratio; +} + + /// /// This event raised when user applied changes in emitter interface /// From b773987177900f2b4c3f3317b90ed2a5a1e47b3e Mon Sep 17 00:00:00 2001 From: Anri Date: Tue, 24 Dec 2024 14:52:05 +0300 Subject: [PATCH 2/8] =?UTF-8?q?=D0=9B=D0=B0=D0=BC=D0=BF=D1=83=D1=81=20?= =?UTF-8?q?=D0=BD=D0=B8=D0=BA=D0=BE=D0=B3=D0=B4=D0=B0=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B2=D1=81=D1=82=D1=80=D0=B5=D1=87=D0=B0=D0=BB=20=D0=BD=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D0=B3=D0=BE=20=D0=BF=D0=BE=D0=B4=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SuperMatter/Crystal/SuperMatterSystem.EventHandlers.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.EventHandlers.cs b/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.EventHandlers.cs index eeb15f9e803d11..dc27d6aa14a73d 100644 --- a/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.EventHandlers.cs +++ b/Content.Server/SS220/SuperMatter/Crystal/SuperMatterSystem.EventHandlers.cs @@ -10,6 +10,7 @@ using Content.Shared.Destructible; using Content.Shared.SS220.SuperMatter.Ui; using Microsoft.EntityFrameworkCore.Diagnostics; +using Content.Shared.Humanoid; namespace Content.Server.SS220.SuperMatterCrystal; @@ -77,7 +78,7 @@ private void OnCollide(Entity entity, ref StartCollideEven return; } - ConsumeObject(args.OtherEntity, entity); + ConsumeObject(args.OtherEntity, entity, HasComp(args.OtherEntity)); } private void OnActivation(Entity entity, ref SuperMatterActivationEvent args) { From 07e0898bc48c4952b7aa504ae3647d976f4acc5f Mon Sep 17 00:00:00 2001 From: Anri Date: Tue, 24 Dec 2024 14:54:20 +0300 Subject: [PATCH 3/8] =?UTF-8?q?=D0=9E=D0=BD=20=D0=BD=D0=B0=D1=87=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BF=D1=80=D1=8B=D0=B3=D0=B0=D1=82=D1=8C=20=D1=81=20?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=BB=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=D1=8F=20=D0=BD=D0=B0=20=D0=B4=D1=80=D1=83=D0=B3=D0=BE?= =?UTF-8?q?=D0=B5,=20=D0=BD=D0=B0=D1=81=D0=BB=D0=B0=D0=B6=D0=B4=D0=B0?= =?UTF-8?q?=D1=8F=D1=81=D1=8C=20=D0=BA=D0=B0=D0=B6=D0=B4=D1=8B=D0=BC=20?= =?UTF-8?q?=D0=BC=D0=B3=D0=BD=D0=BE=D0=B2=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Singularity/Components/RadiationCollectorComponent.cs | 2 +- Content.Server/Tesla/Components/TeslaCoilComponent.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs index 85ac57ef096869..d146d0d44a82c8 100644 --- a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs +++ b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs @@ -46,7 +46,7 @@ public sealed partial class RadiationCollectorComponent : Component public float SMNearReactionRateModifier = 0.2f; [DataField] - public float SMLookupRange = 3f; + public float SMLookupRange = 5f; // SS220-SM-fix-end /// diff --git a/Content.Server/Tesla/Components/TeslaCoilComponent.cs b/Content.Server/Tesla/Components/TeslaCoilComponent.cs index fd1a609aaaf900..931e4912a83470 100644 --- a/Content.Server/Tesla/Components/TeslaCoilComponent.cs +++ b/Content.Server/Tesla/Components/TeslaCoilComponent.cs @@ -20,7 +20,7 @@ public sealed partial class TeslaCoilComponent : Component public float StructureDamageRecoveredNearSM = 0.8f; [DataField] - public float SMLookupRange = 3f; + public float SMLookupRange = 5f; // SS220-SM-fix-end /// From 55b37064ad781e788804764abf189607911f3a5d Mon Sep 17 00:00:00 2001 From: Anri Date: Tue, 24 Dec 2024 15:09:05 +0300 Subject: [PATCH 4/8] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=9B=D0=B0=D0=BC=D0=BF=D1=83=D1=81=20=D0=B2=D1=8B=D0=B3=D0=BB?= =?UTF-8?q?=D1=8F=D0=B4=D0=B5=D0=BB=20=D0=BA=D0=B0=D0=BA=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D1=8F=D1=89=D0=B8=D0=B9=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D0=BD=D0=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Crystal/Components/HighPriorityAPCComponent.cs | 7 +++++++ Content.Server/StationEvents/Events/BreakerFlipRule.cs | 5 ++++- Content.Server/StationEvents/Events/PowerGridCheckRule.cs | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Content.Server/SS220/SuperMatter/Crystal/Components/HighPriorityAPCComponent.cs diff --git a/Content.Server/SS220/SuperMatter/Crystal/Components/HighPriorityAPCComponent.cs b/Content.Server/SS220/SuperMatter/Crystal/Components/HighPriorityAPCComponent.cs new file mode 100644 index 00000000000000..fbd06df48bca98 --- /dev/null +++ b/Content.Server/SS220/SuperMatter/Crystal/Components/HighPriorityAPCComponent.cs @@ -0,0 +1,7 @@ +namespace Content.Server.SS220.SuperMatterCrystal.Components; + +/// +/// For now acts only as a tag. Prohibits event turning of of APC with that component +/// +[RegisterComponent] +public sealed partial class HighPriorityAPCComponent : Component { } diff --git a/Content.Server/StationEvents/Events/BreakerFlipRule.cs b/Content.Server/StationEvents/Events/BreakerFlipRule.cs index 8a25d40abbc27c..99233731edee9b 100644 --- a/Content.Server/StationEvents/Events/BreakerFlipRule.cs +++ b/Content.Server/StationEvents/Events/BreakerFlipRule.cs @@ -1,5 +1,6 @@ using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; +using Content.Server.SS220.SuperMatterCrystal.Components; using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; using Content.Shared.Station.Components; @@ -35,7 +36,9 @@ protected override void Started(EntityUid uid, BreakerFlipRuleComponent componen var query = EntityQueryEnumerator(); while (query.MoveNext(out var apcUid, out var apc, out var xform)) { - if (apc.MainBreakerEnabled && CompOrNull(xform.GridUid)?.Station == chosenStation) + //SS220-SM-fix-begin + if (apc.MainBreakerEnabled && !HasComp(apcUid) + && CompOrNull(xform.GridUid)?.Station == chosenStation) //SS220-SM-fix-end { stationApcs.Add((apcUid, apc)); } diff --git a/Content.Server/StationEvents/Events/PowerGridCheckRule.cs b/Content.Server/StationEvents/Events/PowerGridCheckRule.cs index a4594e1387966d..7aec91e4778ea4 100644 --- a/Content.Server/StationEvents/Events/PowerGridCheckRule.cs +++ b/Content.Server/StationEvents/Events/PowerGridCheckRule.cs @@ -1,6 +1,7 @@ using System.Threading; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; +using Content.Server.SS220.SuperMatterCrystal.Components; using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; using Content.Shared.Station.Components; @@ -29,7 +30,9 @@ protected override void Started(EntityUid uid, PowerGridCheckRuleComponent compo var query = AllEntityQuery(); while (query.MoveNext(out var apcUid ,out var apc, out var transform)) { - if (apc.MainBreakerEnabled && CompOrNull(transform.GridUid)?.Station == chosenStation) + //SS220-SM-fix-begin + if (apc.MainBreakerEnabled && !HasComp(apcUid) + && CompOrNull(transform.GridUid)?.Station == chosenStation) //SS220-SM-fix-end component.Powered.Add(apcUid); } From 2ee588bc02320ca75052a6fe437c024587cc6fde Mon Sep 17 00:00:00 2001 From: Anri Date: Tue, 24 Dec 2024 15:14:55 +0300 Subject: [PATCH 5/8] =?UTF-8?q?=D0=9D=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D1=87=D0=B5=D1=81=D1=82=D0=BD=D0=BE,=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE=20=D0=B5=D0=BB=D0=B5=20=D0=BF=D0=BE=D0=BC=D0=BD=D1=8E=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D0=B5=D1=89=D1=91=20=D0=B1=D0=B5=D1=81?= =?UTF-8?q?=D0=B8=D0=BB=D0=BE=20=D0=BB=D1=8E=D0=B4=D0=B5=D0=B9=20=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=BF=D1=80=D0=BE=D1=81=D1=82=D0=BE=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B4=D0=BE=D0=BB=D0=B6=D0=B8=D1=82=D1=8C=20=D1=80?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=BA=D0=B0=D0=B7=20=D0=BF=D1=80=D0=BE=20?= =?UTF-8?q?=D0=9B=D0=B0=D0=BC=D0=BF=D1=83=D1=81=D0=B0=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Structures/Power/apc.yml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Resources/Prototypes/Entities/Structures/Power/apc.yml b/Resources/Prototypes/Entities/Structures/Power/apc.yml index df99a8fe5ae227..239a844a6e09ba 100644 --- a/Resources/Prototypes/Entities/Structures/Power/apc.yml +++ b/Resources/Prototypes/Entities/Structures/Power/apc.yml @@ -203,6 +203,26 @@ open: true # APCs in use +# SS220-SM-fix-begin + +- type: entity + parent: BaseAPC + id: APCBasic + suffix: Basic, EventProof + components: + - type: HighPriorityAPC + +- type: entity + parent: BaseAPC + id: APCBasic + suffix: Basic, 50kJ, EventProof + components: + - type: Battery + maxCharge: 50000 + startingCharge: 50000 + - type: HighPriorityAPC +# SS220-SM-fix-end + - type: entity parent: BaseAPC id: APCBasic From 6555c1ce66d48cdc0fcc819a62d836e0e6e5db6a Mon Sep 17 00:00:00 2001 From: Anri Date: Tue, 24 Dec 2024 17:28:43 +0300 Subject: [PATCH 6/8] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D0=B8=D0=BC=20?= =?UTF-8?q?=D1=87=D0=B5=D0=BA=D0=B8=20=D0=BF=D0=BE=D0=BC=D0=BE=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8C=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ss220/prototypes/entities/structures/power/apc.ftl | 7 +++++++ Resources/Prototypes/Entities/Structures/Power/apc.yml | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 Resources/Locale/ru-RU/ss220/prototypes/entities/structures/power/apc.ftl diff --git a/Resources/Locale/ru-RU/ss220/prototypes/entities/structures/power/apc.ftl b/Resources/Locale/ru-RU/ss220/prototypes/entities/structures/power/apc.ftl new file mode 100644 index 00000000000000..806a0a1618d08b --- /dev/null +++ b/Resources/Locale/ru-RU/ss220/prototypes/entities/structures/power/apc.ftl @@ -0,0 +1,7 @@ +ent-BaseAPCEventProof = { ent-BaseAPC } + .suffix = Базовый, Ивентозащищённый + .desc = { ent-BaseAPC.desc } + +ent-APCBasicEventProof = { ent-BaseAPC } + .suffix = Базовый, 50кДж, Ивентозащищённый + .desc = { ent-BaseAPC.desc } diff --git a/Resources/Prototypes/Entities/Structures/Power/apc.yml b/Resources/Prototypes/Entities/Structures/Power/apc.yml index 239a844a6e09ba..40f3a7ca6e39e1 100644 --- a/Resources/Prototypes/Entities/Structures/Power/apc.yml +++ b/Resources/Prototypes/Entities/Structures/Power/apc.yml @@ -207,14 +207,14 @@ - type: entity parent: BaseAPC - id: APCBasic + id: BaseAPCEventProof suffix: Basic, EventProof components: - type: HighPriorityAPC - type: entity parent: BaseAPC - id: APCBasic + id: APCBasicEventProof suffix: Basic, 50kJ, EventProof components: - type: Battery From 065ec8c179d11338a7056c591f110a5c1ac530ef Mon Sep 17 00:00:00 2001 From: Anri Date: Wed, 25 Dec 2024 20:59:58 +0300 Subject: [PATCH 7/8] =?UTF-8?q?=D0=A1=D0=B2=D0=B5=D1=82=20=D0=B8=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=BC=D0=BE=D0=BB=D1=8C=D0=B8=D1=86=D0=B5=20=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=D0=B6=D0=B8,=20=D0=B4=D0=B0=20=D0=B2=D1=81=D1=8E?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B4=D1=83=20=D0=B4=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=B6=D0=B8:=20=D1=8F=20=D0=BB=D1=8C=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D0=B2=D1=82=D0=B5=20=D0=BC=D0=BE=D0=BB=D0=B8=D0=B5,=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=D1=85=20=D0=BC=D0=BE=D0=BB=D0=B8=D0=BD=D0=B5?= =?UTF-8?q?=D0=B9,=20=D0=B2=D1=81=D0=B5=D1=85=20=D0=BC=D0=BE=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ui/SuperMatterEmitterExtensionBUI.cs | 23 ++++++++++++ .../Ui/SuperMatterEmitterExtensionMenu.xaml | 1 + .../SuperMatterEmitterExtensionMenu.xaml.cs | 36 ++++++++++++++++--- .../Crystal/SuperMatterSystem.Database.cs | 4 +++ .../SuperMatter/Crystal/SuperMatterSystem.cs | 2 +- .../SuperMatterEmitterExtensionSystem.cs | 33 +++++++++++++++-- .../Components/RadiationCollectorComponent.cs | 2 +- .../EntitySystems/EmitterSystem.cs | 12 +++++-- .../EntitySystems/RadiationCollectorSystem.cs | 4 +-- .../Tesla/Components/TeslaCoilComponent.cs | 2 +- .../Tesla/EntitySystem/TeslaCoilSystem.cs | 5 +-- .../Ui/SuperMatterEmitterExtensionUI.cs | 3 ++ .../Components/SharedEmitterComponent.cs | 2 ++ Resources/Locale/ru-RU/ss220/ui/smEmitter.ftl | 2 ++ .../Generation/Supermatter/smemitter.yml | 2 +- 15 files changed, 116 insertions(+), 17 deletions(-) diff --git a/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs b/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs index eae72bb400cde1..9095edca66dab0 100644 --- a/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs +++ b/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionBUI.cs @@ -2,6 +2,7 @@ using Robust.Client.UserInterface; using Content.Shared.SS220.SuperMatter.Ui; using Content.Shared.SS220.SuperMatter.Emitter; +using Content.Shared.Singularity.Components; namespace Content.Client.SS220.SuperMatter.Emitter.Ui; @@ -9,9 +10,14 @@ public sealed class SuperMatterEmitterExtensionBUI : BoundUserInterface { [ViewVariables] private SuperMatterEmitterExtensionMenu? _menu; + private int? _power; private int? _ratio; + + private bool _emitterActivated = false; + public SuperMatterEmitterExtensionBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey) { } + protected override void Open() { base.Open(); @@ -21,12 +27,29 @@ protected override void Open() _ratio = superMatterEmitter.EnergyToMatterRatio; } + if (EntMan.TryGetComponent(Owner, out var emitterComponent)) + { + _emitterActivated = emitterComponent.IsOn; + } + _menu = this.CreateWindow(); _menu.SetEmitterParams(_ratio, _power); + + var state = _emitterActivated ? ActivationStateEnum.EmitterActivated : ActivationStateEnum.EmitterDeactivated; + _menu.ChangeActivationState(state); + _menu.OnSubmitButtonPressed += (_, powerConsumption, ratio) => { SendMessage(new SuperMatterEmitterExtensionValueMessage(powerConsumption, ratio)); }; + _menu.OnEmitterActivatePressed += (_) => + { + SendMessage(new SuperMatterEmitterExtensionEmitterActivateMessage()); + + var state = _emitterActivated ? ActivationStateEnum.EmitterDeactivated : ActivationStateEnum.EmitterActivated; + _emitterActivated = !_emitterActivated; + _menu.ChangeActivationState(state); + }; } protected override void UpdateState(BoundUserInterfaceState state) diff --git a/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionMenu.xaml b/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionMenu.xaml index 49340b7f712074..2aa1a4099b8850 100644 --- a/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionMenu.xaml +++ b/Content.Client/SS220/SuperMatter/Emitter/Ui/SuperMatterEmitterExtensionMenu.xaml @@ -32,6 +32,7 @@