22 lines
463 B
GDScript
22 lines
463 B
GDScript
extends Resource
|
|
|
|
class_name FieldEmission
|
|
|
|
enum Falloff {
|
|
Linear,
|
|
Flat
|
|
}
|
|
|
|
@export var field: Grid.Field
|
|
@export var amount: int = 10
|
|
@export var range: float = 3
|
|
@export var falloff: Falloff = Falloff.Linear
|
|
|
|
func get_field_value_for_distance(distance: float) -> int:
|
|
if distance == 0: return 0
|
|
match falloff:
|
|
Falloff.Linear:
|
|
return max(0, floor(remap(distance, 0, range, amount, 1)))
|
|
Falloff.Flat: return amount if distance <= range else 0
|
|
return 0
|