-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Trigger Refactor #39034
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
Trigger Refactor #39034
Conversation
are you okay |
I'm good now that it's (almost) finished 😄 |
You bought me at "endless admeme potential" |
Content.Shared/Trigger/Components/Effects/SmokeOnTriggerComponent.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope you don't mind the nitpicks. I personally appreciate getting them, so.
Haven't started testing much yet and I'm scared to look at much less review the yaml changes.
Content.Shared/Trigger/Components/Effects/EmpOnTriggerComponent.cs
Outdated
Show resolved
Hide resolved
Content.Shared/Trigger/Components/Effects/AnchorOnTriggerComponent.cs
Outdated
Show resolved
Hide resolved
Content.Shared/Trigger/Components/Effects/AlertLevelChangeOnTriggerComponent.cs
Show resolved
Hide resolved
/// If TargetUser is true and they have that component they will be toggled instead. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class ItemToggleOnTriggerComponent : BaseXOnTriggerComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably get a field that allows hiding the popups that ItemToggle generates. (See: walking over a mousetrap generates a "The mousetrap was deactivated." message.)
Oh, yeah, I forgot to mention I wasn’t checking what was actually new code and what was just moved. Feel free to ignore anything on old code that you weren’t doing a clean-up pass on. |
mobState: | ||
- Dead | ||
- type: EmitSoundOnTrigger | ||
predicted: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait you use PlayPredicted not PlayLocal so uhhhh I don't know why this fixes this (yet)
Ah, it's really just for the person who kills the implanted entity, since they get marked as the trigger's user. So what I said above.
I love it when github double posts my review, I delete the duplicates, and then that also deletes some but not all of the comments from the review I was trying to keep. Very cool. If someone in here has email notifications for this thread, checking what they were would be appreciated—I think one of the comments was about an issue with an error sprite getting predicted for ExplodesOnTrigger (reproduction being detonate a C4 and watch its sprite at the end). I already forgot what the others were (or if there were others deleted). Edit: oh, one of them was RepulseAttractOnTrigger not getting predicted on client, but that's probably an issue with SharedThrowingSystem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Putting do not merge because I think scar wants to take a look and we should wait until stable is finished when we merge this. As soon as that's ready though lets get a full 2 weeks of testing 🥳 (I think it should be pretty bug free!)
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most admin abusable PR ever and its not even my birthday.
oof ouchie my merge conflicts |
About the PR
This PR got soaped, but it was worth it.
It should make the trigger system much more powerful and flexible to use:
bool
DataField.Why / Balance
The trigger system is really powerful, but underused because it was missing flexibility and prediction. The refactor allows us to replace a lot of components that have been hardcoded for very specific purposes with small reusable building blocks.
For example
ExtinguishOnInteract
would becomeExtinguishOnTrigger
andTriggerOnInteract
, both of which could be combined with any other trigger.Just to name a few other components that could be replaced with this:
AnnounceOnSpawn
EmitSoundOnPickup
StaminaDamageOnEmbed
IgniteOnMeleeHit
UseDelayOnMeleeHit
DamageOnToolInteract
DamageOnInteract
SolutionInjectOnProjectileHit
and a lot more.
Think of it as device linking in yaml. This should open up a lot of new possibilities for yaml contributors as well.
Technical details
The PR is large in size, but the code is really simple.
I moved all trigger code from the Explosion namespace and other places into its own
Trigger
namespace, so that all existing trigger effects can be easily found. Since the triggers and trigger effects are very modular most of them are in their own system handling only a few subscriptions.All code that has been moved to Shared should now be properly networked and predicted. A few exeptions are trigger effects that don't exist in shared, for example atmos and chat code.
Triggers and trigger effects now have a key string that is passed into the
Trigger
method and theTriggerEvent
, and each effect will only be activated if the key is the same. This allows us to have multiple triggers on the same entity without them interfering with each other.Conditions like Whitelists and UseDelays have been removed from all trigger effects, and are now instead checked in an
AttemptTriggerEvent
. This allows us to move them into their own components so they can be used with any trigger.Each trigger effect now has the
TargetUser
datafield, allowing us to select if the effect will target the triggered entity or the user of the trigger. Before this was working different on a case by case basis and some trigger components were renamed to make this more consistent.TODO before this can be merged:
Media
trigger.mp4
Requirements
Breaking changes
All trigger related components and systems have been moved to the
Content.Shared.Client/Shared/Server.Trigger.*
namespace.SharedTriggerOnProximityComponent
was removed. UseTriggerOnProximity
instead.TriggerOnTimedCollideComponent
now usesTimeSpan
s instead of accumulatingframetime
.TriggerOnMobStateChangeComponent
no longer automatically starts timer triggers, this has to be explicitly linked via the same trigger key now.TriggerWhenEmptyComponent
has been renamed toTriggerOnEmptyGunshotComponent
.TriggerImplantActionComponent
has been renamed toTriggerOnActivateImplantComponent
.DamageUserOnTriggerComponent
has been removed in favor ofDamageOnTriggerComponent
. SetTargetUser
totrue
to obtain the same result.GhostKickUserOnTriggerComponent
has been removed in favor ofGhostKickOnTriggerComponent
. SetTargetUser
totrue
to obtain the same result.SoundOnTriggerComponent
has been removed because it was a duplicate ofEmitSoundOnTriggerComponent
.The
CanAnchor
andCanUnanchor
datafields inAnchorOnTriggerComponent
now actually work (they did not do anything before).GibOnTriggerComponent
now targets the owning entity by default. SetTargetUser
totrue
to keep the previous effect.ShockOnTriggerComponent
now has aTargetContainer
bool for when it's used for equipment. Otherwise it will shock the owning entity.ShockOnTriggerComponent
no longer has theCooldown
datafield. UseUseDelayOnTriggerComponent
andUseDelayTriggerConditionComponent
instead.IgniteOnTriggerComponent
no longer plays a sound, useEmitSoundOnTrigger instead
.PolymorphOnTriggerComponent
now targets the owning entity by default. SetTargetUser
totrue
to keep the previous effect.RattleComponent
has been renamed toRattleOnTrigger
and targets the owning entity by default. SetTargetUser
totrue
to keep the previous effect.MouseTrapComponent
now usesItemToggleComponent
for arming and dearming.MouseTrapSystem
has been moved toContent.Shared.Mousetrap
.ActiveListenerComponent
has been moved toContent.Shared.Speech
.OnUseTimerTrigger
has been split up into multiple components. UseTimerTrigger
instead.SignallerComponent
no longer triggers when receiving a signal. AddTriggerOnSignalComponent
to keep this effect.TimerTrigger
does not automatically activate when the item is used in hand, stuck on a wall or when receiving a device link signal. UseTriggerOnUse
,TriggerOnStuck
, orTriggerOnSignal
to send a trigger to start the timer.ActiveTimerTrigger
is now a pure marker component without duplicating the datafields inOnUseTimerTrigger
.UseVerbInstead
has been removed fromTimerTrigger
. UseTriggerOnVerb
instead to start the timer.AutomatedTimerComponent
has been removed, use other triggers to start the timer the way you need.TriggerWhitelistComponent
has been renamed toWhitelistTriggerConditionComponent
.All whitelist checks have been removed from trigger components. Add
WhitelistTriggerConditionComponent
to obtain the same result.All usedelay checks have been removed from trigger components. Use
UseDelayOnTriggerComponent
andUseDelayTriggerConditionComponent
instead.Changelog
no player facing changes