Class: Game_Followers

Inherits:
Object
  • Object
show all
Defined in:
Game_Followers.rb

Overview

** Game_Followers


This is a wrapper for a follower array. This class is used internally for

the Game_Player class.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Game_Followers) initialize(leader)


  • Object Initialization

    leader:  Lead character



17
18
19
20
21
22
23
24
25
# File 'Game_Followers.rb', line 17

def initialize(leader)
  @visible = $data_system.opt_followers
  @gathering = false                    # Gathering processing underway flag
  @data = []
  @data.push(Game_Follower.new(1, leader))
  (2...$game_party.max_battle_members).each do |index|
    @data.push(Game_Follower.new(index, @data[-1]))
  end
end

Instance Attribute Details

- (Object) visible


  • Public Instance Variables




12
13
14
# File 'Game_Followers.rb', line 12

def visible
  @visible
end

Instance Method Details

- (Object) [](index)


  • Get Followers




29
30
31
# File 'Game_Followers.rb', line 29

def [](index)
  @data[index]
end

- (Boolean) collide?(x, y)


  • Detect Collision


Returns:

  • (Boolean)


109
110
111
# File 'Game_Followers.rb', line 109

def collide?(x, y)
  visible_folloers.any? {|follower| follower.pos?(x, y) }
end

- (Object) each


  • Iterator




35
36
37
# File 'Game_Followers.rb', line 35

def each
  @data.each {|follower| yield follower } if block_given?
end

- (Object) gather


  • Gather




78
79
80
# File 'Game_Followers.rb', line 78

def gather
  @gathering = true
end

- (Boolean) gather?


  • Determine if Gathered


Returns:

  • (Boolean)


103
104
105
# File 'Game_Followers.rb', line 103

def gather?
  visible_folloers.all? {|follower| follower.gather? }
end

- (Boolean) gathering?


  • Determine if Gathering


Returns:

  • (Boolean)


84
85
86
# File 'Game_Followers.rb', line 84

def gathering?
  @gathering
end

- (Object) move


  • Movement




63
64
65
# File 'Game_Followers.rb', line 63

def move
  reverse_each {|follower| follower.chase_preceding_character }
end

- (Boolean) moving?


  • Determine if Moving


Returns:

  • (Boolean)


97
98
99
# File 'Game_Followers.rb', line 97

def moving?
  visible_folloers.any? {|follower| follower.moving? }
end

- (Object) refresh


  • Refresh




47
48
49
# File 'Game_Followers.rb', line 47

def refresh
  each {|follower| follower.refresh }
end

- (Object) reverse_each


  • Iterator (Reverse)




41
42
43
# File 'Game_Followers.rb', line 41

def reverse_each
  @data.reverse.each {|follower| yield follower } if block_given?
end

- (Object) synchronize(x, y, d)


  • Synchronize




69
70
71
72
73
74
# File 'Game_Followers.rb', line 69

def synchronize(x, y, d)
  each do |follower|
    follower.moveto(x, y)
    follower.set_direction(d)
  end
end

- (Object) update


  • Frame Update




53
54
55
56
57
58
59
# File 'Game_Followers.rb', line 53

def update
  if gathering?
    move unless moving? || moving?
    @gathering = false if gather?
  end
  each {|follower| follower.update }
end

- (Object) visible_folloers


  • Get Array of Displayed Followers

    "folloers" is typo, but retained because of the compatibility.



91
92
93
# File 'Game_Followers.rb', line 91

def visible_folloers
  @data.select {|follower| follower.visible? }
end