Class: GameMachine::Actor::GameActor

Inherits:
Base
  • Object
show all
Includes:
Commands, Models
Defined in:
server/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, logger, model_filter, #onReceive, player_controller, #receive_message, #schedule_message, #schedule_message_once, #sender, set_player_controller

Instance Attribute Details

#character_idObject (readonly)

Returns the value of attribute character_id


9
10
11
# File 'server/lib/game_machine/actor/game_actor.rb', line 9

def character_id
  @character_id
end

#player_idObject (readonly)

Returns the value of attribute player_id


9
10
11
# File 'server/lib/game_machine/actor/game_actor.rb', line 9

def player_id
  @player_id
end

Instance Method Details

#awake(args) ⇒ Object


11
12
# File 'server/lib/game_machine/actor/game_actor.rb', line 11

def awake(args)
end

#call_mono(klass, message) ⇒ Object


26
27
28
# File 'server/lib/game_machine/actor/game_actor.rb', line 26

def call_mono(klass,message)
  commands.misc.call_mono(klass,message)
end

#new_game_messageObject


17
18
19
# File 'server/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 'server/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
52
53
54
55
56
# File 'server/lib/game_machine/actor/game_actor.rb', line 39

def on_receive(message)
  @player_id = nil
  @character_id = nil

  if message.is_a?(MessageLib::GameMessage)
    @player_id = message.player_id
    unless @player_id.nil?
      @character_id = JavaLib::PlayerService.getInstance.getCharacter(@player_id)
    end

    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 'server/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 'server/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 'server/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