Loading

Paste #pgozldo7g

  1. diff --git a/CorsixTH/Lua/room.lua b/CorsixTH/Lua/room.lua
  2. index b3eeb21..c56b8e7 100644
  3. --- a/CorsixTH/Lua/room.lua
  4. +++ b/CorsixTH/Lua/room.lua
  5. @@ -66,6 +66,9 @@ function Room:initRoom(x, y, w, h, door, door2)
  6.    self.humanoids_enroute = {--[[a set rather than a list]]}
  7.  end
  8.  
  9. +--! Get the tile next to the door.
  10. +--!param inside (bool) If set, get the tile inside the room, else get the tile outside.
  11. +--!return x,y (tile coordniates) of the tile next to the door.
  12.  function Room:getEntranceXY(inside)
  13.    local door = self.door
  14.    local x, y = door.tile_x, door.tile_y
  15. @@ -79,6 +82,8 @@ function Room:getEntranceXY(inside)
  16.    return x, y
  17.  end
  18.  
  19. +--! Construct an 'walk' action to the tile next to the door, just outside the room.
  20. +--!return Action to move to the tile just outside the room.
  21.  function Room:createLeaveAction()
  22.    local x, y = self:getEntranceXY(false)
  23.    return {
  24. @@ -116,6 +121,8 @@ function Room:createEnterAction(humanoid_entering, callback)
  25.      is_entering = humanoid_entering and self or true}
  26.  end
  27.  
  28. +--! Get a patient in the room.
  29. +--!return A patient (humanoid) if there is a patient, nil otherwise.
  30.  function Room:getPatient()
  31.    for humanoid in pairs(self.humanoids) do
  32.      if class.is(humanoid, Patient) then
  33. @@ -124,6 +131,8 @@ function Room:getPatient()
  34.    end
  35.  end
  36.  
  37. +--! Count the number of patients in the room.
  38. +--!return Number of patients in the room.
  39.  function Room:getPatientCount()
  40.    local count = 0
  41.    for humanoid in pairs(self.humanoids) do
  42. @@ -257,13 +266,18 @@ function Room:testStaffCriteria(criteria, extra_humanoid)
  43.    end
  44.  end
  45.  
  46. -local no_staff = {}
  47. +local no_staff = {} -- Constant denoting 'no staff at all' in a room.
  48. +
  49. +--! Get the type and number of maximum staff for the room.
  50. +--!return (table) Type and number of maximum staff.
  51.  function Room:getMaximumStaffCriteria()
  52.    -- Some rooms have dynamic criteria (i.e. dependent upon the number of items
  53.    -- in the room), so this method is provided for such rooms to override it.
  54.    return self.room_info.maximum_staff or self.room_info.required_staff or no_staff
  55.  end
  56.  
  57. +--! Get the type and number of required staff for the room.
  58. +--!return (table) Type and number of required staff.
  59.  function Room:getRequiredStaffCriteria()
  60.    return self.room_info.required_staff or no_staff
  61.  end
  62. @@ -407,17 +421,23 @@ function Room:createDealtWithPatientCallback(humanoid)
  63.    self.waiting_staff_member = humanoid
  64.  end
  65.  
  66. --- Returns the current staff member. Can be overriden in rooms with multiples staff members to return the desired one.
  67. +--! Get the current staff member.
  68. +-- Can be overridden in rooms with multiples staff members to return the desired one.
  69. +--!return (staff) The current staff member.
  70.  function Room:getStaffMember()
  71.    return self.staff_member
  72.  end
  73.  
  74. +--! Set the current staff member.
  75. +--!param staff (staff) Staff member to denote as current staff.
  76.  function Room:setStaffMember(staff)
  77.    self.staff_member = staff
  78.  end
  79.  
  80. +--! Does the given staff member fit in the room?
  81.  -- Returns false if the room is already full of staff or if the given member of staff cannot help out.
  82.  -- Otherwise returns true.
  83. +--!return (bool) True if the staff member can work in the room, else False.
  84.  function Room:staffFitsInRoom(staff)
  85.    local criteria = self:getMaximumStaffCriteria()
  86.    if self:testStaffCriteria(criteria) or not self:testStaffCriteria(criteria, staff) then
  87. @@ -595,6 +615,9 @@ end
  88.  
  89.  local tile_factor = 10     -- how many tiles further are we willing to walk for 1 person fewer in the queue
  90.  local readiness_bonus = 50 -- how many tiles further are we willing to walk if the room has all the required staff
  91. +
  92. +--! Score function to decide how desire-full a room is for a patient.
  93. +--!return (int) The score, lower is better.
  94.  function Room:getUsageScore()
  95.    local queue = self.door.queue
  96.    local score = queue:patientSize() + self:getPatientCount() - self.maximum_patients
  97. @@ -716,6 +739,7 @@ function Room:tryToFindNearbyPatients()
  98.    end
  99.  end
  100.  
  101. +--! Explode the room.
  102.  function Room:crashRoom()
  103.    self.door:closeDoor()
  104.    if self.door2 then
  105. @@ -877,6 +901,7 @@ function Room:makeHumanoidDressIfNecessaryAndThenLeave(humanoid)
  106.    end
  107.  end
  108.  
  109. +--! Deactivate the room from the world.
  110.  function Room:deactivate()
  111.    self.is_active = false -- So that no more patients go to it.
  112.    self.world:notifyRoomRemoved(self)

Comments