Files
owniverse/world/owniverse.gd
T

62 lines
1.4 KiB
GDScript
Raw Normal View History

2026-03-30 00:48:20 +03:00
extends Node
class_name Owniverse
var g_datetime: float = 0
var g_speed: int = 1
2026-04-05 20:15:07 +03:00
var g_speed_in_years = 1
var entities: Dictionary[String, OwniverseEntity] = {}
var items_to_update: Dictionary[String, float] = {}
var cumulative_amount: Dictionary[String, float] = {}
#region Production
func produce(item_id: String, amount: int) -> void:
if item_id == "S" or item_id == 'H':
entities[item_id].amount += 1
_process_enitity(item_id, amount)
func automated_production() -> void:
pass
# add to all lists
func _process_enitity(item_id: String, amount: int) -> void:
items_to_update[item_id] = entities[item_id].amount
func _count_cumulative(item_id: String, amount: int) -> void:
if cumulative_amount.has(item_id):
cumulative_amount[item_id] += amount
else:
cumulative_amount[item_id] = amount
#endregion
func init_enitities() -> void:
for entity_id in Global.OwniverseEntities:
var entity = OwniverseEntity.new()
entity.init_entity(Global.OwniverseEntities[entity_id])
entities[entity_id] = entity
2026-03-30 00:48:20 +03:00
func add_time_delta(delta) -> float:
2026-04-05 20:15:07 +03:00
var year_delta:float = delta * g_speed_in_years
# all ownivewrse activity should be called here
g_datetime += year_delta
2026-03-30 00:48:20 +03:00
return g_datetime
2026-04-05 20:15:07 +03:00
func change_speed(delta: int) -> int:
g_speed = clamp(g_speed + delta, 1, Global.SPEED_LIMIT)
g_speed_in_years = pow(10, g_speed-1)
return g_speed