Files
tbd-station-14/Content.Shared/Trigger/Systems/TriggerOnStrappedOrBuckledSystem.cs
Studio Fae-Wilds 770dc68a48 Add trigger-refactor components and systems: Batch 1 (#39391)
* Adds the following batch of trigger refactor components and their associated systems:

TriggerOnLand: LandEvent
TriggerOnExamined: ExaminedEvent
TriggerOnUnbuckle: UnbuckledEvent
TriggerOnBuckle: BuckledEvent
TriggerOnStrap: StrappedEvent
TriggerOnUnstrapped: UnstrappedEvent

* Removes unnecessary lines from comment

* Fix comment formatting, corrects grammar and increases comment clarity.

* adds last forgotten edit to comments

* Update Content.Shared/Trigger/Systems/TriggerOnStrappedOrBuckledSystem.cs

Removes unnecessary comments

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Trigger/Components/Triggers/TriggerOnBuckledComponent.cs

Increases comment clarity

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Trigger/Components/Triggers/TriggerOnExaminedComponent.cs

Increases comment clarity

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Trigger/Components/Triggers/TriggerOnLandComponent.cs

Increases comment clarity

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Trigger/Components/Triggers/TriggerOnStrappedComponent.cs

Increases comment clarity

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Trigger/Components/Triggers/TriggerOnUnbuckledComponent.cs

Increases comment clarity

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Trigger/Components/Triggers/TriggerOnUnstrappedComponent.cs

Increases comment clarity

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* refactored TriggerOnStrappedOrBuckledSystem.cs
removed TriggerOnExaminedSystem.cs and moved it into TriggerSystem.Interaction.cs

Changes currently untested, not sure how to make it so modders can change what method they want sending out the appropriate trigger key but want to save progress working on it and get feedback from maintainers

* Removed component which already exists as part of TriggerSystem.Interaction.cs

* Restores accidentally removed component

* Apply suggestions from code review

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2025-08-14 09:39:54 +02:00

50 lines
1.9 KiB
C#

using Content.Shared.Buckle.Components;
using Content.Shared.Trigger.Components.Triggers;
namespace Content.Shared.Trigger.Systems;
/// <summary>
/// This is a system covering all trigger interactions involving strapping or buckling objects.
/// The users of strap components are the objects having an entity strapped to them (IE: Chairs)
/// The users of buckle components are entities being buckled to an object. (IE: Mobs and players)
/// </summary>
public sealed partial class TriggerOnStrappedOrBuckledSystem : EntitySystem
{
[Dependency] private readonly TriggerSystem _trigger = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TriggerOnStrappedComponent, StrappedEvent>(OnStrapped);
SubscribeLocalEvent<TriggerOnUnstrappedComponent, UnstrappedEvent>(OnUnstrapped);
SubscribeLocalEvent<TriggerOnBuckledComponent, BuckledEvent>(OnBuckled);
SubscribeLocalEvent<TriggerOnUnbuckledComponent, UnbuckledEvent>(OnUnbuckled);
}
#region Class Methods
// Called by objects entities can be buckled to. (Chairs, surgical tables/)
private void OnStrapped(Entity<TriggerOnStrappedComponent> ent, ref StrappedEvent args)
{
_trigger.Trigger(ent.Owner, args.Strap, ent.Comp.KeyOut);
}
private void OnUnstrapped(Entity<TriggerOnUnstrappedComponent> ent, ref UnstrappedEvent args)
{
_trigger.Trigger(ent.Owner, args.Strap, ent.Comp.KeyOut);
}
// Called by entities that are buckled to an object. (Mobs, players.)
private void OnBuckled(Entity<TriggerOnBuckledComponent> ent, ref BuckledEvent args)
{
_trigger.Trigger(ent.Owner, args.Buckle, ent.Comp.KeyOut);
}
private void OnUnbuckled(Entity<TriggerOnUnbuckledComponent> ent, ref UnbuckledEvent args)
{
_trigger.Trigger(ent.Owner, args.Buckle, ent.Comp.KeyOut);
}
#endregion
}