Class: GameMachine::Actor::GameActor
- Inherits:
-
Base
- Object
- JavaLib::GameActor
- Base
- GameMachine::Actor::GameActor
show all
- Includes:
- Commands, Models
- Defined in:
- lib/game_machine/actor/game_actor.rb
Constant Summary
Constants inherited
from Base
Base::ON_RECEIVE_HOOKS
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Commands
#commands
Methods inherited from Base
aspect, aspects, find, find_by_address, find_distributed, find_distributed_local, find_remote, hashring, local_path, model_filter, #onReceive, player_controller, #receive_message, #schedule_message, #sender, set_player_controller
Instance Attribute Details
#player_id ⇒ Object
Returns the value of attribute player_id.
9
10
11
|
# File 'lib/game_machine/actor/game_actor.rb', line 9
def player_id
@player_id
end
|
Instance Method Details
#awake(args) ⇒ Object
11
12
|
# File 'lib/game_machine/actor/game_actor.rb', line 11
def awake(args)
end
|
#call_mono(klass, message) ⇒ Object
26
27
28
|
# File 'lib/game_machine/actor/game_actor.rb', line 26
def call_mono(klass,message)
commands.misc.call_mono(klass,message)
end
|
#new_game_message ⇒ Object
17
18
19
|
# File 'lib/game_machine/actor/game_actor.rb', line 17
def new_game_message
MessageLib::GameMessage.new
end
|
#on_player_disconnect(player_id) ⇒ Object
14
15
|
# File 'lib/game_machine/actor/game_actor.rb', line 14
def on_player_disconnect(player_id)
end
|
#on_receive(message) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/game_machine/actor/game_actor.rb', line 39
def on_receive(message)
@player_id = nil
if message.is_a?(MessageLib::GameMessage)
@player_id = message.player_id
set_player_id(message.player_id)
on_game_message(message)
elsif message.is_a?(MessageLib::ClientManagerEvent)
if message.event == 'disconnected'
on_player_disconnect(message.player_id)
end
end
end
|
#post_init(*args) ⇒ Object
21
22
23
24
|
# File 'lib/game_machine/actor/game_actor.rb', line 21
def post_init(*args)
awake(args)
commands.misc.client_manager_register(self.class.name)
end
|
#tell_game_actor(game_message, target) ⇒ Object
34
35
36
37
|
# File 'lib/game_machine/actor/game_actor.rb', line 34
def tell_game_actor(game_message,target)
game_message.player_id = player_id
Actor::Base.find(target.name).tell(game_message)
end
|
#tell_player(game_message, target = player_id) ⇒ Object
30
31
32
|
# File 'lib/game_machine/actor/game_actor.rb', line 30
def tell_player(game_message,target=player_id)
commands.player.send_game_message(game_message,target)
end
|