Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Some assorted issues #1567

Merged
merged 9 commits into from Nov 18, 2019
3 changes: 2 additions & 1 deletion CorsixTH/Lua/dialogs/adviser.lua
Expand Up @@ -152,8 +152,9 @@ function UIAdviser:say(speech, talk_until_next_announce, override_current)
self.up_again = true
elseif override_current then
-- He was saying/was about to say something else. Discard those messages.
self.queued_messages[1] = self.queued_messages[#self.queued_messages]
while #self.queued_messages > 1 do
table.remove(self.queued_messages, 2)
table.remove(self.queued_messages)
end
-- Now say the new thing instead.
self:talk()
Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/Lua/entities/humanoid.lua
Expand Up @@ -947,7 +947,7 @@ function Humanoid:tostring()
distance = "nil"
end
local standing = "false"
if action:isStanding() then
if action.isStanding and action:isStanding() then
standing = "true"
end
action_string = action_string .. " - Bench distance: " .. distance .. " Standing: " .. standing
Expand Down
9 changes: 2 additions & 7 deletions CorsixTH/Lua/entities/humanoids/staff.lua
Expand Up @@ -395,9 +395,6 @@ function Staff:checkIfNeedRest()
-- If occupied by patient, staff will go to the staffroom after the patient left.
self.staffroom_needed = true
else
if room then
room.staff_leaving = true
end
self:goToStaffRoom()
end
end
Expand Down Expand Up @@ -511,10 +508,8 @@ function Staff:isIdle()
return true
else
-- It might still be the case that the patient is leaving
for _, action in ipairs(room:getPatient().action_queue) do
if action.is_leaving then
return true
end
if room:getPatient():isLeaving() then
return true
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/Lua/epidemic.lua
Expand Up @@ -544,7 +544,7 @@ end
@param patient (Patient) the patient we wish to determine if they are static.]]
local function is_static(patient)
local action = patient:getCurrentAction()
return action.name == "queue" or action.name == "idle" or
return action.name == "queue" or action.name == "idle" or action.name == "seek_room" or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list still isn't exhaustive. There must be a better way to indicate whether a patient is currently moving - like annotating each of the actions?

(action.name == "use_object" and action.object.object_type.id == "bench")
end

Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/Lua/humanoid_actions/queue.lua
Expand Up @@ -319,7 +319,7 @@ function(action, humanoid, machine, mx, my, fun_after_use)
-- If the patient is still in the queue, insert an idle action so that
-- change_position can do its work.
-- Note that it is inserted after the currently executing use_object action.
if action.is_in_queue then
if action.is_in_queue and not humanoid.going_home then
humanoid:queueAction(IdleAction():setMustHappen(true), 1)
action_queue_on_change_position(action, humanoid)
end
Expand Down
2 changes: 1 addition & 1 deletion CorsixTH/Lua/humanoid_actions/seek_room.lua
Expand Up @@ -358,7 +358,7 @@ local function action_seek_room_start(action, humanoid)
-- don't need this as we unregistered all previous callbacks if we went to research
local room_req = humanoid.hospital:checkDiseaseRequirements(humanoid.disease.id)
-- get required staff
if not room_req then
if not humanoid.diagnosed or not room_req then
action_seek_room_goto_room(rm, humanoid, action.diagnosis_room)
TheApp.ui.bottom_panel:removeMessage(humanoid)
humanoid:unregisterRoomBuildCallback(build_callback)
Expand Down
10 changes: 8 additions & 2 deletions CorsixTH/Lua/room.lua
Expand Up @@ -220,7 +220,13 @@ function Room:getMissingStaff(criteria)
local result = {}
for attribute, count in pairs(criteria) do
for humanoid in pairs(self.humanoids) do
if class.is(humanoid, Staff) and humanoid:fulfillsCriterion(attribute) and not humanoid:isLeaving() and not humanoid.fired then
-- check state of humanoid is appropriate for room
-- check they are staff and meet requirements for the room
-- ensure not leaving (going to staff room) or fired
-- check if answering a call to another room
if class.is(humanoid, Staff) and humanoid:fulfillsCriterion(attribute) and
not humanoid:isLeaving() and not humanoid.fired and
not (humanoid.on_call and humanoid.on_call.object ~= self) then
count = count - 1
end
end
Expand Down Expand Up @@ -762,7 +768,7 @@ function Room:crashRoom()
if not person:isLeaving() then
if class.is(person, Patient) then
--Delay so that room is destroyed before the SeekRoom search.
person:queueAction(IdleAction():setCount(1))
person:setNextAction(IdleAction():setCount(1))
person:queueAction(SeekRoomAction(self.room_info.id))
end
end
Expand Down