lib/demiurge/agent.rb
# This method will move the agent and notify about that change. It
# doesn't use an intention or an agent's action queue, and it
# doesn't wait for a tick to happen. It just does it. The method
# *does* handle exits and generally allows the location to
# respond.  But it's assumed that the offer cycle, if it needs to
# happen, has happened already.
#
# @param pos [String] A position string to move to
# @param options [Hash] A hash of how to do the movement; Demiurge doesn't internally use this hash, but your World Files or display library may do so
# @return [void]
# @since 0.0.1
This method will move the agent and notify about that change. It
doesn't use an intention or an agent's action queue, and it
doesn't wait for a tick to happen. It just does it. The method
does* handle exits and generally allows the location to
respond.  But it's assumed that the offer cycle, if it needs to
happen, has happened already.
This method will move the agent and notify about that change . It doesn ' t use an intention or an agent ' s action queue and it doesn ' t wait for a tick to happen . It just does it . The method does * handle exits and generally allows the location to respond . But it ' s assumed that the offer cycle if it needs to happen has happened already .
def move_to_position(pos, options = {})
      old_pos = self.position
      old_loc = self.location_name
      old_zone_name = self.zone_name
      expected_new_loc = pos.split("#")[0]
      if old_loc && !self.location
        raise ::Demiurge::Errors::LocationNameNotFoundError.new("Item #{@name.inspect} has an old location name (#{old_loc.inspect}) with no matching location object!",
                                                                { "item_name" => @name, "location_name" => old_loc, "moving_to" => pos },
                                                                execution_context: @engine.execution_context);
      end
      if old_loc != nil && expected_new_loc == old_loc
        self.location.item_change_position(self, old_pos, pos)
      elsif old_loc != nil
        self.location.item_change_location(self, old_pos, pos)
      end
      new_loc = self.location_name
      @engine.send_notification({ old_position: old_pos, old_location: old_loc, new_position: self.position, new_location: new_loc },
                                  type: Demiurge::Notifications::MoveFrom, zone: old_zone_name, location: old_loc, actor: @name, include_context: true)
      @engine.send_notification({ old_position: old_pos, old_location: old_loc, new_position: self.position, new_location: new_loc, options: options },
                                  type: Demiurge::Notifications::MoveTo, zone: self.zone_name, location: self.location_name, actor: @name, include_context: true)
    end
def move_to_position ( pos , options = { } ) old_pos = self . position old_loc = self . location_name old_zone_name = self . zone_name expected_new_loc = pos . split ( "#" ) [ 0 ] if old_loc && ! self . location raise :: Demiurge :: Errors :: LocationNameNotFoundError . new ( "Item #{@name.inspect} has an old location name (#{old_loc.inspect}) with no matching location object!" , { "item_name" => @name , "location_name" => old_loc , "moving_to" => pos } , execution_context : @engine . execution_context ) ; end if old_loc != nil && expected_new_loc == old_loc self . location . item_change_position ( self , old_pos , pos ) elsif old_loc != nil self . location . item_change_location ( self , old_pos , pos ) end new_loc = self . location_name @engine . send_notification ( { old_position : old_pos , old_location : old_loc , new_position : self . position , new_location : new_loc } , type : Demiurge :: Notifications :: MoveFrom , zone : old_zone_name , location : old_loc , actor : @name , include_context : true ) @engine . send_notification ( { old_position : old_pos , old_location : old_loc , new_position : self . position , new_location : new_loc , options : options } , type : Demiurge :: Notifications :: MoveTo , zone : self . zone_name , location : self . location_name , actor : @name , include_context : true ) end
This method will move the agent and notify about that change.
This method will move the agent and notify about that change .
# This also handles zone changes. # We're not guaranteed to wind up where we expected, so get the # new location *after* item_change_location or # item_change_position.
None
void
pos
A position string to move to
A position string to move to
options
A hash of how to do the movement; Demiurge doesn't internally use this hash, but your World Files or display library may do so
A hash of how to do the movement ; Demiurge doesn ' t internally use this hash but your World Files or display library may do so
since
None