master
← slarticodefast:predictflash
opened 01:01PM - 20 May 25 UTC
## About the PR
Usual prediction PR, needed for trigger refactor.
~~Currently … a draft because I'm waiting on https://github.com/space-wizards/RobustToolbox/pull/5849 to have the random chance in FlashArea not mispredict.~~
Also fixes a few interaction bugs with the flash lantern and interrogator lamp.
## Why / Balance
prediction good
## Technical details
Moved everything to shared.
Replaced the deprecated timer spawn with an update loop. This is only used for resetting the visuals, ideally we replace this with something like `Flick()` (see https://github.com/space-wizards/RobustToolbox/pull/5810 ) in the future.
Use a `UseDelay` for the cooldown instead of hardcoding it to 4 seconds.
Make the parameters for `Flash` and `FlashArea` sane by using a `TimeSpan` for the duration rather than milliseconds.
`AfterFlashedEvent` is properly raised on the target, user and flash item as the code comment says it would be. Added an check in the subscription to account for that.
Split the `FlashVisuals` enum into `FlashVisuals` and `FlashVisualLayers` because those are completely different things.
Previously for the interrogator lamp and the flash lantern there were multiple event subscriptions blocking each other depending on order they were handled in. If the flash got triggered first, then the light did not get toggled on and vice versa. The previous manual subscription ordering was useless because one used `UseInHandEvent` and the other `ActivateInWorldEvent`. Also it was flashing a second time when the light was turned off. To fix this we instead activate the flash in a `LightToggleEvent` subscription and disable the use in hand activation using a DataField. Light code is quite messy at the moment and we got multiple implementations of toggleable lights that should all be unified and should use ItemToggle instead, but that is out of scope for this PR.
Currently is affected by this bug https://github.com/space-wizards/RobustToolbox/issues/5802 which means the start of the flash sound (in particular the click noise) is cut off sometimes. But that is not this PRs fault.
For the random probability I used the same trick of setting the rng seed that `SharedDiceSystem` uses so that we have predicted randomness. This is the same implementation that the `RandomPredicted` PR uses, but it should be replaced with the API method once that is merged.
## Media
https://github.com/user-attachments/assets/8740d224-e703-4d4a-87a8-c4167ec52694
## Requirements
- [x] I have read and am following the [Pull Request and Changelog Guidelines](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html).
- [x] I have added media to this PR or it does not require an ingame showcase.
## Breaking changes
`DamagedByFlashingComponent`, `FlashImmunityComponent ` were moved to `Content.Shared.Flash.Components`.
`FlashComponent` now uses TimeSpans for the durations and some datafields were changed.
The cooldown for `FlashComponent` is no longer hardcoded to 4 seconds, but uses a use delay. Make sure to add a `UseDelayComponent` to prevent spamming it.
`Flash` and `FlashArea` had their duration parameters changed to use `TimeSpans`.
`AfterFlashedEvent` is now always raised on the user, the target and the flash, not only when used in a melee attack. A `Melee` bool was added to account for that.
`FlashVisuals` was split up into `FlashVisuals` and `FlashVisualLayers`.
**Changelog**
:cl:
- fix: The interrogator lamp and flash lantern now properly flash when toggled on.
DamagedByFlashingComponent
, FlashImmunityComponent
were moved to Content.Shared.Flash.Components
.
FlashComponent
now uses TimeSpans for the durations and some datafields were changed.
The cooldown for FlashComponent
is no longer hardcoded to 4 seconds, but uses a use delay. Make sure to add a UseDelayComponent
to prevent spamming it.
Flash
and FlashArea
had their duration parameters changed to use TimeSpans
.
AfterFlashedEvent
is now always raised on the user, the target and the flash, not only when used in a melee attack. A Melee
bool was added to account for that.
FlashVisuals
was split up into FlashVisuals
and FlashVisualLayers
.
1 Like