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

Update HideMechanismsCommand.cs #30006

Closed
wants to merge 3 commits into from
Closed
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
16 changes: 11 additions & 5 deletions Content.Client/Commands/HideMechanismsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ public sealed class HideMechanismsCommand : LocalizedCommands
{
[Dependency] private readonly IEntityManager _entityManager = default!;

public override string Command => "hidemechanisms";

public override string Description => LocalizationManager.GetString($"cmd-{Command}-desc", ("showMechanismsCommand", ShowMechanismsCommand.CommandName));
private EntityQuery<TransformComponent> _xformQuery;

public override string Help => LocalizationManager.GetString($"cmd-{Command}-help", ("command", Command));
public override string Command => "hidemechanisms";

public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var containerSys = _entityManager.System<SharedContainerSystem>();
var query = _entityManager.AllEntityQueryEnumerator<OrganComponent>();

_xformQuery = _entityManager.GetEntityQuery<TransformComponent>();

while (query.MoveNext(out var uid, out _))
{
if (!_entityManager.TryGetComponent(uid, out SpriteComponent? sprite))
Expand All @@ -29,8 +29,11 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)

sprite.ContainerOccluded = false;

if (!_xformQuery.TryGetComponent(uid, out var xform))
return;
var tempParent = uid;
while (containerSys.TryGetContainingContainer(tempParent, out var container))

while (containerSys.TryGetContainingContainer(xform.ParentUid, tempParent,out var container))
{
if (!container.ShowContents)
{
Expand All @@ -39,6 +42,9 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
}

tempParent = container.Owner;

if (!_xformQuery.TryGetComponent(tempParent, out xform))
break;
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions Content.Client/Commands/ShowMechanismsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ public sealed class ShowMechanismsCommand : LocalizedCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;

public const string CommandName = "showmechanisms";

public override string Command => CommandName;

public override string Help => LocalizationManager.GetString($"cmd-{Command}-help", ("command", Command));
public override string Command => "showmechanisms";

public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
Expand Down
4 changes: 2 additions & 2 deletions Resources/Locale/en-US/commands/hide-mechanisms-command.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cmd-hidemechanisms-desc = Reverts the effects of {$showMechanismsCommand}
cmd-hidemechanisms-help = Usage: {$command}
cmd-hidemechanisms-desc = Reverts the effects of the showmechanisms command.
cmd-hidemechanisms-help = Usage: hidemechanisms
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cmd-showmechanisms-desc = Makes mechanisms visible, even when they shouldn't be.
cmd-showmechanisms-help = Usage: {$command}
cmd-showmechanisms-help = Usage: showmechanisms
Loading