Added get_process_percent()
This commit is contained in:
@@ -16,3 +16,7 @@ func shoot() -> void
|
|||||||
|
|
||||||
@abstract
|
@abstract
|
||||||
func reload() -> void
|
func reload() -> void
|
||||||
|
|
||||||
|
|
||||||
|
@abstract
|
||||||
|
func get_process_percent() -> int
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ func reload() -> void:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func get_process_percent() -> int:
|
||||||
|
return 100 - int(_heat * 100 / heat_capacity)
|
||||||
|
|
||||||
|
|
||||||
func _calculate_critical_heat() -> void:
|
func _calculate_critical_heat() -> void:
|
||||||
_critical_heat = heat_capacity - heat_per_shot
|
_critical_heat = heat_capacity - heat_per_shot
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ func reload() -> void:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func get_process_percent() -> int:
|
||||||
|
return 100 - int(_cooldown * 100 / _delay)
|
||||||
|
|
||||||
|
|
||||||
func _calculate_delay() -> void:
|
func _calculate_delay() -> void:
|
||||||
_delay = 60.0 / firerate
|
_delay = 60.0 / firerate
|
||||||
_delay_tenth = _delay / 10
|
_delay_tenth = _delay / 10
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ extends AbstractReloader
|
|||||||
|
|
||||||
var _bullets_in_magazine : int
|
var _bullets_in_magazine : int
|
||||||
var _reload_time_tenth : float
|
var _reload_time_tenth : float
|
||||||
var _cooldown : float
|
var _countdown : float
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@@ -24,9 +24,9 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if _cooldown > 0:
|
if _countdown > 0:
|
||||||
_cooldown -= delta
|
_countdown -= delta
|
||||||
if _cooldown <= 0:
|
if _countdown <= 0:
|
||||||
_bullets_in_magazine = magazine_size
|
_bullets_in_magazine = magazine_size
|
||||||
|
|
||||||
|
|
||||||
@@ -43,10 +43,13 @@ func shoot() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func reload() -> void:
|
func reload() -> void:
|
||||||
if _cooldown > 0 or _bullets_in_magazine == magazine_size: return
|
if _countdown > 0 or _bullets_in_magazine == magazine_size: return
|
||||||
print("reload")
|
|
||||||
var random_delay := _random.randf_range(-_reload_time_tenth, _reload_time_tenth)
|
var random_delay := _random.randf_range(-_reload_time_tenth, _reload_time_tenth)
|
||||||
_cooldown = reload_time + random_delay
|
_countdown = reload_time + random_delay
|
||||||
|
|
||||||
|
|
||||||
|
func get_process_percent() -> int:
|
||||||
|
return 100 - int(_countdown * 100 / reload_time)
|
||||||
|
|
||||||
|
|
||||||
func _calculate_bullets_in_magazine() -> void:
|
func _calculate_bullets_in_magazine() -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user