Add new entity and item definitions, refactor related code
- Introduced new CSV files for entities and items, defining various properties and characteristics. - Refactored the stage.gd script to handle item selection and descriptions instead of entities. - Updated item button script to reflect changes in item properties and signals. - Created a new entity.gd script to define the OwniverseEntity class with initialization and parsing methods. - Modified owniverse.gd to initialize entities from the new definitions. - Adjusted versioning in export presets and project files to reflect recent changes.
This commit is contained in:
+132
@@ -0,0 +1,132 @@
|
||||
extends Node
|
||||
class_name OwniverseEntity
|
||||
|
||||
var id: String
|
||||
var is_visible: bool = false
|
||||
var unlock: Dictionary = {}
|
||||
var cost: Dictionary = {}
|
||||
var bind: Dictionary = {}
|
||||
var mass: float
|
||||
var space: int
|
||||
var lifespan: int
|
||||
var auto: float
|
||||
var gamma: float
|
||||
var blast: int
|
||||
var life_product: Dictionary = {}
|
||||
var voids: int
|
||||
var output_or: Dictionary = {}
|
||||
var output_and: Dictionary = {}
|
||||
var destroy_level: int
|
||||
var degradation: Dictionary = {}
|
||||
#deg_mass: "",
|
||||
#deg_h: "",
|
||||
#He": "",
|
||||
#Met": "",
|
||||
var planets: Dictionary = {}
|
||||
#var habitable: "",
|
||||
#var rocky: "",
|
||||
#var gas giant: "",
|
||||
#var asteroids: "",
|
||||
var count_as: String
|
||||
var group_as: String
|
||||
var event_group: String
|
||||
var space_bonus: float
|
||||
var civ_bonus: float
|
||||
var claim: String
|
||||
|
||||
var SCD: Dictionary = {
|
||||
"id": "SCD",
|
||||
"is_visible": "1",
|
||||
"unlock": "Star:300",
|
||||
"cost": "",
|
||||
"bind": "Star:1000",
|
||||
"mass": "",
|
||||
"space": "",
|
||||
"lifespan": "10000000",
|
||||
"auto": "", "gamma": "",
|
||||
"blast": "",
|
||||
"life_product": "",
|
||||
"voids": "",
|
||||
"output": "",
|
||||
"destroy_level": "",
|
||||
"deg_mass": "",
|
||||
"H": "",
|
||||
"He": "",
|
||||
"Met": "",
|
||||
"planets": "",
|
||||
"habitable": "",
|
||||
"rocky": "",
|
||||
"gas giant": "",
|
||||
"asteroids": "",
|
||||
"count_as": "",
|
||||
"group_as": "SC",
|
||||
"event_group": "SC",
|
||||
"space_bonus": "0.1",
|
||||
"civ_bonus": "4",
|
||||
"claim": "C2.3"
|
||||
}
|
||||
|
||||
|
||||
func init_entity(values: Dictionary) -> bool:
|
||||
id = values.id
|
||||
is_visible = values.is_visible == "1"
|
||||
unlock = _parse_and_string(values.unlock)
|
||||
cost = _parse_and_string(values.cost)
|
||||
bind = _parse_and_string(values.bind)
|
||||
mass = float(values.mass)
|
||||
space = int(values.space)
|
||||
lifespan = int(values.lifespan)
|
||||
auto = float(values.auto)
|
||||
gamma = float(values.gamma)
|
||||
blast = int(values.blast)
|
||||
life_product = _parse_and_string(values.life_product)
|
||||
voids = int(values.voids)
|
||||
output_or = _parse_or_string(values.output)
|
||||
output_and = _parse_and_string(values.output)
|
||||
destroy_level = int(values.destroy_level)
|
||||
degradation = _parse_and_string(values.degradation)
|
||||
planets = _parse_planet_string(values.planets)
|
||||
count_as = values.count_as
|
||||
group_as = values.group_as
|
||||
event_group = values.event_group
|
||||
space_bonus = float(values.space_bonus)
|
||||
civ_bonus = float(values.civ_bonus)
|
||||
claim = values.claim
|
||||
|
||||
return true
|
||||
|
||||
|
||||
func _parse_or_string(source_line: String) -> Dictionary:
|
||||
var result = {}
|
||||
if source_line.contains("^"):
|
||||
var first_split = source_line.split("^")
|
||||
var second_split = first_split[1].split("%")
|
||||
var probability = float(second_split[1])
|
||||
result["chance"] = probability
|
||||
result["positive"] = second_split[0]
|
||||
result["negative"] = first_split[0]
|
||||
|
||||
return result
|
||||
|
||||
|
||||
func _parse_and_string(source_line: String) -> Dictionary:
|
||||
var result = {}
|
||||
if source_line.contains("&"):
|
||||
var first_split = source_line.split("&")
|
||||
for elem in first_split:
|
||||
var second_split = elem.split(":")
|
||||
result[second_split[0]] = float(second_split[1])
|
||||
|
||||
return result
|
||||
|
||||
func _parse_planet_string(source_line: String) -> Dictionary:
|
||||
var result = {}
|
||||
if source_line.contains("&"):
|
||||
var first_split = source_line.split("&")
|
||||
for elem in first_split:
|
||||
var second_split = elem.split(":")
|
||||
result[second_split[0]] = {}
|
||||
result[second_split[0]]["amount"] = int(second_split[1])
|
||||
result[second_split[0]]["chance"] = int(second_split[2])
|
||||
|
||||
return result
|
||||
@@ -0,0 +1 @@
|
||||
uid://tvj1grut2p4x
|
||||
+9
-1
@@ -4,7 +4,15 @@ class_name Owniverse
|
||||
var g_datetime: float = 0
|
||||
var g_speed: int = 1
|
||||
var g_speed_in_years = 1
|
||||
|
||||
|
||||
var g_entities: Dictionary[String, OwniverseEntity] = {}
|
||||
|
||||
func init_enitities() -> void:
|
||||
for entity_id in Global.OwniverseEntities:
|
||||
var entity = OwniverseEntity.new()
|
||||
entity.init_entity(Global.OwniverseEntities[entity_id])
|
||||
g_entities[entity_id] = entity
|
||||
|
||||
func add_time_delta(delta) -> float:
|
||||
var year_delta:float = delta * g_speed_in_years
|
||||
|
||||
|
||||
Reference in New Issue
Block a user