Class ConeLightComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.ConeLightComponent
All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable

public class ConeLightComponent extends Component
  • Field Summary

    Fields inherited from class com.csse3200.game.components.Component

    enabled, entity
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a ConeLightComponent which can be attached to an entity to enable it to produce light.
    ConeLightComponent(float distance)
    Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
    ConeLightComponent(float distance, com.badlogic.gdx.graphics.Color color)
    Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
    ConeLightComponent(float distance, com.badlogic.gdx.graphics.Color color, float directionDegree)
    Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
    ConeLightComponent(float distance, com.badlogic.gdx.graphics.Color color, float directionDegree, float coneDegree)
    Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
    ConeLightComponent(com.badlogic.gdx.graphics.Color color)
    Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Creates the event listener for the light to enable it to be toggled on and off
    void
    Disposes of the light if the entity is disposed
    boolean
    Determines whether the light is currently on
    void
    setColor(com.badlogic.gdx.graphics.Color color)
    Sets the color of the light
    void
    setConeDegree(float coneDegree)
    Changes the cone degree of the light
    void
    setDirection(float direction)
    Changes the direction of the cone light
    void
    setDistance(float distance)
    Sets the distance/spread of the light
    void
    Toggles the light between an on and off state
    void
    Called every frame draw to ensure that the position of the light is the same as the entity
    void
    write(com.badlogic.gdx.utils.Json json)
    Writes to the json in order to store the lights state

    Methods inherited from class com.csse3200.game.components.Component

    earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ConeLightComponent

      public ConeLightComponent()
      Creates a ConeLightComponent which can be attached to an entity to enable it to produce light.
    • ConeLightComponent

      public ConeLightComponent(float distance)
      Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
      Parameters:
      distance - distance/spread of the light
    • ConeLightComponent

      public ConeLightComponent(com.badlogic.gdx.graphics.Color color)
      Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
      Parameters:
      color - color of the light being created
    • ConeLightComponent

      public ConeLightComponent(float distance, com.badlogic.gdx.graphics.Color color)
      Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
      Parameters:
      distance - distance/spread of the light
      color - color of the light being created
    • ConeLightComponent

      public ConeLightComponent(float distance, com.badlogic.gdx.graphics.Color color, float directionDegree)
      Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
      Parameters:
      distance - distance/spread of the light
      color - color of the light being created
      directionDegree - direction that the light is pointing in
    • ConeLightComponent

      public ConeLightComponent(float distance, com.badlogic.gdx.graphics.Color color, float directionDegree, float coneDegree)
      Creates an ConeLightComponent which can be attached to an entity to enable it to produce light.
      Parameters:
      distance - distance/spread of the light
      color - color of the light being created
      directionDegree - direction that the light is pointing in
      coneDegree - size of the cone in degrees
  • Method Details

    • create

      public void create()
      Creates the event listener for the light to enable it to be toggled on and off
      Overrides:
      create in class Component
    • setDistance

      public void setDistance(float distance)
      Sets the distance/spread of the light
      Parameters:
      distance - distance/spread of the light
    • setColor

      public void setColor(com.badlogic.gdx.graphics.Color color)
      Sets the color of the light
      Parameters:
      color - light color
    • toggleLight

      public void toggleLight()
      Toggles the light between an on and off state
    • getActive

      public boolean getActive()
      Determines whether the light is currently on
      Returns:
      state of the light (on/off)
    • setDirection

      public void setDirection(float direction)
      Changes the direction of the cone light
      Parameters:
      direction - direction of the light
    • setConeDegree

      public void setConeDegree(float coneDegree)
      Changes the cone degree of the light
      Parameters:
      coneDegree - cone degree of the light
    • update

      public void update()
      Called every frame draw to ensure that the position of the light is the same as the entity
      Overrides:
      update in class Component
    • dispose

      public void dispose()
      Disposes of the light if the entity is disposed
      Overrides:
      dispose in class Component
    • write

      public void write(com.badlogic.gdx.utils.Json json)
      Writes to the json in order to store the lights state
      Specified by:
      write in interface com.badlogic.gdx.utils.Json.Serializable
      Overrides:
      write in class Component