-
Notifications
You must be signed in to change notification settings - Fork 2
Component
Abstract class
Extends: N/A
Implements: IBehavior
The simulator uses a component pattern to make the system easy to expand and debug. The component pattern breaks the behavior of entities/ objects in the simulation into individual units. Using generic functions, we can access these components and their individual fields/methods at any time. Components are critical to how the simulator operates; this repository comes with a special IntelliJ IDEA template to help you get started. Click here to follow along with an example of how to use the template to build your own behaviors using the component base class.
Accessibility | Type | Field Name | Description |
---|---|---|---|
protected | Entity | parent | The entity this component is attached to |
protected | boolean | enabled | When true, this object is active in the simulation framework and will respond to calls from the system |
Accessibility | Return Type | Method Name | Description |
---|---|---|---|
public | void | setParent | Attaches this component to a new entity |
public | void | removeSelf | Removes this component from the entity |
public | boolean | isEnabled | Check status of this component |
public | void | setEnabled | Enable or disable the component |
public | Component | getComponent | Returns a component of type specified |
public | void | changeFieldOnGUI | Method used by the GUI system to change specific fields in the class from GUI elements |
Accessibility | Type | Variable Name | Description |
---|---|---|---|
public | Component | onComponentChanged | alert GUI when a value has been changed |
Other methods inherited by IBehavior.
Components are simply added by calling the addComponent(Component c) method from the base entity. The component can be returned as any applicable type. getComponent(). To see a detailed description of how to work with components with code examples, click here.