Commit Graph

8 Commits

Author SHA1 Message Date
RedFoxIV
9ad2748240 Fix PowerCellDrawComponent Consuming Less Power than It Should (#2360)
# Description

Current implementation of `PowerCellSystem.Update()`:
```csharp
    public override void Update(float frameTime)
    {
        base.Update(frameTime);
        var query = EntityQueryEnumerator<PowerCellDrawComponent, PowerCellSlotComponent>();

        while (query.MoveNext(out var uid, out var comp, out var slot))
        {
            if (!comp.Enabled)
                continue;

            if (Timing.CurTime < comp.NextUpdateTime)
                continue;

            comp.NextUpdateTime += comp.Delay;

            if (!TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery, slot))
                continue;

            // TCJ: "Multiplying by frameTime to make this tick-invariant. Otherwise it'll draw 30x to 60x faster than you expect."
            if (_battery.TryUseCharge(batteryEnt.Value, comp.DrawRate * frameTime, battery))
                continue;

            var ev = new PowerCellSlotEmptyEvent();
            RaiseLocalEvent(uid, ref ev);
        }
    }
```

Multiplying `comp.DrawRate` and `frameTime` is only valid if we're
running this code each tick. Right now all power costs are divided by 30
or 60, which, ironically enough, makes power consumption 30 to 60 times
slower than intended.
This does not affect PowerCellDrawComponents with `Delay` set to zero,
since they do get updated every tick.

This will negatively affect equipment that uses this component for
consuming power while on.
Except flashlights, because `HandheldLightSystem` handles flashlight
power draw by itself.

---

<details><summary><h1>Media</h1></summary>
<p>

<details><summary>without fix</summary>

![X3OakRalFc](https://github.com/user-attachments/assets/66ddf553-d336-40e2-bf8a-5859fb1f2731)

</details>

<details><summary>with fix</summary>

![MMHI2SS8bg](https://github.com/user-attachments/assets/63719307-c390-40f8-b58a-028875b620fd)

</details>

</p>
</details>

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- fix: Fixed some items used less power while turned on than they
should.

(cherry picked from commit d8d9141e38c1300e20c50cec322dc287500a8011)
2025-05-10 01:31:00 +03:00
VMSolidus
716c1f15d6 Power Cell Draw Fixes (#1989)
# Description

Power cell draw wasn't tick invariant, so batteries on this codebase
were being drained anywhere from 30 to 60x faster than people expect,
depending on server performance. This was notably something that
severely effected MODSuits, which can now enjoy a battery lifespan of
around 30 minutes. But it's also a big deal for IPCs.

Closes https://github.com/Simple-Station/Einstein-Engines/issues/1956

# Changelog

🆑
- fix: Batteries no longer drain power 30 to 60 times faster than
physics states. This is particularly a large buff to IPCs and MODSuits,
who both no longer have to deal with batteries lasting an absurdly short
amount of time.
- tweak: Solarian Modsuit now provides protection from cold.

(cherry picked from commit 7df5eccecfe8a5a9eb6d12bbcdb2c545dfbe9b55)
2025-03-21 17:12:22 +03:00
deltanedas
c7bd43b94f decouple ItemToggle from PowerCellDraw (#31392)
* remove ItemToggle from PowerCellDraw query

* add EntityQuery for resolves, make them all optional

* move integration to ToggleCellDraw

* add ToggleCellDraw to almost every PowerCellDraw prototype

* :trollface:

* :trollface:

* :trollface:

* let it disable on mapinit

* set update time on mapinit, make borg power logic consistent now

* :trollface:

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
(cherry picked from commit e91fb14656469eaa2a5309c27fb51e8f7c171575)
2025-01-15 18:17:49 +03:00
sleepyyapril
885ee5a831 Wizmerge for Station AI (#1351)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

the adding AI is now up to y'all because i'm not touching loadout code
for name datasets, but it shouldn't be too bad from here

---------

Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com>
Signed-off-by: SolStar <44028047+ewokswagger@users.noreply.github.com>
Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: themias <89101928+themias@users.noreply.github.com>
Co-authored-by: Verm <32827189+Vermidia@users.noreply.github.com>
Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Co-authored-by: Sphiral <145869023+SphiraI@users.noreply.github.com>
Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Co-authored-by: Alzore <140123969+Blackern5000@users.noreply.github.com>
Co-authored-by: ravage <142820619+ravage123321@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: Intoxicating-Innocence <188202277+Intoxicating-Innocence@users.noreply.github.com>
Co-authored-by: Saphire <lattice@saphi.re>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com>
Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
Co-authored-by: CaasGit <87243814+CaasGit@users.noreply.github.com>
Co-authored-by: BramvanZijp <56019239+BramvanZijp@users.noreply.github.com>
Co-authored-by: Boaz1111 <149967078+Boaz1111@users.noreply.github.com>
Co-authored-by: NakataRin <45946146+NakataRin@users.noreply.github.com>
Co-authored-by: Kara <lunarautomaton6@gmail.com>
Co-authored-by: Plykiya <58439124+Plykiya@users.noreply.github.com>
Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Co-authored-by: Doomsdrayk <robotdoughnut@comcast.net>
Co-authored-by: Brandon Hu <103440971+Brandon-Huu@users.noreply.github.com>
Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
Co-authored-by: Julian Giebel <juliangiebel@live.de>
Co-authored-by: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com>
Co-authored-by: Repo <47093363+Titian3@users.noreply.github.com>
Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
Co-authored-by: icekot8 <93311212+icekot8@users.noreply.github.com>
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: no <165581243+pissdemon@users.noreply.github.com>
Co-authored-by: Tornado Tech <54727692+Tornado-Technology@users.noreply.github.com>
Co-authored-by: osjarw <62134478+osjarw@users.noreply.github.com>
Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com>
Co-authored-by: TGRCDev <tgrc@tgrc.dev>
Co-authored-by: Milon <milonpl.git@proton.me>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Co-authored-by: Fildrance <fildrance@gmail.com>
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
Co-authored-by: chavonadelal <156101927+chavonadelal@users.noreply.github.com>
Co-authored-by: SolStar <44028047+ewokswagger@users.noreply.github.com>
Co-authored-by: K-Dynamic <20566341+K-Dynamic@users.noreply.github.com>
Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com>
Co-authored-by: ArchRBX <5040911+ArchRBX@users.noreply.github.com>
Co-authored-by: archrbx <punk.gear5260@fastmail.com>
Co-authored-by: Radezolid <snappednexus@gmail.com>
Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Co-authored-by: EmoGarbage404 <retron404@gmail.com>
Co-authored-by: MilenVolf <63782763+MilenVolf@users.noreply.github.com>
Co-authored-by: Velcroboy <107660393+IamVelcroboy@users.noreply.github.com>
Co-authored-by: Velcroboy <velcroboy333@hotmail.com>
Co-authored-by: neuPanda <chriseparton@gmail.com>
Co-authored-by: neuPanda <spainman0@yahoo.com>
Co-authored-by: Dvir <39403717+dvir001@users.noreply.github.com>
Co-authored-by: Whatstone <whatston3@gmail.com>
Co-authored-by: VideoKompany <135313844+VlaDOS1408@users.noreply.github.com>

(cherry picked from commit 93ed70acfeda357133a701f637d3faeec02749bb)
2025-01-14 00:13:42 +03:00
Spatison
a2557f75a6 Upstream (#129) 2024-11-21 17:49:04 +07:00
Pieter-Jan Briers
e7a3b82a8d Use new ComponentPauseGenerator (#25183)
Also includes some (non critical) changes to the solution file to re-organize the Roslyn components.

(cherry picked from commit e00f74505c62310bd15aeaba8d6530f648397074)
2024-03-07 00:57:05 +01:00
Nemanja
27624ad280 Speed Boots [Tier 3 Civ-Service] (#21438)
* Speed Boots

* validate

* monkey
2023-11-12 20:48:04 +01:00
metalgearsloth
6417bb4fa0 Proto-kinetic crusher (#16277)
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
2023-05-14 13:15:18 +10:00