From 34b7e31e76fa1762436ada3654080079f270100f Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 6 Sep 2022 13:40:31 +1000 Subject: [PATCH] Context menu tweaks (#10883) --- Content.Client/Verbs/VerbSystem.cs | 45 ++++++++++++------- .../Entities/Objects/Tools/jetpacks.yml | 5 ++- .../Weapons/Guns/Projectiles/hitscan.yml | 3 ++ .../Weapons/Guns/Projectiles/impacts.yml | 9 ++++ .../Weapons/Guns/Projectiles/projectiles.yml | 3 ++ 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/Content.Client/Verbs/VerbSystem.cs b/Content.Client/Verbs/VerbSystem.cs index 5062ce57ea..d14f3ab76f 100644 --- a/Content.Client/Verbs/VerbSystem.cs +++ b/Content.Client/Verbs/VerbSystem.cs @@ -21,6 +21,7 @@ using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; +using Robust.Shared.Utility; namespace Content.Client.Verbs { @@ -130,43 +131,53 @@ namespace Content.Client.Verbs // remove any entities in containers if ((visibility & MenuVisibility.InContainer) == 0) { - foreach (var entity in entities.ToList()) + for (var i = entities.Count - 1; i >= 0; i--) { - if (!ContainerSystem.IsInSameOrTransparentContainer(player.Value, entity)) - entities.Remove(entity); + var entity = entities[i]; + + if (ContainerSystem.IsInSameOrTransparentContainer(player.Value, entity)) + continue; + + entities.RemoveSwap(i); } } // remove any invisible entities if ((visibility & MenuVisibility.Invisible) == 0) { - foreach (var entity in entities.ToList()) - { - if (!EntityManager.TryGetComponent(entity, out ISpriteComponent? spriteComponent) || - !spriteComponent.Visible) - { - entities.Remove(entity); - continue; - } + var spriteQuery = GetEntityQuery(); + var tagQuery = GetEntityQuery(); - if (_tagSystem.HasTag(entity, "HideContextMenu")) - entities.Remove(entity); + for (var i = entities.Count - 1; i >= 0; i--) + { + var entity = entities[i]; + + if (!spriteQuery.TryGetComponent(entity, out var spriteComponent) || + !spriteComponent.Visible || + _tagSystem.HasTag(entity, "HideContextMenu", tagQuery)) + { + entities.RemoveSwap(i); + } } } // Remove any entities that do not have LOS if ((visibility & MenuVisibility.NoFov) == 0) { - var playerPos = EntityManager.GetComponent(player.Value).MapPosition; - foreach (var entity in entities.ToList()) + var xformQuery = GetEntityQuery(); + var playerPos = xformQuery.GetComponent(player.Value).MapPosition; + + for (var i = entities.Count - 1; i >= 0; i--) { + var entity = entities[i]; + if (!ExamineSystemShared.InRangeUnOccluded( playerPos, - EntityManager.GetComponent(entity).MapPosition, + xformQuery.GetComponent(entity).MapPosition, ExamineSystemShared.ExamineRange, null)) { - entities.Remove(entity); + entities.RemoveSwap(i); } } } diff --git a/Resources/Prototypes/Entities/Objects/Tools/jetpacks.yml b/Resources/Prototypes/Entities/Objects/Tools/jetpacks.yml index 02553c59e4..2fa2b514cd 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/jetpacks.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/jetpacks.yml @@ -6,7 +6,7 @@ lifetime: 2 - type: Sprite netsync: false - drawdepth: Effects + drawdepth: SmallMobs noRot: true layers: - shader: unshaded @@ -14,6 +14,9 @@ sprite: Effects/atmospherics.rsi state: frezon_old - type: EffectVisuals + - type: Tag + tags: + - HideContextMenu - type: AnimationPlayer - type: entity diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml index 75e77c9f65..ff142824d7 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml @@ -10,6 +10,9 @@ - shader: unshaded map: ["enum.EffectLayers.Unshaded"] - type: EffectVisuals + - type: Tag + tags: + - HideContextMenu - type: AnimationPlayer - type: hitscan diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/impacts.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/impacts.yml index cab052b8d5..394458cba1 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/impacts.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/impacts.yml @@ -13,6 +13,9 @@ sprite: Objects/Weapons/Guns/Projectiles/projectiles_tg.rsi state: impact_bullet - type: EffectVisuals + - type: Tag + tags: + - HideContextMenu - type: entity id: BulletImpactEffectDisabler @@ -29,6 +32,9 @@ sprite: Objects/Weapons/Guns/Projectiles/projectiles_tg.rsi state: impact_laser_blue - type: EffectVisuals + - type: Tag + tags: + - HideContextMenu - type: entity id: BulletImpactEffectKinetic @@ -45,3 +51,6 @@ sprite: Effects/arcs.rsi state: punch - type: EffectVisuals + - type: Tag + tags: + - HideContextMenu diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml index f00aa20d92..7fa616aa9e 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml @@ -13,6 +13,9 @@ sprite: Objects/Weapons/Guns/Projectiles/projectiles.rsi state: muzzle_bullet - type: EffectVisuals + - type: Tag + tags: + - HideContextMenu - type: AnimationPlayer # One bullet to bring them all into the darkness and bind them