class Core::Game::NPC::Behaviour

Attributes

init[R]
motion[R]
trigger[R]
update[R]

Public Class Methods

new(npc, init, trigger, motion, update) click to toggle source
# File lib/game/npc/behaviour.rb, line 11
def initialize(npc, init, trigger, motion, update)
  @self = npc
  @init = init
  @trigger = trigger
  @motion = motion
  @update = update
end

Public Instance Methods

exec_task(task, other=nil) click to toggle source
# File lib/game/npc/behaviour.rb, line 34
def exec_task(task, other=nil)
  task.execute(@self, other) if !task.finished?
  if task.finished?
    if task.remove?
      task = nil
    end
  end
end
on_init() click to toggle source
# File lib/game/npc/behaviour.rb, line 19
def on_init
  exec_task(@init)
  @self.goal.reset
  exec_task(@motion)
end
on_trigger(other) click to toggle source
# File lib/game/npc/behaviour.rb, line 25
def on_trigger(other)
  exec_task(@trigger, other)
end
on_update() click to toggle source
# File lib/game/npc/behaviour.rb, line 29
def on_update
  exec_task(@update)
  exec_task(@motion)
end