diff --git a/Nitrox.Test/Patcher/Patches/Dynamic/SeaDragonMeleeAttack_SwatAttack_PatchTest.cs b/Nitrox.Test/Patcher/Patches/Dynamic/SeaDragonMeleeAttack_SwatAttack_PatchTest.cs index 025cc4e41e..63f36825a0 100644 --- a/Nitrox.Test/Patcher/Patches/Dynamic/SeaDragonMeleeAttack_SwatAttack_PatchTest.cs +++ b/Nitrox.Test/Patcher/Patches/Dynamic/SeaDragonMeleeAttack_SwatAttack_PatchTest.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; using HarmonyLib; -using Microsoft.VisualStudio.TestTools.UnitTesting; using NitroxTest.Patcher; namespace NitroxPatcher.Patches.Dynamic; diff --git a/NitroxClient/GameLogic/AI.cs b/NitroxClient/GameLogic/AI.cs index 21de6a2b94..a34b201ffd 100644 --- a/NitroxClient/GameLogic/AI.cs +++ b/NitroxClient/GameLogic/AI.cs @@ -89,7 +89,7 @@ public static void AggressiveWhenSeeTargetChanged(NitroxId creatureId, NitroxId lastTarget.SetTargetInternal(targetObject); lastTarget.targetLocked = locked; - if (aggressiveWhenSeeTarget.sightedSound != null && !aggressiveWhenSeeTarget.sightedSound.GetIsPlaying()) + if (aggressiveWhenSeeTarget.sightedSound && !aggressiveWhenSeeTarget.sightedSound.GetIsPlaying()) { // TODO: Adapt this code when #1780 is merged aggressiveWhenSeeTarget.sightedSound.StartEvent(); diff --git a/NitroxClient/GameLogic/BulletManager.cs b/NitroxClient/GameLogic/BulletManager.cs index 34f58d7ae6..3fa685980d 100644 --- a/NitroxClient/GameLogic/BulletManager.cs +++ b/NitroxClient/GameLogic/BulletManager.cs @@ -55,6 +55,8 @@ public void ShootSeamothTorpedo(NitroxId bulletId, TechType techType, Vector3 po public void TorpedoHit(NitroxId bulletId, Vector3 position, Quaternion rotation) { + // On the local player, the torpedo might have already exploded while the packet is received with latency. + // Therefore we don't need to log a failed query of bulletId if (NitroxEntity.TryGetComponentFrom(bulletId, out SeamothTorpedo torpedo)) { torpedo.tr.position = position; @@ -111,6 +113,7 @@ private StasisSphere EnsurePlayerHasSphere(ushort playerId) // It should be set to inactive automatically in Bullet.Awake GameObject playerSphereClone = GameObject.Instantiate(stasisSpherePrefab); + playerSphereClone.name = $"remote-{playerId}-{playerSphereClone.name}"; // We mark it to be able to ignore events from remote bullets playerSphereClone.AddComponent(); StasisSphere stasisSphere = playerSphereClone.GetComponent(); @@ -159,8 +162,8 @@ public IEnumerator Initialize() EnsurePlayerHasSphere(remotePlayer.PlayerId); } - playerManager.onCreate += (playerId, _) => { EnsurePlayerHasSphere(playerId); }; - playerManager.onRemove += (playerId, _) => { DestroyPlayerSphere(playerId); }; + playerManager.OnCreate += (playerId, _) => { EnsurePlayerHasSphere(playerId); }; + playerManager.OnRemove += (playerId, _) => { DestroyPlayerSphere(playerId); }; } public class RemotePlayerBullet : MonoBehaviour { } diff --git a/NitroxClient/GameLogic/PlayerManager.cs b/NitroxClient/GameLogic/PlayerManager.cs index bbfdf4d461..4ca5d1b34a 100644 --- a/NitroxClient/GameLogic/PlayerManager.cs +++ b/NitroxClient/GameLogic/PlayerManager.cs @@ -78,7 +78,7 @@ public void RemovePlayer(ushort playerId) { player.Destroy(); playersById.Remove(playerId); - OnRemove(playerId, opPlayer.Value); + OnRemove(playerId, player); DiscordClient.UpdatePartySize(GetTotalPlayerCount()); } } diff --git a/NitroxPatcher/Patches/Dynamic/AggressiveWhenSeeTarget_IsTargetValid_Patch.cs b/NitroxPatcher/Patches/Dynamic/AggressiveWhenSeeTarget_IsTargetValid_Patch.cs index 5253a4f349..2d191205cd 100644 --- a/NitroxPatcher/Patches/Dynamic/AggressiveWhenSeeTarget_IsTargetValid_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/AggressiveWhenSeeTarget_IsTargetValid_Patch.cs @@ -7,7 +7,7 @@ namespace NitroxPatcher.Patches.Dynamic; /// -/// Allow creatures to chose remote players as targets only if they can be attacked () +/// Allow creatures to choose remote players as targets only if they can be attacked () /// public sealed partial class AggressiveWhenSeeTarget_IsTargetValid_Patch : NitroxPatch, IDynamicPatch { @@ -19,7 +19,7 @@ public static bool Prefix(GameObject target, ref bool __result) { return false; } - // We only want to cancel if the target is a remote player which can't attacked + // We only want to cancel if the target is a remote player which can't be attacked if (target.TryGetComponent(out RemotePlayerIdentifier remotePlayerIdentifier) && !remotePlayerIdentifier.RemotePlayer.CanBeAttacked()) { diff --git a/NitroxPatcher/Patches/Dynamic/AttackCyclops_UpdateAggression_Patch.cs b/NitroxPatcher/Patches/Dynamic/AttackCyclops_UpdateAggression_Patch.cs index 81ebde5da8..6d3df4fcbf 100644 --- a/NitroxPatcher/Patches/Dynamic/AttackCyclops_UpdateAggression_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/AttackCyclops_UpdateAggression_Patch.cs @@ -4,7 +4,7 @@ using HarmonyLib; using NitroxClient.Communication.Abstract; using NitroxClient.GameLogic; -using NitroxClient.GameLogic.PlayerLogic; +using NitroxClient.MonoBehaviours.Cyclops; using NitroxModel.DataStructures; using NitroxModel.Helper; using NitroxModel.Packets; @@ -58,9 +58,8 @@ public static bool Prefix(AttackCyclops __instance) public static void Postfix(AttackCyclops __instance) { - if (__instance.currentTarget && __instance.TryGetNitroxId(out NitroxId creatureId) && - __instance.currentTarget.TryGetNitroxId(out NitroxId targetId) && - Resolve().HasAnyLockType(creatureId)) + if (__instance.currentTarget && __instance.currentTarget.TryGetNitroxId(out NitroxId targetId) && + __instance.TryGetNitroxId(out NitroxId creatureId) && Resolve().HasAnyLockType(creatureId)) { float aggressiveToNoise = __instance.aggressiveToNoise.Value; @@ -87,19 +86,6 @@ public static bool IsTargetAValidInhabitedCyclops(IEcoTarget target) public static bool IsTargetAValidInhabitedCyclops(GameObject targetObject) { - // Is a Cyclops - if (!targetObject.TryGetComponent(out SubRoot subRoot) || !subRoot.isCyclops) - { - return false; - } - - // Has the local player inside - if (Player.main && Player.main.currentSub == subRoot) - { - return true; - } - - // Has a remote player inside - return targetObject.GetComponentInChildren(true); + return targetObject.TryGetComponent(out NitroxCyclops nitroxCyclops) && nitroxCyclops.Pawns.Count > 0; } } diff --git a/NitroxPatcher/Patches/Dynamic/AttackLastTarget_CanAttackTarget_Patch.cs b/NitroxPatcher/Patches/Dynamic/AttackLastTarget_CanAttackTarget_Patch.cs index 12b0c80d7d..9a49c9d3bd 100644 --- a/NitroxPatcher/Patches/Dynamic/AttackLastTarget_CanAttackTarget_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/AttackLastTarget_CanAttackTarget_Patch.cs @@ -7,7 +7,7 @@ namespace NitroxPatcher.Patches.Dynamic; /// -/// Allows creatures to chose remote players as targets only if they can be attacked () +/// Allows creatures to choose remote players as targets only if they can be attacked () /// public sealed partial class AttackLastTarget_CanAttackTarget_Patch : NitroxPatch, IDynamicPatch { @@ -19,7 +19,7 @@ public static bool Prefix(GameObject target, ref bool __result) { return false; } - // We only want to cancel if the target is a remote player which can't attacked + // We only want to cancel if the target is a remote player which can't be attacked if (target.TryGetComponent(out RemotePlayerIdentifier remotePlayerIdentifier) && !remotePlayerIdentifier.RemotePlayer.CanBeAttacked()) { diff --git a/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCasting_Patch.cs b/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCasting_Patch.cs index 1cbae4a3c7..c961387e05 100644 --- a/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCasting_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCasting_Patch.cs @@ -1,7 +1,4 @@ using System.Reflection; -using NitroxClient.Communication.Abstract; -using NitroxClient.GameLogic; -using NitroxModel.DataStructures; using NitroxModel.Helper; using NitroxModel.Packets; @@ -17,18 +14,10 @@ public sealed partial class RangedAttackLastTarget_StartCasting_Patch : NitroxPa public static void Prefix(RangedAttackLastTarget __instance) { - if (!Resolve().IsCreatureWhitelisted(__instance.creature) || - !__instance.TryGetNitroxId(out NitroxId creatureId) || - !Resolve().HasAnyLockType(creatureId) || - !__instance.currentTarget || !__instance.currentTarget.TryGetNitroxId(out NitroxId targetId)) + if (RangedAttackLastTarget_StartCharging_Patch.BroadcastRangedAttack(__instance, RangedAttackLastTargetUpdate.ActionState.CASTING)) { - return; + ErrorMessage.AddMessage($"[SEND] {__instance.name} casts against {__instance.currentTarget.name}"); } - - int attackTypeIndex = __instance.attackTypes.GetIndex(__instance.currentAttack); - - Resolve().Send(new RangedAttackLastTargetUpdate(creatureId, targetId, attackTypeIndex, RangedAttackLastTargetUpdate.ActionState.CASTING)); - ErrorMessage.AddMessage($"[SEND] {__instance.name} casts against {__instance.currentTarget.name}"); } } diff --git a/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCharging_Patch.cs b/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCharging_Patch.cs index c093333c25..f80800b807 100644 --- a/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCharging_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/RangedAttackLastTarget_StartCharging_Patch.cs @@ -8,7 +8,7 @@ namespace NitroxPatcher.Patches.Dynamic; /// -/// Prevents non simulating players from running locally . +/// Prevents non simulating players from running locally . /// Broadcasts this event on the simulating player. /// public sealed partial class RangedAttackLastTarget_StartCharging_Patch : NitroxPatch, IDynamicPatch @@ -17,18 +17,42 @@ public sealed partial class RangedAttackLastTarget_StartCharging_Patch : NitroxP public static void Prefix(RangedAttackLastTarget __instance) { - if (!Resolve().IsCreatureWhitelisted(__instance.creature) || - !__instance.TryGetNitroxId(out NitroxId creatureId) || - !Resolve().HasAnyLockType(creatureId) || - !__instance.currentTarget || !__instance.currentTarget.TryGetNitroxId(out NitroxId targetId)) + if (BroadcastRangedAttack(__instance, RangedAttackLastTargetUpdate.ActionState.CHARGING)) { - return; + ErrorMessage.AddMessage($"[SEND] {__instance.name} charges against {__instance.currentTarget.name}"); + } + } + + /// + /// Broadcasts a range attack CHARGING or CASTING state if the attacking creature is whitelisted, valid and if the target is valid. + /// + /// + /// true if the broadcast was done (all conditions met) + /// + internal static bool BroadcastRangedAttack(RangedAttackLastTarget attackBehaviour, RangedAttackLastTargetUpdate.ActionState actionState) + { + // should action be broadcasted + if (!Resolve().IsCreatureWhitelisted(attackBehaviour.creature)) + { + return false; + } + + // Attacker object validity + if (!attackBehaviour.TryGetNitroxId(out NitroxId creatureId) || !Resolve().HasAnyLockType(creatureId)) + { + return false; + } + + // Target validity + if (!attackBehaviour.currentTarget || !attackBehaviour.currentTarget.TryGetNitroxId(out NitroxId targetId)) + { + return false; } - int attackTypeIndex = __instance.attackTypes.GetIndex(__instance.currentAttack); + int attackTypeIndex = attackBehaviour.attackTypes.GetIndex(attackBehaviour.currentAttack); - Resolve().Send(new RangedAttackLastTargetUpdate(creatureId, targetId, attackTypeIndex, RangedAttackLastTargetUpdate.ActionState.CHARGING)); - ErrorMessage.AddMessage($"[SEND] {__instance.name} charges against {__instance.currentTarget.name}"); + Resolve().Send(new RangedAttackLastTargetUpdate(creatureId, targetId, attackTypeIndex, actionState)); + return true; } } diff --git a/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_GrabVehicle_Patch.cs b/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_GrabVehicle_Patch.cs index e100afe95c..5cf0b9370a 100644 --- a/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_GrabVehicle_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_GrabVehicle_Patch.cs @@ -1,5 +1,5 @@ using System.Reflection; -using NitroxClient.MonoBehaviours; +using NitroxClient.MonoBehaviours.Vehicles; using NitroxModel.Helper; namespace NitroxPatcher.Patches.Dynamic; @@ -13,9 +13,9 @@ public sealed partial class ReaperLeviathan_GrabVehicle_Patch : NitroxPatch, IDy public static void Prefix(Vehicle vehicle) { - if (vehicle.TryGetComponent(out RemotelyControlled remotelyControlled)) + if (vehicle.TryGetComponent(out VehicleMovementReplicator vehicleMovementReplicator)) { - remotelyControlled.enabled = false; + vehicleMovementReplicator.enabled = false; } } } diff --git a/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_ReleaseVehicle_Patch.cs b/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_ReleaseVehicle_Patch.cs index bb2b5f144c..a23e26a21a 100644 --- a/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_ReleaseVehicle_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/ReaperLeviathan_ReleaseVehicle_Patch.cs @@ -1,5 +1,5 @@ using System.Reflection; -using NitroxClient.MonoBehaviours; +using NitroxClient.MonoBehaviours.Vehicles; using NitroxModel.Helper; namespace NitroxPatcher.Patches.Dynamic; @@ -13,10 +13,9 @@ public sealed partial class ReaperLeviathan_ReleaseVehicle_Patch : NitroxPatch, public static void Prefix(ReaperLeviathan __instance) { - if (__instance.holdingVehicle && - __instance.holdingVehicle.TryGetComponent(out RemotelyControlled remotelyControlled)) + if (__instance.holdingVehicle && __instance.holdingVehicle.TryGetComponent(out VehicleMovementReplicator vehicleMovementReplicator)) { - remotelyControlled.enabled = true; + vehicleMovementReplicator.enabled = true; } } } diff --git a/NitroxPatcher/Patches/Dynamic/SeaDragon_GrabExosuit_Patch.cs b/NitroxPatcher/Patches/Dynamic/SeaDragon_GrabExosuit_Patch.cs index 764e7b8be9..e04022c63a 100644 --- a/NitroxPatcher/Patches/Dynamic/SeaDragon_GrabExosuit_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/SeaDragon_GrabExosuit_Patch.cs @@ -1,6 +1,7 @@ using System.Reflection; using NitroxClient.Communication.Abstract; -using NitroxClient.MonoBehaviours; +using NitroxClient.GameLogic; +using NitroxClient.MonoBehaviours.Vehicles; using NitroxModel.DataStructures; using NitroxModel.Helper; using NitroxModel.Packets; @@ -8,7 +9,7 @@ namespace NitroxPatcher.Patches.Dynamic; /// -/// Broadcasts the exosuit grab by Sea Dragons and temporarily disables exosuit's position sync while they're grabbed. +/// Broadcasts the exosuit grab by Sea Dragons (if local player has remote control of them) and temporarily disables exosuit's position sync while they're grabbed. /// public sealed partial class SeaDragon_GrabExosuit_Patch : NitroxPatch, IDynamicPatch { @@ -16,12 +17,13 @@ public sealed partial class SeaDragon_GrabExosuit_Patch : NitroxPatch, IDynamicP public static void Prefix(SeaDragon __instance, Exosuit exosuit) { - if (exosuit.TryGetComponent(out RemotelyControlled remotelyControlled)) + if (exosuit.TryGetComponent(out VehicleMovementReplicator vehicleMovementReplicator)) { - remotelyControlled.enabled = false; + vehicleMovementReplicator.enabled = false; } - if (__instance.TryGetNitroxId(out NitroxId seaDragonId) && exosuit.TryGetNitroxId(out NitroxId targetId)) + if (__instance.TryGetNitroxId(out NitroxId seaDragonId) && Resolve().HasAnyLockType(seaDragonId) && + exosuit.TryGetNitroxId(out NitroxId targetId)) { Resolve().Send(new SeaDragonGrabExosuit(seaDragonId, targetId)); } diff --git a/NitroxPatcher/Patches/Dynamic/SeaDrargon_ReleaseExosuit_Patch.cs b/NitroxPatcher/Patches/Dynamic/SeaDragon_ReleaseExosuit_Patch.cs similarity index 54% rename from NitroxPatcher/Patches/Dynamic/SeaDrargon_ReleaseExosuit_Patch.cs rename to NitroxPatcher/Patches/Dynamic/SeaDragon_ReleaseExosuit_Patch.cs index 14ec2adbbc..6da6949d6c 100644 --- a/NitroxPatcher/Patches/Dynamic/SeaDrargon_ReleaseExosuit_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/SeaDragon_ReleaseExosuit_Patch.cs @@ -1,5 +1,5 @@ using System.Reflection; -using NitroxClient.MonoBehaviours; +using NitroxClient.MonoBehaviours.Vehicles; using NitroxModel.Helper; namespace NitroxPatcher.Patches.Dynamic; @@ -7,16 +7,15 @@ namespace NitroxPatcher.Patches.Dynamic; /// /// Enables exosuits's position sync when they're released from sea dragons /// -public sealed partial class SeaDrargon_ReleaseExosuit_Patch : NitroxPatch, IDynamicPatch +public sealed partial class SeaDragon_ReleaseExosuit_Patch : NitroxPatch, IDynamicPatch { public static readonly MethodInfo TARGET_METHOD = Reflect.Method((SeaDragon t) => t.ReleaseExosuit()); public static void Prefix(SeaDragon __instance) { - if (__instance.holdingExosuit && - __instance.holdingExosuit.TryGetComponent(out RemotelyControlled remotelyControlled)) + if (__instance.holdingExosuit && __instance.holdingExosuit.TryGetComponent(out VehicleMovementReplicator vehicleMovementReplicator)) { - remotelyControlled.enabled = true; + vehicleMovementReplicator.enabled = true; } } } diff --git a/NitroxPatcher/Patches/Dynamic/StasisSphere_OnHit_Patch.cs b/NitroxPatcher/Patches/Dynamic/StasisSphere_OnHit_Patch.cs index ec541907f9..e793938bd6 100644 --- a/NitroxPatcher/Patches/Dynamic/StasisSphere_OnHit_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/StasisSphere_OnHit_Patch.cs @@ -23,13 +23,18 @@ public static bool Prefix(StasisSphere __instance) return false; } - ushort localPlayerId = Resolve().PlayerId; + ushort? localPlayerId = Resolve().PlayerId; + // If the lcoal player id isn't set then there's already a bigger problem/no problem and we can ignore that + if (!localPlayerId.HasValue) + { + return true; + } NitroxVector3 position = __instance.tr.position.ToDto(); NitroxQuaternion rotation = __instance.tr.rotation.ToDto(); // Calculate the chargeNormalized value which was passed to StasisSphere.Shoot float chargeNormalized = Mathf.Unlerp(__instance.minRadius, __instance.maxRadius, __instance.radius); - Resolve().Send(new StasisSphereHit(localPlayerId, position, rotation, chargeNormalized, __instance._consumption)); + Resolve().Send(new StasisSphereHit(localPlayerId.Value, position, rotation, chargeNormalized, __instance._consumption)); return true; } } diff --git a/NitroxPatcher/Patches/Dynamic/StasisSphere_Shoot_Patch.cs b/NitroxPatcher/Patches/Dynamic/StasisSphere_Shoot_Patch.cs index 0d30c9bb3b..20b978188a 100644 --- a/NitroxPatcher/Patches/Dynamic/StasisSphere_Shoot_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/StasisSphere_Shoot_Patch.cs @@ -12,15 +12,15 @@ public sealed partial class StasisSphere_Shoot_Patch : NitroxPatch, IDynamicPatc { private static readonly MethodInfo TARGET_METHOD = Reflect.Method((StasisSphere t) => t.Shoot(default, default, default, default, default)); - private static ushort LocalPlayerId => Resolve().PlayerId; + private static ushort? LocalPlayerId => Resolve().PlayerId; public static void Prefix(StasisSphere __instance, Vector3 position, Quaternion rotation, float speed, float lifeTime, float chargeNormalized) { - if (__instance.GetComponent()) + if (__instance.GetComponent() || !LocalPlayerId.HasValue) { return; } - Resolve().Send(new StasisSphereShot(LocalPlayerId, position.ToDto(), rotation.ToDto(), speed, lifeTime, chargeNormalized)); + Resolve().Send(new StasisSphereShot(LocalPlayerId.Value, position.ToDto(), rotation.ToDto(), speed, lifeTime, chargeNormalized)); } } diff --git a/NitroxServer/Communication/Packets/Processors/Abstract/TransmitIfCanSeePacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/Abstract/TransmitIfCanSeePacketProcessor.cs index ce99585169..2fdaf04cab 100644 --- a/NitroxServer/Communication/Packets/Processors/Abstract/TransmitIfCanSeePacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/Abstract/TransmitIfCanSeePacketProcessor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using NitroxModel.DataStructures; using NitroxModel.DataStructures.GameLogic; using NitroxModel.Packets; @@ -36,21 +37,10 @@ public void TransmitIfCanSeeEntities(Packet packet, Player senderPlayer, List +public class AggressiveWhenSeeTargetChangedProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public AggressiveWhenSeeTargetChangedProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(AggressiveWhenSeeTargetChanged packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.CreatureId, packet.TargetId]); } diff --git a/NitroxServer/Communication/Packets/Processors/AttackCyclopsTargetChangedProcessor.cs b/NitroxServer/Communication/Packets/Processors/AttackCyclopsTargetChangedProcessor.cs index 0f621d329c..ab38b9d84e 100644 --- a/NitroxServer/Communication/Packets/Processors/AttackCyclopsTargetChangedProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/AttackCyclopsTargetChangedProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class AttackCyclopsTargetChangedProcessor : TransmitIfCanSeePacketProcessor +public class AttackCyclopsTargetChangedProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public AttackCyclopsTargetChangedProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(AttackCyclopsTargetChanged packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.CreatureId, packet.TargetId]); } diff --git a/NitroxServer/Communication/Packets/Processors/CreatureActionChangedProcessor.cs b/NitroxServer/Communication/Packets/Processors/CreatureActionChangedProcessor.cs index a7c8529f9e..9e1cceaaaf 100644 --- a/NitroxServer/Communication/Packets/Processors/CreatureActionChangedProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/CreatureActionChangedProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class CreatureActionChangedProcessor : TransmitIfCanSeePacketProcessor +public class CreatureActionChangedProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public CreatureActionChangedProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(CreatureActionChanged packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.CreatureId]); } diff --git a/NitroxServer/Communication/Packets/Processors/CreaturePoopPerformedProcessor.cs b/NitroxServer/Communication/Packets/Processors/CreaturePoopPerformedProcessor.cs index 8c4e943ef7..7e0e1816b4 100644 --- a/NitroxServer/Communication/Packets/Processors/CreaturePoopPerformedProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/CreaturePoopPerformedProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class CreaturePoopPerformedProcessor : TransmitIfCanSeePacketProcessor +public class CreaturePoopPerformedProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public CreaturePoopPerformedProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(CreaturePoopPerformed packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.CreatureId]); } diff --git a/NitroxServer/Communication/Packets/Processors/RangedAttackLastTargetUpdateProcessor.cs b/NitroxServer/Communication/Packets/Processors/RangedAttackLastTargetUpdateProcessor.cs index fec65a04f6..1cc4587d15 100644 --- a/NitroxServer/Communication/Packets/Processors/RangedAttackLastTargetUpdateProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/RangedAttackLastTargetUpdateProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class RangedAttackLastTargetUpdateProcessor : TransmitIfCanSeePacketProcessor +public class RangedAttackLastTargetUpdateProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public RangedAttackLastTargetUpdateProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(RangedAttackLastTargetUpdate packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.CreatureId, packet.TargetId]); } diff --git a/NitroxServer/Communication/Packets/Processors/SeaDragonAttackTargetProcessor.cs b/NitroxServer/Communication/Packets/Processors/SeaDragonAttackTargetProcessor.cs index d81bc37e49..5a88d136ed 100644 --- a/NitroxServer/Communication/Packets/Processors/SeaDragonAttackTargetProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/SeaDragonAttackTargetProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class SeaDragonAttackTargetProcessor : TransmitIfCanSeePacketProcessor +public class SeaDragonAttackTargetProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public SeaDragonAttackTargetProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(SeaDragonAttackTarget packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.SeaDragonId, packet.TargetId]); } diff --git a/NitroxServer/Communication/Packets/Processors/SeaDragonGrabExosuitProcessor.cs b/NitroxServer/Communication/Packets/Processors/SeaDragonGrabExosuitProcessor.cs index 056127cee9..bad33a597f 100644 --- a/NitroxServer/Communication/Packets/Processors/SeaDragonGrabExosuitProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/SeaDragonGrabExosuitProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class SeaDragonGrabExosuitProcessor : TransmitIfCanSeePacketProcessor +public class SeaDragonGrabExosuitProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public SeaDragonGrabExosuitProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(SeaDragonGrabExosuit packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.SeaDragonId, packet.TargetId]); } diff --git a/NitroxServer/Communication/Packets/Processors/SeaDragonSwatAttackProcessor.cs b/NitroxServer/Communication/Packets/Processors/SeaDragonSwatAttackProcessor.cs index f955c6afb7..0c0dc26ceb 100644 --- a/NitroxServer/Communication/Packets/Processors/SeaDragonSwatAttackProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/SeaDragonSwatAttackProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class SeaDragonSwatAttackProcessor : TransmitIfCanSeePacketProcessor +public class SeaDragonSwatAttackProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public SeaDragonSwatAttackProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(SeaDragonSwatAttack packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.SeaDragonId, packet.TargetId]); } diff --git a/NitroxServer/Communication/Packets/Processors/SeaTreaderSpawnedChunkProcessor.cs b/NitroxServer/Communication/Packets/Processors/SeaTreaderSpawnedChunkProcessor.cs index 71cd6ce55c..b127c126d4 100644 --- a/NitroxServer/Communication/Packets/Processors/SeaTreaderSpawnedChunkProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/SeaTreaderSpawnedChunkProcessor.cs @@ -5,9 +5,10 @@ namespace NitroxServer.Communication.Packets.Processors; -public class SeaTreaderSpawnedChunkProcessor : TransmitIfCanSeePacketProcessor +public class SeaTreaderSpawnedChunkProcessor( + PlayerManager playerManager, + EntityRegistry entityRegistry +) : TransmitIfCanSeePacketProcessor(playerManager, entityRegistry) { - public SeaTreaderSpawnedChunkProcessor(PlayerManager playerManager, EntityRegistry entityRegistry) : base(playerManager, entityRegistry) { } - public override void Process(SeaTreaderSpawnedChunk packet, Player sender) => TransmitIfCanSeeEntities(packet, sender, [packet.CreatureId]); }