# Class Component

java.lang.Object
it.polimi.ingsw.is25am31.model.components.Component

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `AlienLifeSupport`, `BatteryComponent`, `Cabin`, `Cannon`, `CargoHold`, `Engine`, `MainCabin`, `ShieldGenerator`

public class Component extends Object implements Serializable
Represents a general component in the game, serving as the base class for various specialized components. This class handles the management of component properties such as orientation, position, and connections to other components.
Subclasses of this class are designed to override and extend its functionality to represent specific types of components.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Map<Side,Connector>`
  `connector`
  `protected int`
  `id`
  `protected String`
  `name`
  `protected Side`
  `orientation`
  `protected int`
  `x`
  `protected int`
  `y`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Component(int id, String name, Map<Side,Connector> connector, Side orientation)`
  Constructor used by Json to deserialize component properties

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `activate()`
  `boolean`
  `addContains(Good good)`
  `double`
  `calculateFirePower()`
  `int`
  `calculateThrust()`
  `AlienColor`
  `getAlienColor()`
  Returns the alien color if applicable
  `String[]`
  `getAsciiArt()`
  Provides ASCII art representation for structural components
  `int`
  `getCapacity()`
  `Connector`
  `getConnector(Side side)`
  Returns the connector type on a specified side
  `Map<Side,Connector>`
  `getConnectors()`
  Returns a defensive copy of all side-to-connector mappings
  `List<Good>`
  `getContains()`
  `int`
  `getCrewMembers()`
  `AlienColor`
  `getCurrentAlien()`
  `int`
  `getId()`
  `int`
  `getMaxGoodValue()`
  `String`
  `getName()`
  Returns the name of the component
  `Side`
  `getOrientation()`
  Returns the current orientation of the component
  `OrientationShield`
  `getOrientationShield()`
  `int`
  `getPower()`
  `int`
  `getX()`
  `int`
  `getY()`
  `boolean`
  `isActive()`
  `boolean`
  `isAlienLifeSupport()`
  Indicates whether this component supports alien life
  `boolean`
  `isAlienStructural()`
  Indicates whether this is a structural component containing aliens
  `void`
  `modifyCapacity(int change)`
  `boolean`
  `modifyCrewMembers(int change)`
  `void`
  `modifyOrientation(Side newOrientation)`
  Rotates the component to a new orientation and updates its connectors accordingly
  `OrientationShield`
  `protectedSides()`
  `boolean`
  `removeContains(Good good)`
  `void`
  `setOrientationShield()`
  `void`
  `setX(int x)`
  `void`
  `setY(int y)`

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

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

- ## Field Details

  - ### id

    protected int id

  - ### name

    protected String name

  - ### connector

    protected Map<Side,Connector> connector

  - ### orientation

    protected Side orientation

  - ### x

    protected int x

  - ### y

    protected int y

- ## Constructor Details

  - ### Component

    public Component(int id, String name, Map<Side,Connector> connector, Side orientation)
    Constructor used by Json to deserialize component properties
    Parameters:
      `id` - unique component identifier
      `name` - name of the component
      `connector` - map of side-to-connector mappings
      `orientation` - initial orientation of the component

- ## Method Details

  - ### getName

    public String getName()
    Returns the name of the component
    Returns:
      component name

  - ### modifyOrientation

    public void modifyOrientation(Side newOrientation)
    Rotates the component to a new orientation and updates its connectors accordingly
    Parameters:
      `newOrientation` - the target orientation

  - ### getOrientation

    public Side getOrientation()
    Returns the current orientation of the component
    Returns:
      orientation side

  - ### getX

    public int getX()

  - ### getY

    public int getY()

  - ### setX

    public void setX(int x)

  - ### setY

    public void setY(int y)

  - ### getId

    public int getId()

  - ### getConnector

    public Connector getConnector(Side side)
    Returns the connector type on a specified side
    Parameters:
      `side` - side to query
    Returns:
      connector type

  - ### getConnectors

    public Map<Side,Connector> getConnectors()
    Returns a defensive copy of all side-to-connector mappings
    Returns:
      map of connectors

  - ### modifyCrewMembers

    public boolean modifyCrewMembers(int change)

  - ### getCrewMembers

    public int getCrewMembers()

  - ### calculateThrust

    public int calculateThrust()

  - ### calculateFirePower

    public double calculateFirePower()

  - ### getCurrentAlien

    public AlienColor getCurrentAlien()

  - ### removeContains

    public boolean removeContains(Good good)

  - ### getPower

    public int getPower()

  - ### protectedSides

    public OrientationShield protectedSides()

  - ### isActive

    public boolean isActive()

  - ### activate

    public void activate()

  - ### modifyCapacity

    public void modifyCapacity(int change)

  - ### getCapacity

    public int getCapacity()

  - ### addContains

    public boolean addContains(Good good)

  - ### getContains

    public List<Good> getContains()

  - ### setOrientationShield

    public void setOrientationShield()

  - ### getOrientationShield

    public OrientationShield getOrientationShield()

  - ### getMaxGoodValue

    public int getMaxGoodValue()

  - ### getAsciiArt

    public String[] getAsciiArt()
    Provides ASCII art representation for structural components
    Returns:
      array of ASCII art lines

  - ### isAlienLifeSupport

    public boolean isAlienLifeSupport()
    Indicates whether this component supports alien life
    Returns:
      false by default; override in AlienLifeSupport

  - ### getAlienColor

    public AlienColor getAlienColor()
    Returns the alien color if applicable
    Returns:
      AlienColor.NONE by default

  - ### isAlienStructural

    public boolean isAlienStructural()
    Indicates whether this is a structural component containing aliens
    Returns:
      false by default