The Task Launcher component handles creating and managing tasks for both units and buildings.
Attach this component to a unit or a building in order to add tasks that can launched when the unit/building is selected.
Task Launcher Settings:
- Is Active: Enable to activate the task launcher and allow tasks to be launched.
- Code: Unique code for the task launcher to be recognized by custom events.
- Min Health: Minimum health value that the task holder (either the unit or the building) must have in order to launch a task from this task launcher.
- Max Tasks: The maximum amount of the tasks that the task launcher can have on the queue to be launched.
- Declined Task Audio: Audio clip played when a task can not be launched for any reason (insufficient resources, etc..).
To add a task, you can simply click the button “Add Task” which also displays the current task count. To navigate between tasks, you can use both the “<<” (go to previous task) or the “>>” (go to next task) buttons. The task ID that you are currently configuring will be displayed right under the navigation buttons. Right after the task settings, a “Remove Task” button will delete the displayed task when clicked.
General Task Settings:
The first tab on the toolbar provides a list of general settings that applied to all task types.
- Code: Unique code for this task to be recognized by custom events.
- Available by Default: Is this task available to launch by default or not? If this task should be only available once another task is completed, then disable this.
- Faction Types: If the task is faction type specific (only one type of faction can actually start this), then add the faction type asset files to this array. Else, leave this array empty.
- Allowed Type: Pick one of the following types:
- Unit Creation: produce units.
- Destroy: task holder self-destruction.
- Custom Task: will only call custom events.
- Upgrade: upgrade a unit/building.
- Lock Attack: lock/unlock attack types attached to the task launcher entity.
- Description: A short description for the task that will appear when the player’s mouse is over the task icon.
- Task Panel Category: When using categories in the task panel, this is the ID of the task panel that this task belongs to when it appears while selecting this task launcher’s holder and displaying its tasks. Task Panel categories allow to organize tasks based on a criteria that you can decide. For more information about UI task panel categories, check out the UI Manager.
- Icon: The icon that will appear in the task panel for this task.
- Reload Time: Duration before this task takes effect.
- Required Resources: Which resources and how much of these resources does the task need to be launched? Amount of resource types matches the size of the array in this field. For each element of this array, provide the name of the resource and the amount required.
- Missing-Requirements Data: How would the task’s icon look in case either resource requirements are not met or this is a unit creation task and the faction limits for the unit type have been already reached?
- Icon: If assigned, this icon is displayed instead of the original task’s icon, when requirements to launch the task are missing.
- Color: Only if the above ‘Icon‘ field is not assigned, this defines the color of the original icon of the task when requirements to launch the task are missing.
- Complete Resources: These resources are added to the task launcher’s faction when the task is complete.
- Use Mode: Pick one of the following:
- Multiple: Task can be launched multiple times.
- Once This Instance: Task can be launched once (then it’s unavailable) on this instance of the task launcher.
- Once All Instances: Task can be launched once (then it’s unavailable) on the same task launcher type on all instances.
- Update Tasks On Complete: Tasks to lock/unlock once this task is completed.
- Code: Code of the task to unlock or lock.
- Unlock: Enable to unlock the task, disable to lock it.
- Local Only: Enable to lock/unlock the task for all task launcher instances of the faction in the game or disable to update only tasks in this task launcher instance.
- Launch Audio: Audio clip played when the task is added to the queue.
- Complete Audio: Audio clip played when this task is completed.
- Cancel Audio: Audio clip played when this task is cancelled after being added to the queue.
Custom Task Settings:
The second tab of the toolbar provides a list of settings that are specific to the task type that has been chosen in the general task settings tab.
- Unit Creation Task:
- Prefabs: A list of the unit prefabs that can be created using this task. You can more than one prefab for a unit creation task and only one will be randomly chosen each time to be created. If you only want to create one unit type using this task then you can simply assign only one unit prefab into this field.
- Upgrade Prefab: Drag and drop the unit/building’s prefab that has the Upgrade component
- Upgrade Target ID: Since you can define multiple upgrade targets in a list in the Upgrade component, you’d have to input the index of the target that will be upgraded to using this task in this field.
- One Instance Upgrade: Enable this field if the upgrade source is the same as the task launcher in order to allow the task to only upgrade the task launcher entity instance.
- Lock Attack:
- Lock Attack Types: Each attack entity that’s attached to the task launcher entity, with a code in this list will be locked when the task is completed.
- Unlock Attack Types: Each attack entity that’s attached to the task launcher entity, with a code in this list will be unlocked when the task is completed.
- Switch Attack: Enable this option so you can enter an attack entity’s code in the Target Attack Type field that will be activated when the task is completed.
- Other Task Types: There are no custom settings for the rest of the task types.
In addition to the delegate events (which are called for tasks). You can trigger events for each task independently by using the event triggers below:
- Task Launch Event: Triggered when the task is launched.
- Task Complete Event: Triggered when the task is completed.
- Task Cancel Event: Triggered when the task is cancelled.