Class: Game_Followers
- Inherits:
-
Object
- Object
- Game_Followers
- Defined in:
- lib/rgss3_default_scripts/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
-
#visible ⇒ Object
————————————————————————– * Public Instance Variables ————————————————————————–.
Instance Method Summary collapse
-
#[](index) ⇒ Object
————————————————————————– * Get Followers ————————————————————————–.
-
#collide?(x, y) ⇒ Boolean
————————————————————————– * Detect Collision ————————————————————————–.
-
#each ⇒ Object
————————————————————————– * Iterator ————————————————————————–.
-
#gather ⇒ Object
————————————————————————– * Gather ————————————————————————–.
-
#gather? ⇒ Boolean
————————————————————————– * Determine if Gathered ————————————————————————–.
-
#gathering? ⇒ Boolean
————————————————————————– * Determine if Gathering ————————————————————————–.
-
#initialize(leader) ⇒ Game_Followers
constructor
————————————————————————– * Object Initialization leader: Lead character ————————————————————————–.
-
#move ⇒ Object
————————————————————————– * Movement ————————————————————————–.
-
#moving? ⇒ Boolean
————————————————————————– * Determine if Moving ————————————————————————–.
-
#refresh ⇒ Object
————————————————————————– * Refresh ————————————————————————–.
-
#reverse_each ⇒ Object
————————————————————————– * Iterator (Reverse) ————————————————————————–.
-
#synchronize(x, y, d) ⇒ Object
————————————————————————– * Synchronize ————————————————————————–.
-
#update ⇒ Object
————————————————————————– * Frame Update ————————————————————————–.
-
#visible_folloers ⇒ Object
————————————————————————– * Get Array of Displayed Followers “folloers” is typo, but retained because of the compatibility.
Constructor Details
#initialize(leader) ⇒ Game_Followers
-
Object Initialization
leader: Lead character
17 18 19 20 21 22 23 24 25 |
# File 'lib/rgss3_default_scripts/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
#visible ⇒ Object
-
Public Instance Variables
12 13 14 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 12 def visible @visible end |
Instance Method Details
#[](index) ⇒ Object
-
Get Followers
29 30 31 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 29 def [](index) @data[index] end |
#collide?(x, y) ⇒ Boolean
-
Detect Collision
109 110 111 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 109 def collide?(x, y) visible_folloers.any? {|follower| follower.pos?(x, y) } end |
#each ⇒ Object
-
Iterator
35 36 37 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 35 def each @data.each {|follower| yield follower } if block_given? end |
#gather ⇒ Object
-
Gather
78 79 80 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 78 def gather @gathering = true end |
#gather? ⇒ Boolean
-
Determine if Gathered
103 104 105 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 103 def gather? visible_folloers.all? {|follower| follower.gather? } end |
#gathering? ⇒ Boolean
-
Determine if Gathering
84 85 86 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 84 def gathering? @gathering end |
#move ⇒ Object
-
Movement
63 64 65 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 63 def move reverse_each {|follower| follower.chase_preceding_character } end |
#moving? ⇒ Boolean
-
Determine if Moving
97 98 99 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 97 def moving? visible_folloers.any? {|follower| follower.moving? } end |
#refresh ⇒ Object
-
Refresh
47 48 49 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 47 def refresh each {|follower| follower.refresh } end |
#reverse_each ⇒ Object
-
Iterator (Reverse)
41 42 43 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 41 def reverse_each @data.reverse.each {|follower| yield follower } if block_given? end |
#synchronize(x, y, d) ⇒ Object
-
Synchronize
69 70 71 72 73 74 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 69 def synchronize(x, y, d) each do |follower| follower.moveto(x, y) follower.set_direction(d) end end |
#update ⇒ Object
-
Frame Update
53 54 55 56 57 58 59 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 53 def update if gathering? move unless moving? || moving? @gathering = false if gather? end each {|follower| follower.update } end |
#visible_folloers ⇒ Object
-
Get Array of Displayed Followers
"folloers" is typo, but retained because of the compatibility.
91 92 93 |
# File 'lib/rgss3_default_scripts/Game_Followers.rb', line 91 def visible_folloers @data.select {|follower| follower.visible? } end |