]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
NPC exits MeleeOperator on invalid EntityUid (#30005)
authorosjarw <62134478+osjarw@users.noreply.github.com>
Sun, 14 Jul 2024 03:26:38 +0000 (06:26 +0300)
committerGitHub <noreply@github.com>
Sun, 14 Jul 2024 03:26:38 +0000 (13:26 +1000)
EntityUid 0 problem fix

Content.Server/NPC/HTN/PrimitiveTasks/Operators/Combat/Melee/MeleeOperator.cs
Content.Server/NPC/Systems/NPCJukeSystem.cs

index 32be027ec43f646768126dc0b6ea11db4ccaec2c..5a02b86201be210bc6d54dde73c193b7b9f13968 100644 (file)
@@ -89,7 +89,8 @@ public sealed partial class MeleeOperator : HTNOperator, IHtnConditionalShutdown
         HTNOperatorStatus status;
 
         if (_entManager.TryGetComponent<NPCMeleeCombatComponent>(owner, out var combat) &&
-            blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager))
+            blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager) &&
+            target != EntityUid.Invalid)
         {
             combat.Target = target;
 
index da9fa1f7615f4ee4871748d5cf0bb301ed5ad0e6..94a30feb0cb2423d317face141631c2e576923a1 100644 (file)
@@ -143,6 +143,9 @@ public sealed class NPCJukeSystem : EntitySystem
                 if (!_melee.TryGetWeapon(uid, out var weaponUid, out var weapon))
                     return;
 
+                if (!HasComp<TransformComponent>(melee.Target))
+                    return;
+
                 var cdRemaining = weapon.NextAttack - _timing.CurTime;
                 var attackCooldown = TimeSpan.FromSeconds(1f / _melee.GetAttackRate(weaponUid, uid, weapon));