Refactor: restructure world entities and evolution logic; remove unused files and improve batch processing
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
extends Node
|
||||
|
||||
class_name OwniverseEvolution
|
||||
|
||||
var batch_count: int = 40
|
||||
var batches: Dictionary[String, Array] = {}
|
||||
|
||||
var distribution: Dictionary[String, float] = {}
|
||||
|
||||
|
||||
func evolute():
|
||||
pass
|
||||
|
||||
func add_to_batch(enitity: OwniverseEntity, amount: float, year: float) -> void:
|
||||
var to_year: float = year + enitity.lifespan
|
||||
var _entity_batches: Array[OwniverseBatch] = batches[enitity.id]
|
||||
if _entity_batches.size() == 0 or _entity_batches[-1].to_year <= to_year:
|
||||
_entity_batches.append(OwniverseBatch.new(to_year, enitity.lifespan_cycle))
|
||||
|
||||
_entity_batches[-1].add(amount)
|
||||
|
||||
|
||||
func update_distribution(_distribute_by: Dictionary[String, float]) -> void:
|
||||
distribution = {}
|
||||
var _total: float = 0
|
||||
for id in _distribute_by:
|
||||
if _distribute_by[id] != 0:
|
||||
var _value: float = _distribute_by[id]
|
||||
_total += _value
|
||||
distribution[id] = _value
|
||||
|
||||
if _total == 0: return
|
||||
|
||||
for id in distribution:
|
||||
distribution[id] /= _total
|
||||
|
||||
Reference in New Issue
Block a user