示例#1
0
        static void Postfix(ReceptionistSeePatient __instance, TaskStatus __result, SharedCharacterRef ___Character)
        {
            if (!Main.enabled || !Main.settings.SendtoHomeIfHospitalFull)
            {
                return;
            }

            if (__result == TaskStatus.Success && ___Character.Get is Patient patient)
            {
                var level = patient.Level;
                level.WorldState.GetRoomsOfType(RoomDefinition.Type.GPOffice, false, _roomsCache);
                int minQueueLength = int.MaxValue;
                foreach (Room room in _roomsCache)
                {
                    if (minQueueLength > room.QueueLength)
                    {
                        minQueueLength = room.QueueLength;
                    }
                }
                if (_roomsCache.Any() && minQueueLength >= 5)
                {
                    DiagnosisTreatmentComponent_ProcessDiagnosis_Patch.SendHome(patient);
                }
                _roomsCache.Clear();
            }
        }
示例#2
0
 static void Postfix(ReceptionistSeePatient __instance, TaskStatus __result, SharedCharacterRef ___Character)
 {
     if (!Main.enabled || !Main.settings.SendtoHomeIfHospitalFull)
     {
         return;
     }
     try
     {
         if (__result == TaskStatus.Success && ___Character.Get is Patient patient)
         {
             var level = patient.Level;
             level.WorldState.GetRoomsOfType(RoomDefinition.Type.GPOffice, false, _roomsCache);
             int minQueueLength = int.MaxValue;
             foreach (Room room in _roomsCache)
             {
                 if (!room.IsOpen)
                 {
                     continue;
                 }
                 if (minQueueLength > room.QueueLength)
                 {
                     minQueueLength = room.QueueLength;
                 }
             }
             if (_roomsCache.Any() && minQueueLength >= level.HospitalPolicy.QueueWarningLength)
             {
                 //Main.Logger.Log($"send home {patient.Name} min Queue Length {minQueueLength}");
                 DiagnosisTreatmentComponent_ProcessDiagnosis_Patch.SendHome(patient);
             }
             _roomsCache.Clear();
         }
     }
     catch (Exception e)
     {
         Main.Logger.Error(e.ToString());
     }
 }