99 lines
2.8 KiB
GDScript
99 lines
2.8 KiB
GDScript
extends Node
|
|
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
|
|
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 = {}
|
|
var planets: Dictionary = {}
|
|
var count_as: String
|
|
var group_as: String
|
|
var event_group: String
|
|
var space_bonus: float
|
|
var civ_bonus: float
|
|
var claim: String
|
|
|
|
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)
|
|
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 = {}
|
|
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
|
|
|
|
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
|