evolution
This commit is contained in:
@@ -21,8 +21,8 @@ var locked_entities: Array = []
|
||||
var cumulative_amount: Dictionary[String, float] = {}
|
||||
var current_amount: Dictionary[String, float] = {}
|
||||
|
||||
var batch_count: int = 40
|
||||
var entity_batches = {}
|
||||
#var batch_count: int = 40
|
||||
#var entity_batches = {}
|
||||
|
||||
|
||||
func cycle(year_delta: float) -> void:
|
||||
@@ -54,10 +54,6 @@ func _auto_production(year_delta: float) -> void:
|
||||
_count_amount(item, _cycle_production[item])
|
||||
|
||||
|
||||
func _entity_evolution(year_delta: float) -> void:
|
||||
print("evolution: ", year_delta)
|
||||
pass
|
||||
|
||||
func _get_distribution(source: Dictionary) -> Dictionary:
|
||||
var distribution: Dictionary = {}
|
||||
var total: float = 0
|
||||
@@ -74,20 +70,21 @@ func _get_distribution(source: Dictionary) -> Dictionary:
|
||||
#region Production
|
||||
|
||||
func produce(item_id: String, amount: float) -> void:
|
||||
var entity: OwniverseEntity = entities[item_id]
|
||||
var _entity: OwniverseEntity = entities[item_id]
|
||||
|
||||
var entity_transaction = {}
|
||||
|
||||
for elem in entity.cost:
|
||||
if current_amount[elem] < amount * entity.cost[elem]:
|
||||
for elem in _entity.cost:
|
||||
if current_amount[elem] < amount * _entity.cost[elem]:
|
||||
return
|
||||
if entity.cost[elem] == 0: continue
|
||||
if _entity.cost[elem] == 0: continue
|
||||
|
||||
entity_transaction[elem] = -amount * entity.cost[elem]
|
||||
entity_transaction[elem] = -amount * _entity.cost[elem]
|
||||
|
||||
for elem in entity_transaction:
|
||||
_process_enitity(elem, entity_transaction[elem])
|
||||
_process_enitity(item_id, amount)
|
||||
evolution.add(_entity, current_year, amount)
|
||||
|
||||
|
||||
func automated_production(_delta: float) -> void:
|
||||
@@ -164,12 +161,13 @@ func load_data() -> bool:
|
||||
if game_data == {}:
|
||||
return false
|
||||
|
||||
if !game_data.has_all(["cumulative_amount", "current_amount",
|
||||
"entity_batches", "year",
|
||||
if !game_data.has_all(["cumulative_amount", "current_amount"
|
||||
#, "entity_batches"
|
||||
, "year",
|
||||
]):
|
||||
return false
|
||||
|
||||
entity_batches = game_data["entity_batches"]
|
||||
#entity_batches = game_data["entity_batches"]
|
||||
cumulative_amount = game_data["cumulative_amount"]
|
||||
current_amount = game_data["current_amount"]
|
||||
current_year = game_data["year"]
|
||||
@@ -185,36 +183,42 @@ func save_data() -> void:
|
||||
game_data["year"] = current_year
|
||||
game_data["cumulative_amount"] = cumulative_amount
|
||||
game_data["current_amount"] = current_amount
|
||||
game_data["entity_batches"] = entity_batches
|
||||
#game_data["entity_batches"] = entity_batches
|
||||
SaveManager.save_data("owniverse", "qwerty", game_data)
|
||||
|
||||
|
||||
func init_enitities() -> void:
|
||||
for entity_id in Global.OwniverseEntities:
|
||||
var entity = OwniverseEntity.new(Global.OwniverseEntities[entity_id])
|
||||
entities[entity_id] = entity
|
||||
var _auto_production := []
|
||||
for _entity_id in Global.OwniverseEntities:
|
||||
var _entity = OwniverseEntity.new(Global.OwniverseEntities[_entity_id])
|
||||
entities[_entity_id] = _entity
|
||||
|
||||
current_amount[entity_id] = 0
|
||||
cumulative_amount[entity_id] = 0
|
||||
if entity.group_as != "":
|
||||
current_amount[entity.group_as] = 0
|
||||
cumulative_amount[entity.group_as] = 0
|
||||
current_amount[_entity_id] = 0
|
||||
cumulative_amount[_entity_id] = 0
|
||||
if _entity.group_as != "":
|
||||
current_amount[_entity.group_as] = 0
|
||||
cumulative_amount[_entity.group_as] = 0
|
||||
|
||||
if entity.unlock != {}:
|
||||
locked_entities.append(entity)
|
||||
if _entity.unlock != {}:
|
||||
locked_entities.append(_entity)
|
||||
|
||||
evolution.init_entity(_entity)
|
||||
|
||||
if entity.product_per_year_type != "":
|
||||
auto_production.append(entity)
|
||||
if _entity.product_per_year_type != "":
|
||||
auto_production.append(_entity)
|
||||
_auto_production.append(_entity.id)
|
||||
|
||||
# groups
|
||||
if entity.group_as != "":
|
||||
if !entity_groups.has(entity.group_as):
|
||||
entity_groups[entity.group_as] = []
|
||||
entity_groups[entity.group_as].append(entity_id)
|
||||
if _entity.group_as != "":
|
||||
if !entity_groups.has(_entity.group_as):
|
||||
entity_groups[_entity.group_as] = []
|
||||
entity_groups[_entity.group_as].append(_entity_id)
|
||||
|
||||
if entity.event_group != "":
|
||||
if !entity_event_groups.has(entity.event_group):
|
||||
entity_event_groups[entity.event_group] = []
|
||||
entity_event_groups[entity.event_group].append(entity_id)
|
||||
if _entity.event_group != "":
|
||||
if !entity_event_groups.has(_entity.event_group):
|
||||
entity_event_groups[_entity.event_group] = []
|
||||
entity_event_groups[_entity.event_group].append(_entity_id)
|
||||
|
||||
#evolution.init_batches(_auto_production)
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user