NPC exits MeleeOperator on invalid EntityUid (#30005)
EntityUid 0 problem fix
This commit is contained in:
@@ -89,7 +89,8 @@ public sealed partial class MeleeOperator : HTNOperator, IHtnConditionalShutdown
|
|||||||
HTNOperatorStatus status;
|
HTNOperatorStatus status;
|
||||||
|
|
||||||
if (_entManager.TryGetComponent<NPCMeleeCombatComponent>(owner, out var combat) &&
|
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;
|
combat.Target = target;
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ public sealed class NPCJukeSystem : EntitySystem
|
|||||||
if (!_melee.TryGetWeapon(uid, out var weaponUid, out var weapon))
|
if (!_melee.TryGetWeapon(uid, out var weaponUid, out var weapon))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!HasComp<TransformComponent>(melee.Target))
|
||||||
|
return;
|
||||||
|
|
||||||
var cdRemaining = weapon.NextAttack - _timing.CurTime;
|
var cdRemaining = weapon.NextAttack - _timing.CurTime;
|
||||||
var attackCooldown = TimeSpan.FromSeconds(1f / _melee.GetAttackRate(weaponUid, uid, weapon));
|
var attackCooldown = TimeSpan.FromSeconds(1f / _melee.GetAttackRate(weaponUid, uid, weapon));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user