From 3ad8d2531329c1696a2bf86db8db9237309281ab Mon Sep 17 00:00:00 2001 From: realtradam Date: Fri, 11 Jun 2021 02:14:57 -0400 Subject: general cleanup --- docs/FelFlame/Entities.html | 220 +++++++++++++++++++++++++++++++++----------- 1 file changed, 164 insertions(+), 56 deletions(-) (limited to 'docs/FelFlame/Entities.html') diff --git a/docs/FelFlame/Entities.html b/docs/FelFlame/Entities.html index b6f4bb7..4ba4d6f 100644 --- a/docs/FelFlame/Entities.html +++ b/docs/FelFlame/Entities.html @@ -184,7 +184,7 @@
-

Gets an Entity from the given unique ID.

+

Gets an Entity from the given unique ID.

@@ -211,6 +211,30 @@

Iterates over all entities.

+ + + +
  • + + + .from_json(json_string, **opts) ⇒ Object + + + + + + + + + + + + + +
    +

    Creates a new entity using the data from a JSON string TODO: This function is not yet complete.

    +
    +
  • @@ -265,7 +289,7 @@
    -

    A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the IDs of components attached to this entity.

    +

    A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the IDs of the components attached to this entity.

    @@ -298,7 +322,7 @@
  • - #initialize(*components) ⇒ Entities + #initialize(*components) ⇒ Entity @@ -315,7 +339,7 @@
    -

    Creating a new component.

    +

    Creating a new Entity.

  • @@ -403,7 +427,7 @@

    - #initialize(*components) ⇒ Entities + #initialize(*components) ⇒ Entity @@ -412,7 +436,7 @@

    -

    Creating a new component

    +

    Creating a new Entity

    @@ -426,13 +450,13 @@ components - (Component) + (Components)
    -

    Can be any number of components, identical duplicated will be automatically purged however different components from the same component manager are allowed.

    +

    Can be any number of components, identical duplicates will be automatically purged however different components from the same component manager are allowed.

    @@ -446,7 +470,6 @@
     
     
    -9
     10
     11
     12
    @@ -457,10 +480,11 @@
     17
     18
     19
    -20
    +20 +21 -
    # File 'entity_manager.rb', line 9
    +      
    # File 'entity_manager.rb', line 10
     
     def initialize(*components)
       # Assign new unique ID
    @@ -559,13 +583,22 @@
     
    -

    Gets an Entity from the given unique ID. Usage is simular to how an Array lookup works

    +

    Gets an Entity from the given unique ID. Usage is simular to how an Array lookup works

    -

    Parameters:

    + +
    +

    Examples:

    + + +
    # This gets the Entity with ID 7
    +FelFlame::Entities[7]
    + +
    +

    Parameters:

    • @@ -606,12 +639,12 @@
       
       
      -97
      -98
      -99
      +103 +104 +105
    -
    # File 'entity_manager.rb', line 97
    +      
    # File 'entity_manager.rb', line 103
     
     def [](entity_id)
       data[entity_id]
    @@ -633,7 +666,7 @@
     
    -

    Iterates over all entities. In general when using ECS the use of this method should never be neccassary unless you are doing something very wrong, however I will not stop you. You also call other enumerable methods instead of each, such as `each_with_index` or `select`

    +

    Iterates over all entities. In general when using ECS the use of this method should never be neccassary unless you are doing something very wrong, however I will not stop you. You also call other enumerable methods instead of each, such as each_with_index or select

    @@ -660,12 +693,12 @@
     
     
    -104
    -105
    -106
    +110 +111 +112
    -
    # File 'entity_manager.rb', line 104
    +      
    # File 'entity_manager.rb', line 110
     
     def each(&block)
       data.each(&block)
    @@ -673,6 +706,79 @@
         
       
     
    +
    + +
    +

    + + .from_json(json_string, **opts) ⇒ Object + + + + + +

    +
    + +

    Creates a new entity using the data from a JSON string TODO: This function is not yet complete

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + json_string + + + (String) + + + + — +
      +

      A string that was exported originally using the to_json function

      +
      + +
    • + +
    • + + opts + + + (Keywords) + + + + — +
      +

      What values(its ID or the component IDs) should be overwritten TODO: this might change

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +118
    +
    +
    # File 'entity_manager.rb', line 118
    +
    +def from_json(json_string, **opts) end
    +
    @@ -745,9 +851,6 @@
     
     
    -54
    -55
    -56
     57
     58
     59
    @@ -757,19 +860,22 @@
     63
     64
     65
    -66
    +66 +67 +68 +69 -
    # File 'entity_manager.rb', line 54
    +      
    # File 'entity_manager.rb', line 57
     
    -def add component
    +def add(component)
       if components[component.class.to_s.to_sym].nil?
         components[component.class.to_s.to_sym] = [component.id]
    -    component.linked_entities.push id
    +    component.entities.push id
         true
       elsif !components[component.class.to_s.to_sym].include? component.id
         components[component.class.to_s.to_sym].push component.id
    -    component.linked_entities.push id
    +    component.entities.push id
         true
       else
         false
    @@ -792,7 +898,7 @@
     
    -

    A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the IDs of components attached to this entity.

    +

    A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the IDs of the components attached to this entity.

    @@ -819,12 +925,12 @@
     
     
    -24
     25
    -26
    +26 +27
    -
    # File 'entity_manager.rb', line 24
    +      
    # File 'entity_manager.rb', line 25
     
     def components
       @components ||= {}
    @@ -878,7 +984,6 @@
           
     
     
    -36
     37
     38
     39
    @@ -890,18 +995,23 @@
     45
     46
     47
    -48
    +48 +49 +50 +51
    -
    # File 'entity_manager.rb', line 36
    +      
    # File 'entity_manager.rb', line 37
     
     def delete
       components.each do |component_manager, component_array|
         component_array.each do |component_id|
           FelFlame.const_get(
             component_manager.to_s.delete_prefix('FelFlame::')
    -      )[component_id].linked_entities.delete(id)
    -    end
    +      )[component_id].entities.delete(id)
    +      # The following is neater, but doesnt work for some reason :/
    +      #Object.const_get(component_manager)[component_id].entities.delete(id)
    +    end
       end
       FelFlame::Entities.data[id] = nil
       @id = nil
    @@ -977,21 +1087,21 @@
           
     
     
    -71
    -72
    -73
     74
     75
     76
     77
    -78
    +78 +79 +80 +81
    -
    # File 'entity_manager.rb', line 71
    +      
    # File 'entity_manager.rb', line 74
     
    -def remove component
    +def remove(component)
       components[component.class.to_s.to_sym].delete component.id
    -  if component.linked_entities.delete id
    +  if component.entities.delete id
         true
       else
         false
    @@ -1041,12 +1151,12 @@
           
     
     
    -30
     31
    -32
    +32 +33
    -
    # File 'entity_manager.rb', line 30
    +      
    # File 'entity_manager.rb', line 31
     
     def to_i
       id
    @@ -1100,14 +1210,12 @@
           
     
     
    -83
    -84
    +86
    -
    # File 'entity_manager.rb', line 83
    +      
    # File 'entity_manager.rb', line 86
     
    -def to_json
    -end
    +def to_json() end
    @@ -1118,9 +1226,9 @@ -- cgit v1.2.3