2021-04-29 14:45:18 +00:00
|
|
|
package uulm.teamname.marvelous.gamelibrary.entities;
|
2021-04-29 14:40:23 +00:00
|
|
|
|
|
|
|
/** Represents a distinct identification for every {@link Entity} in a game.
|
|
|
|
*/
|
|
|
|
public class EntityID {
|
|
|
|
/** The index of the entity.
|
|
|
|
*/
|
|
|
|
public final int id;
|
|
|
|
|
|
|
|
/** The type of the entity.
|
|
|
|
*/
|
|
|
|
public final EntityType type;
|
|
|
|
|
|
|
|
/** Constructs a new {@link Entity}-{@link EntityID} based on the given index and {@link EntityType}.
|
|
|
|
* @param id The index of the entity.
|
|
|
|
* @param type The type of the entity.
|
|
|
|
*/
|
|
|
|
public EntityID(int id, EntityType type) {
|
|
|
|
this.id = id;
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Checks if the id has the same {@link EntityType} as the given one.
|
|
|
|
* @param other The type to compare to.
|
|
|
|
* @return Whether or not the id has the same type.
|
|
|
|
*/
|
|
|
|
public boolean isSameType(EntityType other) {
|
|
|
|
return type == other;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Serializes the id for debugging.
|
|
|
|
* @return A debug string containing all the necessary information about the id.
|
|
|
|
*/
|
|
|
|
public String toString() {
|
|
|
|
return "["+type.toString()+":"+id+"]";
|
|
|
|
}
|
|
|
|
}
|