Advertisement
Guest User

Untitled

a guest
May 11th, 2025
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | Fixit | 0 0
  1. var turn_index = 0
  2.  
  3. func _process(_delta: float) -> void:
  4. var refresh = false # whether we need to redraw, update light, and update chunks
  5. if not player.action is Actions.none: # if the player is going to do an action this frame, set refresh to true
  6. refresh = true
  7. if entities.is_empty(): # do nothing if there are no entities
  8. return
  9. if turn_index >= entities.size(): # wrap index
  10. turn_index = 0
  11. var entity = entities[turn_index] # select entity
  12. if not is_instance_valid(entity) or not entities.has(entity): # skip dead or invalid entities
  13. entities.erase(entity)
  14. return
  15. if entity.energy <= 0: # recharge and move to next entity
  16. entity.recharge()
  17. turn_index += 1
  18. return
  19. entity.turn()
  20. if refresh: # refresh
  21. redraw()
  22. update_light(player.position)
  23. update_chunks()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement