]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Added decelerator percentage drain (#35643)
authorrokudara-sen <160833839+rokudara-sen@users.noreply.github.com>
Mon, 3 Mar 2025 16:37:28 +0000 (17:37 +0100)
committerGitHub <noreply@github.com>
Mon, 3 Mar 2025 16:37:28 +0000 (11:37 -0500)
* Added variable PercentageDrain to SinguloFoodComponent

* Set percentageDrain to 0.03 (3%) for anti particles

* Added percentageDrain logic in public OnConsumed

* Simplify SinguloFoodComponent and set percentageDrain to negative

* EnergyFactor now applies to positive values too

* Better commenting on EnergyFactor

* Update Content.Server/Singularity/Components/SinguloFoodComponent.cs

* Documentation of EnergyFactor

* Fixing spelling mistake

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Server/Singularity/Components/SinguloFoodComponent.cs
Content.Server/Singularity/EntitySystems/SingularitySystem.cs
Resources/Prototypes/Entities/Structures/Power/Generation/PA/particles.yml

index e9f9da15c13121797472aea9eeb9e5f51b8ad26d..edd0aeaf11bad86266b7b3bbff08264b254e7758 100644 (file)
@@ -6,8 +6,20 @@ namespace Content.Server.Singularity.Components
     [RegisterComponent]
     public sealed partial class SinguloFoodComponent : Component
     {
-        [ViewVariables(VVAccess.ReadWrite)]
-        [DataField("energy")]
-        public float Energy { get; set; } = 1f;
+        /// <summary>
+        /// Flat adjustment to the singularity's energy when this entity is eaten by the event horizon.
+        /// </summary>
+        [DataField]
+        public float Energy = 1f;
+
+        /// <summary>
+        /// Multiplier applied to singularity's energy.
+        /// 1.0 = no change, 0.97 = 3% reduction, 1.05 = 5% increase
+        /// </summary>
+        /// /// <remarks>
+        /// This is calculated using the singularity's energy level before <see cref="Energy"/> has been added.
+        /// </remarks>
+        [DataField]
+        public float EnergyFactor = 1f;
     }
 }
index 6b9182fb4dfbd6c430f7108374d6420e149a1a1b..f28502fc75eccf42773f8b909fc983222db5c895 100644 (file)
@@ -256,7 +256,12 @@ public sealed class SingularitySystem : SharedSingularitySystem
     public void OnConsumed(EntityUid uid, SinguloFoodComponent comp, ref EventHorizonConsumedEntityEvent args)
     {
         if (EntityManager.TryGetComponent<SingularityComponent>(args.EventHorizonUid, out var singulo))
-            AdjustEnergy(args.EventHorizonUid, comp.Energy, singularity: singulo);
+        {
+            // Calculate the percentage change (positive or negative)
+            var percentageChange = singulo.Energy * (comp.EnergyFactor - 1f);
+            // Apply both the flat and percentage changes
+            AdjustEnergy(args.EventHorizonUid, comp.Energy + percentageChange, singularity: singulo);
+        }
     }
 
     /// <summary>
index 6e55bfec5e8633ce2b3c369eb47ecc1336b6377e..9d5ffc24867ffb55ace59da938a586549a62aec8 100644 (file)
@@ -80,3 +80,4 @@
     lifetime: 0.6
   - type: SinguloFood
     energy: -10
+    energyFactor: 0.97