Skip to content

Commit

Permalink
Removes obsolete visibility system functions (space-wizards#5209)
Browse files Browse the repository at this point in the history
* Removes obsolete visibility system functions

* guh, forgot to add the test

---------

Co-authored-by: plykiya <[email protected]>
  • Loading branch information
Plykiya and plykiya committed Jun 28, 2024
1 parent 08970e7 commit b8924f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
19 changes: 0 additions & 19 deletions Robust.Server/GameObjects/EntitySystems/VisibilitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ public override void Shutdown()
EntityManager.EntityInitialized -= OnEntityInit;
}

[Obsolete("Use Entity<T> variant")]
public void AddLayer(EntityUid uid, VisibilityComponent component, int layer, bool refresh = true)
{
AddLayer((uid, component), (ushort)layer, refresh);
}

public void AddLayer(Entity<VisibilityComponent?> ent, ushort layer, bool refresh = true)
{
ent.Comp ??= _visibilityQuery.CompOrNull(ent.Owner) ?? AddComp<VisibilityComponent>(ent.Owner);
Expand All @@ -59,13 +53,6 @@ public void AddLayer(Entity<VisibilityComponent?> ent, ushort layer, bool refres
RefreshVisibility(ent);
}


[Obsolete("Use Entity<T> variant")]
public void RemoveLayer(EntityUid uid, VisibilityComponent component, int layer, bool refresh = true)
{
RemoveLayer((uid, component), (ushort)layer, refresh);
}

public void RemoveLayer(Entity<VisibilityComponent?> ent, ushort layer, bool refresh = true)
{
if (!_visibilityQuery.Resolve(ent.Owner, ref ent.Comp, false))
Expand All @@ -80,12 +67,6 @@ public void RemoveLayer(Entity<VisibilityComponent?> ent, ushort layer, bool ref
RefreshVisibility(ent);
}

[Obsolete("Use Entity<T> variant")]
public void SetLayer(EntityUid uid, VisibilityComponent component, int layer, bool refresh = true)
{
SetLayer((uid, component), (ushort)layer, refresh);
}

public void SetLayer(Entity<VisibilityComponent?> ent, ushort layer, bool refresh = true)
{
ent.Comp ??= _visibilityQuery.CompOrNull(ent.Owner) ?? AddComp<VisibilityComponent>(ent.Owner);
Expand Down
10 changes: 5 additions & 5 deletions Robust.UnitTesting/Shared/GameState/VisibilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ await server.WaitPost(() =>
metaComp[i] = server.EntMan.GetComponent<MetaDataComponent>(ent);
visComp[i] = server.EntMan.AddComponent<VisibilityComponent>(ent);
vis.AddLayer(ent, visComp[i], 1 << i);
vis.AddLayer((ent, visComp[i]), (ushort)(1 << i));
if (i > 0)
xforms.SetParent(ent, ents[i - 1]);
}
Expand All @@ -62,7 +62,7 @@ await server.WaitPost(() =>
// Adding a layer to the root entity's mask will apply it to all children
var extraMask = 1 << (N + 1);
mask = RequiredMask | extraMask;
vis.AddLayer(ents[0], visComp[0], extraMask);
vis.AddLayer((ents[0], visComp[0]), (ushort)extraMask);
for (int i = 0; i < N; i++)
{
mask |= 1 << i;
Expand All @@ -71,7 +71,7 @@ await server.WaitPost(() =>
}

// Removing the removes it from all children.
vis.RemoveLayer(ents[0], visComp[0], extraMask);
vis.RemoveLayer((ents[0], visComp[0]), (ushort)extraMask);
mask = RequiredMask;
for (int i = 0; i < N; i++)
{
Expand Down Expand Up @@ -101,7 +101,7 @@ await server.WaitPost(() =>
}

// Re-attaching the entity also updates the masks.
await server.WaitPost(() => xforms.SetParent(ents[split], ents[split-1]));
await server.WaitPost(() => xforms.SetParent(ents[split], ents[split - 1]));
mask = RequiredMask;
for (int i = 0; i < N; i++)
{
Expand All @@ -111,7 +111,7 @@ await server.WaitPost(() =>
}

// Setting a mask on a child does not propagate upwards, only downwards
vis.AddLayer(ents[split], visComp[split], extraMask);
vis.AddLayer((ents[split], visComp[split]), (ushort)extraMask);
mask = RequiredMask;
for (int i = 0; i < split; i++)
{
Expand Down

0 comments on commit b8924f3

Please sign in to comment.