Refactor item management and unlock logic; remove unused item update list and signal
This commit is contained in:
@@ -3,8 +3,6 @@ class_name Owniverse
|
||||
|
||||
#var state: State = State.new()
|
||||
|
||||
signal unlock_item(item_id: String)
|
||||
|
||||
var entities: Dictionary[String, OwniverseEntity] = {}
|
||||
var entity_groups: Dictionary[String, Array] = {}
|
||||
var entity_event_groups: Dictionary[String, Array] = {}
|
||||
@@ -65,15 +63,18 @@ func _add_time_delta(new_owniverse: Owniverse, delta: float):
|
||||
new_owniverse.state.year = floorf(new_owniverse.state.datetime)
|
||||
|
||||
|
||||
func produce_hs(entity_id: String, value: float) -> float:
|
||||
var _to_produce: float = floorf(value)
|
||||
_to_produce = min(_to_produce, state.energy)
|
||||
state.energy -= _to_produce
|
||||
state.amount[entity_id] += _to_produce
|
||||
stats.total_amount[entity_id] += _to_produce
|
||||
return _to_produce
|
||||
|
||||
|
||||
|
||||
|
||||
# ----------
|
||||
|
||||
func cycle(delta: float):
|
||||
var new_state:State = State.new()
|
||||
#new_state.evolute(state, delta, current_speed_in_years)
|
||||
|
||||
|
||||
# TODO review
|
||||
|
||||
|
||||
|
||||
#region auto production and evolution
|
||||
@@ -105,6 +106,15 @@ func _get_distribution(source: Dictionary) -> Dictionary:
|
||||
|
||||
#region Production
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----
|
||||
|
||||
|
||||
|
||||
func produce(item_id: String, amount: float) -> void:
|
||||
var _entity: OwniverseEntity = entities[item_id]
|
||||
|
||||
@@ -123,6 +133,9 @@ func produce(item_id: String, amount: float) -> void:
|
||||
#state.add(_entity, current_year, amount)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func automated_production(_delta: float) -> void:
|
||||
for entity_id in auto_production:
|
||||
var _entity = entities[entity_id]
|
||||
@@ -186,8 +199,9 @@ func load_data() -> bool:
|
||||
#entity_batches = game_data["entity_batches"]
|
||||
cumulative_amount = _game_data["cumulative_amount"]
|
||||
current_amount = _game_data["current_amount"]
|
||||
#state = _game_data["state"]
|
||||
#stats = _game_data["stats"]
|
||||
#print("loaded ", _game_data)
|
||||
state = _game_data["state"]
|
||||
stats = _game_data["stats"]
|
||||
|
||||
for item in current_amount:
|
||||
items_to_update[item] = current_amount[item]
|
||||
@@ -206,8 +220,7 @@ func save_data() -> void:
|
||||
|
||||
#game_data["entity_batches"] = entity_batches
|
||||
SaveManager.save_data("owniverse", "qwerty", _game_data)
|
||||
print("saved")
|
||||
#, _game_data)
|
||||
#print("saved ", _game_data)
|
||||
|
||||
|
||||
func init_enitities() -> Dictionary:
|
||||
|
||||
Reference in New Issue
Block a user