<commit_before>/* Omega JS Motel Event Callback
 *
 * Methods here will get mixed into the CommandTracker module
 *
 * Copyright (C) 2014 <NAME> <<EMAIL>>
 *  Licensed under the AGPLv3+ http://www.gnu.org/licenses/agpl.txt
 */

Omega.Callbacks.motel = function(event, event_args){
  var entity = $.grep(this.page.all_entities(), function(entity){
                 return entity.location &&
                        entity.location.id == event_args[0].id;
               })[0];
  if(entity == null) return;
  var new_loc = new Omega.Location(event_args[0]);

  // reset last moved if movement strategy changed
  if(entity.location.movement_strategy.json_class !=
     new_loc.movement_strategy.json_class)
    entity.last_moved = null;
  else
    entity.last_moved = new Date();

  entity.location = new_loc; // TODO should this just be an update?

  if(this.page.canvas.is_root(entity.parent_id)){
    this.page.canvas.reload(entity, function(){
      if(entity.update_gfx) entity.update_gfx();
    });
  }

  this.page.canvas.entity_container.refresh();
};
<commit_msg>UI: use Location update method in motel callback<commit_after>/* Omega JS Motel Event Callback
 *
 * Methods here will get mixed into the CommandTracker module
 *
 * Copyright (C) 2014 <NAME> <<EMAIL>>
 *  Licensed under the AGPLv3+ http://www.gnu.org/licenses/agpl.txt
 */

Omega.Callbacks.motel = function(event, event_args){
  var entity = $.grep(this.page.all_entities(), function(entity){
                 return entity.location &&
                        entity.location.id == event_args[0].id;
               })[0];
  if(entity == null) return;
  var new_loc = new Omega.Location(event_args[0]);

  // reset last moved if movement strategy changed
  if(entity.location.movement_strategy.json_class !=
     new_loc.movement_strategy.json_class)
    entity.last_moved = null;
  else
    entity.last_moved = new Date();

  entity.location.update(new_loc);

  if(this.page.canvas.is_root(entity.parent_id)){
    this.page.canvas.reload(entity, function(){
      if(entity.update_gfx) entity.update_gfx();
    });
  }

  this.page.canvas.entity_container.refresh();
};

{'fraction_non_alphanumeric': 0.12897196261682242, 'fraction_numerical': 0.007476635514018692, 'mean_word_length': 3.23960396039604, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '361570', 'n_tokens_mistral': 689, 'n_tokens_neox': 671, 'n_words': 147}