Skip to content
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

Shared portion of PvsOverrideSystem to allow for usage in shared #5651

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions Robust.Client/GameStates/PvsOverrideSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Robust.Shared.GameStates;

namespace Robust.Client.GameStates;

public sealed partial class PvsOverrideSystem : SharedPvsOverrideSystem;
23 changes: 17 additions & 6 deletions Robust.Server/GameStates/PvsOverrideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Robust.Server.GameStates;

public sealed class PvsOverrideSystem : EntitySystem
public sealed class PvsOverrideSystem : SharedPvsOverrideSystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IConsoleHost _console = default!;
Expand Down Expand Up @@ -134,17 +135,21 @@ private void Clear(EntityUid uid)
/// Forces the entity, all of its parents, and all of its children to ignore normal PVS range limitations,
/// causing them to always be sent to all clients.
/// </summary>
public void AddGlobalOverride(EntityUid uid)
public override void AddGlobalOverride(EntityUid uid)
{
base.AddGlobalOverride(uid);

if (GlobalOverride.Add(uid))
_hasOverride.Add(uid);
}

/// <summary>
/// Removes an entity from the global overrides.
/// </summary>
public void RemoveGlobalOverride(EntityUid uid)
public override void RemoveGlobalOverride(EntityUid uid)
{
base.RemoveGlobalOverride(uid);

GlobalOverride.Remove(uid);
// Not bothering to clear _hasOverride, as we'd have to check all the other collections, and at that point we
// might as well just do that when the entity gets deleted anyways.
Expand Down Expand Up @@ -203,17 +208,21 @@ public void RemoveForceSend(EntityUid uid, ICommonSession session)
/// Forces the entity, all of its parents, and all of its children to ignore normal PVS range limitations for a
/// specific session.
/// </summary>
public void AddSessionOverride(EntityUid uid, ICommonSession session)
public override void AddSessionOverride(EntityUid uid, ICommonSession session)
{
base.AddSessionOverride(uid, session);

if (SessionOverrides.GetOrNew(session).Add(uid))
_hasOverride.Add(uid);
}

/// <summary>
/// Removes an entity from a session's overrides.
/// </summary>
public void RemoveSessionOverride(EntityUid uid, ICommonSession session)
public override void RemoveSessionOverride(EntityUid uid, ICommonSession session)
{
base.RemoveSessionOverride(uid, session);

if (!SessionOverrides.TryGetValue(session, out var overrides))
return;

Expand All @@ -228,8 +237,10 @@ public void RemoveSessionOverride(EntityUid uid, ICommonSession session)
/// Forces the entity, all of its parents, and all of its children to ignore normal PVS range limitations,
/// causing them to always be sent to all clients.
/// </summary>
public void AddSessionOverrides(EntityUid uid, Filter filter)
public override void AddSessionOverrides(EntityUid uid, Filter filter)
{
base.AddSessionOverrides(uid, filter);

foreach (var session in filter.Recipients)
{
AddSessionOverride(uid, session);
Expand Down
50 changes: 50 additions & 0 deletions Robust.Shared/GameStates/SharedPvsOverrideSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Player;

namespace Robust.Shared.GameStates;

public abstract class SharedPvsOverrideSystem : EntitySystem
{
/// <summary>
/// Forces the entity, all of its parents, and all of its children to ignore normal PVS range limitations,
/// causing them to always be sent to all clients.
/// </summary>
public virtual void AddGlobalOverride(EntityUid uid)
{

}

/// <summary>
/// Removes an entity from the global overrides.
/// </summary>
public virtual void RemoveGlobalOverride(EntityUid uid)
{

}

/// <summary>
/// Forces the entity, all of its parents, and all of its children to ignore normal PVS range limitations for a
/// specific session.
/// </summary>
public virtual void AddSessionOverride(EntityUid uid, ICommonSession session)
{

}

/// <summary>
/// Removes an entity from a session's overrides.
/// </summary>
public virtual void RemoveSessionOverride(EntityUid uid, ICommonSession session)
{

}

/// <summary>
/// Forces the entity, all of its parents, and all of its children to ignore normal PVS range limitations,
/// causing them to always be sent to all clients.
/// </summary>
public virtual void AddSessionOverrides(EntityUid uid, Filter filter)
{

}
}
Loading