new ResourceGatherer()
- Source:
Methods
AddToPlayerCounter(type)
Parameters:
Name | Type | Description |
---|---|---|
type |
string | A generic resource type. |
- Source:
CanCarryMore()
Returns whether this unit can carry more of the given type of resource.
(This ignores whether the unit is actually able to gather that
resource type or not.)
- Source:
CanGather(target) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
target |
number | The entity ID of the target to check. |
- Source:
Returns:
- Whether we can gather from the target.
- Type
- boolean
CanReturnResource(target, checkCarriedResource) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
target |
number | The entity to check. |
checkCarriedResource |
boolean | Whether we need to check the resource we are carrying. |
- Source:
Returns:
- Whether we can return carried resources.
- Type
- boolean
CommitResources(target)
Transfer our carried resources to our owner immediately.
Only resources of the appropriate types will be transferred.
(This should typically be called after reaching a dropsite.)
Parameters:
Name | Type | Description |
---|---|---|
target |
number | The target entity ID to drop resources at. |
- Source:
DropResources()
Drop all currently-carried resources.
(Currently they just vanish after being dropped - we don't bother depositing
them onto the ground.)
- Source:
GetCarryingStatus()
Returns data about what resources the unit is currently carrying,
in the form [ {"type":"wood", "amount":7, "max":10} ]
- Source:
GetLastCarriedType()
Returns the exact resource type we last picked up, as long as
we're still carrying something similar enough, in the form
{ generic, specific }
- Source:
GetMainCarryingType()
Returns the generic type of one particular resource this unit is
currently carrying, or undefined if none.
- Source:
GetTargetGatherRate()
Compute the amount of resources collected per second from the target.
Returns 0 if resources cannot be collected (e.g. the target doesn't
exist, or is the wrong type).
- Source:
GetTaskedResourceType() → {string}
- Source:
Returns:
- A generic resource type if we were tasked to gather.
- Type
- string
GiveResources(resources)
Used to instantly give resources to unit
Parameters:
Name | Type | Description |
---|---|---|
resources |
The same structure as returned form GetCarryingStatus |
- Source:
IsCarryingAnythingExcept()
Returns whether this unit is carrying any resources of a type that is
not the requested type. (This is to support cases where the unit is
only meant to be able to carry one type at once.)
- Source:
IsTargetInRange(target) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
target |
number | The entity ID of the target to check. |
- Source:
Returns:
- Whether this entity is in range of its target.
- Type
- boolean
PerformGather()
Gather from our target entity.
- Source:
RemoveFromPlayerCounter(playerid)
Parameters:
Name | Type | Description |
---|---|---|
playerid |
number | Optionally a player ID. |
- Source:
StartGathering(target, callerIID) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
target |
number | The target to gather from. |
callerIID |
number | The IID to notify on specific events. |
- Source:
Returns:
- Whether we started gathering.
- Type
- boolean
StopGathering(reason)
Parameters:
Name | Type | Description |
---|---|---|
reason |
string | The reason why we stopped gathering used to notify the caller. |
- Source: