public override void Process(MedicalCabinetClicked packet) { GameObject gameObject = NitroxEntity.RequireObjectFrom(packet.Id); MedicalCabinet cabinet = gameObject.RequireComponent <MedicalCabinet>(); bool medkitPickedUp = !packet.HasMedKit && cabinet.hasMedKit; cabinet.hasMedKit = packet.HasMedKit; cabinet.timeSpawnMedKit = packet.NextSpawnTime; bool isDoorOpen = (bool)cabinet.ReflectionGet("doorOpen"); bool doorChangedState = isDoorOpen != packet.DoorOpen; if (doorChangedState) { cabinet.Invoke("ToggleDoorState", 0f); } else if (medkitPickedUp) { cabinet.Invoke("ToggleDoorState", 1.8f); } }
public override void Process(MedicalCabinetClicked packet) { Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(packet.Guid); if (opGameObject.IsPresent()) { GameObject gameObject = opGameObject.Get(); MedicalCabinet cabinet = gameObject.GetComponent <MedicalCabinet>(); if (cabinet != null) { bool medkitPickedUp = !packet.HasMedKit && cabinet.hasMedKit; cabinet.hasMedKit = packet.HasMedKit; cabinet.timeSpawnMedKit = packet.NextSpawnTime; bool isDoorOpen = (bool)cabinet.ReflectionGet("doorOpen"); bool doorChangedState = isDoorOpen != packet.DoorOpen; if (doorChangedState) { cabinet.Invoke("ToggleDoorState", 0f); } else if (medkitPickedUp) { cabinet.Invoke("ToggleDoorState", 1.8f); } } else { Console.WriteLine("Guid " + packet.Guid + " did not have a MedicalCabinet script"); } } else { Console.WriteLine("Could not locate medical cabinet with guid: " + packet.Guid); } }
public override void Process(MedicalCabinetClicked packet) { GameObject gameObject = NitroxEntity.RequireObjectFrom(packet.Id); MedicalCabinet cabinet = gameObject.RequireComponent <MedicalCabinet>(); bool medkitPickedUp = !packet.HasMedKit && cabinet.hasMedKit; bool doorChangedState = cabinet.doorOpen != packet.DoorOpen; cabinet.hasMedKit = packet.HasMedKit; cabinet.timeSpawnMedKit = packet.NextSpawnTime; using (packetSender.Suppress <PlayFMODCustomEmitter>()) using (FMODSystem.SuppressSounds()) { if (doorChangedState) { cabinet.Invoke(nameof(MedicalCabinet.ToggleDoorState), 0f); } else if (medkitPickedUp) { cabinet.Invoke(nameof(MedicalCabinet.ToggleDoorState), 2f); } } }