<commit_before>--[[
  ComponentType
  =============

  A Component is an instance or collection of instances in the game that gets
  used in conjunction with other classes.

  For example, the Trigger class is instantiated with a specifically named Part
  with a ModuleScript inside of it. A ComponentType is used to find all
  Instances's in the game that match that criteria.

  Constructors
  ------------

  ComponentType.new(string remoteName, function callback)
    `remoteName` is the name of a RemoteFunction that will be used by the client
    to retrieve the `FoundComponents` property.

    `callback` determines what represents a Component. Whenever it returns true,
    the object that was passed into it will be considered a Component.

    For example, the following will make all Instances with a ModuleScript named
    "ComponentData" a Component in FoundComponents.

      local function callback(obj)
        local module = obj:FindFirstChild("ModuleScript")
        return module and module.Name == "ComponentData"
      end

      ComponentType.new("GetComponent", callback)

  Properties
  ----------

  self.Remote
    RemoteFunction named after `remoteName`.

    The OnServerInvoke function is automatically setup to return
    self.FoundComponents, so when the client runs InvokeServer() they will get
    the current list of Components.

  self.Callback
    Reference to the `callback` function.

  self.Location=workspace
    The location that will be recursed through when looking through Components.

    This can be changed to anything in the game, but should typically be a
    descendant of Workspace.

  self.FoundComponents={}
    List of all the Components that are found when `FindComponents()` is called.

  Methods
  -------

  FindComponents()
    Locates all of the Components.

    If any instance has a BoolValue named "Disabled" set to true, the instance
    will be ignored. This is used in development so we can add Components
    without them being picked up until we hook them up properly.

  GetComponents()
    This is used server-side for when we need to get the list of components.
--]]

local replicatedStorage = game:GetService("ReplicatedStorage")

local remotes = require(replicatedStorage.Events.Remotes)
local find = require(replicatedStorage.Util.Find)

-- This is used when finding Components. It allows us to skip instances that
-- have a Disabled BoolValue set to true.
local function isDisabled(obj)
  local disabled = obj:FindFirstChild("Disabled")
  if disabled and disabled:IsA("BoolValue") then
    return disabled.Value
  end
end

local ComponentType = {}
ComponentType.__index = ComponentType

function ComponentType.new(remoteName, callback)
  local self = {}
  setmetatable(self, ComponentType)

  self.Remote = remotes.getFunction(remoteName)
  self.Callback = callback

  self.Location = workspace
  self.FoundComponents = {}

  function self.Remote.OnServerInvoke()
    return self.FoundComponents
  end

  return self
end

function ComponentType:FindComponents()
  self.FoundComponents = find(self.Location, function(obj)
    return not isDisabled(obj) and self.Callback(obj)
  end)
end

function ComponentType:GetComponents()
  return self.FoundComponents
end

return ComponentType<commit_msg>Remove unused method<commit_after>--[[
  ComponentType
  =============

  A Component is an instance or collection of instances in the game that gets
  used in conjunction with other classes.

  For example, the Trigger class is instantiated with a specifically named Part
  with a ModuleScript inside of it. A ComponentType is used to find all
  Instances's in the game that match that criteria.

  Constructors
  ------------

  ComponentType.new(string remoteName, function callback)
    `remoteName` is the name of a RemoteFunction that will be used by the client
    to retrieve the `FoundComponents` property.

    `callback` determines what represents a Component. Whenever it returns true,
    the object that was passed into it will be considered a Component.

    For example, the following will make all Instances with a ModuleScript named
    "ComponentData" a Component in FoundComponents.

      local function callback(obj)
        local module = obj:FindFirstChild("ModuleScript")
        return module and module.Name == "ComponentData"
      end

      ComponentType.new("GetComponent", callback)

  Properties
  ----------

  self.Remote
    RemoteFunction named after `remoteName`.

    The OnServerInvoke function is automatically setup to return
    self.FoundComponents, so when the client runs InvokeServer() they will get
    the current list of Components.

  self.Callback
    Reference to the `callback` function.

  self.Location=workspace
    The location that will be recursed through when looking through Components.

    This can be changed to anything in the game, but should typically be a
    descendant of Workspace.

  self.FoundComponents={}
    List of all the Components that are found when `FindComponents()` is called.

  Methods
  -------

  FindComponents()
    Locates all of the Components.

    If any instance has a BoolValue named "Disabled" set to true, the instance
    will be ignored. This is used in development so we can add Components
    without them being picked up until we hook them up properly.
--]]

local replicatedStorage = game:GetService("ReplicatedStorage")

local remotes = require(replicatedStorage.Events.Remotes)
local find = require(replicatedStorage.Util.Find)

-- This is used when finding Components. It allows us to skip instances that
-- have a Disabled BoolValue set to true.
local function isDisabled(obj)
  local disabled = obj:FindFirstChild("Disabled")
  if disabled and disabled:IsA("BoolValue") then
    return disabled.Value
  end
end

local ComponentType = {}
ComponentType.__index = ComponentType

function ComponentType.new(remoteName, callback)
  local self = {}
  setmetatable(self, ComponentType)

  self.Remote = remotes.getFunction(remoteName)
  self.Callback = callback

  self.Location = workspace
  self.FoundComponents = {}

  function self.Remote.OnServerInvoke()
    return self.FoundComponents
  end

  return self
end

function ComponentType:FindComponents()
  self.FoundComponents = find(self.Location, function(obj)
    return not isDisabled(obj) and self.Callback(obj)
  end)
end

return ComponentType
{'fraction_non_alphanumeric': 0.06870588235294117, 'fraction_numerical': 0.0, 'mean_word_length': 3.7159763313609466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '934000', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1568, 'n_words': 695}