text: (function(GoNorth) {
      "use strict";
      (function(DefaultNodeShapes) {
          (function(Conditions) {
  
              /// Condition Type for checking the alive state of a npc to choose
              var conditionTypeCheckNpcAliveStateState = 9;
  
  
              /// Npc state alive
              var npcStateAlive = 0;
  
              /// Npc state dead
              var npcStateDead = 1;
  
              /// Npc state label lookup
              var npcStateLabelLookup = { };
              npcStateLabelLookup[npcStateAlive] = DefaultNodeShapes.Localization.Conditions.NpcAliveStateAlive;
              npcStateLabelLookup[npcStateDead] = DefaultNodeShapes.Localization.Conditions.NpcAliveStateDead;
  
  
              /**
               * Check npc alive state condition
               * @class
               */
              Conditions.CheckNpcAliveStateCondition = function()
              {
                  GoNorth.DefaultNodeShapes.Conditions.BaseCondition.apply(this);
                  GoNorth.DefaultNodeShapes.Shapes.SharedObjectLoading.apply(this);
              };
  
              Conditions.CheckNpcAliveStateCondition.prototype = jQuery.extend({ }, GoNorth.DefaultNodeShapes.Conditions.BaseCondition.prototype);
              Conditions.CheckNpcAliveStateCondition.prototype = jQuery.extend(Conditions.CheckNpcAliveStateCondition.prototype, GoNorth.DefaultNodeShapes.Shapes.SharedObjectLoading.prototype);
  
              /**
               * Returns the template name for the condition
               * 
               * @returns {string} Template name
               */
              Conditions.CheckNpcAliveStateCondition.prototype.getTemplateName = function() {
                  return "gn-nodeNpcAliveStateCheck";
              };
              
              /**
               * Returns true if the condition can be selected in the dropdown list, else false
               * 
               * @returns {bool} true if the condition can be selected, else false
               */
              Conditions.CheckNpcAliveStateCondition.prototype.canBeSelected = function() {
                  return true;
              };
  
              /**
               * Returns the type of the condition
               * 
               * @returns {number} Type of the condition
               */
              Conditions.CheckNpcAliveStateCondition.prototype.getType = function() {
                  return conditionTypeCheckNpcAliveStateState;
              };
  
              /**
               * Returns the label of the condition
               * 
               * @returns {string} Label of the condition
               */
              Conditions.CheckNpcAliveStateCondition.prototype.getLabel = function() {
                  return DefaultNodeShapes.Localization.Conditions.CheckNpcAliveStateLabel;
              };
  
              /**
               * Returns the objects on which an object depends
               * 
               * @param {object} existingData Existing condition data
               * @returns {object[]} Objects on which the condition depends
               */
              Conditions.CheckNpcAliveStateCondition.prototype.getConditionDependsOnObject = function(existingData) {
                  if(!existingData.npcId)
                  {
                      return [];
                  }
  
                  return [{
                      objectType: Conditions.RelatedToObjectNpc,
                      objectId: existingData.npcId
                  }];
              };
  
              /**
               * Returns the object resource
               * 
               * @returns {int} Object Resource
               */
              Conditions.CheckNpcAliveStateCondition.prototype.getObjectResource = function() {
                  return GoNorth.DefaultNodeShapes.Shapes.ObjectResourceNpc;
              };
  
              /**
               * Returns the object id from existing condition data for request caching
               * 
               * @param {object} existingData Existing condition data
               * @returns {string} Object Id for caching
               */
              Conditions.CheckNpcAliveStateCondition.prototype.getObjectId = function(existingData) {
                  return existingData.npcId;
              };
  
              /**
               * Loads an npc
               * 
               * @param {string} npcId Npc Id
               * @returns {jQuery.Deferred} Deferred for the loading process
               */
              Conditions.CheckNpcAliveStateCondition.prototype.loadObject = function(npcId) {
                  var loadingDef = new jQuery.Deferred();
  
                  jQuery.ajax({ 
                      url: "/api/KortistoApi/FlexFieldObject?id=" + npcId, 
                      type: "GET"
                  }).done(function(npc) {
                      loadingDef.resolve(npc);
                  }).fail(function(xhr) {
                      loadingDef.reject();
                  });
  
                  return loadingDef;
              };
  
              /**
               * Creates a npc alive state object
               * 
               * @param {number} npcState Alive State of the npc
               * @returns {object} Npc Alive State object
               */
              Conditions.CheckNpcAliveStateCondition.prototype.createState = function(npcState)
              {
                  return {
                      npcState: npcState,
                      label: npcStateLabelLookup[npcState]
                  };
              };
              
              /**
               * Returns the data for the condition
               * 
               * @param {object} existingData Existing condition data
               * @param {object} element Element to which the data belongs
               * @returns {object} Condition data
               */
              Conditions.CheckNpcAliveStateCondition.prototype.buildConditionData = function(existingData, element) {
                  var conditionData = {
                      selectedNpcId: new ko.observable(),
                      selectedNpcName: new ko.observable(DefaultNodeShapes.Localization.Conditions.ChooseNpcLabel),
                      selectedNpcState: new ko.observable(),
                      npcStates: [ 
                          this.createState(npcStateAlive),
                          this.createState(npcStateDead)
                      ]
                  };
  
                  conditionData.chooseNpc = function() {
                      GoNorth.DefaultNodeShapes.openNpcSearchDialog().then(function(npc) {
                          conditionData.selectedNpcId(npc.id);
                          conditionData.selectedNpcName(npc.name);
                      });
                  };
  
                  // Load existing data
                  if(existingData)
                  {
                      conditionData.selectedNpcId(existingData.npcId);
                      conditionData.selectedNpcState(existingData.state)
  
                      if(existingData.npcId) 
                      {
                          this.loadObjectShared(existingData).then(function(npc) {
                              conditionData.selectedNpcName(npc.name);
                          }, function() {
                              element.errorOccured(true);
                          });
                      }
                  }
  
                  return conditionData;
              };
  
              /**
               * Serializes condition data
               * 
               * @param {object} conditionData Condition data
               * @returns {object} Serialized data
               */
              Conditions.CheckNpcAliveStateCondition.prototype.serializeConditionData = function(conditionData) {
                  return {
                      npcId: conditionData.selectedNpcId(),
                      state: conditionData.selectedNpcState()
                  };
              };
  
              /**
               * Returns the condition data as a display string
               * 
               * @param {object} existingData Serialzied condition data
               * @returns {jQuery.Deferred} Deferred for the loading process
               */
              Conditions.CheckNpcAliveStateCondition.prototype.getConditionString = function(existingData) {
                  var def = new jQuery.Deferred();
                  
                  // Check if data is valid
                  if(!existingData.npcId)
                  {
                      def.resolve(DefaultNodeShapes.Localization.Conditions.MissingInformations);
                      return def.promise();
                  }
  
                  // Load data and build string
                  var self = this;
                  this.loadObjectShared(existingData).then(function(npc) {
                      var conditionText = DefaultNodeShapes.Localization.Conditions.StateLabel + "(" + npc.name + ") = " + npcStateLabelLookup[existingData.state];
  
                      def.resolve(conditionText);
                  }, function() {
                      def.reject();
                  });
  
                  return def.promise();
              };
  
              GoNorth.DefaultNodeShapes.Conditions.getConditionManager().addConditionType(new Conditions.CheckNpcAliveStateCondition());
  
          }(DefaultNodeShapes.Conditions = DefaultNodeShapes.Conditions || {}));
      }(GoNorth.DefaultNodeShapes = GoNorth.DefaultNodeShapes || {}));
  }(window.GoNorth = window.GoNorth || {}));