From 3a656865216f074ac1f3ee0e20b94b4755230862 Mon Sep 17 00:00:00 2001 From: Dvir <39403717+dvir001@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:32:13 +0300 Subject: [PATCH] Small Mobs Fixing (#1665) * Einstein-Engines fix https://github.com/Simple-Station/Einstein-Engines/pull/530 * Update BluespaceErrorRule.cs --- .../NPC/Systems/NPCCombatSystem.Ranged.cs | 1 + .../StationEvents/Events/BluespaceErrorRule.cs | 16 ++++++++++++++-- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs b/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs index 10ec54c8954..18f09341e91 100644 --- a/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs +++ b/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs @@ -203,6 +203,7 @@ private void UpdateRanged(float frameTime) return; } + _gun.SetTarget(gun, comp.Target); // Frontier - This ensures that the bullet won't fly over the target if it's downed _gun.AttemptShoot(uid, gunUid, gun, targetCordinates); } } diff --git a/Content.Server/StationEvents/Events/BluespaceErrorRule.cs b/Content.Server/StationEvents/Events/BluespaceErrorRule.cs index e924b7ac83a..e39d09d7d33 100644 --- a/Content.Server/StationEvents/Events/BluespaceErrorRule.cs +++ b/Content.Server/StationEvents/Events/BluespaceErrorRule.cs @@ -11,6 +11,7 @@ using Content.Shared.Humanoid; using Content.Shared.Mobs.Components; using Robust.Shared.Random; +using Content.Server._NF.Salvage; namespace Content.Server.StationEvents.Events; @@ -75,6 +76,17 @@ protected override void Ended(EntityUid uid, BluespaceErrorRuleComponent compone var gridValue = _pricing.AppraiseGrid(gridUid, null); + // Handle mobrestrictions getting deleted + var query = AllEntityQuery(); + + while (query.MoveNext(out var salvUid, out var salvMob)) + { + if (gridTransform.GridUid == salvMob.LinkedGridEntity) + { + QueueDel(salvUid); + } + } + var mobQuery = AllEntityQuery(); _playerMobs.Clear(); @@ -96,8 +108,8 @@ protected override void Ended(EntityUid uid, BluespaceErrorRuleComponent compone _transform.SetCoordinates(mob.Entity.Owner, new EntityCoordinates(mob.MapUid, mob.LocalPosition)); } - var query = EntityQuery(); - foreach (var account in query) + var queryBank = EntityQuery(); + foreach (var account in queryBank) { _cargo.DeductFunds(account, (int)-(gridValue * component.RewardFactor)); } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 6ae981dee48..75aa3ab5027 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -205,6 +205,14 @@ private void StopShooting(EntityUid uid, GunComponent gun) Dirty(uid, gun); } + /// + /// Frontier - Sets the targeted entity of the gun. Should be called before attempting to shoot to avoid shooting over the target. + /// + public void SetTarget(GunComponent gun, EntityUid target) + { + gun.Target = target; + } + /// /// Attempts to shoot at the target coordinates. Resets the shot counter after every shot. ///