Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var turn_index = 0
- func _process(_delta: float) -> void:
- var refresh = false # whether we need to redraw, update light, and update chunks
- if not player.action is Actions.none: # if the player is going to do an action this frame, set refresh to true
- refresh = true
- if entities.is_empty(): # do nothing if there are no entities
- return
- if turn_index >= entities.size(): # wrap index
- turn_index = 0
- var entity = entities[turn_index] # select entity
- if not is_instance_valid(entity) or not entities.has(entity): # skip dead or invalid entities
- entities.erase(entity)
- return
- if entity.energy <= 0: # recharge and move to next entity
- entity.recharge()
- turn_index += 1
- return
- entity.turn()
- if refresh: # refresh
- redraw()
- update_light(player.position)
- update_chunks()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement