parts_logic.gd 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. extends FutariParticles
  2. onready var floor_l=get_node("../../../../scene/floor_anix/left_f")
  3. onready var mi=get_node("../MeshInstance/StaticBody")
  4. onready var self_obj=get_node("../")
  5. var last_pause=false
  6. var pause_c_state=false
  7. var local_time=0.0
  8. var idx=0
  9. var rand_state=0.0
  10. var isalive=true
  11. var full_time=180
  12. #logic same as for vertex shader
  13. func _ready():
  14. randomize()
  15. idx=self_obj.name.substr(3,2).to_int()
  16. local_time=idx
  17. self_obj.set_visible(true)
  18. rand_state=randf()
  19. self.emitting=false
  20. self_obj.translation=Vector3(17.5*(sin(2.0*PI*(local_time/48.0))),0,44+(4.0+8+8*sin(2.0*PI*(local_time/48.0))+14.0*smoothstep(full_time,0,local_time))*(idx%5))
  21. func hide_colliders():
  22. if(last_pause!=get_tree().paused):
  23. if(get_tree().paused):
  24. pause_c_state=mi.get_child(0).disabled
  25. hide_colliders_on_rc()
  26. else:
  27. for a in range(mi.get_child_count()):
  28. mi.get_child(a).set_disabled(pause_c_state)
  29. onready var pause_camera=get_node("../../../pause_camera")
  30. func unfree():
  31. #-7, 48
  32. if((pause_camera.dex)&&(isalive)):
  33. isalive=false
  34. hide_colliders_on_rc()
  35. if((self_obj.translation.z<-1)):
  36. hide_it()
  37. if((self_obj.translation.z<-7)):
  38. self_obj.translation=Vector3(17.5*sin(2.0*PI*(local_time/48.0)),0,44+(4.0+8+8*sin(2.0*PI*(local_time/48.0))+14.0*smoothstep(full_time,0,local_time))*(idx%5))
  39. rand_state=randf()
  40. isalive=true
  41. show_colliders_on_rc()
  42. hide_it()
  43. if((self_obj.translation.z>44)):
  44. isalive=true
  45. show_colliders_on_rc()
  46. hide_it()
  47. if((self_obj.translation.z<38)&&(self_obj.translation.z>-1)):
  48. show_it()
  49. func hide_colliders_on_rc():
  50. for a in range(mi.get_child_count()):
  51. mi.get_child(a).set_disabled(true)
  52. func show_colliders_on_rc():
  53. for a in range(mi.get_child_count()):
  54. mi.get_child(a).set_disabled(false)
  55. func show_it():
  56. #self_obj.set_visible(true)
  57. if(isalive):
  58. self.emitting=true
  59. if((!isalive)&&(pause_camera.dex)):
  60. if(pause_camera.dex_timer>3.0):
  61. self.emitting=false
  62. func hide_it():
  63. #self_obj.set_visible(false)
  64. self.emitting=false
  65. func move_n_(delta):
  66. if(!get_tree().paused):
  67. self_obj.translation.z+=-(0.8+1.5*smoothstep(0,full_time,local_time))*(01.0+2.0*rand_state)*delta
  68. func _process(delta):
  69. hide_colliders()
  70. unfree()
  71. move_n_(delta)
  72. if(!get_tree().paused):
  73. local_time+=delta
  74. last_pause=get_tree().paused
  75. if((self.get_speed_scale()<1.0)&&(!get_tree().paused)):
  76. self.set_speed_scale(floor_l.get_speed_scale())
  77. if((get_tree().paused)&&(self.get_speed_scale()>0.001)):
  78. self.set_speed_scale(floor_l.get_speed_scale())