Remove gun .Owners (#14585)

This commit is contained in:
metalgearsloth
2023-03-11 20:08:22 +11:00
committed by GitHub
parent 19f5c403b5
commit 330bb7bb14
18 changed files with 333 additions and 280 deletions

View File

@@ -49,8 +49,9 @@ public sealed partial class NPCCombatSystem
var bodyQuery = GetEntityQuery<PhysicsComponent>();
var xformQuery = GetEntityQuery<TransformComponent>();
var combatQuery = GetEntityQuery<SharedCombatModeComponent>();
var query = EntityQueryEnumerator<NPCRangedCombatComponent, TransformComponent>();
foreach (var (comp, xform) in EntityQuery<NPCRangedCombatComponent, TransformComponent>())
while (query.MoveNext(out var uid, out var comp, out var xform))
{
if (comp.Status == CombatStatus.Unspecified)
continue;
@@ -70,14 +71,12 @@ public sealed partial class NPCCombatSystem
continue;
}
if (combatQuery.TryGetComponent(comp.Owner, out var combatMode))
if (combatQuery.TryGetComponent(uid, out var combatMode))
{
combatMode.IsInCombatMode = true;
}
var gun = _gun.GetGun(comp.Owner);
if (gun == null)
if (!_gun.TryGetGun(uid, out var gunUid, out var gun))
{
comp.Status = CombatStatus.NoWeapon;
comp.ShootAccumulator = 0f;
@@ -98,7 +97,7 @@ public sealed partial class NPCCombatSystem
if (comp.LOSAccumulator < 0f)
{
comp.LOSAccumulator += UnoccludedCooldown;
comp.TargetInLOS = _interaction.InRangeUnobstructed(comp.Owner, comp.Target, distance + 0.1f);
comp.TargetInLOS = _interaction.InRangeUnobstructed(uid, comp.Target, distance + 0.1f);
}
if (!comp.TargetInLOS)
@@ -110,7 +109,7 @@ public sealed partial class NPCCombatSystem
if (!oldInLos && comp.SoundTargetInLOS != null)
{
_audio.PlayPvs(comp.SoundTargetInLOS, comp.Owner);
_audio.PlayPvs(comp.SoundTargetInLOS, uid);
}
comp.ShootAccumulator += frameTime;
@@ -127,7 +126,7 @@ public sealed partial class NPCCombatSystem
var goalRotation = (targetSpot - worldPos).ToWorldAngle();
var rotationSpeed = comp.RotationSpeed;
if (!_rotate.TryRotateTo(comp.Owner, goalRotation, frameTime, comp.AccuracyThreshold, rotationSpeed?.Theta ?? double.MaxValue, xform))
if (!_rotate.TryRotateTo(uid, goalRotation, frameTime, comp.AccuracyThreshold, rotationSpeed?.Theta ?? double.MaxValue, xform))
{
continue;
}
@@ -154,7 +153,7 @@ public sealed partial class NPCCombatSystem
targetCordinates = new EntityCoordinates(xform.MapUid!.Value, targetSpot);
}
_gun.AttemptShoot(comp.Owner, gun, targetCordinates);
_gun.AttemptShoot(uid, gunUid, gun, targetCordinates);
}
}
}