Class: GameMachine::Actor::Factory

Inherits:
Object
  • Object
show all
Includes:
JavaLib::IActorFactory
Defined in:
server/lib/game_machine/actor/factory.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, args) ⇒ Factory

Returns a new instance of Factory


7
8
9
10
# File 'server/lib/game_machine/actor/factory.rb', line 7

def initialize(klass,args)
  @klass = klass
  @args = args
end

Class Method Details

.createObject


30
31
# File 'server/lib/game_machine/actor/factory.rb', line 30

def self.create
end

Instance Method Details

#createObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'server/lib/game_machine/actor/factory.rb', line 12

def create
  if @klass.respond_to?(:reload_on_change?)
    if @klass.reload_on_change?
      GameMachine.logger.info "Checking if #{@klass.name} should be reloaded"
      GameMachine::Actor::Reloadable.reload_if_changed(@klass.name)
      @klass = @klass.name.constantize
    end
  end
  actor = @klass.new
  if actor.respond_to?(:initialize_states)
    actor.initialize_states
  end
  if actor.respond_to?(:post_init)
    actor.post_init(*@args)
  end
  actor
end