mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 08:04:23 +00:00
Rename methods and improve Priority
This commit is contained in:
parent
32e00ede01
commit
f1871a02ae
1 changed files with 20 additions and 14 deletions
|
@ -16,36 +16,42 @@ signal priority_changed_no_args
|
||||||
@export var default_priority: int = 0
|
@export var default_priority: int = 0
|
||||||
@export var alternative_priority: int = 1
|
@export var alternative_priority: int = 1
|
||||||
|
|
||||||
var priority: int = 0
|
var priority: int = 0:
|
||||||
|
get:
|
||||||
|
return priority
|
||||||
## Set [field priority] to [field default_priority].
|
set(value):
|
||||||
func default() -> void:
|
|
||||||
set_priority(default_priority)
|
|
||||||
|
|
||||||
## Set [field priority] to [field alternative_priority]
|
|
||||||
func alternative() -> void:
|
|
||||||
set_priority(alternative_priority)
|
|
||||||
|
|
||||||
## Toggle [field priority] between [field default_priority] and [field alternative_priority].
|
|
||||||
func toggle_priority() -> void:
|
|
||||||
if priority == default_priority:
|
|
||||||
set_priority(alternative_priority)
|
|
||||||
else:
|
|
||||||
set_priority(default_priority)
|
|
||||||
|
|
||||||
## Set the [field priority] to a specific value.
|
|
||||||
func set_priority(value: int):
|
|
||||||
var old = priority
|
var old = priority
|
||||||
priority = value
|
priority = value
|
||||||
priority_changed.emit(priority, old)
|
priority_changed.emit(priority, old)
|
||||||
|
|
||||||
## Set the [field priority] to a specific value if the [param variant] is truthy, otherwise set it to a different value.
|
|
||||||
func set_priority_if_truthy(variant: Variant, truthy: int, falsy: int = 0):
|
## Set [field priority] to [field default_priority].
|
||||||
if variant:
|
func priority_default() -> void:
|
||||||
set_priority(truthy)
|
priority = default_priority
|
||||||
|
|
||||||
|
## Set [field priority] to [field alternative_priority]
|
||||||
|
func priority_alternative() -> void:
|
||||||
|
priority = alternative_priority
|
||||||
|
|
||||||
|
## Toggle [field priority] between [field default_priority] and [field alternative_priority].
|
||||||
|
func priority_toggle() -> void:
|
||||||
|
if priority == default_priority:
|
||||||
|
priority = alternative_priority
|
||||||
else:
|
else:
|
||||||
set_priority(falsy)
|
priority = default_priority
|
||||||
|
|
||||||
|
## Set the [field priority] to a specific value.
|
||||||
|
func priority_set(value: int):
|
||||||
|
priority = value
|
||||||
|
|
||||||
|
## Set the [field priority] to a specific value if the [param variant] is truthy, otherwise set it to a different value.
|
||||||
|
##
|
||||||
|
## Defaults to using [field alternative_priority] for truthy, and [field default_priority] for falsy
|
||||||
|
func priority_conditional(variant: Variant, truthy: int = alternative_priority, falsy: int = default_priority):
|
||||||
|
if variant:
|
||||||
|
priority = truthy
|
||||||
|
else:
|
||||||
|
priority = falsy
|
||||||
|
|
||||||
## Get the node to which the [field priority] of this one applies to.
|
## Get the node to which the [field priority] of this one applies to.
|
||||||
func get_ref() -> Node:
|
func get_ref() -> Node:
|
||||||
|
|
Loading…
Reference in a new issue