<commit_before>// The MIT License (MIT)
//
// Copyright (c) 2013 <NAME>, <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.


// The `TANK` namespace provides access to the core functionality of the engine.
// This includes creating entities and spaces, and registering components
(function (TANK)
{
  "use strict";

  // ### Enable/Disable error messages
  TANK.errorsEnabled = true;

  // ### Enable/Disable warning messages
  TANK.warningsEnabled = true;

  // ### Enable/Disable logging messages
  TANK.logsEnabled = true;

  // ### Create an Entity
  // Creates a new entity and returns it. The parameters to the function are
  // passed directly to `Entity.addComponents` after construction.
  // Components can be given as a string of comma seperated values, a list of strings, or some combination of the above.

  // `Entity TANK.createEntity(...)`

  // - `...` a string of comma seperated values, a list of strings, or some combination of the above.
  // - `return` A new entity.
  TANK.createEntity = function ()
  {
    var entity = new TANK.Entity(-1);
    return entity.addComponents.apply(entity, arguments);
  };

  // ### Create Entity from prefab
  // Creates a new `Entity` using a given prefab.

  // `Entity TANK.createEntityFromPrefab(prefabName)`

  // - `prefabName` Name of the prefab to clone.
  // - `return` A new `Entity`.
  TANK.createEntityFromPrefab = function (prefabName)
  {
    var prefab = TANK.getPrefab(prefabName);
    if (!prefab)
    {
      TANK.warning("Could not find a prefab named " + prefabName);
      return;
    }

    var entity = TANK.createEntity();
    var component;
    var componentData;
    var componentName, propertyName;
    for (componentName in prefab)
    {
      if (prefab.hasOwnProperty(componentName))
      {
        entity.addComponent(componentName);

        // Copy over fields from prefab into new component
        component = entity[componentName];
        componentData = prefab[componentName];
        for (propertyName in componentData)
        {
          if (componentData.hasOwnProperty(propertyName))
          {
            component[propertyName] = componentData[propertyName];
          }
        }
      }
    }

    return entity;
  };

  // ### Create a space
  // Creates a new `Space` and returns it. The parameters to the function are passed
  // directly to `Space.addComponents` after construction.

  // `Space TANK.createSpace(...)

  // - `...` a string of comma seperated values, a list of strings, or some combination of the above.
  // - `return` A new space.
  TANK.createSpace = function ()
  {
    var space = new TANK.Space();
    space.addComponents.apply(space, arguments);
    return space;
  }

  // ### Add a space to the engine
  // Adds the given space to the engine, which will initialize all of its components.

  // `void TANK.addSpace(space, name)`

  // - `space` The space object to add.
  // - `name` The name to refer to the space by. The space will then be accessible through `TANK.SpaceName`.
  TANK.addSpace = function (space, name)
  {
    TANK._spaces[name] = space;
    TANK[name] = space;

    for (var i in space._components)
    {
      if (space._components.hasOwnProperty(i))
        space._components[i].initialize();
    }

    for (var i in space._components)
    {
      if (space._components.hasOwnProperty(i))
        space.dispatchEvent("OnComponentInitialized", space._components[i]);
    }

    space._initialized = true;
  }

  // ### Remove a space from the engine
  // Removes the given space from the engine, uninitializing all its components.

  // `void TANK.removeSpace(space)`

  // - `space` Either the name of the space or the space object.
  TANK.removeSpace = function (space)
  {
    if (typeof space === "string")
    {
      if (TANK[space])
      {
        TANK._spacesDeleted.push(TANK[space]);
      }
      else
      {
        TANK.error("Attempting to remove Space " + space + " which doesn't exist.");
      }
    }
    else if (space instanceof TANK.Space)
    {
      TANK._spacesDeleted.push(space);
    }
    else
    {
      TANK.error("Attemping to remove a Space with neither a string name, nor Space reference: " + arg);
    }
  }

  // ### Register an object prefab
  // Use this to define an entity with a set of components that
  // can be instantiated later, like a blueprint.
<commit_msg>Fix bug with space removal<commit_after>// The MIT License (MIT)
//
// Copyright (c) 2013 <NAME>, <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.


// The `TANK` namespace provides access to the core functionality of the engine.
// This includes creating entities and spaces, and registering components
(function (TANK)
{
  "use strict";

  // ### Enable/Disable error messages
  TANK.errorsEnabled = true;

  // ### Enable/Disable warning messages
  TANK.warningsEnabled = true;

  // ### Enable/Disable logging messages
  TANK.logsEnabled = true;

  // ### Create an Entity
  // Creates a new entity and returns it. The parameters to the function are
  // passed directly to `Entity.addComponents` after construction.
  // Components can be given as a string of comma seperated values, a list of strings, or some combination of the above.

  // `Entity TANK.createEntity(...)`

  // - `...` a string of comma seperated values, a list of strings, or some combination of the above.
  // - `return` A new entity.
  TANK.createEntity = function ()
  {
    var entity = new TANK.Entity(-1);
    return entity.addComponents.apply(entity, arguments);
  };

  // ### Create Entity from prefab
  // Creates a new `Entity` using a given prefab.

  // `Entity TANK.createEntityFromPrefab(prefabName)`

  // - `prefabName` Name of the prefab to clone.
  // - `return` A new `Entity`.
  TANK.createEntityFromPrefab = function (prefabName)
  {
    var prefab = TANK.getPrefab(prefabName);
    if (!prefab)
    {
      TANK.warning("Could not find a prefab named " + prefabName);
      return;
    }

    var entity = TANK.createEntity();
    var component;
    var componentData;
    var componentName, propertyName;
    for (componentName in prefab)
    {
      if (prefab.hasOwnProperty(componentName))
      {
        entity.addComponent(componentName);

        // Copy over fields from prefab into new component
        component = entity[componentName];
        componentData = prefab[componentName];
        for (propertyName in componentData)
        {
          if (componentData.hasOwnProperty(propertyName))
          {
            component[propertyName] = componentData[propertyName];
          }
        }
      }
    }

    return entity;
  };

  // ### Create a space
  // Creates a new `Space` and returns it. The parameters to the function are passed
  // directly to `Space.addComponents` after construction.

  // `Space TANK.createSpace(...)

  // - `...` a string of comma seperated values, a list of strings, or some combination of the above.
  // - `return` A new space.
  TANK.createSpace = function ()
  {
    var space = new TANK.Space();
    space.addComponents.apply(space, arguments);
    return space;
  }

  // ### Add a space to the engine
  // Adds the given space to the engine, which will initialize all of its components.

  // `void TANK.addSpace(space, name)`

  // - `space` The space object to add.
  // - `name` The name to refer to the space by. The space will then be accessible through `TANK.SpaceName`.
  TANK.addSpace = function (space, name)
  {
    TANK._spaces[name] = space;
    TANK[name] = space;

    for (var i in space._components)
    {
      if (space._components.hasOwnProperty(i))
        space._components[i].initialize();
    }

    for (var i in space._components)
    {
      if (space._components.hasOwnProperty(i))
        space.dispatchEvent("OnComponentInitialized", space._components[i]);
    }

    space._initialized = true;
  }

  // ### Remove a space from the engine
  // Removes the given space from the engine, uninitializing all its components.

  // `void TANK.removeSpace(space)`

  // - `space` Either the name of the space or the space object.
  TANK.removeSpace = function (space)
  {
    if (typeof space === "string")
    {
      if (TANK[space])
      {
        TANK._spacesDeleted.push(TANK[space]);
      }
      else
      {
        TANK.error("Attempting to remove Space " + space + " which doesn't exist.");
      }
    }
    else if (space instanceof TANK.Space)
    {
      TANK._spacesDeleted.push(space);
    }
    else
    {
      TANK.error("Attemping to remove a Space with neither a string name, nor Space reference: " + space);
    }
  }

  // ### Register an object prefab
  // Use this to define an entity with a set of components that
  // can be instantiated later, like a blueprint.

{'fraction_non_alphanumeric': 0.10576629716261568, 'fraction_numerical': 0.0010169836265636124, 'mean_word_length': 2.7011667293940533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '288128', 'n_tokens_mistral': 2815, 'n_tokens_neox': 2752, 'n_words': 1024}