Upgrader
Overview
This component determines whether an entity (the "upgrader") can perform upgrades on a target entity (e.g., a structure or item). It enforces two conditions: the upgrader must support the target's upgrade type, and the entity performing the upgrade (doer) must carry the appropriate tag (<type>_upgradeuser).
Dependencies & Tags
The component itself does not add or remove tags on the host entity. However:
- It relies on the
upgradeablecomponent being present on the target entity (accessed viatarget.components.upgradeable.upgradetype). - It reads the
upgradeablecomponent’supgradetypeproperty. - It checks for the existence of a tag
<upgradetype>_upgradeuseron thedoerentity.
No explicit tag management is performed by this component’s constructor.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
upgradetype | string | UPGRADETYPES.DEFAULT | The type of upgrades this upgrader supports. Used to match against target upgrade types and check for user tags. |
upgradevalue | number | 1 | Represents the magnitude or level of upgrade power—currently unused in the provided code. |
Main Functions
CanUpgrade(target, doer)
- Description: Checks whether this upgrader can legally upgrade the given target entity. Enforces compatibility based on upgrade type and user permissions.
- Parameters:
target: The entity to be upgraded. Must have aupgradeablecomponent with a publicupgradetypeproperty.doer: The entity performing the upgrade action. Must have a tag matching<upgradetype>_upgradeuser(e.g.,"structure_upgrader"→"structure_upgradeuser").
Events & Listeners
None.