# Conflicts: # Content.Client/Launcher/LauncherConnecting.cs # Content.Client/Launcher/LauncherConnectingGui.xaml # Content.Client/Launcher/LauncherConnectingGui.xaml.cs # Content.Server/Administration/Managers/BanManager.cs # Content.Server/Medical/Components/HealthAnalyzerComponent.cs # Content.Server/Medical/HealthAnalyzerSystem.cs # Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs # Content.Server/StationEvents/Events/RandomSentienceRule.cs # Content.Shared/Interaction/Components/BlockMovementComponent.cs # Content.Shared/Interaction/SharedInteractionSystem.Blocking.cs # Content.Shared/Materials/SharedMaterialReclaimerSystem.cs # Resources/Prototypes/Accents/word_replacements.yml # Resources/Prototypes/Catalog/Fills/Books/bookshelf.yml # Resources/Prototypes/Entities/Mobs/Customization/Markings/cat_parts.yml # Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml # Resources/Prototypes/Entities/Structures/Machines/lathe.yml # Resources/Prototypes/Objectives/objectiveGroups.yml # Resources/Prototypes/Objectives/stealTargetGroups.yml # Resources/Prototypes/Roles/Jobs/Security/detective.yml # Resources/Prototypes/Species/human.yml # Resources/Prototypes/Voice/speech_emotes.yml # Resources/ServerInfo/Guidebook/Antagonist/Antagonists.xml # Resources/ServerInfo/Guidebook/Antagonist/MinorAntagonists.xml # Resources/ServerInfo/Guidebook/Antagonist/Nuclear Operatives.xml # Resources/ServerInfo/Guidebook/Antagonist/Revolutionaries.xml # Resources/ServerInfo/Guidebook/Antagonist/SpaceNinja.xml # Resources/ServerInfo/Guidebook/Antagonist/Traitors.xml # Resources/ServerInfo/Guidebook/Antagonist/Zombies.xml # Resources/migration.yml
63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
using Content.Shared.Hands;
|
|
using Content.Shared.Interaction.Components;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Item;
|
|
using Content.Shared.Movement.Events;
|
|
|
|
namespace Content.Shared.Interaction;
|
|
|
|
// TODO deduplicate with AdminFrozenComponent
|
|
/// <summary>
|
|
/// Handles <see cref="BlockMovementComponent"/>, which prevents various
|
|
/// kinds of movement and interactions when attached to an entity.
|
|
/// </summary>
|
|
public partial class SharedInteractionSystem
|
|
{
|
|
public void InitializeBlocking()
|
|
{
|
|
SubscribeLocalEvent<BlockMovementComponent, UpdateCanMoveEvent>(OnMoveAttempt);
|
|
SubscribeLocalEvent<BlockMovementComponent, UseAttemptEvent>(CancelEvent);
|
|
SubscribeLocalEvent<BlockMovementComponent, InteractionAttemptEvent>(CancelInteractEvent);
|
|
SubscribeLocalEvent<BlockMovementComponent, DropAttemptEvent>(CancelEvent);
|
|
SubscribeLocalEvent<BlockMovementComponent, PickupAttemptEvent>(CancelEvent);
|
|
SubscribeLocalEvent<BlockMovementComponent, ChangeDirectionAttemptEvent>(CancelEvent);
|
|
|
|
SubscribeLocalEvent<BlockMovementComponent, ComponentStartup>(OnBlockingStartup);
|
|
SubscribeLocalEvent<BlockMovementComponent, ComponentShutdown>(OnBlockingShutdown);
|
|
}
|
|
|
|
private void CancelInteractEvent(Entity<BlockMovementComponent> ent, ref InteractionAttemptEvent args)
|
|
{
|
|
if (ent.Comp.BlockInteraction)
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnMoveAttempt(EntityUid uid, BlockMovementComponent component, UpdateCanMoveEvent args)
|
|
{
|
|
if (component.LifeStage > ComponentLifeStage.Running)
|
|
return;
|
|
|
|
args.Cancel(); // no more scurrying around
|
|
}
|
|
|
|
private void CancelEvent(EntityUid uid, BlockMovementComponent component, CancellableEntityEventArgs args)
|
|
{
|
|
// Sunrise-Start
|
|
if (!component.BlockUseAttempt)
|
|
return;
|
|
// Sunrise-End
|
|
|
|
args.Cancel();
|
|
}
|
|
|
|
private void OnBlockingStartup(EntityUid uid, BlockMovementComponent component, ComponentStartup args)
|
|
{
|
|
_actionBlockerSystem.UpdateCanMove(uid);
|
|
}
|
|
|
|
private void OnBlockingShutdown(EntityUid uid, BlockMovementComponent component, ComponentShutdown args)
|
|
{
|
|
_actionBlockerSystem.UpdateCanMove(uid);
|
|
}
|
|
}
|
|
|