core.game

## Class Observation

- java.lang.Object
- - core.game.Observation

- All Implemented Interfaces:
    java.lang.Comparable<Observation>

      public class Observation
      extends java.lang.Object
      implements java.lang.Comparable<Observation>

  Created by Diego on 19/03/14.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `category` Category of this observation (static, resource, npc, etc.).
    `int` | `itype` Type of sprite of this observation.
    `int` | `obsID` unique ID for this observation
    `Vector2d` | `position` Position of the observation.
    `Vector2d` | `reference` Reference to the position used for comparing this observation with others.
    `double` | `sqDist` Distance from this observation to the reference.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Observation(int itype, int id, Vector2d pos, Vector2d posReference, int category)` New observation.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(Observation o)` Compares this observation to others, using distances to the reference position.
    `boolean` | `equals(java.lang.Object other)` Compares two Observations to check if they are equal.
    `void` | `update(int itype, int id, Vector2d pos, Vector2d posReference, int category)` Updates this observation

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### category

          public int category

      Category of this observation (static, resource, npc, etc.).

    - #### itype

          public int itype

      Type of sprite of this observation.

    - #### obsID

          public int obsID

      unique ID for this observation

    - #### position

          public Vector2d position

      Position of the observation.

    - #### reference

          public Vector2d reference

      Reference to the position used for comparing this observation with others.

    - #### sqDist

          public double sqDist

      Distance from this observation to the reference.

  - ### Constructor Detail

    - #### Observation

          public Observation(int itype,
                     int id,
                     Vector2d pos,
                     Vector2d posReference,
                     int category)

      New observation. It is the observation of a sprite, recording its ID and position.
      Parameters:
        `itype` - type of the sprite of this observation
        `id` - ID of the observation.
        `pos` - position of the sprite.
        `posReference` - reference to compare this position to others.
        `category` - category of this observation (NPC, static, resource, etc.)

  - ### Method Detail

    - #### update

          public void update(int itype,
                    int id,
                    Vector2d pos,
                    Vector2d posReference,
                    int category)

      Updates this observation
      Parameters:
        `itype` - type of the sprite of this observation
        `id` - ID of the observation.
        `pos` - position of the sprite.
        `posReference` - reference to compare this position to others.
        `category` - category of this observation (NPC, static, resource, etc.)

    - #### compareTo

          public int compareTo(Observation o)

      Compares this observation to others, using distances to the reference position.
      Specified by:
        `compareTo` in interface `java.lang.Comparable<Observation>`
      Parameters:
        `o` - other observation.
      Returns:
        -1 if this precedes o, 1 if same distance or o is closer to reference.

    - #### equals

          public boolean equals(java.lang.Object other)

      Compares two Observations to check if they are equal. The reference attribute is NOT compared in this object.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `other` - the other observation.
      Returns:
        true if both objects are the same Observation.