Class: Core::Game::CompositeGoal
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #advance ⇒ Object
- #current ⇒ Object
-
#initialize(policy = :abort) ⇒ CompositeGoal
constructor
A new instance of CompositeGoal.
- #reset ⇒ Object
- #start ⇒ Object
- #update ⇒ Object
Methods inherited from Array
Constructor Details
#initialize(policy = :abort) ⇒ CompositeGoal
Returns a new instance of CompositeGoal.
39 40 41 42 43 44 |
# File 'lib/game/npc/goal.rb', line 39 def initialize(policy=:abort) super() @current = 0 @policy = policy @state = :progress end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
38 39 40 |
# File 'lib/game/npc/goal.rb', line 38 def state @state end |
Instance Method Details
#advance ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/game/npc/goal.rb', line 73 def advance @current += 1 if @current == self.size @state = :finished @current = 0 end end |
#current ⇒ Object
53 54 55 |
# File 'lib/game/npc/goal.rb', line 53 def current return self[@current] end |
#reset ⇒ Object
45 46 47 48 49 |
# File 'lib/game/npc/goal.rb', line 45 def reset self.clear @current = 0 @state = :reset end |
#start ⇒ Object
50 51 52 |
# File 'lib/game/npc/goal.rb', line 50 def start @state = :progress end |
#update ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/game/npc/goal.rb', line 56 def update if @state == :progress awesome_print(self) if !current case current.state when :before if current.class != MotionGoal current.setup end when :progress return when :failed handle_failed when :finished advance end end end |