~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to CorsixTH/Lua/humanoid_actions/queue.lua

  • Committer: corsixth.bot at gmail
  • Date: 2014-03-31 23:30:23 UTC
  • Revision ID: svn-v4:c39591fa-788f-11de-a72b-d90af8dea425:trunk:2687
Remove trailing whitespaces in .h, .cpp, .c and .lua files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    end
48
48
    n = n - 1
49
49
  end
50
 
  
 
50
 
51
51
  local action = humanoid.action_queue[n]
52
52
  assert(action.must_happen)
53
53
  local on_interrupt = action.on_interrupt
123
123
local function action_queue_leave_bench(action, humanoid)
124
124
  local index
125
125
  for i, current_action in ipairs(humanoid.action_queue) do
126
 
    -- Check to see that we haven't 
 
126
    -- Check to see that we haven't
127
127
    -- gotten to the actual queue action yet.
128
128
    -- Instead of crashing if we have, try with the assumption
129
129
    -- that we're actually standing.
163
163
      end
164
164
    end
165
165
  end
166
 
  
 
166
 
167
167
  if not must_stand then
168
168
    -- Try to find a bench
169
169
    local bench_max_distance
199
199
      return
200
200
    end
201
201
  end
202
 
  
 
202
 
203
203
  -- Stand up in the correct position in the queue
204
204
  local standing_index = 0
205
205
  local our_room = humanoid:getRoom()
275
275
end)
276
276
 
277
277
-- While queueing one could get thirsty.
278
 
local action_queue_get_soda = permanent"action_queue_get_soda"( 
 
278
local action_queue_get_soda = permanent"action_queue_get_soda"(
279
279
function(action, humanoid, machine, mx, my, fun_after_use)
280
280
  local num_actions_prior
281
281
  if action:isStanding() then
283
283
  else
284
284
    num_actions_prior = action_queue_leave_bench(action, humanoid)
285
285
  end
286
 
  
 
286
 
287
287
  -- Callback function used after the drinks machine has been used.
288
288
  local --[[persistable:action_queue_get_soda_after_use]] function after_use()
289
289
    fun_after_use() -- Defined in patient:tickDay
290
290
    -- Insert an idle action so that change_position can do its work.
291
291
    -- Note that it is inserted after the currently executing use_object action.
292
292
    humanoid:queueAction({
293
 
      name = "idle", 
 
293
      name = "idle",
294
294
      --direction = machine,
295
295
      must_happen = true,
296
296
    }, 1)
297
297
    action_queue_on_change_position(action, humanoid)
298
298
  end
299
 
  
 
299
 
300
300
  -- Walk to the machine and then use it.
301
301
  humanoid:queueAction({
302
302
    name = "walk",
332
332
 
333
333
local function action_queue_start(action, humanoid)
334
334
  local queue = action.queue
335
 
  
 
335
 
336
336
  if action.done_init then
337
337
    return
338
338
  end
343
343
  action.onLeaveQueue = action_queue_on_leave
344
344
  action.onGetSoda = action_queue_get_soda
345
345
  action.isStanding = action_queue_is_standing
346
 
  
 
346
 
347
347
  action.is_in_queue = true
348
348
  queue:unexpect(humanoid)
349
349
  queue:push(humanoid, action)
350
 
  
 
350
 
351
351
  local door = action.reserve_when_done
352
352
  if door then
353
353
    door:updateDynamicInfo()
360
360
    must_happen = true,
361
361
  }, 0)
362
362
  action:onChangeQueuePosition(humanoid)
363
 
  
 
363
 
364
364
  if queue.same_room_priority then
365
365
    queue.same_room_priority:getRoom():tryAdvanceQueue()
366
366
  end