Class Component

java.lang.Object
com.deco2800.game.components.Component
Direct Known Subclasses:
AITaskComponent, AnimationTestingComponent, ArcherAnimationController, ArcherAnimationController, ArcherComponent, AtlantisGameAreaEventHandler, AttackListener, BaseComponent, BuilderAnimationController, BuilderComponent, BuildingActions, BuildingAnimationController, BuildingFixComponent, BuildingHealthManager, bulletHitShips, CameraComponent, CollectStatsComponent, ColliderComponent, CombatStatsComponent, damageAnimation, DialogueBoxActions, DirectionalBuildingAnimationController, DurationBarComponent, EndGameActions, EnemyAnimationController, EnemyDetectionComponent, EnemySignal, EntityDirectionComponent, FloodingGenerator, ForagerAnimationController, ForagerComponent, FriendlyComponent, GateCollider, GhostAnimationController, HealthAnimation, HopliteAnimationController, HopliteAnimationController, HopliteComponent, InputComponent, InventoryComponent, MainGameActions, MainMenuActions, MapComponent, MinerAnimationController, MinerComponent, PauseMenuActions, PhysicsComponent, PhysicsMovementComponent, PlayerActions, RenderComponent, ResourceCollectComponent, SelectableComponent, ShopUIFunctionalityComponent, SpearmanAnimationController, SpearmanAnimationController, SpearmanComponent, StoneAnimationController, StoneComponent, StoryActions, SwordsmanAnimationController, SwordsmanAnimationController, SwordsmanComponent, Terminal, TextureImageComponent, TextureScaler, TouchAttackComponent, TreeAnimationController, TreeComponent, TroopContainerComponent, TutorialActions, UnitSpawningComponent, UpdateBuildingDirection, WorkerInventoryComponent

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

      public Boolean isAnimationRenderComponent()
    • toString

      public String toString()
      Overrides:
      toString in class Object