Record Class Typecode

java.lang.Object
java.lang.Record
dev.twilite.game.menu.Typecode

public record Typecode(Coord.Map map, Typecode.EntityType type, boolean inactive, int index, int world) extends Record
Packed entity metadata used by minimenu actions.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Typecode(Coord.Map map, Typecode.EntityType type, boolean inactive, int index, int world)
    Creates an instance of a Typecode record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<? extends Unit>
    Resolves the entity referenced by this typecode.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static Typecode
    fromPacked(long typecode)
    Decodes a packed game typecode.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the inactive record component.
    int
    Returns the value of the index record component.
    map()
    Returns the value of the map record component.
    static long
    pack(Coord.Map coord, Typecode.EntityType type, boolean inactive, int index, int world)
    Packs entity metadata into the game's typecode format.
    long
    Packs this typecode instance.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.
    int
    Returns the value of the world record component.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Typecode

      public Typecode(Coord.Map map, Typecode.EntityType type, boolean inactive, int index, int world)
      Creates an instance of a Typecode record class.
      Parameters:
      map - the value for the map record component
      type - the value for the type record component
      inactive - the value for the inactive record component
      index - the value for the index record component
      world - the value for the world record component
  • Method Details

    • pack

      public static long pack(Coord.Map coord, Typecode.EntityType type, boolean inactive, int index, int world)
      Packs entity metadata into the game's typecode format.
    • fromPacked

      public static Typecode fromPacked(long typecode)
      Decodes a packed game typecode.
    • packed

      public long packed()
      Packs this typecode instance.
    • entity

      public Optional<? extends Unit> entity()
      Resolves the entity referenced by this typecode.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • map

      public Coord.Map map()
      Returns the value of the map record component.
      Returns:
      the value of the map record component
    • type

      public Typecode.EntityType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • inactive

      public boolean inactive()
      Returns the value of the inactive record component.
      Returns:
      the value of the inactive record component
    • index

      public int index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • world

      public int world()
      Returns the value of the world record component.
      Returns:
      the value of the world record component