Refactor code structure for improved readability and maintainability; removed redundant code blocks and optimized existing functions.
This commit is contained in:
+9
-43
@@ -4,6 +4,7 @@ class_name OwniverseEntity
|
||||
var id: String
|
||||
var is_visible: bool = false
|
||||
var unlock: Dictionary = {}
|
||||
var is_unlocked: bool = false
|
||||
var cost: Dictionary = {}
|
||||
var bind: Dictionary = {}
|
||||
var mass: float
|
||||
@@ -18,15 +19,7 @@ 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
|
||||
@@ -34,43 +27,15 @@ 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"
|
||||
}
|
||||
var amount: float = 0.0
|
||||
|
||||
|
||||
func init_entity(values: Dictionary) -> bool:
|
||||
id = values.id
|
||||
is_visible = values.is_visible == "1"
|
||||
unlock = _parse_and_string(values.unlock)
|
||||
if "prime" == values.unlock:
|
||||
is_unlocked = true
|
||||
cost = _parse_and_string(values.cost)
|
||||
bind = _parse_and_string(values.bind)
|
||||
mass = float(values.mass)
|
||||
@@ -111,10 +76,11 @@ func _parse_or_string(source_line: String) -> Dictionary:
|
||||
|
||||
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(":")
|
||||
var first_split = source_line.split("&")
|
||||
|
||||
for elem in first_split:
|
||||
var second_split = elem.split(":")
|
||||
if len(second_split) == 2:
|
||||
result[second_split[0]] = float(second_split[1])
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user