This class serves as the base for all swarm objects. SwarmItems are managed by a SwarmItemManager. A SwarmItem should be activated by its manager and killed through this class.
More...
List of all members.
Public Types |
| enum | STATE { Inactive,
Active
} |
| | An item can only be active or inactive. More...
|
Public Member Functions |
| virtual void | Initialize (SwarmItemManager swarmItemManager, int prefabIndex, bool debugEvents) |
| | Sets up an item upon creation.
|
| virtual void | OnSetParentTransform () |
| | This method is called by the manager after the item is moved to either the active or inactive list. It is often useful to modify an item's position, rotation, or scale here since these values will be set to Vector3.zero, Quaternion.Identity, and Vector3.one, respectively.
|
| virtual void | Kill () |
| | This is the method that should be called when an item is no longer needed. Killing will recycle the item to the manager's inactive list, not send it to the garbage collector.
|
| virtual void | PreDestroy () |
| | This is called before an object is destroyed by a prune event from the manager. You should call Destroy on any objects in your inherited class that need their memory freed using an overload of this method.
|
| virtual void | FrameUpdate () |
| | This method is called from the manager every frame.
|
Public Attributes |
| float | minimumLifeSpan = 0 |
| | sets the random length of time the item is to live (between minimum and maximum). zero or lower means the item will live until killed manually. if both minimum and maximum are identical, then the lifespan is fixed and not random.
|
| float | maximumLifeSpan = 0 |
Protected Member Functions |
| virtual void | OnStateChange () |
| | Method that is called if the state is changed. This can be used to further process an item when it is activated or deactivated.
|
Protected Attributes |
| STATE | _state |
| | the state of the item (inactive or active)
|
| SwarmItemManager | _swarmItemManager |
| | the item's parent manager
|
| Transform | _thisTransform |
| | cached transform for faster lookups
|
| int | _prefabIndex |
| | index of the manager's prefab for this item
|
| float | _lifeSpanLeft |
| | the amount of time left for the item to live
|
| bool | _debugEvents |
| | debug events that occur with this item (set in manager)
|
Properties |
| STATE | State [get, set] |
| | Sets the state of the item to inactive or active.
|
| Transform | ThisTransform [get] |
| | Accessor to the transform of this item.
|
| Vector3 | Position [get, set] |
| | The absolute position of an item in world space.
|
| int | PrefabIndex [get] |
| | The index of the manager's prefab.
|
Detailed Description
This class serves as the base for all swarm objects. SwarmItems are managed by a SwarmItemManager. A SwarmItem should be activated by its manager and killed through this class.
Member Enumeration Documentation
An item can only be active or inactive.
- Enumerator:
| Inactive |
Inactive means that the item is not visible and not processed. It will reside in the manager's inactive list.
|
| Active |
Active means the item will be visible and processed in frameupdate. It will reside in the manager's active list.
|
Member Function Documentation
| virtual void SwarmItem.FrameUpdate |
( |
| ) |
[virtual] |
This method is called from the manager every frame.
| virtual void SwarmItem.Initialize |
( |
SwarmItemManager |
swarmItemManager, |
|
|
int |
prefabIndex, |
|
|
bool |
debugEvents |
|
) |
| [virtual] |
Sets up an item upon creation.
- Parameters:
-
| swarmItemManager | The item's manager |
| prefabIndex | The index of the manager's prefab |
| virtual void SwarmItem.Kill |
( |
| ) |
[virtual] |
This is the method that should be called when an item is no longer needed. Killing will recycle the item to the manager's inactive list, not send it to the garbage collector.
| virtual void SwarmItem.OnSetParentTransform |
( |
| ) |
[virtual] |
This method is called by the manager after the item is moved to either the active or inactive list. It is often useful to modify an item's position, rotation, or scale here since these values will be set to Vector3.zero, Quaternion.Identity, and Vector3.one, respectively.
| virtual void SwarmItem.OnStateChange |
( |
| ) |
[protected, virtual] |
Method that is called if the state is changed. This can be used to further process an item when it is activated or deactivated.
| virtual void SwarmItem.PreDestroy |
( |
| ) |
[virtual] |
This is called before an object is destroyed by a prune event from the manager. You should call Destroy on any objects in your inherited class that need their memory freed using an overload of this method.
Member Data Documentation
debug events that occur with this item (set in manager)
the amount of time left for the item to live
index of the manager's prefab for this item
the state of the item (inactive or active)
the item's parent manager
cached transform for faster lookups
sets the random length of time the item is to live (between minimum and maximum). zero or lower means the item will live until killed manually. if both minimum and maximum are identical, then the lifespan is fixed and not random.
Property Documentation
Vector3 SwarmItem.Position [get, set] |
The absolute position of an item in world space.
int SwarmItem.PrefabIndex [get] |
The index of the manager's prefab.
STATE SwarmItem.State [get, set] |
Sets the state of the item to inactive or active.
Transform SwarmItem.ThisTransform [get] |
Accessor to the transform of this item.
The documentation for this class was generated from the following file: