42 lines
1.6 KiB
GDScript
42 lines
1.6 KiB
GDScript
extends Node2D
|
|
## Two lightweight exhaust plumes aligned with the lander's nozzles.
|
|
var source: Control
|
|
var nozzle_positions: Array[Vector2] = [Vector2(-30.5,32.0),Vector2(28.5,32.0)]
|
|
var _strength := 0.0
|
|
var _phase := 0.0
|
|
var _boost := false
|
|
|
|
func _process(delta: float) -> void:
|
|
if not is_instance_valid(source):
|
|
return
|
|
var active: bool = source.engine_thrust_active()
|
|
_boost = source._motion.boost_active and active
|
|
var target := 1.0 if active else 0.0
|
|
if _strength <= 0 and target == 0:
|
|
return
|
|
_phase += delta
|
|
_strength = move_toward(_strength,target,5.5*delta)
|
|
queue_redraw()
|
|
|
|
func _draw() -> void:
|
|
if _strength <= 0.01:
|
|
return
|
|
var outer := Color("ff5919") if _boost else Color("218de8")
|
|
var inner := Color("ffbe52") if _boost else Color("50e5ff")
|
|
var core := Color("fff2cb") if _boost else Color("ddfbff")
|
|
for index in nozzle_positions.size():
|
|
var mouth := nozzle_positions[index]
|
|
var flicker := 0.9 + 0.1*sin(_phase*31.0+index*1.7)
|
|
var length := (34.0 if _boost else 23.0)*_strength*flicker
|
|
draw_circle(mouth+Vector2(0,3),8.0*_strength,Color(outer,0.08*_strength))
|
|
draw_circle(mouth,4.5,Color(inner,0.32*_strength))
|
|
_plume(mouth,5.0,length,Color(outer,0.5*_strength))
|
|
_plume(mouth,3.1,length*0.78,Color(inner,0.8*_strength))
|
|
_plume(mouth,1.5,length*0.48,Color(core,0.95*_strength))
|
|
|
|
func _plume(mouth: Vector2, half_width: float, length: float, color: Color) -> void:
|
|
draw_colored_polygon(PackedVector2Array([
|
|
mouth+Vector2(-half_width,-2), mouth+Vector2(-half_width*0.7,length*0.35),
|
|
mouth+Vector2(0,length),mouth+Vector2(half_width*0.7,length*0.35),
|
|
mouth+Vector2(half_width,-2)]),color)
|