Record Class DamageInfo

java.lang.Object
java.lang.Record
megamek.common.DamageInfo
Record Components:
entity - the target entity that will suffer damage
hit - the hit data for the location hit
damage - the amount of damage to apply
ammoExplosion - ammo explosion type damage is applied directly to the IS, hurts the pilot, causes auto-ejects, and can blow the unit to smithereens
damageType - The DamageType of the attack (mostly used by specialty armor handling).
damageIS - Should the target location's internal structure be damaged directly?
areaSatArty - Is the damage from an area saturating artillery attack / AE damage?
throughFront - Is the damage coming through the hex the unit is facing? For Cowl, etc.
underWater - Is the damage coming from an underwater attack?
nukeS2S - is this a ship-to-ship nuke?

public record DamageInfo(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S) extends Record
Record class for passing damage application information to a Damage Manager's damageEntity() method.

This moves a lot of boilerplate and chained function call responsibility out of TWGameManager in preparation for replacing those overloaded functions with a single function, and having callers instantiate DamageInfo

  • Constructor Details

    • DamageInfo

      public DamageInfo(Entity entity, HitData hit, int damage)
    • DamageInfo

      public DamageInfo(Entity entity, HitData hit, int damage, boolean ammoExplosion)
    • DamageInfo

      public DamageInfo(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType bFrag, boolean damageIS)
    • DamageInfo

      public DamageInfo(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType bFrag, boolean damageIS, boolean areaSatArty)
    • DamageInfo

      public DamageInfo(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType bFrag, boolean damageIS, boolean areaSatArty, boolean throughFront)
    • DamageInfo

      public DamageInfo(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType bFrag, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater)
    • DamageInfo

      public DamageInfo(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S)
      Creates an instance of a DamageInfo record class.
      Parameters:
      entity - the value for the entity record component
      hit - the value for the hit record component
      damage - the value for the damage record component
      ammoExplosion - the value for the ammoExplosion record component
      damageType - the value for the damageType record component
      damageIS - the value for the damageIS record component
      areaSatArty - the value for the areaSatArty record component
      throughFront - the value for the throughFront record component
      underWater - the value for the underWater record component
      nukeS2S - the value for the nukeS2S record component
  • Method Details

    • 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.
    • entity

      public Entity entity()
      Returns the value of the entity record component.
      Returns:
      the value of the entity record component
    • hit

      public HitData hit()
      Returns the value of the hit record component.
      Returns:
      the value of the hit record component
    • damage

      public int damage()
      Returns the value of the damage record component.
      Returns:
      the value of the damage record component
    • ammoExplosion

      public boolean ammoExplosion()
      Returns the value of the ammoExplosion record component.
      Returns:
      the value of the ammoExplosion record component
    • damageType

      public DamageType damageType()
      Returns the value of the damageType record component.
      Returns:
      the value of the damageType record component
    • damageIS

      public boolean damageIS()
      Returns the value of the damageIS record component.
      Returns:
      the value of the damageIS record component
    • areaSatArty

      public boolean areaSatArty()
      Returns the value of the areaSatArty record component.
      Returns:
      the value of the areaSatArty record component
    • throughFront

      public boolean throughFront()
      Returns the value of the throughFront record component.
      Returns:
      the value of the throughFront record component
    • underWater

      public boolean underWater()
      Returns the value of the underWater record component.
      Returns:
      the value of the underWater record component
    • nukeS2S

      public boolean nukeS2S()
      Returns the value of the nukeS2S record component.
      Returns:
      the value of the nukeS2S record component