Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Content.Shared.Whitelist;
using Robust.Shared.GameStates;

namespace Content.Shared._Scp.Other.ScpRestrictMovementOnVisibility;

[RegisterComponent, NetworkedComponent]
public sealed partial class ScpRestrictMovementOnVisibilityComponent : Component
{
[DataField]
public EntityWhitelist? ContainersMoveWhitelist;

[DataField]
public EntityWhitelist? ContainersMoveBlacklist;
Comment thread
WardexOfficial marked this conversation as resolved.

[DataField]
public float ContainmentRoomSearchRadius = 8f;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared._Scp.Watching;
using Content.Shared.ActionBlocker;
using Content.Shared.Interaction.Events;
using Content.Shared.Movement.Events;
using Content.Shared.Storage.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Containers;

namespace Content.Shared._Scp.Other.ScpRestrictMovementOnVisibility;

public sealed class SharedScpRestrictMovementOnVisibilitySystem : EntitySystem

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Имя файла не соответствует имени класса.

Файл называется SharedRestrictMovementOnVisibilitySystem.cs, а класс — SharedScpRestrictMovementOnVisibilitySystem. По конвенциям C# имя файла должно совпадать с именем класса.

🔧 Предлагаемое исправление

Переименуйте файл в SharedScpRestrictMovementOnVisibilitySystem.cs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@Content.Shared/_Scp/Other/ScpRestrictMovementOnVisibility/SharedRestrictMovementOnVisibilitySystem.cs`
at line 12, The file name does not match the public class name; rename the file
containing the class SharedScpRestrictMovementOnVisibilitySystem to
SharedScpRestrictMovementOnVisibilitySystem.cs so the C# file name matches the
public class name and follows project conventions.

{
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly EyeWatchingSystem _watching = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;

private EntityQuery<InsideEntityStorageComponent> _insideQuery;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ScpRestrictMovementOnVisibilityComponent, AttackAttemptEvent>(OnAttackAttempt);

SubscribeLocalEvent<ScpRestrictMovementOnVisibilityComponent, ChangeDirectionAttemptEvent>(OnDirectionAttempt);
SubscribeLocalEvent<ScpRestrictMovementOnVisibilityComponent, UpdateCanMoveEvent>(OnMoveAttempt);
SubscribeLocalEvent<ScpRestrictMovementOnVisibilityComponent, MoveInputEvent>(OnMoveInput);
SubscribeLocalEvent<ScpRestrictMovementOnVisibilityComponent, MoveEvent>(OnMove);

_insideQuery = GetEntityQuery<InsideEntityStorageComponent>();
}
Comment thread
WardexOfficial marked this conversation as resolved.

public void OnAttackAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref AttackAttemptEvent args)
{
if (IsInContainer(ent, out _))
{
args.Cancel();
return;
}

if (_watching.IsWatchedByAny(ent, useTimeCompensation: true))
{
args.Cancel();
return;
}
}

public void OnDirectionAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref ChangeDirectionAttemptEvent args)
{
// В контейнере можно двигаться
if (IsInContainer(ent, out _))
return;

if (!_watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;

args.Cancel();
}

public void OnMoveAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref UpdateCanMoveEvent args)
{
// В контейнере можно двигаться
if (IsInContainer(ent, out _))
return;

if (!_watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;

args.Cancel();
}

public void OnMoveInput(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveInputEvent args)
{
// Метод подвязанный на MoveInputEvent так же нужен, вместе с методом на MoveEvent
// Этот метод исправляет проблему, когда сущность должен мочь двинуться, но ему об этом никто не сказал
// То есть последний вопрос от сущности МОГУ ЛИ Я ДВИНУТЬСЯ был когда он еще мог двинуться, через MoveEvent
// Потом он перестал мочь, и следственно больше НЕ МОЖЕТ задать вопрос, может они двинуться
// Это фикслось в игре сменой направления спрайта мышкой
// Но данный метод как раз будет спрашивать у сущности, может ли он сдвинуться, когда как раз не двигается
_blocker.UpdateCanMove(ent);
}

public void OnMove(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveEvent args)
{
_blocker.UpdateCanMove(ent);
}
Comment on lines +35 to +88

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Обработчики событий должны быть private.

Методы OnAttackAttempt, OnDirectionAttempt, OnMoveAttempt, OnMoveInput, OnMove используются только для подписки через SubscribeLocalEvent и не являются частью публичного API системы.

♻️ Предлагаемое исправление
-    public void OnAttackAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref AttackAttemptEvent args)
+    private void OnAttackAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref AttackAttemptEvent args)
-    public void OnDirectionAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref ChangeDirectionAttemptEvent args)
+    private void OnDirectionAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref ChangeDirectionAttemptEvent args)
-    public void OnMoveAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref UpdateCanMoveEvent args)
+    private void OnMoveAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref UpdateCanMoveEvent args)
-    public void OnMoveInput(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveInputEvent args)
+    private void OnMoveInput(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveInputEvent args)
-    public void OnMove(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveEvent args)
+    private void OnMove(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveEvent args)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public void OnAttackAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref AttackAttemptEvent args)
{
if (IsInContainer(ent, out _))
{
args.Cancel();
return;
}
if (_watching.IsWatchedByAny(ent, useTimeCompensation: true))
{
args.Cancel();
return;
}
}
public void OnDirectionAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref ChangeDirectionAttemptEvent args)
{
// В контейнере можно двигаться
if (IsInContainer(ent, out _))
return;
if (!_watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;
args.Cancel();
}
public void OnMoveAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref UpdateCanMoveEvent args)
{
// В контейнере можно двигаться
if (IsInContainer(ent, out _))
return;
if (!_watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;
args.Cancel();
}
public void OnMoveInput(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveInputEvent args)
{
// Метод подвязанный на MoveInputEvent так же нужен, вместе с методом на MoveEvent
// Этот метод исправляет проблему, когда сущность должен мочь двинуться, но ему об этом никто не сказал
// То есть последний вопрос от сущности МОГУ ЛИ Я ДВИНУТЬСЯ был когда он еще мог двинуться, через MoveEvent
// Потом он перестал мочь, и следственно больше НЕ МОЖЕТ задать вопрос, может они двинуться
// Это фикслось в игре сменой направления спрайта мышкой
// Но данный метод как раз будет спрашивать у сущности, может ли он сдвинуться, когда как раз не двигается
_blocker.UpdateCanMove(ent);
}
public void OnMove(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveEvent args)
{
_blocker.UpdateCanMove(ent);
}
private void OnAttackAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref AttackAttemptEvent args)
{
if (IsInContainer(ent, out _))
{
args.Cancel();
return;
}
if (_watching.IsWatchedByAny(ent, useTimeCompensation: true))
{
args.Cancel();
return;
}
}
private void OnDirectionAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref ChangeDirectionAttemptEvent args)
{
// В контейнере можно двигаться
if (IsInContainer(ent, out _))
return;
if (!_watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;
args.Cancel();
}
private void OnMoveAttempt(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref UpdateCanMoveEvent args)
{
// В контейнере можно двигаться
if (IsInContainer(ent, out _))
return;
if (!_watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;
args.Cancel();
}
private void OnMoveInput(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveInputEvent args)
{
// Метод подвязанный на MoveInputEvent так же нужен, вместе с методом на MoveEvent
// Этот метод исправляет проблему, когда сущность должен мочь двинуться, но ему об этом никто не сказал
// То есть последний вопрос от сущности МОГУ ЛИ Я ДВИНУТЬСЯ был когда он еще мог двинуться, через MoveEvent
// Потом он перестал мочь, и следственно больше НЕ МОЖЕТ задать вопрос, может они двинуться
// Это фикслось в игре сменой направления спрайта мышкой
// Но данный метод как раз будет спрашивать у сущности, может ли он сдвинуться, когда как раз не двигается
_blocker.UpdateCanMove(ent);
}
private void OnMove(Entity<ScpRestrictMovementOnVisibilityComponent> ent, ref MoveEvent args)
{
_blocker.UpdateCanMove(ent);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@Content.Shared/_Scp/Other/ScpRestrictMovementOnVisibility/SharedRestrictMovementOnVisibilitySystem.cs`
around lines 35 - 88, Change the event handler methods from public to private:
OnAttackAttempt, OnDirectionAttempt, OnMoveAttempt, OnMoveInput, and OnMove in
SharedRestrictMovementOnVisibilitySystem; these handlers are only subscribed via
SubscribeLocalEvent and not part of the public API, so update their access
modifiers to private (ensure no external code relies on them being public).


public bool IsInContainer(Entity<ScpRestrictMovementOnVisibilityComponent> ent, [NotNullWhen(true)] out EntityUid? storage)
{
storage = null;

if (!_insideQuery.TryComp(ent, out var insideEntityStorageComponent))
return false;

if (!_containerSystem.TryGetContainingContainer(ent.Owner, out var container))
return false;

if (!_whitelist.CheckBoth(container.Owner, ent.Comp.ContainersMoveBlacklist, ent.Comp.ContainersMoveWhitelist))
return false;

storage = insideEntityStorageComponent.Storage;
return true;
}
}
70 changes: 1 addition & 69 deletions Content.Shared/_Scp/Scp173/SharedScp173System.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Content.Shared._Scp.Blinking;
using Content.Shared._Scp.Containment.Cage;
Expand All @@ -7,8 +7,6 @@
using Content.Shared._Scp.Watching;
using Content.Shared.ActionBlocker;
using Content.Shared.DoAfter;
using Content.Shared.Interaction.Events;
using Content.Shared.Movement.Events;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Storage.Components;
Expand Down Expand Up @@ -39,79 +37,13 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<Scp173Component, AttackAttemptEvent>(OnAttackAttempt);

SubscribeLocalEvent<Scp173Component, ChangeDirectionAttemptEvent>(OnDirectionAttempt);
SubscribeLocalEvent<Scp173Component, UpdateCanMoveEvent>(OnMoveAttempt);
SubscribeLocalEvent<Scp173Component, MoveInputEvent>(OnMoveInput);
SubscribeLocalEvent<Scp173Component, MoveEvent>(OnMove);

SubscribeLocalEvent<Scp173Component, Scp173BlindAction>(OnStartedBlind);
SubscribeLocalEvent<Scp173Component, Scp173StartBlind>(OnBlind);

_insideQuery = GetEntityQuery<InsideEntityStorageComponent>();
_scpCageQuery = GetEntityQuery<ScpCageComponent>();
}

#region Movement

private void OnAttackAttempt(Entity<Scp173Component> ent, ref AttackAttemptEvent args)
{
if (IsInScpCage(ent, out _))
{
args.Cancel();
return;
}

if (Watching.IsWatchedByAny(ent, useTimeCompensation: true))
{
args.Cancel();
return;
}
}

private void OnDirectionAttempt(Entity<Scp173Component> ent, ref ChangeDirectionAttemptEvent args)
{
// В клетке можно двигаться
if (IsInScpCage(ent, out _))
return;

if (!Watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;

args.Cancel();
}

private void OnMoveAttempt(Entity<Scp173Component> ent, ref UpdateCanMoveEvent args)
{
// В клетке можно двигаться
if (IsInScpCage(ent, out _))
return;

if (!Watching.IsWatchedByAny(ent, useTimeCompensation: true))
return;

args.Cancel();
}

private void OnMoveInput(Entity<Scp173Component> ent, ref MoveInputEvent args)
{
// Метод подвязанный на MoveInputEvent так же нужен, вместе с методом на MoveEvent
// Этот метод исправляет проблему, когда 173 должен мочь двинуться, но ему об этом никто не сказал
// То есть последний вопрос от 173 МОГУ ЛИ Я ДВИНУТЬСЯ был когда он еще мог двинуться, через MoveEvent
// Потом он перестал мочь, и следственно больше НЕ МОЖЕТ задать вопрос, может они двинуться
// Это фикслось в игре сменой направления спрайта мышкой
// Но данный метод как раз будет спрашивать у 173, может ли он сдвинуться, когда как раз не двигается
_blocker.UpdateCanMove(ent);
}

private void OnMove(Entity<Scp173Component> ent, ref MoveEvent args)
{
_blocker.UpdateCanMove(ent);
}

#endregion

#region Abillities

private void OnStartedBlind(Entity<Scp173Component> ent, ref Scp173BlindAction args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- type: entity
- type: entity
parent:
- BaseScp
- MobCombat
Expand All @@ -19,6 +19,10 @@
- type: Scp
class: Euclid
- type: Scp173
- type: ScpRestrictMovementOnVisibility
containersMoveWhitelist:
components:
- ScpCage
- type: ShowBlinkable
- type: XenoArtifact
effectsTable: !type:GroupSelector
Expand Down
Loading