|
1 |
| -using NitroxClient.Communication.Packets.Processors.Abstract; |
| 1 | +using NitroxClient.Communication.Abstract; |
| 2 | +using NitroxClient.Communication.Packets.Processors.Abstract; |
| 3 | +using NitroxClient.GameLogic.FMOD; |
2 | 4 | using NitroxClient.MonoBehaviours;
|
3 | 5 | using NitroxClient.Unity.Helper;
|
4 |
| -using NitroxModel.Helper; |
5 | 6 | using NitroxModel.Packets;
|
6 | 7 | using UnityEngine;
|
7 | 8 |
|
8 |
| -namespace NitroxClient.Communication.Packets.Processors |
| 9 | +namespace NitroxClient.Communication.Packets.Processors; |
| 10 | + |
| 11 | +public class MedicalCabinetClickedProcessor : ClientPacketProcessor<MedicalCabinetClicked> |
9 | 12 | {
|
10 |
| - public class MedicalCabinetClickedProcessor : ClientPacketProcessor<MedicalCabinetClicked> |
| 13 | + private readonly IPacketSender packetSender; |
| 14 | + |
| 15 | + public MedicalCabinetClickedProcessor(IPacketSender packetSender) |
11 | 16 | {
|
12 |
| - public override void Process(MedicalCabinetClicked packet) |
13 |
| - { |
14 |
| - GameObject gameObject = NitroxEntity.RequireObjectFrom(packet.Id); |
15 |
| - MedicalCabinet cabinet = gameObject.RequireComponent<MedicalCabinet>(); |
| 17 | + this.packetSender = packetSender; |
| 18 | + } |
16 | 19 |
|
17 |
| - bool medkitPickedUp = !packet.HasMedKit && cabinet.hasMedKit; |
| 20 | + public override void Process(MedicalCabinetClicked packet) |
| 21 | + { |
| 22 | + GameObject gameObject = NitroxEntity.RequireObjectFrom(packet.Id); |
| 23 | + MedicalCabinet cabinet = gameObject.RequireComponent<MedicalCabinet>(); |
18 | 24 |
|
19 |
| - cabinet.hasMedKit = packet.HasMedKit; |
20 |
| - cabinet.timeSpawnMedKit = packet.NextSpawnTime; |
| 25 | + bool medkitPickedUp = !packet.HasMedKit && cabinet.hasMedKit; |
| 26 | + bool doorChangedState = cabinet.doorOpen != packet.DoorOpen; |
21 | 27 |
|
22 |
| - bool isDoorOpen = cabinet.doorOpen; |
23 |
| - bool doorChangedState = isDoorOpen != packet.DoorOpen; |
| 28 | + cabinet.hasMedKit = packet.HasMedKit; |
| 29 | + cabinet.timeSpawnMedKit = packet.NextSpawnTime; |
24 | 30 |
|
| 31 | + using (packetSender.Suppress<PlayFMODCustomEmitter>()) |
| 32 | + using (FMODSystem.SuppressSounds()) |
| 33 | + { |
25 | 34 | if (doorChangedState)
|
26 | 35 | {
|
27 | 36 | cabinet.Invoke(nameof(MedicalCabinet.ToggleDoorState), 0f);
|
28 | 37 | }
|
29 | 38 | else if (medkitPickedUp)
|
30 | 39 | {
|
31 |
| - cabinet.Invoke(nameof(MedicalCabinet.ToggleDoorState), 1.8f); |
| 40 | + cabinet.Invoke(nameof(MedicalCabinet.ToggleDoorState), 2f); |
32 | 41 | }
|
33 | 42 | }
|
34 | 43 | }
|
|
0 commit comments