Skip to content

Event-Driven Power #2377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

WarMechanic
Copy link
Contributor

@WarMechanic WarMechanic commented May 2, 2025

Will require: #2355

Description

Draft PR with nothing in it, but now I have a space to write out my TODO. I will be pushing changes here later.

First foot in the war against frameTime EQE. Many devices on the station have a fixed load which makes frameTime updates overkill. Recharging batteries don't need to be updated on frameTime, since they recharge at a fixed rate and can have their charge interpolated.


TODO

  • C.Se/Power/EntitySystems/BatterySystem.cs

    • Replace frameTime recharging with event-driven charge updates.
      • Remove frameTime update in BatterySystem for self recharging power cells
      • Remove frameTime update events originating from PowerNetSystem for PowerNetBatteries
      • Adjust the TrySetCharge func to use a time delta rather than frameTime
      • Create a new UpdateCharge function that is called whenever recharge rate is changed, the battery is examined or charge is used
  • C.Se/Power/EntitySystems/PowerNetSystem.cs

    • Investigate UpdateApcPowerReceiver(frameTime);
      • Split off battery usage checks into its own function
      • What the fuck does |= mean?
      • This Seems to be responsible for enabling / disabling all powered devices on an APC grid. Should be using bubble down logic, aka consider the natural transport of electricity from Generator -> Substation -> APC -> Powered Device. Rather than checking every single powered device, check whether an APC has enough power to support child power devices.
    • Investigate UpdatePowerConsumer();
      • Updates power received when the delta is high enough. Would be rendered obsolete by event-drive.
    • Investigate UpdateNetworkBattery();
      • Raises a PowerNetBatterySupplyEvent(bool) which isn't used by many systems.
    • Remove Update(float frameTime) { ... }

Media

Example Media Embed


Changelog

🆑

  • add: Added fun :D
  • tweak: Tweaked fun
  • fix: Fixed fun!
  • remove: Removed fun :(

@github-actions github-actions bot added Changes: C# Changes any cs files Changes: YML Changes any yml files labels May 2, 2025
@SimpleStation14 SimpleStation14 changed the title Event-driven Power Event-Driven Power May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes: C# Changes any cs files Changes: YML Changes any yml files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant