Class Component

java.lang.Object
com.csse3200.game.components.Component
Direct Known Subclasses:
AITaskComponent, BombShipAnimationController, Boss1AnimationController, Boss2AnimationController, BossProjectileAnimationController, BurnEffectProjectileAnimationController, CameraComponent, ColliderComponent, CombatStatsComponent, CostComponent, DeflectingComponent, DeleteOnMapEdgeComponent, DemonAnimationController, DodgingComponent, DragonKnightAnimationController, DroidAnimationController, DropComponent, EconTowerAnimationController, EffectsComponent, EngineerBulletsAnimationController, ExplosionAnimationController, FireTowerAnimationController, FireworkAnimationController, FireworksTowerAnimationController, FireWormAnimationController, GhostAnimationController, HumanAnimationController, IceBabyAnimationController, IncomeUpgradeComponent, InputComponent, InventoryComponent, MainGameActions, MainMenuActions, MobBossProjectAnimController, MobProjectileAnimationController, MobProjectileAnimationController, OnCollisionAnimationController, PatrickAnimationController, PauseMenuTimeStopComponent, PhysicsComponent, PhysicsMovementComponent, PierceProjectileAnimationController, PierceTowerAnimationController, PlayerActions, ProjectileAnimationController, RenderComponent, RicochetComponent, RicochetTowerAnimationController, SelfDestructOnHitComponent, SkeletonAnimationController, SnowBallProjectileAnimationController, SplitFireworksComponent, SplitMoblings, StunEffectProjectileAnimationController, StunTowerAnimationController, Terminal, TNTAnimationController, TNTDamageComponent, TouchAttackComponent, TowerAnimationController, TowerUpgraderComponent, UpgradableStatsComponent, WallTowerAnimationController, WaterQueenAnimationController, WaterSlimeAnimationController, WizardAnimationController, XenoAnimationController

public class Component extends Object
Core component class from which all components inherit. Contains logic for creating, updating, and disposing. Components can be attached to an entity to give it specific behaviour. It is unlikely that changes will need to be made here.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected Entity
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called when the entity is created and registered.
    void
    Called when the component is disposed.
    void
    Early update called once per frame of the game, before update().
    Get the entity to which this component belongs.
    void
    setEnabled(boolean enabled)
    Enable or disable the component.
    void
    setEntity(Entity entity)
    Set the entity to which this component belongs.
     
    final void
    Used to trigger the component to early-update itself.
    final void
    Used to trigger the component to update itself.
    void
    Called once per frame of the game, and should be used for most component logic.

    Methods inherited from class java.lang.Object

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

    • entity

      protected Entity entity
    • enabled

      protected boolean enabled
  • Constructor Details

    • Component

      public Component()
  • Method Details

    • create

      public void create()
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
    • earlyUpdate

      public void earlyUpdate()
      Early update called once per frame of the game, before update(). Use this only for logic that must run before other updates, such as physics. Not called if component is disabled.
    • update

      public void update()
      Called once per frame of the game, and should be used for most component logic. Not called if component is disabled.
    • dispose

      public void dispose()
      Called when the component is disposed. Dispose of any internal resources here.
    • setEntity

      public void setEntity(Entity entity)
      Set the entity to which this component belongs. This is called by the Entity, and should not be set manually.
      Parameters:
      entity - The entity to which the component is attached.
    • getEntity

      public Entity getEntity()
      Get the entity to which this component belongs.
      Returns:
      entity
    • setEnabled

      public void setEnabled(boolean enabled)
      Enable or disable the component. While disabled, a component does not run update() or earlyUpdate(). Other events inside the component may still fire. The component can still be disposed while disabled.
      Parameters:
      enabled - Should component be enabled
    • triggerUpdate

      public final void triggerUpdate()
      Used to trigger the component to update itself. This should not need to be called manually.
    • triggerEarlyUpdate

      public final void triggerEarlyUpdate()
      Used to trigger the component to early-update itself. This should not need to be called manually.
    • toString

      public String toString()
      Overrides:
      toString in class Object