Compare commits
38 Commits
15d8fa4f2c
...
config
| Author | SHA1 | Date | |
|---|---|---|---|
| c44936d1fe | |||
| 68c1345660 | |||
| dbf334c829 | |||
| f225c1330e | |||
| fba98c928f | |||
| 282ace4c11 | |||
| 1ea1cc59fb | |||
| 123c544423 | |||
| 10c5ad678f | |||
| 3716c2b734 | |||
| 5317f35198 | |||
| ed17664ef1 | |||
| 49f7129bd5 | |||
| 1641189b75 | |||
| 54a6056b77 | |||
| 69b35d2bfc | |||
| af96b95f61 | |||
| aad094f842 | |||
| 26857e8414 | |||
| 510e37c37b | |||
| 121cd5407f | |||
| 7c663e29a6 | |||
| c64d31fa46 | |||
| f097e9a25f | |||
| 37a70ea321 | |||
| 8dad554800 | |||
| 6b95619806 | |||
| 66cf9ae23a | |||
| ef17b0ce42 | |||
| eeaa309c08 | |||
| 7669245229 | |||
| 4e3e3ac715 | |||
| 9677133c54 | |||
| abc261c03a | |||
| 17e9913c98 | |||
| 900b5fdec1 | |||
| 3e19e44f24 | |||
| 42b51cc6f4 |
@@ -32,7 +32,6 @@ cost = 15
|
|||||||
player_placeable = true
|
player_placeable = true
|
||||||
construction_time_seconds = 1
|
construction_time_seconds = 1
|
||||||
surface_mask = [
|
surface_mask = [
|
||||||
"AA",
|
|
||||||
"A>",
|
"A>",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -42,8 +41,8 @@ cost = 20
|
|||||||
player_placeable = true
|
player_placeable = true
|
||||||
construction_time_seconds = 1
|
construction_time_seconds = 1
|
||||||
surface_mask = [
|
surface_mask = [
|
||||||
"AA ",
|
"AA",
|
||||||
"AA>",
|
" v",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[building]]
|
[[building]]
|
||||||
@@ -52,9 +51,8 @@ cost = 35
|
|||||||
player_placeable = true
|
player_placeable = true
|
||||||
construction_time_seconds = 1
|
construction_time_seconds = 1
|
||||||
surface_mask = [
|
surface_mask = [
|
||||||
"AAA ",
|
"AA ",
|
||||||
"AAA>",
|
"AA>",
|
||||||
"AAA ",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[building]]
|
[[building]]
|
||||||
|
|||||||
@@ -1,95 +1,260 @@
|
|||||||
[[module]]
|
# modules.toml
|
||||||
id = "armor_plate"
|
#
|
||||||
surface_mask = ["OO", "OO"]
|
# First real-content iteration: module ids and surface masks are the designed
|
||||||
materials = [{item = "iron_ingot", amount = 2}]
|
# content; stats, materials, and threat costs are placeholders until the
|
||||||
player_production_level = 1
|
# recipe and balancing passes.
|
||||||
production_time_seconds = 3
|
#
|
||||||
threat_cost = 2.0
|
# Surface mask footprint ladder — footprints gate which hulls can mount a
|
||||||
fill_color = "#808080"
|
# module, purely through geometry (see ships.toml for the matching hull
|
||||||
glyph = "A"
|
# grids):
|
||||||
|
#
|
||||||
|
# 1x1 laser_cannon_s, salvager, repair_tool fits every hull, incl. drones
|
||||||
|
# 1x2 maneuvering_thrusters, sensor_booster,
|
||||||
|
# armor_plates frigate and up
|
||||||
|
# 1x3 afterburner frigate and up (eats most of a frigate)
|
||||||
|
# L-shape weapon_stabilizer, weapon_primer,
|
||||||
|
# weapon_upgrade frigate and up
|
||||||
|
# 2x2 laser_cannon_m, drone_bay cruiser and up (no 2x2 area on s hulls)
|
||||||
|
# 3x3 laser_cannon_l battleship and up (no 3x3 area on m hulls)
|
||||||
|
# 2x6 drone_hangar carrier only
|
||||||
|
|
||||||
[module.health]
|
# -----------------------------------------------------------------------------
|
||||||
multiplied_hp_formula = "1.0 + 0.2 * x"
|
# Weapons
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "sensor_booster"
|
id = "laser_cannon_s"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["O"]
|
surface_mask = ["O"]
|
||||||
materials = [{item = "circuit_board", amount = 1}]
|
materials = [{item = "laser_cannon_s_module", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 2
|
production_time_seconds = 0.5
|
||||||
threat_cost = 1.0
|
|
||||||
fill_color = "#40A0FF"
|
|
||||||
glyph = "S"
|
|
||||||
|
|
||||||
[module.sensor]
|
|
||||||
added_sensor_range_formula = "2 + x"
|
|
||||||
|
|
||||||
[[module]]
|
|
||||||
id = "weapon_upgrade"
|
|
||||||
surface_mask = ["OO"]
|
|
||||||
materials = [{item = "iron_ingot", amount = 1}, {item = "circuit_board", amount = 1}]
|
|
||||||
player_production_level = 1
|
|
||||||
production_time_seconds = 4
|
|
||||||
threat_cost = 3.0
|
|
||||||
fill_color = "#FF4040"
|
|
||||||
glyph = "W"
|
|
||||||
|
|
||||||
[module.weapon]
|
|
||||||
multiplied_damage_formula = "1.0 + 0.15 * x"
|
|
||||||
|
|
||||||
[[module]]
|
|
||||||
id = "engine_booster"
|
|
||||||
surface_mask = ["O", "O"]
|
|
||||||
materials = [{item = "iron_ingot", amount = 2}]
|
|
||||||
player_production_level = 1
|
|
||||||
production_time_seconds = 3
|
|
||||||
threat_cost = 1.5
|
|
||||||
fill_color = "#40FF80"
|
|
||||||
glyph = "E"
|
|
||||||
|
|
||||||
[module.movement]
|
|
||||||
added_speed_formula = "0.5 * x"
|
|
||||||
|
|
||||||
[[module]]
|
|
||||||
id = "laser_cannon"
|
|
||||||
surface_mask = ["O"]
|
|
||||||
materials = [{item = "iron_ingot", amount = 1}]
|
|
||||||
player_production_level = 1
|
|
||||||
production_time_seconds = 5
|
|
||||||
threat_cost = 5.0
|
|
||||||
fill_color = "#FF8040"
|
fill_color = "#FF8040"
|
||||||
glyph = "L"
|
glyph = "Ls"
|
||||||
|
|
||||||
[module.weapon]
|
[module.weapon]
|
||||||
damage_formula = "2"
|
damage_formula = "2"
|
||||||
attack_range_formula = "5"
|
attack_range_m_formula = "50"
|
||||||
attack_rate_formula = "2.0"
|
attack_rate_hz_formula = "2.0"
|
||||||
|
|
||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "salvage_bay_module"
|
id = "laser_cannon_m"
|
||||||
surface_mask = ["OO"]
|
unlock_at_station_level = -1
|
||||||
materials = [{item = "iron_ingot", amount = 2}]
|
surface_mask = [
|
||||||
|
"OO",
|
||||||
|
"OO"]
|
||||||
|
materials = [{item = "laser_cannon_m_module", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 5
|
production_time_seconds = 2
|
||||||
threat_cost = 0.0
|
fill_color = "#FF8040"
|
||||||
|
glyph = "Lm"
|
||||||
|
|
||||||
|
[module.weapon]
|
||||||
|
damage_formula = "10"
|
||||||
|
attack_range_m_formula = "70"
|
||||||
|
attack_rate_hz_formula = "1.5"
|
||||||
|
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "laser_cannon_l"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = [
|
||||||
|
"OOO",
|
||||||
|
"OOO",
|
||||||
|
"OOO"]
|
||||||
|
materials = [{item = "laser_cannon_l_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 8
|
||||||
|
fill_color = "#FF8040"
|
||||||
|
glyph = "Ll"
|
||||||
|
|
||||||
|
[module.weapon]
|
||||||
|
damage_formula = "40"
|
||||||
|
attack_range_m_formula = "100"
|
||||||
|
attack_rate_hz_formula = "0.8"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Utility tools
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "salvager"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["O"]
|
||||||
|
materials = [{item = "salvager_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 2
|
||||||
fill_color = "#AACC44"
|
fill_color = "#AACC44"
|
||||||
glyph = "Sv"
|
glyph = "Sv"
|
||||||
|
|
||||||
[module.salvage]
|
[module.salvage]
|
||||||
collection_range_formula = "50"
|
collection_range_m_formula = "500"
|
||||||
cargo_capacity_formula = "10"
|
cargo_capacity_formula = "10"
|
||||||
collection_rate_formula = "0.5"
|
collection_rate_hz_formula = "0.5"
|
||||||
|
|
||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "repair_tool_module"
|
id = "repair_tool"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["O"]
|
surface_mask = ["O"]
|
||||||
materials = [{item = "circuit_board", amount = 2}]
|
materials = [{item = "repair_tool_module", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 5
|
production_time_seconds = 2
|
||||||
threat_cost = 0.0
|
|
||||||
fill_color = "#66CCFF"
|
fill_color = "#66CCFF"
|
||||||
glyph = "Rp"
|
glyph = "Rp"
|
||||||
|
|
||||||
[module.repair]
|
[module.repair]
|
||||||
repair_rate_formula = "5 + x"
|
repair_rate_hz_formula = "5 + x"
|
||||||
repair_range_formula = "80"
|
repair_range_m_formula = "800"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Propulsion
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "afterburner"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["OOO"]
|
||||||
|
materials = [{item = "afterburner_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 2
|
||||||
|
fill_color = "#40A0FF"
|
||||||
|
glyph = "Ab"
|
||||||
|
|
||||||
|
[module.movement]
|
||||||
|
multiplied_speed_mps_formula = "1.6"
|
||||||
|
added_main_acceleration_mpss_formula = "60"
|
||||||
|
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "maneuvering_thrusters"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["OO"]
|
||||||
|
materials = [{item = "maneuvering_thrusters_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 2
|
||||||
|
fill_color = "#40A0FF"
|
||||||
|
glyph = "Mt"
|
||||||
|
|
||||||
|
[module.movement]
|
||||||
|
multiplied_speed_mps_formula = "1.2"
|
||||||
|
added_maneuvering_acceleration_mpss_formula = "10"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Defense & sensors
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "armor_plates"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["OO"]
|
||||||
|
materials = [{item = "armor_plates_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 3
|
||||||
|
fill_color = "#808080"
|
||||||
|
glyph = "A"
|
||||||
|
|
||||||
|
[module.health]
|
||||||
|
added_hp_formula = "40"
|
||||||
|
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "sensor_booster"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["OO"]
|
||||||
|
materials = [{item = "sensor_booster_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 2
|
||||||
|
fill_color = "#40A0FF"
|
||||||
|
glyph = "S"
|
||||||
|
|
||||||
|
[module.sensor]
|
||||||
|
added_sensor_range_m_formula = "50"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Weapon modifiers
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "weapon_upgrade"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = [
|
||||||
|
"OO",
|
||||||
|
"OX",
|
||||||
|
]
|
||||||
|
materials = [{item = "weapon_upgrade_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 4
|
||||||
|
fill_color = "#FF4040"
|
||||||
|
glyph = "Wu"
|
||||||
|
|
||||||
|
[module.weapon]
|
||||||
|
multiplied_damage_formula = "1.2"
|
||||||
|
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "weapon_primer"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = [
|
||||||
|
"OO",
|
||||||
|
"OX",
|
||||||
|
]
|
||||||
|
materials = [{item = "weapon_primer_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 4
|
||||||
|
fill_color = "#FF4040"
|
||||||
|
glyph = "Wp"
|
||||||
|
|
||||||
|
[module.weapon]
|
||||||
|
multiplied_attack_rate_hz_formula = "1.2"
|
||||||
|
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "weapon_stabilizer"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = [
|
||||||
|
"OO",
|
||||||
|
"OX",
|
||||||
|
]
|
||||||
|
materials = [{item = "weapon_stabilizer_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 4
|
||||||
|
fill_color = "#FF4040"
|
||||||
|
glyph = "Ws"
|
||||||
|
|
||||||
|
[module.weapon]
|
||||||
|
multiplied_attack_range_m_formula = "1.5"
|
||||||
|
multiplied_attack_rate_hz_formula = "0.8"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Drone modules
|
||||||
|
#
|
||||||
|
# Footprint-only placeholders: the drone launching capability is not
|
||||||
|
# implemented yet, so these modules define no capability section.
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "drone_bay"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = [
|
||||||
|
"OO",
|
||||||
|
"OO"]
|
||||||
|
materials = [{item = "drone_bay_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 5
|
||||||
|
fill_color = "#CC66FF"
|
||||||
|
glyph = "Db"
|
||||||
|
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "drone_hangar"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = [
|
||||||
|
"OOOOOO",
|
||||||
|
"OOOOOO"]
|
||||||
|
materials = [{item = "drone_hangar_module", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 20
|
||||||
|
fill_color = "#9933CC"
|
||||||
|
glyph = "Dh"
|
||||||
|
|||||||
@@ -1,3 +1,29 @@
|
|||||||
|
# recipes.toml
|
||||||
|
#
|
||||||
|
# First real-content iteration of the production tree. Quantities and
|
||||||
|
# durations are a first guess; the balancing pass will tune them and assign
|
||||||
|
# real unlock_at_station_level values (everything is unlocked for now so the
|
||||||
|
# full tree is testable).
|
||||||
|
#
|
||||||
|
# Input chain per game phase — each phase adds exactly one new base input:
|
||||||
|
#
|
||||||
|
# early iron_ore + copper_ore -> ingots -> copper_wire, steel_plate,
|
||||||
|
# circuit_board
|
||||||
|
# mid + titanium_ore -> titanium_frame; assembler-made
|
||||||
|
# mechanical_parts, targeting_unit,
|
||||||
|
# drive_unit
|
||||||
|
# late + advanced_alloy -> reinforced_plating, capital_core.
|
||||||
|
# advanced_alloy CANNOT be mined; it only
|
||||||
|
# comes from reprocessing salvaged scrap,
|
||||||
|
# so capital production requires combat.
|
||||||
|
#
|
||||||
|
# Run tools/verify_recipes.py after editing to check that every consumed
|
||||||
|
# item has a producer and every item has a visuals.toml entry.
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Mining (tier 0)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[[recipe]]
|
[[recipe]]
|
||||||
id = "mine_iron_ore"
|
id = "mine_iron_ore"
|
||||||
building = "miner"
|
building = "miner"
|
||||||
@@ -12,6 +38,18 @@ inputs = []
|
|||||||
outputs = [{item = "copper_ore", amount = 1}]
|
outputs = [{item = "copper_ore", amount = 1}]
|
||||||
duration_seconds = 1.5
|
duration_seconds = 1.5
|
||||||
|
|
||||||
|
# Titanium is the midgame ore: mined three times slower than iron.
|
||||||
|
[[recipe]]
|
||||||
|
id = "mine_titanium_ore"
|
||||||
|
building = "miner"
|
||||||
|
inputs = []
|
||||||
|
outputs = [{item = "titanium_ore", amount = 1}]
|
||||||
|
duration_seconds = 3.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Smelting (tier 1)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[[recipe]]
|
[[recipe]]
|
||||||
id = "iron_ingot"
|
id = "iron_ingot"
|
||||||
building = "smelter"
|
building = "smelter"
|
||||||
@@ -27,19 +65,18 @@ outputs = [{item = "copper_ingot", amount = 1}]
|
|||||||
duration_seconds = 2.5
|
duration_seconds = 2.5
|
||||||
|
|
||||||
[[recipe]]
|
[[recipe]]
|
||||||
id = "circuit_board"
|
id = "titanium_ingot"
|
||||||
building = "assembler"
|
building = "smelter"
|
||||||
inputs = [{item = "iron_ingot", amount = 3}, {item = "copper_ingot", amount = 2}]
|
inputs = [{item = "titanium_ore", amount = 3}]
|
||||||
outputs = [{item = "circuit_board", amount = 1}]
|
outputs = [{item = "titanium_ingot", amount = 1}]
|
||||||
duration_seconds = 5.0
|
|
||||||
|
|
||||||
[[recipe]]
|
|
||||||
id = "building_blocks"
|
|
||||||
building = "assembler"
|
|
||||||
inputs = [{item = "iron_ingot", amount = 4}]
|
|
||||||
outputs = [{item = "building_block", amount = 10}]
|
|
||||||
duration_seconds = 4.0
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Reprocessing
|
||||||
|
#
|
||||||
|
# The only source of advanced_alloy: salvaged scrap from destroyed ships.
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[[recipe]]
|
[[recipe]]
|
||||||
id = "reprocessing_cycle"
|
id = "reprocessing_cycle"
|
||||||
building = "reprocessing_plant"
|
building = "reprocessing_plant"
|
||||||
@@ -49,15 +86,354 @@ duration_seconds = 3.0
|
|||||||
[[recipe.outputs]]
|
[[recipe.outputs]]
|
||||||
item = "iron_ingot"
|
item = "iron_ingot"
|
||||||
amount = 2
|
amount = 2
|
||||||
probability = 0.6
|
probability = 0.45
|
||||||
|
|
||||||
[[recipe.outputs]]
|
[[recipe.outputs]]
|
||||||
item = "circuit_board"
|
item = "copper_ingot"
|
||||||
amount = 1
|
amount = 1
|
||||||
probability = 0.3
|
probability = 0.25
|
||||||
|
|
||||||
|
[[recipe.outputs]]
|
||||||
|
item = "titanium_ingot"
|
||||||
|
amount = 1
|
||||||
|
probability = 0.15
|
||||||
|
|
||||||
[[recipe.outputs]]
|
[[recipe.outputs]]
|
||||||
item = "advanced_alloy"
|
item = "advanced_alloy"
|
||||||
amount = 1
|
amount = 1
|
||||||
probability = 0.1
|
probability = 0.15
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Basic components (tier 2, early game)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "copper_wire"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "copper_ingot", amount = 1}]
|
||||||
|
outputs = [{item = "copper_wire", amount = 2}]
|
||||||
|
duration_seconds = 1.5
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "steel_plate"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "iron_ingot", amount = 2}]
|
||||||
|
outputs = [{item = "steel_plate", amount = 1}]
|
||||||
|
duration_seconds = 2.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "circuit_board"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "iron_ingot", amount = 1}, {item = "copper_wire", amount = 2}]
|
||||||
|
outputs = [{item = "circuit_board", amount = 1}]
|
||||||
|
duration_seconds = 2.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "building_blocks"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "iron_ingot", amount = 4}]
|
||||||
|
outputs = [{item = "building_block", amount = 10}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Advanced components (tier 3, midgame)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "mechanical_parts"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "steel_plate", amount = 1}, {item = "iron_ingot", amount = 1}]
|
||||||
|
outputs = [{item = "mechanical_parts", amount = 2}]
|
||||||
|
duration_seconds = 2.5
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "targeting_unit"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "circuit_board", amount = 2}, {item = "copper_wire", amount = 1}]
|
||||||
|
outputs = [{item = "targeting_unit", amount = 1}]
|
||||||
|
duration_seconds = 3.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "drive_unit"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "steel_plate", amount = 1},
|
||||||
|
{item = "mechanical_parts", amount = 1},
|
||||||
|
{item = "circuit_board", amount = 1},
|
||||||
|
]
|
||||||
|
outputs = [{item = "drive_unit", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "titanium_frame"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "titanium_ingot", amount = 2}, {item = "steel_plate", amount = 1}]
|
||||||
|
outputs = [{item = "titanium_frame", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Capital components (tier 4, lategame — gated on advanced_alloy)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "reinforced_plating"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "steel_plate", amount = 2}, {item = "advanced_alloy", amount = 1}]
|
||||||
|
outputs = [{item = "reinforced_plating", amount = 1}]
|
||||||
|
duration_seconds = 5.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "capital_core"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "targeting_unit", amount = 1},
|
||||||
|
{item = "drive_unit", amount = 1},
|
||||||
|
{item = "advanced_alloy", amount = 2},
|
||||||
|
]
|
||||||
|
outputs = [{item = "capital_core", amount = 1}]
|
||||||
|
duration_seconds = 8.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Module items — early game
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "laser_cannon_s_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "iron_ingot", amount = 2}, {item = "circuit_board", amount = 1}]
|
||||||
|
outputs = [{item = "laser_cannon_s_module", amount = 1}]
|
||||||
|
duration_seconds = 3.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "salvager_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "steel_plate", amount = 1}, {item = "circuit_board", amount = 1}]
|
||||||
|
outputs = [{item = "salvager_module", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "repair_tool_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "circuit_board", amount = 2}, {item = "copper_wire", amount = 1}]
|
||||||
|
outputs = [{item = "repair_tool_module", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "armor_plates_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "steel_plate", amount = 2}]
|
||||||
|
outputs = [{item = "armor_plates_module", amount = 1}]
|
||||||
|
duration_seconds = 3.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "sensor_booster_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "circuit_board", amount = 1}, {item = "copper_wire", amount = 2}]
|
||||||
|
outputs = [{item = "sensor_booster_module", amount = 1}]
|
||||||
|
duration_seconds = 3.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "maneuvering_thrusters_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "mechanical_parts", amount = 1}, {item = "copper_wire", amount = 1}]
|
||||||
|
outputs = [{item = "maneuvering_thrusters_module", amount = 1}]
|
||||||
|
duration_seconds = 3.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Module items — midgame
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "afterburner_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "drive_unit", amount = 1}, {item = "steel_plate", amount = 1}]
|
||||||
|
outputs = [{item = "afterburner_module", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "weapon_upgrade_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "targeting_unit", amount = 1}, {item = "steel_plate", amount = 1}]
|
||||||
|
outputs = [{item = "weapon_upgrade_module", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "weapon_primer_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "targeting_unit", amount = 1}, {item = "copper_wire", amount = 2}]
|
||||||
|
outputs = [{item = "weapon_primer_module", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "weapon_stabilizer_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "targeting_unit", amount = 1}, {item = "mechanical_parts", amount = 1}]
|
||||||
|
outputs = [{item = "weapon_stabilizer_module", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "laser_cannon_m_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "targeting_unit", amount = 1}, {item = "titanium_frame", amount = 1}]
|
||||||
|
outputs = [{item = "laser_cannon_m_module", amount = 1}]
|
||||||
|
duration_seconds = 6.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "drone_bay_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "titanium_frame", amount = 1},
|
||||||
|
{item = "mechanical_parts", amount = 1},
|
||||||
|
{item = "circuit_board", amount = 1},
|
||||||
|
]
|
||||||
|
outputs = [{item = "drone_bay_module", amount = 1}]
|
||||||
|
duration_seconds = 6.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Module items — lategame
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "laser_cannon_l_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "targeting_unit", amount = 2},
|
||||||
|
{item = "reinforced_plating", amount = 2},
|
||||||
|
{item = "titanium_frame", amount = 1},
|
||||||
|
]
|
||||||
|
outputs = [{item = "laser_cannon_l_module", amount = 1}]
|
||||||
|
duration_seconds = 12.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "drone_hangar_module"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "capital_core", amount = 1},
|
||||||
|
{item = "titanium_frame", amount = 2},
|
||||||
|
{item = "reinforced_plating", amount = 2},
|
||||||
|
]
|
||||||
|
outputs = [{item = "drone_hangar_module", amount = 1}]
|
||||||
|
duration_seconds = 20.0
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Ship hulls
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "drone_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [{item = "iron_ingot", amount = 5}, {item = "circuit_board", amount = 1}]
|
||||||
|
outputs = [{item = "drone_hull", amount = 1}]
|
||||||
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "frigate_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "steel_plate", amount = 3},
|
||||||
|
{item = "mechanical_parts", amount = 1},
|
||||||
|
{item = "circuit_board", amount = 1},
|
||||||
|
]
|
||||||
|
outputs = [{item = "frigate_hull", amount = 1}]
|
||||||
|
duration_seconds = 8.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "destroyer_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "steel_plate", amount = 5},
|
||||||
|
{item = "mechanical_parts", amount = 2},
|
||||||
|
{item = "circuit_board", amount = 1},
|
||||||
|
]
|
||||||
|
outputs = [{item = "destroyer_hull", amount = 1}]
|
||||||
|
duration_seconds = 10.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "cruiser_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "titanium_frame", amount = 2},
|
||||||
|
{item = "steel_plate", amount = 4},
|
||||||
|
{item = "drive_unit", amount = 1},
|
||||||
|
]
|
||||||
|
outputs = [{item = "cruiser_hull", amount = 1}]
|
||||||
|
duration_seconds = 15.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "battlecruiser_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "titanium_frame", amount = 3},
|
||||||
|
{item = "steel_plate", amount = 6},
|
||||||
|
{item = "drive_unit", amount = 1},
|
||||||
|
{item = "targeting_unit", amount = 1},
|
||||||
|
]
|
||||||
|
outputs = [{item = "battlecruiser_hull", amount = 1}]
|
||||||
|
duration_seconds = 20.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "battleship_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "titanium_frame", amount = 4},
|
||||||
|
{item = "reinforced_plating", amount = 2},
|
||||||
|
{item = "drive_unit", amount = 2},
|
||||||
|
]
|
||||||
|
outputs = [{item = "battleship_hull", amount = 1}]
|
||||||
|
duration_seconds = 30.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "dreadnought_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "capital_core", amount = 1},
|
||||||
|
{item = "titanium_frame", amount = 6},
|
||||||
|
{item = "reinforced_plating", amount = 4},
|
||||||
|
{item = "drive_unit", amount = 2},
|
||||||
|
]
|
||||||
|
outputs = [{item = "dreadnought_hull", amount = 1}]
|
||||||
|
duration_seconds = 60.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "carrier_hull"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
building = "assembler"
|
||||||
|
inputs = [
|
||||||
|
{item = "capital_core", amount = 1},
|
||||||
|
{item = "titanium_frame", amount = 5},
|
||||||
|
{item = "reinforced_plating", amount = 3},
|
||||||
|
{item = "drive_unit", amount = 2},
|
||||||
|
]
|
||||||
|
outputs = [{item = "carrier_hull", amount = 1}]
|
||||||
|
duration_seconds = 60.0
|
||||||
|
|||||||
@@ -1,154 +1,295 @@
|
|||||||
|
# ships.toml
|
||||||
|
#
|
||||||
|
# First real-content iteration: ship ids and layout grids are the designed
|
||||||
|
# content; stats, materials, and production times are placeholders until the
|
||||||
|
# recipe and balancing passes.
|
||||||
|
#
|
||||||
|
# Size classes:
|
||||||
|
# xs drone 1 cell — exactly one 1x1 module
|
||||||
|
# s frigate, destroyer no 2x2 area anywhere: only 1x1/1x2/1x3/L modules fit
|
||||||
|
# m cruiser, battlecruiser 2x2 areas (m guns, drone bays) but no 3x3 area
|
||||||
|
# l battleship four m guns, or exactly one 3x3 l gun at heavy
|
||||||
|
# opportunity cost
|
||||||
|
# xl dreadnought, carrier dreadnought fits three l guns but no drone
|
||||||
|
# hangar; carrier fits one drone hangar (2x6)
|
||||||
|
# but no l gun (its deck rows are broken up
|
||||||
|
# by elevator shafts)
|
||||||
|
|
||||||
[[ship]]
|
[[ship]]
|
||||||
id = "fighter"
|
id = "drone"
|
||||||
available_from_start = true
|
unlock_at_station_level = -1
|
||||||
layout = ["XOX", "OOO", "XOX"]
|
layout = ["O"]
|
||||||
default_modules = [{type = "laser_cannon", x = 1, y = 1, rotation = "east"}]
|
default_modules = [{type = "laser_cannon_s", x = 0, y = 0, rotation = "east"}]
|
||||||
|
|
||||||
[ship.schematic]
|
[ship.schematic]
|
||||||
materials = [{item = "iron_ingot", amount = 3}, {item = "circuit_board", amount = 1}]
|
materials = [{item = "iron_ore", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 10
|
production_time_seconds = 5
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "10"
|
|
||||||
|
|
||||||
[ship.health]
|
[ship.health]
|
||||||
hp_formula = "3"
|
hp_formula = "3"
|
||||||
|
|
||||||
[ship.movement]
|
[ship.movement]
|
||||||
speed_formula = "4"
|
speed_mps_formula = "40"
|
||||||
main_acceleration_formula = "8"
|
main_acceleration_mpss_formula = "80"
|
||||||
maneuvering_acceleration_formula = "4"
|
maneuvering_acceleration_mpss_formula = "40"
|
||||||
angular_acceleration_formula = "12.56"
|
angular_acceleration_radpss_formula = "12.56"
|
||||||
max_rotation_speed_formula = "6.28"
|
max_rotation_speed_radps_formula = "6.28"
|
||||||
|
|
||||||
[ship.sensor]
|
[ship.sensor]
|
||||||
sensor_range_formula = "15"
|
sensor_range_m_formula = "150"
|
||||||
|
|
||||||
[ship.loot]
|
[ship.loot]
|
||||||
scrap_drop = 2
|
scrap_drop = 2
|
||||||
|
|
||||||
|
|
||||||
|
# Frigate — 5 cells in a plus shape. Holds a couple of small guns plus at
|
||||||
|
# most one 1x2 support (every 1x2 placement crosses the center cell), or one
|
||||||
|
# L-shaped weapon modifier, or an afterburner spanning the full center line.
|
||||||
[[ship]]
|
[[ship]]
|
||||||
id = "sniper"
|
id = "frigate"
|
||||||
available_from_start = true
|
unlock_at_station_level = -1
|
||||||
layout = ["XOOX", "OOOO", "XOOX"]
|
layout = [
|
||||||
default_modules = [{type = "laser_cannon", x = 1, y = 1, rotation = "east"}]
|
"XOX",
|
||||||
|
"OOO",
|
||||||
|
"XOX",
|
||||||
|
]
|
||||||
|
|
||||||
[ship.schematic]
|
[ship.schematic]
|
||||||
materials = [{item = "iron_ingot", amount = 3}, {item = "circuit_board", amount = 1}]
|
materials = [{item = "frigate_hull", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 10
|
production_time_seconds = 10
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "10"
|
|
||||||
|
|
||||||
[ship.health]
|
[ship.health]
|
||||||
hp_formula = "8"
|
hp_formula = "30"
|
||||||
|
|
||||||
[ship.movement]
|
[ship.movement]
|
||||||
speed_formula = "1"
|
speed_mps_formula = "30"
|
||||||
main_acceleration_formula = "1.5"
|
main_acceleration_mpss_formula = "50"
|
||||||
maneuvering_acceleration_formula = "0.5"
|
maneuvering_acceleration_mpss_formula = "25"
|
||||||
angular_acceleration_formula = "9.42"
|
angular_acceleration_radpss_formula = "8"
|
||||||
max_rotation_speed_formula = "3.14"
|
max_rotation_speed_radps_formula = "4"
|
||||||
|
|
||||||
[ship.sensor]
|
[ship.sensor]
|
||||||
sensor_range_formula = "25"
|
sensor_range_m_formula = "200"
|
||||||
|
|
||||||
[ship.loot]
|
[ship.loot]
|
||||||
scrap_drop = 2
|
scrap_drop = 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Destroyer — 8 cells: a long gun deck with three turret bumps on top.
|
||||||
|
# Still no 2x2 area, so it packs more small guns than a frigate but can never
|
||||||
|
# mount medium hardware.
|
||||||
[[ship]]
|
[[ship]]
|
||||||
id = "gunship"
|
id = "destroyer"
|
||||||
available_from_start = true
|
unlock_at_station_level = -1
|
||||||
layout = ["XOOOX", "OOOOO", "OOOOO", "XOOOX"]
|
layout = [
|
||||||
default_modules = [{type = "laser_cannon", x = 1, y = 1, rotation = "east"}]
|
"OXOXO",
|
||||||
|
"OOOOO",
|
||||||
|
]
|
||||||
|
|
||||||
[ship.schematic]
|
[ship.schematic]
|
||||||
materials = [{item = "iron_ingot", amount = 3}, {item = "circuit_board", amount = 1}]
|
materials = [{item = "destroyer_hull", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 10
|
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "10"
|
|
||||||
|
|
||||||
[ship.health]
|
|
||||||
hp_formula = "12"
|
|
||||||
|
|
||||||
[ship.movement]
|
|
||||||
speed_formula = "1"
|
|
||||||
main_acceleration_formula = "1.5"
|
|
||||||
maneuvering_acceleration_formula = "0.5"
|
|
||||||
angular_acceleration_formula = "15.7"
|
|
||||||
max_rotation_speed_formula = "3.14"
|
|
||||||
|
|
||||||
[ship.sensor]
|
|
||||||
sensor_range_formula = "20"
|
|
||||||
|
|
||||||
[ship.loot]
|
|
||||||
scrap_drop = 2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[ship]]
|
|
||||||
id = "salvage_ship"
|
|
||||||
available_from_start = true
|
|
||||||
layout = ["OOO", "OOO"]
|
|
||||||
|
|
||||||
[ship.schematic]
|
|
||||||
materials = [{item = "iron_ingot", amount = 4}]
|
|
||||||
player_production_level = 3
|
|
||||||
production_time_seconds = 10
|
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "0"
|
|
||||||
|
|
||||||
[ship.health]
|
|
||||||
hp_formula = "40 + 4*x"
|
|
||||||
|
|
||||||
[ship.movement]
|
|
||||||
speed_formula = "110"
|
|
||||||
main_acceleration_formula = "220"
|
|
||||||
maneuvering_acceleration_formula = "110"
|
|
||||||
angular_acceleration_formula = "12.56"
|
|
||||||
max_rotation_speed_formula = "6.28"
|
|
||||||
|
|
||||||
[ship.sensor]
|
|
||||||
sensor_range_formula = "250"
|
|
||||||
|
|
||||||
[ship.loot]
|
|
||||||
scrap_drop = 2
|
|
||||||
|
|
||||||
|
|
||||||
[[ship]]
|
|
||||||
id = "repair_ship"
|
|
||||||
available_from_start = false
|
|
||||||
layout = ["XOX", "OOO", "XOX"]
|
|
||||||
|
|
||||||
[ship.schematic]
|
|
||||||
materials = [{item = "iron_ingot", amount = 4}, {item = "circuit_board", amount = 2}]
|
|
||||||
player_production_level = 3
|
|
||||||
production_time_seconds = 15
|
production_time_seconds = 15
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "0"
|
|
||||||
|
|
||||||
[ship.health]
|
[ship.health]
|
||||||
hp_formula = "60 + 5*x"
|
hp_formula = "50"
|
||||||
|
|
||||||
[ship.movement]
|
[ship.movement]
|
||||||
speed_formula = "130"
|
speed_mps_formula = "25"
|
||||||
main_acceleration_formula = "260"
|
main_acceleration_mpss_formula = "40"
|
||||||
maneuvering_acceleration_formula = "130"
|
maneuvering_acceleration_mpss_formula = "20"
|
||||||
angular_acceleration_formula = "12.56"
|
angular_acceleration_radpss_formula = "6"
|
||||||
max_rotation_speed_formula = "6.28"
|
max_rotation_speed_radps_formula = "3"
|
||||||
|
|
||||||
[ship.sensor]
|
[ship.sensor]
|
||||||
sensor_range_formula = "250"
|
sensor_range_m_formula = "220"
|
||||||
|
|
||||||
[ship.loot]
|
[ship.loot]
|
||||||
scrap_drop = 2
|
scrap_drop = 8
|
||||||
|
|
||||||
|
|
||||||
|
# Cruiser — 12 cells with notched corners. Fits at most two 2x2 m guns
|
||||||
|
# (stacked through the middle), leaving the four side cells for small
|
||||||
|
# supports; no 3x3 area exists for an l gun.
|
||||||
|
[[ship]]
|
||||||
|
id = "cruiser"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
layout = [
|
||||||
|
"XOOX",
|
||||||
|
"OOOO",
|
||||||
|
"OOOO",
|
||||||
|
"XOOX",
|
||||||
|
]
|
||||||
|
|
||||||
|
[ship.schematic]
|
||||||
|
materials = [{item = "cruiser_hull", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 25
|
||||||
|
|
||||||
|
[ship.health]
|
||||||
|
hp_formula = "120"
|
||||||
|
|
||||||
|
[ship.movement]
|
||||||
|
speed_mps_formula = "20"
|
||||||
|
main_acceleration_mpss_formula = "30"
|
||||||
|
maneuvering_acceleration_mpss_formula = "15"
|
||||||
|
angular_acceleration_radpss_formula = "4"
|
||||||
|
max_rotation_speed_radps_formula = "2"
|
||||||
|
|
||||||
|
[ship.sensor]
|
||||||
|
sensor_range_m_formula = "250"
|
||||||
|
|
||||||
|
[ship.loot]
|
||||||
|
scrap_drop = 15
|
||||||
|
|
||||||
|
|
||||||
|
# Battlecruiser — 16 cells: a wide bow split into two gun cheeks, tapering
|
||||||
|
# toward the stern. Fits three 2x2 m guns (two in the cheeks, one through
|
||||||
|
# the middle) with small support slots left over; the split bow and tapered
|
||||||
|
# stern leave no 3x3 area for an l gun and no 2x6 area for a drone hangar.
|
||||||
|
[[ship]]
|
||||||
|
id = "battlecruiser"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
layout = [
|
||||||
|
"OOXXOO",
|
||||||
|
"OOOOOO",
|
||||||
|
"XOOOOX",
|
||||||
|
"XXOOXX",
|
||||||
|
]
|
||||||
|
|
||||||
|
[ship.schematic]
|
||||||
|
materials = [{item = "battlecruiser_hull", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 35
|
||||||
|
|
||||||
|
[ship.health]
|
||||||
|
hp_formula = "180"
|
||||||
|
|
||||||
|
[ship.movement]
|
||||||
|
speed_mps_formula = "18"
|
||||||
|
main_acceleration_mpss_formula = "25"
|
||||||
|
maneuvering_acceleration_mpss_formula = "12"
|
||||||
|
angular_acceleration_radpss_formula = "3"
|
||||||
|
max_rotation_speed_radps_formula = "1.5"
|
||||||
|
|
||||||
|
[ship.sensor]
|
||||||
|
sensor_range_m_formula = "260"
|
||||||
|
|
||||||
|
[ship.loot]
|
||||||
|
scrap_drop = 20
|
||||||
|
|
||||||
|
|
||||||
|
# Battleship — 24 cells: a broadside hull with notched flanks on every other
|
||||||
|
# row. Fits four 2x2 m guns (two per gun deck) with the bow, stern, and flank
|
||||||
|
# cells left for supports. All 3x3 placements crowd the center columns, so at
|
||||||
|
# most ONE l gun fits — and mounting it blocks every m gun mount, leaving
|
||||||
|
# only narrow support strips. The notched rows are never adjacent-and-full,
|
||||||
|
# so no 2x6 drone hangar fits.
|
||||||
|
[[ship]]
|
||||||
|
id = "battleship"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
layout = [
|
||||||
|
"XOOOOX",
|
||||||
|
"OOOOOO",
|
||||||
|
"XOOOOX",
|
||||||
|
"OOOOOO",
|
||||||
|
"XOOOOX",
|
||||||
|
]
|
||||||
|
|
||||||
|
[ship.schematic]
|
||||||
|
materials = [{item = "battleship_hull", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 60
|
||||||
|
|
||||||
|
[ship.health]
|
||||||
|
hp_formula = "350"
|
||||||
|
|
||||||
|
[ship.movement]
|
||||||
|
speed_mps_formula = "14"
|
||||||
|
main_acceleration_mpss_formula = "18"
|
||||||
|
maneuvering_acceleration_mpss_formula = "8"
|
||||||
|
angular_acceleration_radpss_formula = "2"
|
||||||
|
max_rotation_speed_radps_formula = "1"
|
||||||
|
|
||||||
|
[ship.sensor]
|
||||||
|
sensor_range_m_formula = "280"
|
||||||
|
|
||||||
|
[ship.loot]
|
||||||
|
scrap_drop = 35
|
||||||
|
|
||||||
|
|
||||||
|
# Dreadnought — 36 cells: the main battery deck is split into three 3x3 gun
|
||||||
|
# slots by structural spacer columns, so exactly three l guns fit side by
|
||||||
|
# side (or m guns / supports in unused slots). The spacers cap every
|
||||||
|
# horizontal run at 5 cells, so the 2x6 drone hangar can never fit — carriers
|
||||||
|
# stay the only hangar hull. Bow and stern strips hold supports.
|
||||||
|
[[ship]]
|
||||||
|
id = "dreadnought"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
layout = [
|
||||||
|
"XXXOOOOOXXX",
|
||||||
|
"OOOXOOOXOOO",
|
||||||
|
"OOOXOOOXOOO",
|
||||||
|
"OOOXOOOXOOO",
|
||||||
|
"XXOOXXXOOXX",
|
||||||
|
]
|
||||||
|
|
||||||
|
[ship.schematic]
|
||||||
|
materials = [{item = "dreadnought_hull", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 120
|
||||||
|
|
||||||
|
[ship.health]
|
||||||
|
hp_formula = "800"
|
||||||
|
|
||||||
|
[ship.movement]
|
||||||
|
speed_mps_formula = "8"
|
||||||
|
main_acceleration_mpss_formula = "10"
|
||||||
|
maneuvering_acceleration_mpss_formula = "5"
|
||||||
|
angular_acceleration_radpss_formula = "1"
|
||||||
|
max_rotation_speed_radps_formula = "0.5"
|
||||||
|
|
||||||
|
[ship.sensor]
|
||||||
|
sensor_range_m_formula = "300"
|
||||||
|
|
||||||
|
[ship.loot]
|
||||||
|
scrap_drop = 60
|
||||||
|
|
||||||
|
|
||||||
|
# Carrier — 37 cells: the top flight deck (rows 0-1) is the only place wide
|
||||||
|
# enough for the 2x6 drone hangar, and exactly one fits. The middle deck row
|
||||||
|
# is broken up by elevator shafts (the X cells) so no 3x3 l gun can ever fit;
|
||||||
|
# the lower decks hold supports and 2x2 point-defense m guns.
|
||||||
|
[[ship]]
|
||||||
|
id = "carrier"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
layout = [
|
||||||
|
"XOOOOOOOOX",
|
||||||
|
"OOOOOOOOOO",
|
||||||
|
"OOXOOXOOXO",
|
||||||
|
"XOOOOOOOOX",
|
||||||
|
"XXXOOOOXXX",
|
||||||
|
]
|
||||||
|
|
||||||
|
[ship.schematic]
|
||||||
|
materials = [{item = "carrier_hull", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 120
|
||||||
|
|
||||||
|
[ship.health]
|
||||||
|
hp_formula = "700"
|
||||||
|
|
||||||
|
[ship.movement]
|
||||||
|
speed_mps_formula = "9"
|
||||||
|
main_acceleration_mpss_formula = "10"
|
||||||
|
maneuvering_acceleration_mpss_formula = "5"
|
||||||
|
angular_acceleration_radpss_formula = "1"
|
||||||
|
max_rotation_speed_radps_formula = "0.5"
|
||||||
|
|
||||||
|
[ship.sensor]
|
||||||
|
sensor_range_m_formula = "350"
|
||||||
|
|
||||||
|
[ship.loot]
|
||||||
|
scrap_drop = 60
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ surface_mask = [
|
|||||||
level = 1
|
level = 1
|
||||||
hp_formula = "300"
|
hp_formula = "300"
|
||||||
damage_formula = "5"
|
damage_formula = "5"
|
||||||
range_formula = "20"
|
range_m_formula = "200"
|
||||||
fire_rate_formula = "1"
|
fire_rate_hz_formula = "1"
|
||||||
scrap_drop_formula = "10"
|
scrap_drop_formula = "10"
|
||||||
|
|
||||||
[enemy_station]
|
[enemy_station]
|
||||||
@@ -25,6 +25,6 @@ surface_mask = [
|
|||||||
]
|
]
|
||||||
hp_formula = "300 + 150*x"
|
hp_formula = "300 + 150*x"
|
||||||
damage_formula = "2 + 1*x"
|
damage_formula = "2 + 1*x"
|
||||||
range_formula = "20"
|
range_m_formula = "200"
|
||||||
fire_rate_formula = "1.0 + 0.2*x"
|
fire_rate_hz_formula = "1.0 + 0.2*x"
|
||||||
scrap_drop_formula = "10 + 5*x"
|
scrap_drop_formula = "10 + 5*x"
|
||||||
|
|||||||
@@ -106,6 +106,8 @@ glyph = "E"
|
|||||||
# drawn around it. One section per ItemType.
|
# drawn around it. One section per ItemType.
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# --- ores ---
|
||||||
|
|
||||||
[items.iron_ore]
|
[items.iron_ore]
|
||||||
fill = "#8a5a4a"
|
fill = "#8a5a4a"
|
||||||
outline = "#201010"
|
outline = "#201010"
|
||||||
@@ -114,6 +116,12 @@ outline = "#201010"
|
|||||||
fill = "#c47a3a"
|
fill = "#c47a3a"
|
||||||
outline = "#3a1a0a"
|
outline = "#3a1a0a"
|
||||||
|
|
||||||
|
[items.titanium_ore]
|
||||||
|
fill = "#9aa3ad"
|
||||||
|
outline = "#2a2e33"
|
||||||
|
|
||||||
|
# --- ingots ---
|
||||||
|
|
||||||
[items.iron_ingot]
|
[items.iron_ingot]
|
||||||
fill = "#b0b0b8"
|
fill = "#b0b0b8"
|
||||||
outline = "#202028"
|
outline = "#202028"
|
||||||
@@ -122,21 +130,157 @@ outline = "#202028"
|
|||||||
fill = "#d48a4a"
|
fill = "#d48a4a"
|
||||||
outline = "#402010"
|
outline = "#402010"
|
||||||
|
|
||||||
[items.circuit_board]
|
[items.titanium_ingot]
|
||||||
fill = "#2ea35a"
|
fill = "#c8d2dc"
|
||||||
outline = "#0a2a14"
|
outline = "#3a4048"
|
||||||
|
|
||||||
|
# --- salvage loop ---
|
||||||
|
|
||||||
|
[items.scrap]
|
||||||
|
fill = "#7a7268"
|
||||||
|
outline = "#201a14"
|
||||||
|
|
||||||
[items.advanced_alloy]
|
[items.advanced_alloy]
|
||||||
fill = "#a06acc"
|
fill = "#a06acc"
|
||||||
outline = "#201030"
|
outline = "#201030"
|
||||||
|
|
||||||
|
# --- basic components ---
|
||||||
|
|
||||||
|
[items.copper_wire]
|
||||||
|
fill = "#e09a50"
|
||||||
|
outline = "#3a2008"
|
||||||
|
|
||||||
|
[items.steel_plate]
|
||||||
|
fill = "#8a92a0"
|
||||||
|
outline = "#22262c"
|
||||||
|
|
||||||
|
[items.circuit_board]
|
||||||
|
fill = "#2ea35a"
|
||||||
|
outline = "#0a2a14"
|
||||||
|
|
||||||
[items.building_block]
|
[items.building_block]
|
||||||
fill = "#c8b070"
|
fill = "#c8b070"
|
||||||
outline = "#302810"
|
outline = "#302810"
|
||||||
|
|
||||||
[items.scrap]
|
# --- advanced components ---
|
||||||
fill = "#7a7268"
|
|
||||||
outline = "#201a14"
|
[items.mechanical_parts]
|
||||||
|
fill = "#6f7a66"
|
||||||
|
outline = "#1c2018"
|
||||||
|
|
||||||
|
[items.targeting_unit]
|
||||||
|
fill = "#3a9e8c"
|
||||||
|
outline = "#0c2824"
|
||||||
|
|
||||||
|
[items.drive_unit]
|
||||||
|
fill = "#4a6ad0"
|
||||||
|
outline = "#101a38"
|
||||||
|
|
||||||
|
[items.titanium_frame]
|
||||||
|
fill = "#b8c4d4"
|
||||||
|
outline = "#343c48"
|
||||||
|
|
||||||
|
# --- capital components ---
|
||||||
|
|
||||||
|
[items.reinforced_plating]
|
||||||
|
fill = "#8a6ad0"
|
||||||
|
outline = "#1c1038"
|
||||||
|
|
||||||
|
[items.capital_core]
|
||||||
|
fill = "#b040d0"
|
||||||
|
outline = "#280c30"
|
||||||
|
|
||||||
|
# --- module items ---
|
||||||
|
|
||||||
|
[items.laser_cannon_s_module]
|
||||||
|
fill = "#691313"
|
||||||
|
outline = "#f3ff4f"
|
||||||
|
|
||||||
|
[items.laser_cannon_m_module]
|
||||||
|
fill = "#892020"
|
||||||
|
outline = "#f3ff4f"
|
||||||
|
|
||||||
|
[items.laser_cannon_l_module]
|
||||||
|
fill = "#a92d2d"
|
||||||
|
outline = "#f3ff4f"
|
||||||
|
|
||||||
|
[items.salvager_module]
|
||||||
|
fill = "#b2cfdd"
|
||||||
|
outline = "#236137"
|
||||||
|
|
||||||
|
[items.repair_tool_module]
|
||||||
|
fill = "#2e9ba3"
|
||||||
|
outline = "#689275"
|
||||||
|
|
||||||
|
[items.armor_plates_module]
|
||||||
|
fill = "#808080"
|
||||||
|
outline = "#202020"
|
||||||
|
|
||||||
|
[items.sensor_booster_module]
|
||||||
|
fill = "#40a0ff"
|
||||||
|
outline = "#102840"
|
||||||
|
|
||||||
|
[items.maneuvering_thrusters_module]
|
||||||
|
fill = "#5090e0"
|
||||||
|
outline = "#142438"
|
||||||
|
|
||||||
|
[items.afterburner_module]
|
||||||
|
fill = "#6080c0"
|
||||||
|
outline = "#182030"
|
||||||
|
|
||||||
|
[items.weapon_upgrade_module]
|
||||||
|
fill = "#ff4040"
|
||||||
|
outline = "#401010"
|
||||||
|
|
||||||
|
[items.weapon_primer_module]
|
||||||
|
fill = "#e03838"
|
||||||
|
outline = "#380e0e"
|
||||||
|
|
||||||
|
[items.weapon_stabilizer_module]
|
||||||
|
fill = "#c03030"
|
||||||
|
outline = "#300c0c"
|
||||||
|
|
||||||
|
[items.drone_bay_module]
|
||||||
|
fill = "#cc66ff"
|
||||||
|
outline = "#331040"
|
||||||
|
|
||||||
|
[items.drone_hangar_module]
|
||||||
|
fill = "#9933cc"
|
||||||
|
outline = "#260c33"
|
||||||
|
|
||||||
|
# --- ship hulls (outline matches the ship's fleet color in [ships.*]) ---
|
||||||
|
|
||||||
|
[items.drone_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#3366ff"
|
||||||
|
|
||||||
|
[items.frigate_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#44aaff"
|
||||||
|
|
||||||
|
[items.destroyer_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#33ccaa"
|
||||||
|
|
||||||
|
[items.cruiser_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#66cc33"
|
||||||
|
|
||||||
|
[items.battlecruiser_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#cccc33"
|
||||||
|
|
||||||
|
[items.battleship_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#ff9933"
|
||||||
|
|
||||||
|
[items.dreadnought_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#ff5533"
|
||||||
|
|
||||||
|
[items.carrier_hull]
|
||||||
|
fill = "#1b1b1b"
|
||||||
|
outline = "#cc66ff"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Ships
|
# Ships
|
||||||
@@ -144,24 +288,36 @@ outline = "#201a14"
|
|||||||
# Ships are drawn as oriented triangles/arrows. Color is keyed to schematic id.
|
# Ships are drawn as oriented triangles/arrows. Color is keyed to schematic id.
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[ships.fighter]
|
[ships.drone]
|
||||||
fill = "#3366ff"
|
fill = "#3366ff"
|
||||||
outline = "#ffffff"
|
outline = "#ffffff"
|
||||||
|
|
||||||
[ships.sniper]
|
[ships.frigate]
|
||||||
fill = "#3366ff"
|
fill = "#44aaff"
|
||||||
outline = "#ffffff"
|
outline = "#ffffff"
|
||||||
|
|
||||||
[ships.gunship]
|
[ships.destroyer]
|
||||||
fill = "#3366ff"
|
fill = "#33ccaa"
|
||||||
outline = "#ffffff"
|
outline = "#ffffff"
|
||||||
|
|
||||||
[ships.salvage_ship]
|
[ships.cruiser]
|
||||||
fill = "#33cc66"
|
fill = "#66cc33"
|
||||||
outline = "#ffffff"
|
outline = "#ffffff"
|
||||||
|
|
||||||
[ships.repair_ship]
|
[ships.battlecruiser]
|
||||||
fill = "#66ccff"
|
fill = "#cccc33"
|
||||||
|
outline = "#ffffff"
|
||||||
|
|
||||||
|
[ships.battleship]
|
||||||
|
fill = "#ff9933"
|
||||||
|
outline = "#ffffff"
|
||||||
|
|
||||||
|
[ships.dreadnought]
|
||||||
|
fill = "#ff5533"
|
||||||
|
outline = "#ffffff"
|
||||||
|
|
||||||
|
[ships.carrier]
|
||||||
|
fill = "#cc66ff"
|
||||||
outline = "#ffffff"
|
outline = "#ffffff"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -3,31 +3,32 @@ height_tiles = 30
|
|||||||
refund_percentage = 75
|
refund_percentage = 75
|
||||||
starting_building_blocks = 1000
|
starting_building_blocks = 1000
|
||||||
scrap_despawn_seconds = 30
|
scrap_despawn_seconds = 30
|
||||||
belt_speed_tiles_per_second = 2
|
tile_size_m = 10
|
||||||
tunnel_max_distance = 10
|
belt_speed_mps = 20
|
||||||
|
tunnel_max_distance_tiles = 10
|
||||||
departure_interval_seconds = 20
|
departure_interval_seconds = 20
|
||||||
|
|
||||||
[regions]
|
[regions]
|
||||||
asteroid_width = 40
|
asteroid_width_tiles = 40
|
||||||
player_buffer_width = 20
|
player_buffer_width_tiles = 20
|
||||||
contest_zone_width = 60
|
contest_zone_width_tiles = 60
|
||||||
enemy_buffer_width = 20
|
enemy_buffer_width_tiles = 20
|
||||||
|
|
||||||
[expansion]
|
[expansion]
|
||||||
columns_per_expansion = 10
|
columns_per_expansion_tiles = 10
|
||||||
cost_building_blocks = 200
|
cost_building_blocks = 200
|
||||||
|
|
||||||
[push]
|
[push]
|
||||||
push_expand_columns = 10
|
push_expand_columns_tiles = 10
|
||||||
boss_advance_seconds = 60
|
boss_advance_seconds = 60
|
||||||
|
|
||||||
[waves]
|
[waves]
|
||||||
threat_rate_formula = "0.01*x"
|
threat_rate_formula = "x"
|
||||||
ship_level_formula = "1"
|
ship_level_formula = "1"
|
||||||
gap_min_seconds = 15
|
gap_min_seconds = 15
|
||||||
gap_max_seconds = 45
|
gap_max_seconds = 45
|
||||||
spawn_duration_seconds = 10
|
spawn_duration_seconds = 10
|
||||||
boss_countdown_seconds = 300
|
boss_countdown_seconds = 300
|
||||||
boss_threat_duration_seconds = 60
|
boss_threat_duration_seconds = 60
|
||||||
boss_quiet_before_seconds = 60
|
boss_quiet_before_seconds = 20
|
||||||
boss_quiet_after_seconds = 60
|
boss_quiet_after_seconds = 20
|
||||||
|
|||||||
@@ -1,118 +1,85 @@
|
|||||||
[[arena]]
|
[[arena]]
|
||||||
name = "Fighters vs Sniper"
|
name = "Fighters vs Sniper"
|
||||||
height_tiles = 20
|
height_tiles = 20
|
||||||
player_buffer_width = 10
|
player_buffer_width_tiles = 10
|
||||||
contest_zone_width = 60
|
contest_zone_width_tiles = 60
|
||||||
enemy_buffer_width = 10
|
enemy_buffer_width_tiles = 10
|
||||||
|
|
||||||
[[arena.team]]
|
[[arena.team]]
|
||||||
name = "Alpha"
|
name = "Alpha"
|
||||||
[[arena.team.ship]]
|
[[arena.team.ship]]
|
||||||
schematic = "fighter"
|
schematic = "drone"
|
||||||
level = 1
|
level = 1
|
||||||
count = 5
|
count = 5
|
||||||
modules = [
|
modules = [
|
||||||
{type = "laser_cannon", x = 1, y = 1, rotation = "east"},
|
{type = "laser_cannon_s", x = 1, y = 1, rotation = "east"},
|
||||||
{type = "weapon_upgrade", x = 0, y = 1, rotation = "east"},
|
|
||||||
{type = "sensor_booster", x = 2, y = 1, rotation = "east"},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[arena.team]]
|
[[arena.team]]
|
||||||
name = "Beta"
|
name = "Beta"
|
||||||
[[arena.team.ship]]
|
[[arena.team.ship]]
|
||||||
schematic = "sniper"
|
schematic = "drone"
|
||||||
level = 1
|
level = 1
|
||||||
count = 1
|
count = 2
|
||||||
modules = [
|
modules = [
|
||||||
{type = "laser_cannon", x = 1, y = 1, rotation = "east"},
|
{type = "laser_cannon_s", x = 1, y = 1, rotation = "east"},
|
||||||
{type = "armor_plate", x = 1, y = 0, rotation = "east"},
|
{type = "weapon_stabilizer", x = 1, y = 1, rotation = "east"},
|
||||||
{type = "weapon_upgrade", x = 1, y = 2, rotation = "east"},
|
{type = "weapon_stabilizer", x = 1, y = 1, rotation = "east"},
|
||||||
|
{type = "weapon_upgrade", x = 1, y = 1, rotation = "east"},
|
||||||
|
{type = "sensor_booster", x = 1, y = 1, rotation = "east"},
|
||||||
|
{type = "sensor_booster", x = 1, y = 1, rotation = "east"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
[[arena]]
|
[[arena]]
|
||||||
name = "Sniper vs Gunship"
|
name = "Fighters vs Supported"
|
||||||
height_tiles = 20
|
height_tiles = 20
|
||||||
player_buffer_width = 10
|
player_buffer_width_tiles = 10
|
||||||
contest_zone_width = 60
|
contest_zone_width_tiles = 60
|
||||||
enemy_buffer_width = 10
|
enemy_buffer_width_tiles = 10
|
||||||
|
|
||||||
[[arena.team]]
|
[[arena.team]]
|
||||||
name = "Alpha"
|
name = "Fighters"
|
||||||
[[arena.team.ship]]
|
[[arena.team.ship]]
|
||||||
schematic = "sniper"
|
schematic = "drone"
|
||||||
level = 1
|
|
||||||
count = 1
|
|
||||||
modules = [
|
|
||||||
{type = "laser_cannon", x = 1, y = 1, rotation = "east"},
|
|
||||||
{type = "armor_plate", x = 1, y = 0, rotation = "east"},
|
|
||||||
{type = "sensor_booster", x = 0, y = 1, rotation = "east"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[[arena.team]]
|
|
||||||
name = "Beta"
|
|
||||||
[[arena.team.ship]]
|
|
||||||
schematic = "gunship"
|
|
||||||
level = 1
|
|
||||||
count = 1
|
|
||||||
modules = [
|
|
||||||
{type = "laser_cannon", x = 2, y = 1, rotation = "east"},
|
|
||||||
{type = "armor_plate", x = 1, y = 0, rotation = "east"},
|
|
||||||
{type = "weapon_upgrade", x = 3, y = 1, rotation = "east"},
|
|
||||||
{type = "engine_booster", x = 0, y = 1, rotation = "east"},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
[[arena]]
|
|
||||||
name = "Gunship vs Fighters"
|
|
||||||
height_tiles = 20
|
|
||||||
player_buffer_width = 10
|
|
||||||
contest_zone_width = 60
|
|
||||||
enemy_buffer_width = 10
|
|
||||||
|
|
||||||
[[arena.team]]
|
|
||||||
name = "Alpha"
|
|
||||||
[[arena.team.ship]]
|
|
||||||
schematic = "gunship"
|
|
||||||
level = 1
|
|
||||||
count = 1
|
|
||||||
modules = [
|
|
||||||
{type = "laser_cannon", x = 2, y = 2, rotation = "east"},
|
|
||||||
{type = "armor_plate", x = 1, y = 0, rotation = "east"},
|
|
||||||
{type = "weapon_upgrade", x = 3, y = 2, rotation = "east"},
|
|
||||||
{type = "engine_booster", x = 0, y = 1, rotation = "east"},
|
|
||||||
]
|
|
||||||
|
|
||||||
[[arena.team]]
|
|
||||||
name = "Beta"
|
|
||||||
[[arena.team.ship]]
|
|
||||||
schematic = "fighter"
|
|
||||||
level = 1
|
level = 1
|
||||||
count = 5
|
count = 5
|
||||||
modules = [
|
modules = [
|
||||||
{type = "laser_cannon", x = 1, y = 1, rotation = "east"},
|
{type = "laser_cannon_s", x = 1, y = 1, rotation = "east"},
|
||||||
{type = "engine_booster", x = 1, y = 0, rotation = "east"},
|
|
||||||
{type = "sensor_booster", x = 2, y = 1, rotation = "east"},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[arena.team]]
|
||||||
|
name = "Supported"
|
||||||
|
[[arena.team.ship]]
|
||||||
|
schematic = "drone"
|
||||||
|
level = 1
|
||||||
|
count = 3
|
||||||
|
modules = [
|
||||||
|
{type = "laser_cannon_s", x = 1, y = 1, rotation = "east"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[arena.team.ship]]
|
||||||
|
schematic = "drone"
|
||||||
|
level = 1
|
||||||
|
count = 2
|
||||||
|
modules = [
|
||||||
|
{type = "repair_tool", x = 1, y = 1, rotation = "east"},
|
||||||
|
]
|
||||||
|
|
||||||
[[arena]]
|
[[arena]]
|
||||||
name = "Stations and Ships"
|
name = "Stations and Ships"
|
||||||
height_tiles = 60
|
height_tiles = 60
|
||||||
player_buffer_width = 15
|
player_buffer_width_tiles = 15
|
||||||
contest_zone_width = 40
|
contest_zone_width_tiles = 40
|
||||||
enemy_buffer_width = 15
|
enemy_buffer_width_tiles = 15
|
||||||
|
|
||||||
[[arena.team]]
|
[[arena.team]]
|
||||||
name = "Fortified"
|
name = "Fortified"
|
||||||
[[arena.team.ship]]
|
[[arena.team.ship]]
|
||||||
schematic = "fighter"
|
schematic = "drone"
|
||||||
level = 1
|
level = 1
|
||||||
count = 3
|
count = 3
|
||||||
modules = [
|
modules = [
|
||||||
{type = "laser_cannon", x = 1, y = 1, rotation = "east"},
|
{type = "laser_cannon_s", x = 1, y = 1, rotation = "east"},
|
||||||
{type = "weapon_upgrade", x = 2, y = 1, rotation = "east"},
|
|
||||||
{type = "sensor_booster", x = 1, y = 0, rotation = "east"},
|
|
||||||
]
|
]
|
||||||
[[arena.team.station]]
|
[[arena.team.station]]
|
||||||
type = "player_station"
|
type = "player_station"
|
||||||
@@ -128,10 +95,9 @@ enemy_buffer_width = 15
|
|||||||
[[arena.team]]
|
[[arena.team]]
|
||||||
name = "Swarm"
|
name = "Swarm"
|
||||||
[[arena.team.ship]]
|
[[arena.team.ship]]
|
||||||
schematic = "fighter"
|
schematic = "drone"
|
||||||
level = 1
|
level = 1
|
||||||
count = 8
|
count = 8
|
||||||
modules = [
|
modules = [
|
||||||
{type = "laser_cannon", x = 1, y = 1, rotation = "east"},
|
{type = "laser_cannon_s", x = 1, y = 1, rotation = "east"},
|
||||||
{type = "engine_booster", x = 1, y = 0, rotation = "east"},
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
[[module]]
|
[[module]]
|
||||||
id = "armor_plate"
|
id = "armor_plate"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["OO"]
|
surface_mask = ["OO"]
|
||||||
materials = [{item = "iron_ingot", amount = 2}]
|
materials = [{item = "iron_ingot", amount = 2}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 3
|
production_time_seconds = 3
|
||||||
threat_cost = 2.0
|
|
||||||
fill_color = "#808080"
|
fill_color = "#808080"
|
||||||
glyph = "A"
|
glyph = "A"
|
||||||
|
|
||||||
@@ -13,24 +13,24 @@ multiplied_hp_formula = "1.5"
|
|||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "sensor_booster"
|
id = "sensor_booster"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["O"]
|
surface_mask = ["O"]
|
||||||
materials = [{item = "circuit_board", amount = 1}]
|
materials = [{item = "circuit_board", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 2
|
production_time_seconds = 2
|
||||||
threat_cost = 1.0
|
|
||||||
fill_color = "#40A0FF"
|
fill_color = "#40A0FF"
|
||||||
glyph = "S"
|
glyph = "S"
|
||||||
|
|
||||||
[module.sensor]
|
[module.sensor]
|
||||||
added_sensor_range_formula = "10"
|
added_sensor_range_m_formula = "100"
|
||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "weapon_upgrade"
|
id = "weapon_upgrade"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["O"]
|
surface_mask = ["O"]
|
||||||
materials = [{item = "iron_ingot", amount = 1}, {item = "circuit_board", amount = 1}]
|
materials = [{item = "iron_ingot", amount = 1}, {item = "circuit_board", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 4
|
production_time_seconds = 4
|
||||||
threat_cost = 3.0
|
|
||||||
fill_color = "#FF4040"
|
fill_color = "#FF4040"
|
||||||
glyph = "W"
|
glyph = "W"
|
||||||
|
|
||||||
@@ -39,44 +39,99 @@ multiplied_damage_formula = "1.2"
|
|||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "laser_cannon"
|
id = "laser_cannon"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["O"]
|
surface_mask = ["O"]
|
||||||
materials = [{item = "iron_ingot", amount = 1}]
|
materials = [{item = "iron_ingot", amount = 1}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 5
|
production_time_seconds = 5
|
||||||
threat_cost = 5.0
|
|
||||||
fill_color = "#FF8040"
|
fill_color = "#FF8040"
|
||||||
glyph = "L"
|
glyph = "L"
|
||||||
|
|
||||||
[module.weapon]
|
[module.weapon]
|
||||||
damage_formula = "2"
|
damage_formula = "2"
|
||||||
attack_range_formula = "5"
|
attack_range_m_formula = "50"
|
||||||
attack_rate_formula = "2.0"
|
attack_rate_hz_formula = "2.0"
|
||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "salvage_bay_module"
|
id = "salvager"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["OO"]
|
surface_mask = ["OO"]
|
||||||
materials = [{item = "iron_ingot", amount = 2}]
|
materials = [{item = "iron_ingot", amount = 2}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 5
|
production_time_seconds = 5
|
||||||
threat_cost = 0.0
|
|
||||||
fill_color = "#AACC44"
|
fill_color = "#AACC44"
|
||||||
glyph = "Sv"
|
glyph = "Sv"
|
||||||
|
|
||||||
[module.salvage]
|
[module.salvage]
|
||||||
collection_range_formula = "50"
|
collection_range_m_formula = "500"
|
||||||
cargo_capacity_formula = "10"
|
cargo_capacity_formula = "10"
|
||||||
collection_rate_formula = "0.5"
|
collection_rate_hz_formula = "0.5"
|
||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
id = "repair_tool_module"
|
id = "repair_tool"
|
||||||
|
unlock_at_station_level = -1
|
||||||
surface_mask = ["O"]
|
surface_mask = ["O"]
|
||||||
materials = [{item = "circuit_board", amount = 2}]
|
materials = [{item = "circuit_board", amount = 2}]
|
||||||
player_production_level = 1
|
player_production_level = 1
|
||||||
production_time_seconds = 5
|
production_time_seconds = 5
|
||||||
threat_cost = 0.0
|
|
||||||
fill_color = "#66CCFF"
|
fill_color = "#66CCFF"
|
||||||
glyph = "Rp"
|
glyph = "Rp"
|
||||||
|
|
||||||
[module.repair]
|
[module.repair]
|
||||||
repair_rate_formula = "5 + x"
|
repair_rate_hz_formula = "5 + x"
|
||||||
repair_range_formula = "80"
|
repair_range_m_formula = "800"
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "weapon_primer"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["O"]
|
||||||
|
materials = [{item = "iron_ingot", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 4
|
||||||
|
fill_color = "#FF4040"
|
||||||
|
glyph = "Wp"
|
||||||
|
|
||||||
|
[module.weapon]
|
||||||
|
multiplied_attack_rate_hz_formula = "1.2"
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "weapon_stabilizer"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["O"]
|
||||||
|
materials = [{item = "iron_ingot", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 4
|
||||||
|
fill_color = "#FF4040"
|
||||||
|
glyph = "Ws"
|
||||||
|
|
||||||
|
[module.weapon]
|
||||||
|
multiplied_attack_range_m_formula = "1.5"
|
||||||
|
multiplied_attack_rate_hz_formula = "0.8"
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "afterburner"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["O"]
|
||||||
|
materials = [{item = "iron_ingot", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 2
|
||||||
|
fill_color = "#40A0FF"
|
||||||
|
glyph = "Ab"
|
||||||
|
|
||||||
|
[module.movement]
|
||||||
|
multiplied_speed_mps_formula = "1.6"
|
||||||
|
added_main_acceleration_mpss_formula = "60"
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
id = "maneuvering_thrusters"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
surface_mask = ["O"]
|
||||||
|
materials = [{item = "iron_ingot", amount = 1}]
|
||||||
|
player_production_level = 1
|
||||||
|
production_time_seconds = 2
|
||||||
|
fill_color = "#40A0FF"
|
||||||
|
glyph = "Mt"
|
||||||
|
|
||||||
|
[module.movement]
|
||||||
|
multiplied_speed_mps_formula = "1.2"
|
||||||
|
added_maneuvering_acceleration_mpss_formula = "10"
|
||||||
|
|||||||
@@ -40,6 +40,38 @@ inputs = [{item = "iron_ingot", amount = 4}]
|
|||||||
outputs = [{item = "building_block", amount = 10}]
|
outputs = [{item = "building_block", amount = 10}]
|
||||||
duration_seconds = 4.0
|
duration_seconds = 4.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "premium_circuit"
|
||||||
|
building = "assembler"
|
||||||
|
unlock_at_station_level = -1
|
||||||
|
inputs = [{item = "circuit_board", amount = 1}]
|
||||||
|
outputs = [{item = "premium_circuit", amount = 1}]
|
||||||
|
duration_seconds = 8.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "quick_circuit"
|
||||||
|
building = "assembler"
|
||||||
|
unlock_at_station_level = 0
|
||||||
|
inputs = [{item = "copper_ingot", amount = 3}]
|
||||||
|
outputs = [{item = "circuit_board", amount = 1}]
|
||||||
|
duration_seconds = 3.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "advanced_circuit"
|
||||||
|
building = "assembler"
|
||||||
|
unlock_at_station_level = 1
|
||||||
|
inputs = [{item = "iron_ingot", amount = 5}]
|
||||||
|
outputs = [{item = "circuit_board", amount = 1}]
|
||||||
|
duration_seconds = 6.0
|
||||||
|
|
||||||
|
[[recipe]]
|
||||||
|
id = "exotic_alloy"
|
||||||
|
building = "assembler"
|
||||||
|
unlock_at_station_level = 0
|
||||||
|
inputs = [{item = "exotic_ore", amount = 2}]
|
||||||
|
outputs = [{item = "exotic_alloy", amount = 1}]
|
||||||
|
duration_seconds = 10.0
|
||||||
|
|
||||||
[[recipe]]
|
[[recipe]]
|
||||||
id = "reprocessing_cycle"
|
id = "reprocessing_cycle"
|
||||||
building = "reprocessing_plant"
|
building = "reprocessing_plant"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[[ship]]
|
[[ship]]
|
||||||
id = "interceptor"
|
id = "interceptor"
|
||||||
available_from_start = true
|
unlock_at_station_level = -1
|
||||||
layout = ["XOX", "OOO", "XOX"]
|
layout = ["XOX", "OOO", "XOX"]
|
||||||
default_modules = [{type = "laser_cannon", x = 1, y = 1, rotation = "east"}]
|
default_modules = [{type = "laser_cannon", x = 1, y = 1, rotation = "east"}]
|
||||||
|
|
||||||
@@ -9,21 +9,18 @@ materials = [{item = "iron_ingot", amount = 3}, {item = "circuit_board", amount
|
|||||||
player_production_level = 3
|
player_production_level = 3
|
||||||
production_time_seconds = 10
|
production_time_seconds = 10
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "5 + 1*x"
|
|
||||||
|
|
||||||
[ship.health]
|
[ship.health]
|
||||||
hp_formula = "40 + 5*x"
|
hp_formula = "40 + 5*x"
|
||||||
|
|
||||||
[ship.movement]
|
[ship.movement]
|
||||||
speed_formula = "200 + 5*x"
|
speed_mps_formula = "2000 + 50*x"
|
||||||
main_acceleration_formula = "100000"
|
main_acceleration_mpss_formula = "1000000"
|
||||||
maneuvering_acceleration_formula = "100000"
|
maneuvering_acceleration_mpss_formula = "1000000"
|
||||||
angular_acceleration_formula = "100000"
|
angular_acceleration_radpss_formula = "100000"
|
||||||
max_rotation_speed_formula = "100000"
|
max_rotation_speed_radps_formula = "100000"
|
||||||
|
|
||||||
[ship.sensor]
|
[ship.sensor]
|
||||||
sensor_range_formula = "200"
|
sensor_range_m_formula = "2000"
|
||||||
|
|
||||||
[ship.loot]
|
[ship.loot]
|
||||||
scrap_drop = 2
|
scrap_drop = 2
|
||||||
@@ -31,7 +28,7 @@ scrap_drop = 2
|
|||||||
|
|
||||||
[[ship]]
|
[[ship]]
|
||||||
id = "destroyer"
|
id = "destroyer"
|
||||||
available_from_start = true
|
unlock_at_station_level = -1
|
||||||
layout = ["XOOX", "OOOO", "XOOX"]
|
layout = ["XOOX", "OOOO", "XOOX"]
|
||||||
default_modules = [{type = "laser_cannon", x = 1, y = 1, rotation = "east"}]
|
default_modules = [{type = "laser_cannon", x = 1, y = 1, rotation = "east"}]
|
||||||
|
|
||||||
@@ -40,21 +37,18 @@ materials = [{item = "iron_ingot", amount = 5}, {item = "circuit_board", amount
|
|||||||
player_production_level = 5
|
player_production_level = 5
|
||||||
production_time_seconds = 20
|
production_time_seconds = 20
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "10 + 2*x"
|
|
||||||
|
|
||||||
[ship.health]
|
[ship.health]
|
||||||
hp_formula = "120 + 15*x"
|
hp_formula = "120 + 15*x"
|
||||||
|
|
||||||
[ship.movement]
|
[ship.movement]
|
||||||
speed_formula = "120"
|
speed_mps_formula = "1200"
|
||||||
main_acceleration_formula = "100000"
|
main_acceleration_mpss_formula = "1000000"
|
||||||
maneuvering_acceleration_formula = "100000"
|
maneuvering_acceleration_mpss_formula = "1000000"
|
||||||
angular_acceleration_formula = "100000"
|
angular_acceleration_radpss_formula = "100000"
|
||||||
max_rotation_speed_formula = "100000"
|
max_rotation_speed_radps_formula = "100000"
|
||||||
|
|
||||||
[ship.sensor]
|
[ship.sensor]
|
||||||
sensor_range_formula = "300"
|
sensor_range_m_formula = "3000"
|
||||||
|
|
||||||
[ship.loot]
|
[ship.loot]
|
||||||
scrap_drop = 4
|
scrap_drop = 4
|
||||||
@@ -62,7 +56,7 @@ scrap_drop = 4
|
|||||||
|
|
||||||
[[ship]]
|
[[ship]]
|
||||||
id = "salvage_ship"
|
id = "salvage_ship"
|
||||||
available_from_start = true
|
unlock_at_station_level = -1
|
||||||
layout = ["OOO", "OOO"]
|
layout = ["OOO", "OOO"]
|
||||||
|
|
||||||
[ship.schematic]
|
[ship.schematic]
|
||||||
@@ -70,21 +64,18 @@ materials = [{item = "iron_ingot", amount = 4}]
|
|||||||
player_production_level = 3
|
player_production_level = 3
|
||||||
production_time_seconds = 10
|
production_time_seconds = 10
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "0"
|
|
||||||
|
|
||||||
[ship.health]
|
[ship.health]
|
||||||
hp_formula = "40 + 4*x"
|
hp_formula = "40 + 4*x"
|
||||||
|
|
||||||
[ship.movement]
|
[ship.movement]
|
||||||
speed_formula = "110"
|
speed_mps_formula = "1100"
|
||||||
main_acceleration_formula = "100000"
|
main_acceleration_mpss_formula = "1000000"
|
||||||
maneuvering_acceleration_formula = "100000"
|
maneuvering_acceleration_mpss_formula = "1000000"
|
||||||
angular_acceleration_formula = "100000"
|
angular_acceleration_radpss_formula = "100000"
|
||||||
max_rotation_speed_formula = "100000"
|
max_rotation_speed_radps_formula = "100000"
|
||||||
|
|
||||||
[ship.sensor]
|
[ship.sensor]
|
||||||
sensor_range_formula = "250"
|
sensor_range_m_formula = "2500"
|
||||||
|
|
||||||
[ship.loot]
|
[ship.loot]
|
||||||
scrap_drop = 2
|
scrap_drop = 2
|
||||||
@@ -92,7 +83,7 @@ scrap_drop = 2
|
|||||||
|
|
||||||
[[ship]]
|
[[ship]]
|
||||||
id = "repair_ship"
|
id = "repair_ship"
|
||||||
available_from_start = false
|
unlock_at_station_level = 0
|
||||||
layout = ["XOX", "OOO", "XOX"]
|
layout = ["XOX", "OOO", "XOX"]
|
||||||
|
|
||||||
[ship.schematic]
|
[ship.schematic]
|
||||||
@@ -100,21 +91,18 @@ materials = [{item = "iron_ingot", amount = 4}, {item = "circuit_board", amount
|
|||||||
player_production_level = 3
|
player_production_level = 3
|
||||||
production_time_seconds = 15
|
production_time_seconds = 15
|
||||||
|
|
||||||
[ship.threat]
|
|
||||||
cost_formula = "0"
|
|
||||||
|
|
||||||
[ship.health]
|
[ship.health]
|
||||||
hp_formula = "60 + 5*x"
|
hp_formula = "60 + 5*x"
|
||||||
|
|
||||||
[ship.movement]
|
[ship.movement]
|
||||||
speed_formula = "130"
|
speed_mps_formula = "1300"
|
||||||
main_acceleration_formula = "100000"
|
main_acceleration_mpss_formula = "1000000"
|
||||||
maneuvering_acceleration_formula = "100000"
|
maneuvering_acceleration_mpss_formula = "1000000"
|
||||||
angular_acceleration_formula = "100000"
|
angular_acceleration_radpss_formula = "100000"
|
||||||
max_rotation_speed_formula = "100000"
|
max_rotation_speed_radps_formula = "100000"
|
||||||
|
|
||||||
[ship.sensor]
|
[ship.sensor]
|
||||||
sensor_range_formula = "250"
|
sensor_range_m_formula = "2500"
|
||||||
|
|
||||||
[ship.loot]
|
[ship.loot]
|
||||||
scrap_drop = 2
|
scrap_drop = 2
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ surface_mask = [
|
|||||||
level = 5
|
level = 5
|
||||||
hp_formula = "300 + 40*x"
|
hp_formula = "300 + 40*x"
|
||||||
damage_formula = "5 + 4*x"
|
damage_formula = "5 + 4*x"
|
||||||
range_formula = "300 + 20*x"
|
range_m_formula = "3000 + 200*x"
|
||||||
fire_rate_formula = "0.5 + 0.2*x"
|
fire_rate_hz_formula = "0.5 + 0.2*x"
|
||||||
scrap_drop_formula = "x"
|
scrap_drop_formula = "x"
|
||||||
|
|
||||||
[enemy_station]
|
[enemy_station]
|
||||||
@@ -25,6 +25,6 @@ surface_mask = [
|
|||||||
]
|
]
|
||||||
hp_formula = "300 + 150*x"
|
hp_formula = "300 + 150*x"
|
||||||
damage_formula = "20 + 10*x"
|
damage_formula = "20 + 10*x"
|
||||||
range_formula = "350 + 20*x"
|
range_m_formula = "3500 + 200*x"
|
||||||
fire_rate_formula = "1.0 + 0.2*x"
|
fire_rate_hz_formula = "1.0 + 0.2*x"
|
||||||
scrap_drop_formula = "10 + 5*x"
|
scrap_drop_formula = "10 + 5*x"
|
||||||
|
|||||||
@@ -3,22 +3,23 @@ height_tiles = 60
|
|||||||
refund_percentage = 75
|
refund_percentage = 75
|
||||||
starting_building_blocks = 100
|
starting_building_blocks = 100
|
||||||
scrap_despawn_seconds = 30
|
scrap_despawn_seconds = 30
|
||||||
belt_speed_tiles_per_second = 2
|
tile_size_m = 10
|
||||||
tunnel_max_distance = 10
|
belt_speed_mps = 20
|
||||||
|
tunnel_max_distance_tiles = 10
|
||||||
departure_interval_seconds = 20
|
departure_interval_seconds = 20
|
||||||
|
|
||||||
[regions]
|
[regions]
|
||||||
asteroid_width = 40
|
asteroid_width_tiles = 40
|
||||||
player_buffer_width = 10
|
player_buffer_width_tiles = 10
|
||||||
contest_zone_width = 30
|
contest_zone_width_tiles = 30
|
||||||
enemy_buffer_width = 15
|
enemy_buffer_width_tiles = 15
|
||||||
|
|
||||||
[expansion]
|
[expansion]
|
||||||
columns_per_expansion = 10
|
columns_per_expansion_tiles = 10
|
||||||
cost_building_blocks = 200
|
cost_building_blocks = 200
|
||||||
|
|
||||||
[push]
|
[push]
|
||||||
push_expand_columns = 20
|
push_expand_columns_tiles = 20
|
||||||
boss_advance_seconds = 60
|
boss_advance_seconds = 60
|
||||||
|
|
||||||
[waves]
|
[waves]
|
||||||
|
|||||||
@@ -59,23 +59,43 @@ Simulation types shared across subsystems:
|
|||||||
- `Item` — `struct Item { ItemType type; }`. Items on belts have no persistent identity across ticks.
|
- `Item` — `struct Item { ItemType type; }`. Items on belts have no persistent identity across ticks.
|
||||||
- `Port` — `struct Port { QPoint tile; Rotation direction; }`. Identifies a belt-adjacent cell and the direction of flow across that cell.
|
- `Port` — `struct Port { QPoint tile; Rotation direction; }`. Identifies a belt-adjacent cell and the direction of flow across that cell.
|
||||||
- `MovementIntent` — `struct MovementIntent { int priority; QVector2D target; }`. Priority follows the order declared under Movement Arbitration. Cleared at the start of each tick; the highest-priority write wins; `tickMovement` reads the winner.
|
- `MovementIntent` — `struct MovementIntent { int priority; QVector2D target; }`. Priority follows the order declared under Movement Arbitration. Cleared at the start of each tick; the highest-priority write wins; `tickMovement` reads the winner.
|
||||||
- `FireEvent` — `struct FireEvent { EntityId shooter; EntityId target; Tick emittedAt; }`. Transient record emitted each time a weapon fires (REQ-SHP-FIRING, REQ-SHP-FIRING-BEAM). Buffered in a sim-owned queue and drained by the renderer; see Sim → UI Events.
|
- `WeaponFiredEvent` — `struct WeaponFiredEvent : public Event { entt::entity shooter; entt::entity target; Tick emittedAt; }`. Transient record emitted each time a weapon fires (REQ-SHP-FIRING, REQ-SHP-FIRING-BEAM). Buffered in a sim-owned vector during the tick, then drained and re-emitted via EventManager by the UI frame handler; see Sim → UI Events.
|
||||||
- `SchematicDropEvent` — `struct SchematicDropEvent { ShipSchematicId schematic; int newLevel; bool wasNewUnlock; }`. Emitted when a destroyed enemy-defence-station set awards a schematic (REQ-DEF-SCHEMATIC-DROP). The UI renders a toast (REQ-UI-SCHEMATIC-TOAST); `wasNewUnlock` chooses between the "unlocked" and "level → N" wording.
|
- `SchematicChoiceOption` — `struct SchematicChoiceOption { string schematicId; SchematicType type; string displayName; bool isNewUnlock; int targetLevel; }`. Describes one option in the schematic choice dialog (REQ-DEF-SCHEMATIC-DROP). Up to three are generated when an enemy station set is destroyed. `SchematicType` is `Ship`, `Module`, or `Recipe`.
|
||||||
|
- `SchematicChoicesAvailableEvent` — EventManager event carrying a `vector<SchematicChoiceOption>`. Sent by the UI each frame when pending choices are detected; handled by `MainWindow` which opens the schematic choice dialog.
|
||||||
|
|
||||||
## Sim → UI Events
|
## Event System
|
||||||
|
|
||||||
The sim owns a small set of per-frame event queues that the UI drains on each render. These carry one-shot signals that are not derivable from persistent state — currently weapon fires (REQ-SHP-FIRING-BEAM) and schematic drops (REQ-UI-SCHEMATIC-TOAST). Additional event types can be added here later (e.g., building-complete, unit-death flashes) without changing the pattern.
|
All inter-component communication — both sim→UI and UI→UI — uses a unified `EventManager`/`EventHandler` system. No custom Qt signals/slots are used for inter-widget communication.
|
||||||
|
|
||||||
Implementation: a plain `std::vector<FireEvent>` owned by `Simulation`, one vector per event type. Combat resolution (tick-order step 8) appends to it. The UI calls `simulation.drainFireEvents()` once per rendered frame, which returns the accumulated vector by move and clears the internal one. Beams are tracked by the renderer for 0.3 s of wall time (9 ticks at 30 Hz) using the events' `emittedAt` tick, then discarded. If either the shooter or target entity is gone when the renderer looks them up, the beam is dropped early.
|
### EventManager
|
||||||
|
|
||||||
We deliberately do **not** use `QObject` signals/slots or `QEvent`:
|
`EventManager` is a singleton (`EventManager::getInstance()`) that routes events to registered handlers.
|
||||||
|
|
||||||
- **Determinism.** A plain ordered vector preserves tick-order exactly; the queue is part of per-tick state, inspectable in tests.
|
- `sendEventImmediately(shared_ptr<Event>)` — synchronous dispatch to all handlers of the event's type.
|
||||||
- **Sim/UI seam.** The sim exposes pull-style access only; the UI never subscribes into the sim, keeping the simulation/presentation split clean.
|
- `addEvent(shared_ptr<Event>)` — queues the event for later batch processing.
|
||||||
- **Headless testability.** Catch2 tests read the queue directly after `tick()`; no event loop, no `QApplication`.
|
- `processEvents()` — drains the queue, dispatching each event to its handlers.
|
||||||
- **Zero overhead.** Sim types remain plain structs — no `QObject`, no moc, no signal dispatch machinery.
|
|
||||||
|
|
||||||
If the number of event types grows past a handful, we can wrap them in a small `EventQueue<T>` template, still owned by the sim. Signals/slots would only be warranted if we needed multiple independent subscribers or cross-thread dispatch, and we need neither.
|
The EventManager is thread-safe (mutex-guarded).
|
||||||
|
|
||||||
|
### EventHandler
|
||||||
|
|
||||||
|
`EventHandler<T>` is a CRTP-style template that a class inherits to receive events of type `T`. It provides `registerForEvent()` / `unregisterForEvent()` and requires an override of `handleEvent(shared_ptr<const T>)`.
|
||||||
|
|
||||||
|
`CombinedEventHandler<Ts...>` is a variadic template for classes that handle multiple event types. It provides `registerForEvents()` / `unregisterForEvents()` and requires one `handleEvent` override per type.
|
||||||
|
|
||||||
|
### Sim → UI Events
|
||||||
|
|
||||||
|
The simulation layer stays free of EventManager — it uses a plain `std::vector<WeaponFiredEvent>` internally (owned by `CombatSystem`). This preserves determinism, tick-order fidelity, and headless testability (Catch2 tests read the queue directly via `drainWeaponFiredEvents()` after `tick()`).
|
||||||
|
|
||||||
|
The UI frame handler (`GameWorldView::onFrame` / `ArenaView::onFrame`) bridges the gap: each frame it calls `simulation.drainWeaponFiredEvents()`, then re-emits each `WeaponFiredEvent` via `EventManager::sendEventImmediately()`. Subscribers (the same view's `handleEvent(WeaponFiredEvent)`) create `ActiveBeam` records tracked for 0.3 s of wall time, then discarded. If either the shooter or target entity is gone when the renderer looks them up, the beam is dropped early.
|
||||||
|
|
||||||
|
Schematic drops: when an enemy station set is destroyed, the simulation generates up to 3 `SchematicChoiceOption` entries and stores them as pending state. The UI polls `hasSchematicChoicesPending()` each frame and, when true, sends a `SchematicChoicesAvailableEvent` via EventManager. `MainWindow` handles this event by pausing the game and opening a modal `SchematicChoiceDialog`. The player's selection is fed back via `applySchematicChoice(index)`.
|
||||||
|
|
||||||
|
### UI Events
|
||||||
|
|
||||||
|
All UI interactions — building selection, builder/blueprint mode transitions, speed changes, demolish mode, escape menu, layout dialog requests — are communicated via EventManager events rather than Qt signals/slots. Each event is a small struct inheriting `Event` (e.g., `SelectionChangedEvent`, `BuildingTypeSelectedEvent`, `SpeedChangeRequestedEvent`). Widgets register as `CombinedEventHandler` for the events they care about and emit events via `EventManager::sendEventImmediately()`.
|
||||||
|
|
||||||
|
Bidirectional interactions use separate request/notification event types to avoid infinite recursion (e.g., `ExitBuilderModeRequestedEvent` from `BuildButtonGrid` → `GameWorldView`, vs. `BuilderModeExitedEvent` from `GameWorldView` → `BuildButtonGrid`).
|
||||||
|
|
||||||
## Tick Order
|
## Tick Order
|
||||||
|
|
||||||
@@ -88,8 +108,8 @@ Within a single simulation tick, subsystems run in this fixed order. The order i
|
|||||||
5. **Building → belt push** — buildings push items from output buffer onto the belt tile at their output port (REQ-MAT-OUTPUT-PORT).
|
5. **Building → belt push** — buildings push items from output buffer onto the belt tile at their output port (REQ-MAT-OUTPUT-PORT).
|
||||||
6. **Belt tick** — advance items along belt tiles; apply splitter routing (REQ-BLD-SPLITTER).
|
6. **Belt tick** — advance items along belt tiles; apply splitter routing (REQ-BLD-SPLITTER).
|
||||||
7. **Ship behavior systems** — clear `MovementIntent` on each ship, then run `tickThreatResponse`, `tickScrapCollector`, `tickRepairBehavior`, `tickHomeReturn` in any order (arbitration is via intent priority).
|
7. **Ship behavior systems** — clear `MovementIntent` on each ship, then run `tickThreatResponse`, `tickScrapCollector`, `tickRepairBehavior`, `tickHomeReturn` in any order (arbitration is via intent priority).
|
||||||
8. **Combat resolution** — ships and defence stations acquire targets, fire, apply damage; queue deaths. Each fire appends a `FireEvent` to the sim's fire-event queue (REQ-SHP-FIRING-BEAM).
|
8. **Combat resolution** — ships and defence stations acquire targets, fire, apply damage; queue deaths. Each fire appends a `WeaponFiredEvent` to the sim's weapon-fired-event queue (REQ-SHP-FIRING-BEAM).
|
||||||
9. **Deaths & loot** — process queued deaths: drop scrap (REQ-RES-SCRAP-DROP); if a full enemy-defence-station set was destroyed this tick, award one schematic (REQ-DEF-SCHEMATIC-DROP) and append a `SchematicDropEvent`; remove entities.
|
9. **Deaths & loot** — process queued deaths: drop scrap (REQ-RES-SCRAP-DROP); if a full enemy-defence-station set was destroyed this tick, generate up to 3 schematic choice options (REQ-DEF-SCHEMATIC-DROP) stored as pending state for the UI to present; remove entities.
|
||||||
10. **`tickMovement`** — advance ship positions based on final `MovementIntent`.
|
10. **`tickMovement`** — advance ship positions based on final `MovementIntent`.
|
||||||
11. **Scrap despawn** — decrement scrap timers; remove expired scrap (REQ-RES-SCRAP-DROP).
|
11. **Scrap despawn** — decrement scrap timers; remove expired scrap (REQ-RES-SCRAP-DROP).
|
||||||
|
|
||||||
@@ -280,7 +300,7 @@ The game world is rendered by a single `GameWorldView` widget that inherits `QOp
|
|||||||
|
|
||||||
### Threading
|
### Threading
|
||||||
|
|
||||||
Sim and UI run on the same thread for v1. `paintEvent` reads sim state directly without locks. If profiling later justifies moving the sim to a worker thread, the pull-style `drainFireEvents()` / `drainSchematicDropEvents()` / `forEachVisualItem()` APIs already support a clean snapshot-and-render split; a single mutex at the sim boundary would suffice.
|
Sim and UI run on the same thread for v1. `paintEvent` reads sim state directly without locks. If profiling later justifies moving the sim to a worker thread, the pull-style `drainWeaponFiredEvents()` / `getPendingSchematicChoices()` / `applySchematicChoice()` / `forEachVisualItem()` APIs already support a clean snapshot-and-render split; a single mutex at the sim boundary would suffice. The `ArenaSimulation` used by the balancing tool runs headlessly on a worker thread; fire events accumulate in its internal vector and are only drained when `ArenaView` drives `tickOnce()` on the main thread during interactive inspection.
|
||||||
|
|
||||||
### Layer Order (back to front)
|
### Layer Order (back to front)
|
||||||
|
|
||||||
@@ -289,9 +309,9 @@ Sim and UI run on the same thread for v1. `paintEvent` reads sim state directly
|
|||||||
3. **Belt items** — 10×10 colored squares emitted by `BeltSystem::forEachVisualItem`.
|
3. **Belt items** — 10×10 colored squares emitted by `BeltSystem::forEachVisualItem`.
|
||||||
4. **Scrap** — glyphs at world positions.
|
4. **Scrap** — glyphs at world positions.
|
||||||
5. **Ships** — colored arrows oriented by velocity; color keyed to role (player combat / salvage / repair / enemy).
|
5. **Ships** — colored arrows oriented by velocity; color keyed to role (player combat / salvage / repair / enemy).
|
||||||
6. **Laser beams** — lines derived from live `FireEvent`s kept by the renderer for 0.3 s (REQ-SHP-FIRING-BEAM).
|
6. **Laser beams** — lines derived from live `WeaponFiredEvent`s kept by the renderer for 0.3 s (REQ-SHP-FIRING-BEAM).
|
||||||
7. **Build overlays** — ghost in builder mode (REQ-BLD-GHOST), demolish-mode tint, tile highlight under cursor, box-drag selection rectangle.
|
7. **Build overlays** — ghost in builder mode (REQ-BLD-GHOST), demolish-mode tint, tile highlight under cursor, box-drag selection rectangle.
|
||||||
8. **Screen-space UI** — schematic toasts (REQ-UI-SCHEMATIC-TOAST) and any other screen-anchored elements, drawn after resetting the world-space transform.
|
8. **Screen-space UI** — screen-anchored elements, drawn after resetting the world-space transform.
|
||||||
|
|
||||||
### Coordinates and Scrolling
|
### Coordinates and Scrolling
|
||||||
|
|
||||||
|
|||||||
194
docs/content_design.md
Normal file
194
docs/content_design.md
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
# Content Design — Ships & Modules
|
||||||
|
|
||||||
|
First real-content iterations (June 2026). Pass 1 defined ship hull grids and
|
||||||
|
module surface masks; pass 2 defined the production tree (recipes). Stats and
|
||||||
|
threat costs in the config files are still placeholders for the balancing
|
||||||
|
pass.
|
||||||
|
|
||||||
|
## Design principle: footprint gating
|
||||||
|
|
||||||
|
Which module fits on which hull is controlled purely by geometry — no
|
||||||
|
explicit allow-lists. Each hull grid is shaped so that it physically cannot
|
||||||
|
contain the footprint of modules from a larger size class. This keeps the
|
||||||
|
rules transparent to the player ("it doesn't fit because there is no room")
|
||||||
|
and makes them trivially moddable through the config files alone.
|
||||||
|
|
||||||
|
### Module footprint ladder
|
||||||
|
|
||||||
|
| Footprint | Modules | Smallest hull that fits it |
|
||||||
|
|-----------|---------|----------------------------|
|
||||||
|
| 1x1 | laser_cannon_s, salvager, repair_tool | drone |
|
||||||
|
| 1x2 | maneuvering_thrusters, sensor_booster, armor_plates | frigate |
|
||||||
|
| 1x3 | afterburner | frigate (eats most of it) |
|
||||||
|
| L-shape (3 cells) | weapon_stabilizer, weapon_primer, weapon_upgrade | frigate |
|
||||||
|
| 2x2 | laser_cannon_m, drone_bay | cruiser |
|
||||||
|
| 3x3 | laser_cannon_l | battleship |
|
||||||
|
| 2x6 | drone_hangar | carrier (only) |
|
||||||
|
|
||||||
|
### Hull grids
|
||||||
|
|
||||||
|
`O` = buildable cell, `X` = hull structure (not buildable).
|
||||||
|
|
||||||
|
**drone (xs, 1 cell)** — exactly one 1x1 module: a small gun, a salvager, or
|
||||||
|
a repair tool. This is what makes drone roles swappable.
|
||||||
|
|
||||||
|
O
|
||||||
|
|
||||||
|
**frigate (s, 5 cells)** — plus shape. Every 1x2 placement crosses the center
|
||||||
|
cell, so at most ONE 1x2 support fits; alternatively one L-shaped weapon
|
||||||
|
modifier or one afterburner through the center line. Gun-boat with one or two
|
||||||
|
support modules, as intended.
|
||||||
|
|
||||||
|
XOX
|
||||||
|
OOO
|
||||||
|
XOX
|
||||||
|
|
||||||
|
**destroyer (s, 8 cells)** — gun deck with three turret bumps. More cells
|
||||||
|
than the frigate (more small guns), but still no 2x2 area anywhere, so medium
|
||||||
|
hardware can never be mounted.
|
||||||
|
|
||||||
|
OXOXO
|
||||||
|
OOOOO
|
||||||
|
|
||||||
|
**cruiser (m, 12 cells)** — notched corners. Fits at most two 2x2 m guns
|
||||||
|
(stacked through the middle), leaving the side cells for supports. No 3x3
|
||||||
|
area.
|
||||||
|
|
||||||
|
XOOX
|
||||||
|
OOOO
|
||||||
|
OOOO
|
||||||
|
XOOX
|
||||||
|
|
||||||
|
**battlecruiser (m, 16 cells)** — split bow with two gun cheeks, tapered
|
||||||
|
stern. Fits three 2x2 m guns — one more than the cruiser — with small support
|
||||||
|
slots left over. The bow split and stern taper prevent any 3x3 area (no l
|
||||||
|
gun) and any 2x6 area (no drone hangar).
|
||||||
|
|
||||||
|
OOXXOO
|
||||||
|
OOOOOO
|
||||||
|
XOOOOX
|
||||||
|
XXOOXX
|
||||||
|
|
||||||
|
**battleship (l, 24 cells)** — broadside hull with notched flanks on every
|
||||||
|
other row. Fits four 2x2 m guns (two per gun deck) — one more than the
|
||||||
|
battlecruiser — with bow, stern, and flank cells for supports. All 3x3
|
||||||
|
placements crowd the center columns, so at most ONE l gun fits: mounted
|
||||||
|
center it blocks every m gun mount (pure support strips remain), mounted
|
||||||
|
offset it still allows two m guns. The notched rows are never adjacent-and-
|
||||||
|
full, so no 2x6 drone hangar fits.
|
||||||
|
|
||||||
|
XOOOOX
|
||||||
|
OOOOOO
|
||||||
|
XOOOOX
|
||||||
|
OOOOOO
|
||||||
|
XOOOOX
|
||||||
|
|
||||||
|
**dreadnought (xl, 36 cells)** — the main battery deck is split into three
|
||||||
|
3x3 gun slots by structural spacer columns, so exactly three l guns fit side
|
||||||
|
by side (or m guns / supports in unused slots), plus bow/stern strips for
|
||||||
|
supports. The spacers cap every horizontal run at 5 cells, so the 2x6 drone
|
||||||
|
hangar can never fit — the carrier stays the only hangar hull.
|
||||||
|
|
||||||
|
XXXOOOOOXXX
|
||||||
|
OOOXOOOXOOO
|
||||||
|
OOOXOOOXOOO
|
||||||
|
OOOXOOOXOOO
|
||||||
|
XXOOXXXOOXX
|
||||||
|
|
||||||
|
**carrier (xl, 37 cells)** — the top flight deck (rows 0–1) is the only
|
||||||
|
region wide enough for the 2x6 drone hangar, and exactly one fits. The middle
|
||||||
|
deck row is broken up by elevator shafts (X cells placed so every 3-column
|
||||||
|
window hits one), which is what prevents any 3x3 l gun from ever fitting.
|
||||||
|
Lower decks hold supports and 2x2 point-defense m guns.
|
||||||
|
|
||||||
|
XOOOOOOOOX
|
||||||
|
OOOOOOOOOO
|
||||||
|
OOXOOXOOXO
|
||||||
|
XOOOOOOOOX
|
||||||
|
XXXOOOOXXX
|
||||||
|
|
||||||
|
### Verified gating matrix
|
||||||
|
|
||||||
|
Checked programmatically against the configs (all four mask rotations,
|
||||||
|
all placements) with `tools/verify_layouts.py` — re-run it after editing
|
||||||
|
layout grids or surface masks:
|
||||||
|
|
||||||
|
python dota_factory/tools/verify_layouts.py
|
||||||
|
|
||||||
|
| Footprint | drone | frigate | destroyer | cruiser | battlecruiser | battleship | dreadnought | carrier |
|
||||||
|
|-----------|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
||||||
|
| 1x1 | x | x | x | x | x | x | x | x |
|
||||||
|
| 1x2 | | x | x | x | x | x | x | x |
|
||||||
|
| 1x3 | | x | x | x | x | x | x | x |
|
||||||
|
| L-shape | | x | x | x | x | x | x | x |
|
||||||
|
| 2x2 | | | | x | x | x | x | x |
|
||||||
|
| 3x3 | | | | | | x | x | |
|
||||||
|
| 2x6 | | | | | | | | x |
|
||||||
|
|
||||||
|
Maximum simultaneous (disjoint) placements: m guns — cruiser 2,
|
||||||
|
battlecruiser 3, battleship 4; l guns — battleship 1, dreadnought 3;
|
||||||
|
drone hangar — carrier 1.
|
||||||
|
|
||||||
|
## Production tree
|
||||||
|
|
||||||
|
Design principle: each game phase adds exactly one new base input chain, so
|
||||||
|
factory complexity ramps alongside ship size.
|
||||||
|
|
||||||
|
| Phase | New input | How acquired | Unlocks |
|
||||||
|
|-------|-----------|--------------|---------|
|
||||||
|
| early | iron_ore, copper_ore | mined | drone, frigate, destroyer; small guns and basic supports |
|
||||||
|
| mid | titanium_ore | mined (3x slower than iron) | cruiser, battlecruiser; m guns, drone bay, weapon modifiers |
|
||||||
|
| late | advanced_alloy | ONLY from reprocessing salvaged scrap | battleship, dreadnought, carrier; l guns, drone hangar |
|
||||||
|
|
||||||
|
The advanced_alloy gate is the core loop hook: capital ship production
|
||||||
|
requires fighting (salvaging scrap from kills and reprocessing it), not just
|
||||||
|
mining. The reprocessing plant turns 5 scrap into iron/copper/titanium ingots
|
||||||
|
or advanced_alloy probabilistically.
|
||||||
|
|
||||||
|
Intermediate components, by tier:
|
||||||
|
|
||||||
|
- **Tier 2 (early):** copper_wire (copper), steel_plate (iron), circuit_board
|
||||||
|
(iron + wire), building_block (iron).
|
||||||
|
- **Tier 3 (mid):** mechanical_parts (steel + iron), targeting_unit (circuits
|
||||||
|
+ wire), drive_unit (steel + mechanical_parts + circuit), titanium_frame
|
||||||
|
(titanium + steel).
|
||||||
|
- **Tier 4 (late):** reinforced_plating (steel + advanced_alloy),
|
||||||
|
capital_core (targeting_unit + drive_unit + 2 advanced_alloy).
|
||||||
|
|
||||||
|
Hulls and modules consume intermediates of their tier: early items are built
|
||||||
|
from tier-2 parts, midgame items require tier-3 parts (deeper chains, more
|
||||||
|
assemblers), capital items require tier-4 parts (and therefore combat). Hull
|
||||||
|
items are named `<ship>_hull`; module items `<module>_module`. Every item has
|
||||||
|
an `[items.*]` entry in visuals.toml; hull item outlines match the ship's
|
||||||
|
fleet color from `[ships.*]`.
|
||||||
|
|
||||||
|
Consistency is checked by `tools/verify_recipes.py` — re-run it after editing
|
||||||
|
recipes, ship/module materials, or visuals:
|
||||||
|
|
||||||
|
python dota_factory/tools/verify_recipes.py
|
||||||
|
|
||||||
|
It verifies every consumed item has a producer, every item has a visuals
|
||||||
|
entry, flags orphaned items, and prints which items are reprocessing-only
|
||||||
|
(currently exactly advanced_alloy).
|
||||||
|
|
||||||
|
## Deliberate placeholders / open questions for later passes
|
||||||
|
|
||||||
|
- All new hulls have `threat.cost_formula = "0"` so enemy waves do not spawn
|
||||||
|
them yet (WaveSystem treats any ship with positive threat cost as wave-
|
||||||
|
eligible, regardless of unlock level). The balancing pass should set real
|
||||||
|
threat costs together with `default_modules` loadouts so waves spawn them
|
||||||
|
armed.
|
||||||
|
- All new hulls and all assembler recipes are `unlock_at_station_level = -1`
|
||||||
|
(available from the start) to make testing easy; the balancing pass should
|
||||||
|
stagger these so mid/lategame recipes drop as schematics from enemy defence
|
||||||
|
stations.
|
||||||
|
- Recipe quantities and durations are a first guess, deliberately roughly
|
||||||
|
tiered (capital hulls ~60 s, drones 4 s); the balancing pass tunes them.
|
||||||
|
- `drone_bay` and `drone_hangar` are footprint-only placeholders: the drone
|
||||||
|
launching capability does not exist in the simulation yet, so they define
|
||||||
|
no capability section.
|
||||||
|
- Renames in this pass: `laser_cannon_xs` → `laser_cannon_s` (the old 2x2
|
||||||
|
`laser_cannon_s` became `laser_cannon_m`), `armor_plate` → `armor_plates`,
|
||||||
|
`manuvering_thrusters` → `maneuvering_thrusters` (typo fix). Test data
|
||||||
|
under `bin/test/data/config` intentionally still uses the old ids — it is
|
||||||
|
an independent fixture set.
|
||||||
@@ -6,9 +6,9 @@ Config files use the TOML format. The following config files drive game paramete
|
|||||||
|
|
||||||
- **world.toml** — world dimensions, region widths, expansion amounts, building refund percentage, wave timing, boss wave timing, enemy ship level formula, belt speed, starting building blocks, departure interval.
|
- **world.toml** — world dimensions, region widths, expansion amounts, building refund percentage, wave timing, boss wave timing, enemy ship level formula, belt speed, starting building blocks, departure interval.
|
||||||
- **buildings.toml** — building block cost and construction time per building type.
|
- **buildings.toml** — building block cost and construction time per building type.
|
||||||
- **recipes.toml** — crafting recipes: inputs, outputs, quantities, durations, and reprocessing plant probabilities.
|
- **recipes.toml** — crafting recipes: inputs, outputs, quantities, durations, and reprocessing plant probabilities. Assembler recipe entries may optionally define `unlock_at_station_level` (integer): -1 means the recipe is explicitly unlocked at game start; a value ≥ 0 means the recipe starts locked and a schematic for it can be awarded via defence station destruction (see REQ-LOCK-EXPLICIT, REQ-DEF-SCHEMATIC-DROP).
|
||||||
- **ships.toml** — per schematic: a human-readable display name (used in toasts and UI), hull stats (HP, max linear speed, sensor range, main acceleration, maneuvering acceleration, angular acceleration, max rotation speed) as formulas of ship level, required build materials, threat cost formula, player production level, whether the schematic is available from game start, a layout grid defining the ship's module slots, and a `default_modules` list used for enemy wave ships (see REQ-WAV-DEFAULT-MODULES).
|
- **ships.toml** — per schematic: a human-readable display name (used in the UI), hull stats (HP, max linear speed, sensor range, main acceleration, maneuvering acceleration, angular acceleration, max rotation speed) as formulas of ship level, required build materials, player production level, the station level at which the schematic becomes available for unlock (`unlock_at_station_level`; -1 means the player starts with the schematic already unlocked), a layout grid defining the ship's module slots, a `scrap_drop` loot value, and a `default_modules` list used for enemy wave ships (see REQ-WAV-DEFAULT-MODULES).
|
||||||
- **modules.toml** — per module type: id, surface mask, materials list, player production level, production time, threat cost, fill color, glyph, and an optional capability section and/or stat modifier formulas. A module with a capability section (`[module.weapon]`, `[module.salvage]`, or `[module.repair]`) containing base stat formulas is a **capability module** that grants the ship a weapon, salvage bay, or repair tool per instance (see REQ-MOD-CONFIG for the full list of formulas per capability type). A module with only `added_*`/`multiplied_*` formulas is a **passive module** that modifies stats on the ship or on capability module instances (see REQ-MOD-STAT-CALC).
|
- **modules.toml** — per module type: id, surface mask, materials list, initial player production level, production time, fill color, glyph, the station level at which the schematic becomes available for unlock (`unlock_at_station_level`; -1 means the player starts with the module schematic already unlocked), and an optional capability section and/or stat modifier formulas. A module with a capability section (`[module.weapon]`, `[module.salvage]`, or `[module.repair]`) containing base stat formulas is a **capability module** that grants the ship a weapon, salvage bay, or repair tool per instance (see REQ-MOD-CONFIG for the full list of formulas per capability type). A module with only `added_*`/`multiplied_*` formulas is a **passive module** that modifies stats on the ship or on capability module instances (see REQ-MOD-STAT-CALC).
|
||||||
- **stations.toml** — HP, damage, range, fire rate, and scrap drop for player and enemy defence stations, defined as formulas of station level.
|
- **stations.toml** — HP, damage, range, fire rate, and scrap drop for player and enemy defence stations, defined as formulas of station level.
|
||||||
- **visuals.toml** — rendering-only config (not game parameters): fill and outline colors and glyphs for every building type, item type, ship schematic, and station type; beam color and width; overlay and toast colors. Loaded by the UI at startup; the simulation does not read it.
|
- **visuals.toml** — rendering-only config (not game parameters): fill and outline colors and glyphs for every building type, item type, ship schematic, and station type; beam color and width; overlay and toast colors. Loaded by the UI at startup; the simulation does not read it.
|
||||||
- **ship_layouts.toml** — named layout blueprints per ship type; written and read by the application to persist the layout blueprint panel (REQ-MOD-UI-BLUEPRINT-PANEL through REQ-MOD-UI-BLUEPRINT-FILE-LOAD). Not a game parameter file; the simulation does not read it.
|
- **ship_layouts.toml** — named layout blueprints per ship type; written and read by the application to persist the layout blueprint panel (REQ-MOD-UI-BLUEPRINT-PANEL through REQ-MOD-UI-BLUEPRINT-FILE-LOAD). Not a game parameter file; the simulation does not read it.
|
||||||
@@ -107,14 +107,14 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
|
|
||||||
## Building Types
|
## Building Types
|
||||||
|
|
||||||
- REQ-BLD-MINER: **Miner** (2×2): The player selects which ore type it extracts. Each ore type corresponds to a `recipes.toml [[recipe]]` entry with `building = "miner"`, defining the output item and `duration_seconds`. Every asteroid tile is equivalent for mining — any miner can produce any ore type based solely on its selected recipe. Ore never depletes.
|
- REQ-BLD-MINER: **Miner** (2×2): The player selects which ore type it extracts. Each ore type corresponds to a `recipes.toml [[recipe]]` entry with `building = "miner"`, defining the output item and `duration_seconds`. Every asteroid tile is equivalent for mining — any miner can produce any ore type based solely on its selected recipe. Ore never depletes. Only implicitly unlocked ore-type recipes are available for selection (REQ-LOCK-UI-RECIPE).
|
||||||
- REQ-BLD-SMELTER: **Smelter** (2×2): Converts ore or scrap into basic materials. No recipe selection required. Inputs, outputs, and rates are defined in `recipes.toml [[recipe]]` entries with `building = "smelter"`.
|
- REQ-BLD-SMELTER: **Smelter** (2×2): Converts ore or scrap into basic materials. No recipe selection required. Inputs, outputs, and rates are defined in `recipes.toml [[recipe]]` entries with `building = "smelter"`.
|
||||||
- REQ-BLD-ASSEMBLER: **Assembler** (3×3): The player selects a recipe from the config-defined crafting tree. Produces the selected output item at the rate defined in the corresponding `recipes.toml [[recipe]]` entry with `building = "assembler"`.
|
- REQ-BLD-ASSEMBLER: **Assembler** (3×3): The player selects a recipe from the config-defined crafting tree. Produces the selected output item at the rate defined in the corresponding `recipes.toml [[recipe]]` entry with `building = "assembler"`. Only implicitly unlocked recipes are available for selection (REQ-LOCK-UI-RECIPE).
|
||||||
- REQ-BLD-REPROCESSING: **Reprocessing Plant** (3×3): Consumes scrap per cycle and produces exactly one higher-level intermediate product per cycle via weighted random pick. The input quantity, possible output items, per-output weights, and amounts are defined in `recipes.toml [[recipe]]` entries with `building = "reprocessing_plant"` (`inputs`, `outputs[].item`, `outputs[].amount`, `outputs[].weight`). Weights are normalized at load time; their sum does not need to equal 1. The output is rolled at cycle start (see REQ-MAT-CYCLE). The output buffer holds at most one cycle's output — see REQ-MAT-OUTPUT-BUFFER-REPROCESSING.
|
- REQ-BLD-REPROCESSING: **Reprocessing Plant** (3×3): Consumes scrap per cycle and produces exactly one higher-level intermediate product per cycle via weighted random pick. The input quantity, possible output items, per-output weights, and amounts are defined in `recipes.toml [[recipe]]` entries with `building = "reprocessing_plant"` (`inputs`, `outputs[].item`, `outputs[].amount`, `outputs[].weight`). Weights are normalized at load time; their sum does not need to equal 1. The output is rolled at cycle start (see REQ-MAT-CYCLE); the pool of eligible outputs is restricted to implicitly unlocked item types (REQ-LOCK-REPROCESSING-POOL). The output buffer holds at most one cycle's output — see REQ-MAT-OUTPUT-BUFFER-REPROCESSING.
|
||||||
- REQ-BLD-SHIPYARD: **Shipyard** (4×2): The player selects a schematic. When all required materials — the ship's base materials (`[ship.schematic].materials`) plus the materials of all modules in the configured layout (REQ-MOD-MATERIALS) — are present in its input buffer, the shipyard consumes them and begins a production cycle lasting the ship's base `[ship.schematic].production_time_seconds` plus the sum of production times contributed by all module instances in the configured layout (REQ-MOD-PRODUCTION-TIME). One ship of that type is spawned at `ships.toml [ship.schematic].player_production_level` (initial value 5, incremented by duplicate schematic drops per REQ-DEF-SCHEMATIC-DROP) with the configured modules when the cycle completes. The shipyard cannot start a new cycle while one is in progress. If the player confirms a layout change (REQ-MOD-UI-DIALOG) while a production cycle is in progress, the current cycle is cancelled and all consumed materials are discarded; the shipyard returns to idle with the new layout configuration.
|
- REQ-BLD-SHIPYARD: **Shipyard** (4×2): The player selects a schematic. When all required materials — the ship's base materials (`[ship.schematic].materials`) plus the materials of all modules in the configured layout (REQ-MOD-MATERIALS) — are present in its input buffer, the shipyard consumes them and begins a production cycle lasting the ship's base `[ship.schematic].production_time_seconds` plus the sum of production times contributed by all module instances in the configured layout (REQ-MOD-PRODUCTION-TIME). One ship of that type is spawned at `ships.toml [ship.schematic].player_production_level` (initial value 5, incremented by duplicate schematic drops per REQ-DEF-SCHEMATIC-DROP) with the configured modules when the cycle completes. The shipyard cannot start a new cycle while one is in progress. If the player confirms a layout change (REQ-MOD-UI-DIALOG) while a production cycle is in progress, the current cycle is cancelled and all consumed materials are discarded; the shipyard returns to idle with the new layout configuration.
|
||||||
- REQ-BLD-SALVAGE-BAY: **Salvage Bay** (3×2): A dedicated drop-off point for salvage ships. Scrap delivered here is placed onto connected output belts.
|
- REQ-BLD-SALVAGE-BAY: **Salvage Bay** (3×2): A dedicated drop-off point for salvage ships. Scrap delivered here is placed onto connected output belts.
|
||||||
- REQ-BLD-BELT: **Belt** (1×1): Transports items. A belt tile has one direction (N, S, E, W) set at placement (modified by rotation). Curved belts are auto-derived: when a belt tile's outgoing direction leads into another belt whose direction is orthogonal, the downstream belt is rendered and behaves as a curve. Belt speed is defined in `world.toml [world].belt_speed_tiles_per_second` (REQ-GW-BELT-SPEED).
|
- REQ-BLD-BELT: **Belt** (1×1): Transports items. A belt tile has one direction (N, S, E, W) set at placement (modified by rotation). Curved belts are auto-derived: when a belt tile's outgoing direction leads into another belt whose direction is orthogonal, the downstream belt is rendered and behaves as a curve. Belt speed is defined in `world.toml [world].belt_speed_tiles_per_second` (REQ-GW-BELT-SPEED).
|
||||||
- REQ-BLD-SPLITTER: **Splitter** (1×1): Distributes incoming items between two output directions. Each output can optionally have a filter (a list of item types), configurable via the selected building panel. Routing rules:
|
- REQ-BLD-SPLITTER: **Splitter** (1×1): Distributes incoming items between two output directions. Each output can optionally have a filter (a list of item types), configurable via the selected building panel; only implicitly unlocked item types are available as filter options (REQ-LOCK-UI-SPLITTER). Routing rules:
|
||||||
- An item matching only one output's filter is routed to that output.
|
- An item matching only one output's filter is routed to that output.
|
||||||
- An item matching both outputs' filters is distributed by strict alternation between those outputs.
|
- An item matching both outputs' filters is distributed by strict alternation between those outputs.
|
||||||
- An item matching neither output's filter is routed to the unfiltered output. If both outputs have a filter and the item matches neither, the splitter stalls and moves no items until the situation is resolved.
|
- An item matching neither output's filter is routed to the unfiltered output. If both outputs have a filter and the item matches neither, the splitter stalls and moves no items until the situation is resolved.
|
||||||
@@ -149,7 +149,7 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
## Ships
|
## Ships
|
||||||
|
|
||||||
- REQ-SHP-AUTONOMOUS: Ships are produced by shipyards and are fully autonomous once produced.
|
- REQ-SHP-AUTONOMOUS: Ships are produced by shipyards and are fully autonomous once produced.
|
||||||
- REQ-SHP-STATS: Base hull stats are defined as formulas of ship level in `ships.toml`: HP (`[ship.health].hp_formula`), max linear speed (`[ship.movement].speed_formula`), sensor range (`[ship.sensors].range_formula`), main acceleration (`[ship.movement].main_acceleration_formula`, tiles/s²), maneuvering acceleration (`[ship.movement].maneuvering_acceleration_formula`, tiles/s²), angular acceleration (`[ship.movement].angular_acceleration_formula`, rad/s²), max rotation speed (`[ship.movement].max_rotation_speed_formula`, rad/s). Required build materials (`[ship.schematic].materials`) and availability from game start (`[[ship]].available_from_start`) are also defined there. Combat, salvage, and repair capabilities are provided by modules (see REQ-MOD-CONFIG). Final hull stats incorporate passive module modifiers per REQ-MOD-STAT-CALC.
|
- REQ-SHP-STATS: Base hull stats are defined as formulas of ship level in `ships.toml`: HP (`[ship.health].hp_formula`), max linear speed (`[ship.movement].speed_formula`), sensor range (`[ship.sensors].range_formula`), main acceleration (`[ship.movement].main_acceleration_formula`, tiles/s²), maneuvering acceleration (`[ship.movement].maneuvering_acceleration_formula`, tiles/s²), angular acceleration (`[ship.movement].angular_acceleration_formula`, rad/s²), max rotation speed (`[ship.movement].max_rotation_speed_formula`, rad/s). Required build materials (`[ship.schematic].materials`) and the station level at which the schematic becomes available for unlock (`[[ship]].unlock_at_station_level`; -1 = player starts with the schematic already unlocked) are also defined there. Combat, salvage, and repair capabilities are provided by modules (see REQ-MOD-CONFIG). Final hull stats incorporate passive module modifiers per REQ-MOD-STAT-CALC.
|
||||||
- REQ-SHP-SPAWN-PLAYER: A ship produced by a shipyard spawns centered on the shipyard's output port tile.
|
- REQ-SHP-SPAWN-PLAYER: A ship produced by a shipyard spawns centered on the shipyard's output port tile.
|
||||||
- REQ-SHP-SPAWN-ENEMY: Enemy ships spawn at a uniformly random position within the current enemy buffer zone — random X across the buffer's width and random Y across the world height.
|
- REQ-SHP-SPAWN-ENEMY: Enemy ships spawn at a uniformly random position within the current enemy buffer zone — random X across the buffer's width and random Y across the world height.
|
||||||
- REQ-SHP-MOVEMENT: Ships move using a physics-based model. Each ship has a velocity and a facing direction, both updated each tick. The main acceleration (`main_acceleration_formula`) is applied along the ship's current facing direction only. The maneuvering acceleration (`maneuvering_acceleration_formula`) can be applied in any direction independently of the facing direction, enabling lateral or braking movement without rotating. The angular acceleration (`angular_acceleration_formula`) controls how quickly the ship rotates. Linear speed is capped at the ship's `speed_formula` value; rotation rate is capped at the ship's `max_rotation_speed_formula` value. Ship position refers to the ship's center for all range, sensor, and attack checks.
|
- REQ-SHP-MOVEMENT: Ships move using a physics-based model. Each ship has a velocity and a facing direction, both updated each tick. The main acceleration (`main_acceleration_formula`) is applied along the ship's current facing direction only. The maneuvering acceleration (`maneuvering_acceleration_formula`) can be applied in any direction independently of the facing direction, enabling lateral or braking movement without rotating. The angular acceleration (`angular_acceleration_formula`) controls how quickly the ship rotates. Linear speed is capped at the ship's `speed_formula` value; rotation rate is capped at the ship's `max_rotation_speed_formula` value. Ship position refers to the ship's center for all range, sensor, and attack checks.
|
||||||
@@ -169,7 +169,7 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
|
|
||||||
Each repair module instance operates independently: it has its own repair rate (`repair_rate`) and repair range (`repair_range`). On each tick, a module first attempts to heal the ship's current behavior-level navigation target if that target is within the module's `repair_range` and is damaged (HP above zero and below maximum HP). If those conditions are not met — because the target is out of the module's `repair_range`, already at full health, or destroyed — the module independently searches for the nearest damaged friendly (player ship or player defence station) within its own `repair_range` and heals that instead. If no valid target is found within range, the module idles. A ship with multiple repair modules can therefore heal different targets simultaneously. Navigation is driven solely by the behavior-level target; individual module fallback targets do not affect which direction the ship moves.
|
Each repair module instance operates independently: it has its own repair rate (`repair_rate`) and repair range (`repair_range`). On each tick, a module first attempts to heal the ship's current behavior-level navigation target if that target is within the module's `repair_range` and is damaged (HP above zero and below maximum HP). If those conditions are not met — because the target is out of the module's `repair_range`, already at full health, or destroyed — the module independently searches for the nearest damaged friendly (player ship or player defence station) within its own `repair_range` and heals that instead. If no valid target is found within range, the module idles. A ship with multiple repair modules can therefore heal different targets simultaneously. Navigation is driven solely by the behavior-level target; individual module fallback targets do not affect which direction the ship moves.
|
||||||
- REQ-SHP-ENEMY-AI: **Enemy ships** — engage the closest valid target (player defence station, HQ, or player ship) within their sensor range. If no target is in sensor range, they move toward the asteroid (leftward in world coordinates).
|
- REQ-SHP-ENEMY-AI: **Enemy ships** — engage the closest valid target (player defence station, HQ, or player ship) within their sensor range. If no target is in sensor range, they move toward the asteroid (leftward in world coordinates).
|
||||||
- REQ-SHP-SCHEMATICS: The player selects a schematic per shipyard by clicking it. New schematics are unlocked automatically when an enemy defence station set is destroyed (REQ-DEF-SCHEMATIC-DROP) — there is no physical loot to collect.
|
- REQ-SHP-SCHEMATICS: The player selects a schematic per shipyard by clicking it. New schematics are unlocked by destroying enemy defence station sets (REQ-DEF-SCHEMATIC-DROP) — there is no physical loot to collect.
|
||||||
|
|
||||||
## Ship Modules
|
## Ship Modules
|
||||||
|
|
||||||
@@ -179,9 +179,9 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
- `id` — unique identifier, also used as the display name in the UI.
|
- `id` — unique identifier, also used as the display name in the UI.
|
||||||
- `surface_mask` — footprint within the ship layout grid (see Module Surface Mask Format).
|
- `surface_mask` — footprint within the ship layout grid (see Module Surface Mask Format).
|
||||||
- `materials` — list of materials required per instance (added to the ship's build cost).
|
- `materials` — list of materials required per instance (added to the ship's build cost).
|
||||||
- `player_production_level` — fixed level for this module type; used as `x` in its stat formulas.
|
- `player_production_level` — initial level for this module type; used as `x` in its stat formulas. Incremented by 1 on each duplicate schematic drop (REQ-DEF-SCHEMATIC-DROP).
|
||||||
|
- `unlock_at_station_level` — the enemy defence station level at which this module's schematic becomes available for unlock; -1 means the player starts with the module schematic already unlocked.
|
||||||
- `production_time_seconds` — time added to the ship's production cycle per instance.
|
- `production_time_seconds` — time added to the ship's production cycle per instance.
|
||||||
- `threat_cost` — threat cost added to the ship's threat cost per instance.
|
|
||||||
- `fill_color` — fill color used to render this module's cells in the layout grid.
|
- `fill_color` — fill color used to render this module's cells in the layout grid.
|
||||||
- `glyph` — single character rendered on this module's cells in the layout grid and preview widget.
|
- `glyph` — single character rendered on this module's cells in the layout grid and preview widget.
|
||||||
- An optional **capability section** (`[module.weapon]`, `[module.salvage]`, or `[module.repair]`) containing base stat formulas. A module with base stat formulas is a capability module — each placed instance grants the ship an independent weapon, salvage bay, or repair tool with its own state (cooldown, target, cargo). A ship may have multiple capability module instances of the same or different types. Base stat formulas per capability type:
|
- An optional **capability section** (`[module.weapon]`, `[module.salvage]`, or `[module.repair]`) containing base stat formulas. A module with base stat formulas is a capability module — each placed instance grants the ship an independent weapon, salvage bay, or repair tool with its own state (cooldown, target, cargo). A ship may have multiple capability module instances of the same or different types. Base stat formulas per capability type:
|
||||||
@@ -202,7 +202,19 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
|
|
||||||
- REQ-MOD-MATERIALS: The total materials required to build a ship are the union of the ship's base `[ship.schematic].materials` and the `materials` of every module instance in the configured layout. Quantities of the same item type are summed.
|
- REQ-MOD-MATERIALS: The total materials required to build a ship are the union of the ship's base `[ship.schematic].materials` and the `materials` of every module instance in the configured layout. Quantities of the same item type are summed.
|
||||||
- REQ-MOD-PRODUCTION-TIME: The total production time is the ship's base `[ship.schematic].production_time_seconds` plus the sum of `production_time_seconds` for every module instance in the configured layout.
|
- REQ-MOD-PRODUCTION-TIME: The total production time is the ship's base `[ship.schematic].production_time_seconds` plus the sum of `production_time_seconds` for every module instance in the configured layout.
|
||||||
- REQ-MOD-THREAT: The total threat cost of a ship is the ship's base `[ship.threat].cost_formula` evaluated at the ship's level, plus the sum of `threat_cost` for every module instance in the configured layout.
|
- REQ-MOD-THREAT: The threat cost of a ship is dynamically derived from the accumulated total production time required to produce that ship from scratch. One second of production time equals one threat. The total production time is the sum of:
|
||||||
|
1. The ship's base `production_time_seconds`.
|
||||||
|
2. The `production_time_seconds` of every module instance in the configured layout.
|
||||||
|
3. For every material required (the union of the ship's base materials and all module instance materials, with quantities summed per item type): the recursive production time of that material multiplied by the required quantity (see REQ-THREAT-ITEM).
|
||||||
|
|
||||||
|
- REQ-THREAT-ITEM: The threat value of an item type (in seconds) is determined by the recipe that produces it:
|
||||||
|
- **Miner recipe**: the recipe's `duration_seconds`.
|
||||||
|
- **Smelter recipe**: the recipe's `duration_seconds` plus the sum of each input's threat value multiplied by that input's required quantity.
|
||||||
|
- **Assembler recipe**: the recipe's `duration_seconds` plus the sum of each input's threat value multiplied by that input's required quantity.
|
||||||
|
- **Reprocessing-only item** (an item type that has no miner, smelter, or assembler recipe producing it, and is only obtainable via reprocessing): `(scrap_threat × scrap_per_cycle + duration_seconds) / probability`, where `scrap_threat` is the threat value of scrap (see REQ-THREAT-SCRAP), `scrap_per_cycle` is the number of scrap consumed per reprocessing cycle, `duration_seconds` is the reprocessing cycle time, and `probability` is the normalized weight of that item in the reprocessing output pool.
|
||||||
|
- **Multiple recipes**: if an item type can be produced by more than one non-reprocessing recipe (miner, smelter, or assembler), its threat value is the **maximum** across all such recipes. The reprocessing path is only used when no other recipe exists.
|
||||||
|
|
||||||
|
- REQ-THREAT-SCRAP: The threat value of scrap is derived from the ship schematic with the smallest configured `scrap_drop` value (from `ships.toml [ship.loot].scrap_drop`). Scrap threat = that ship's threat cost (REQ-MOD-THREAT) / that ship's `scrap_drop` value. If multiple schematics share the same smallest `scrap_drop`, any one of them may be used.
|
||||||
- REQ-MOD-STAT-CALC: For each stat (on the ship hull or on a capability module instance), the final value is computed as: `final = base × total_multiplier + total_additive`, where:
|
- REQ-MOD-STAT-CALC: For each stat (on the ship hull or on a capability module instance), the final value is computed as: `final = base × total_multiplier + total_additive`, where:
|
||||||
- `base` is the stat's base formula evaluated at the ship's production level (for hull stats) or at the capability module's `player_production_level` (for capability module stats).
|
- `base` is the stat's base formula evaluated at the ship's production level (for hull stats) or at the capability module's `player_production_level` (for capability module stats).
|
||||||
- `total_multiplier` = 1 + sum of (m_i − 1) for each multiplicative modifier m_i from all passive module instances. Each m_i is evaluated from the module's multiplicative formula at the module's `player_production_level`.
|
- `total_multiplier` = 1 + sum of (m_i − 1) for each multiplicative modifier m_i from all passive module instances. Each m_i is evaluated from the module's multiplicative formula at the module's `player_production_level`.
|
||||||
@@ -222,11 +234,32 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
- REQ-MOD-UI-DIALOG: Clicking the "Configure" button opens the **layout configuration dialog** as a modal. While the dialog is open, the game is paused (speed set to 0×). On close, the game speed is restored to what it was before the dialog was opened.
|
- REQ-MOD-UI-DIALOG: Clicking the "Configure" button opens the **layout configuration dialog** as a modal. While the dialog is open, the game is paused (speed set to 0×). On close, the game speed is restored to what it was before the dialog was opened.
|
||||||
|
|
||||||
The dialog contains:
|
The dialog contains:
|
||||||
- **Left**: The ship's layout grid rendered at full scale. Buildable cells are white; non-buildable cells are black. Placed modules are rendered with their `fill_color` and `glyph`. The ghost of the currently selected module is shown at the cursor position when in placement mode.
|
- **Top**: The ship's layout grid rendered at full scale. Buildable cells are white; non-buildable cells are black. Placed modules are rendered with their `fill_color` and `glyph`. The ghost of the currently selected module is shown at the cursor position when in placement mode.
|
||||||
- **Center**: A grid of module selection buttons (one per module type defined in `modules.toml`) plus a "Remove" button. Each module button shows the module id and its glyph.
|
- **Left** (below the grid): The ship stats panel (see REQ-MOD-UI-STATS-PANEL).
|
||||||
- **Right**: The layout blueprint panel (see REQ-MOD-UI-BLUEPRINT-PANEL through REQ-MOD-UI-BLUEPRINT-FILE-LOAD).
|
- **Center** (below the grid): A grid of module selection buttons (one per **unlocked** module type; see REQ-DEF-SCHEMATIC-DROP) plus a "Remove" button. Each module button shows the module id and its glyph.
|
||||||
|
- **Right** (below the grid): The layout blueprint panel (see REQ-MOD-UI-BLUEPRINT-PANEL through REQ-MOD-UI-BLUEPRINT-FILE-LOAD).
|
||||||
- **Bottom**: A "Confirm" button and a "Cancel" button. Cancel discards all changes made in this dialog session and closes the dialog. Confirm applies the changes: the shipyard's configured layout is updated, the required materials and cycle time displayed in the selected building panel are recalculated, and the ship layout preview is refreshed.
|
- **Bottom**: A "Confirm" button and a "Cancel" button. Cancel discards all changes made in this dialog session and closes the dialog. Confirm applies the changes: the shipyard's configured layout is updated, the required materials and cycle time displayed in the selected building panel are recalculated, and the ship layout preview is refreshed.
|
||||||
|
|
||||||
|
- REQ-MOD-UI-STATS-PANEL: The **ship stats panel** in the layout configuration dialog shows the stats of the currently configured ship layout as they would be computed at the schematic's `player_production_level`, incorporating all passive module modifiers per REQ-MOD-STAT-CALC. The panel updates in real time whenever modules are placed or removed in the layout grid.
|
||||||
|
|
||||||
|
The panel always shows all hull stats as final computed values:
|
||||||
|
- HP
|
||||||
|
- Max linear speed
|
||||||
|
- Sensor range
|
||||||
|
- Main acceleration
|
||||||
|
- Maneuvering acceleration
|
||||||
|
- Angular acceleration
|
||||||
|
- Max rotation speed
|
||||||
|
|
||||||
|
In addition, the panel shows capability module stats conditioned on which capability module types are present in the current layout:
|
||||||
|
- **Weapons** (shown only if at least one weapon module is placed): combined DPS = Σ(damage_i × attack_rate_i) across all weapon module instances; maximum range = max(attack_range_i) across all weapon module instances.
|
||||||
|
- **Salvage** (shown only if at least one salvage module is placed): combined collection rate = Σ(collection_rate_i) across all salvage module instances; maximum range = max(collection_range_i) across all salvage module instances.
|
||||||
|
- **Repair** (shown only if at least one repair module is placed): combined repair rate = Σ(repair_rate_i) across all repair module instances; maximum range = max(repair_range_i) across all repair module instances.
|
||||||
|
|
||||||
|
All capability module stat values incorporate passive modifiers targeting the relevant capability category per REQ-MOD-STAT-CALC. Each capability module instance uses its own `player_production_level` for formula evaluation.
|
||||||
|
|
||||||
|
While debug draw mode is active (REQ-UI-DEBUG-DRAW), the panel additionally shows the ship's derived threat cost (REQ-MOD-THREAT) for the current layout configuration. This value updates in real time as modules are placed or removed.
|
||||||
|
|
||||||
- REQ-MOD-UI-LAYOUT-SIZE: Ship layouts are small enough to display in the layout configuration dialog without scrolling (maximum grid size fits within the dialog).
|
- REQ-MOD-UI-LAYOUT-SIZE: Ship layouts are small enough to display in the layout configuration dialog without scrolling (maximum grid size fits within the dialog).
|
||||||
|
|
||||||
### Layout Blueprints
|
### Layout Blueprints
|
||||||
@@ -235,7 +268,7 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
|
|
||||||
- REQ-MOD-UI-BLUEPRINT-CREATE: Clicking "Create Blueprint" opens a modal dialog prompting for a name. The dialog has Confirm and Cancel buttons. Clicking Cancel closes the dialog with no effect. Clicking Confirm with a non-empty name creates a blueprint from the module layout currently shown in the left-side layout grid (the in-progress state of the dialog, not the previously confirmed shipyard layout) and appends it to the blueprint list.
|
- REQ-MOD-UI-BLUEPRINT-CREATE: Clicking "Create Blueprint" opens a modal dialog prompting for a name. The dialog has Confirm and Cancel buttons. Clicking Cancel closes the dialog with no effect. Clicking Confirm with a non-empty name creates a blueprint from the module layout currently shown in the left-side layout grid (the in-progress state of the dialog, not the previously confirmed shipyard layout) and appends it to the blueprint list.
|
||||||
|
|
||||||
- REQ-MOD-UI-BLUEPRINT-ENTRY: Each blueprint entry shows the blueprint name and a delete icon ("×") to the right of the name. Clicking the entry (name area) loads that blueprint's module list into the left-side layout grid, replacing all currently placed modules. Module instances that are invalid for the current ship layout (unknown module type, position outside the grid, position on a non-buildable cell, or overlapping another module in the same blueprint) are silently skipped; the remaining valid instances are placed. Clicking the delete icon ("×") removes that blueprint entry from the list immediately.
|
- REQ-MOD-UI-BLUEPRINT-ENTRY: Each blueprint entry shows the blueprint name and a delete icon ("×") to the right of the name. Clicking the entry (name area) loads that blueprint's module list into the left-side layout grid, replacing all currently placed modules. Module instances that are invalid for the current ship layout (unknown module type, locked module type, position outside the grid, position on a non-buildable cell, or overlapping another module in the same blueprint) are silently skipped; the remaining valid instances are placed. Clicking the delete icon ("×") removes that blueprint entry from the list immediately.
|
||||||
|
|
||||||
- REQ-MOD-UI-BLUEPRINT-STARTUP: At application startup, layout blueprints are loaded from `ship_layouts.toml` in the same directory as the application executable. Blueprint entries missing required fields (`name` or `ship_type`) are silently skipped. If the file does not exist, the blueprint list starts empty with no error. If the file exists but cannot be parsed (malformed TOML), a modal error dialog describes the failure and the blueprint list starts empty.
|
- REQ-MOD-UI-BLUEPRINT-STARTUP: At application startup, layout blueprints are loaded from `ship_layouts.toml` in the same directory as the application executable. Blueprint entries missing required fields (`name` or `ship_type`) are silently skipped. If the file does not exist, the blueprint list starts empty with no error. If the file exists but cannot be parsed (malformed TOML), a modal error dialog describes the failure and the blueprint list starts empty.
|
||||||
|
|
||||||
@@ -250,18 +283,55 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
- REQ-DEF-ENEMY-FIRE: Enemy defence stations automatically fire at player ships within range.
|
- REQ-DEF-ENEMY-FIRE: Enemy defence stations automatically fire at player ships within range.
|
||||||
- REQ-DEF-NO-CROSSFIRE: Enemy and player defence stations are never in each other's firing range.
|
- REQ-DEF-NO-CROSSFIRE: Enemy and player defence stations are never in each other's firing range.
|
||||||
- REQ-DEF-PUSH: When both enemy defence stations in a set are destroyed, the boss countdown is advanced (REQ-WAV-BOSS-ADVANCE), the scrollable area is extended (REQ-GW-PUSH-EXPAND), a new set of enemy defence stations is placed at the new boundary, and exactly one schematic drop is awarded for the destroyed set (REQ-DEF-SCHEMATIC-DROP).
|
- REQ-DEF-PUSH: When both enemy defence stations in a set are destroyed, the boss countdown is advanced (REQ-WAV-BOSS-ADVANCE), the scrollable area is extended (REQ-GW-PUSH-EXPAND), a new set of enemy defence stations is placed at the new boundary, and exactly one schematic drop is awarded for the destroyed set (REQ-DEF-SCHEMATIC-DROP).
|
||||||
- REQ-DEF-SCHEMATIC-DROP: Each destroyed set of enemy defence stations awards exactly one schematic drop (not one per station). The drop is automatic — no physical item to collect. A schematic is chosen uniformly at random from all schematics defined in `ships.toml`. If the player does not yet have that schematic, it is unlocked. If the player already has it, the schematic's `[ship.schematic].player_production_level` is incremented by 1 — so subsequent ships of that type are produced at a higher level. The player is notified via a toast (REQ-UI-SCHEMATIC-TOAST).
|
- REQ-DEF-SCHEMATIC-DROP: Each destroyed set of enemy defence stations awards exactly one schematic drop (not one per station). The drop opens a **schematic choice dialog** — a modal dialog that pauses the game (speed set to 0×; on close, speed is restored to what it was before the dialog opened). Up to three schematic options are drawn uniformly at random **without replacement** from the eligible drop pool. If the pool contains fewer than three entries, only that many options are shown. The eligible drop pool contains:
|
||||||
|
- All **ship schematics** and **module schematics** whose `unlock_at_station_level` is -1 or is ≤ the level of the destroyed station set.
|
||||||
|
- All **assembler recipe schematics** whose `unlock_at_station_level` is ≥ 0 and ≤ the level of the destroyed station set, whose output item is currently implicitly unlocked (REQ-LOCK-IMPLICIT), and which have not yet been awarded.
|
||||||
|
|
||||||
|
Each option in the dialog displays: the schematic name (ship `display_name` from `ships.toml`, module `id` from `modules.toml`, or the output item type for assembler recipes), the schematic type (ship, module, or assembler recipe), and whether selecting it would be a **new unlock** or a **level-up** (showing the target level for level-ups). Assembler recipe schematics are always new unlocks since they are removed from the pool once awarded.
|
||||||
|
|
||||||
|
Each option additionally displays a vertical list of item names labeled "Unlocks recipes for:", showing which recipes would newly become implicitly unlocked (REQ-LOCK-IMPLICIT) if this option were selected — specifically, the output items of miner recipes and assembler recipes (without `unlock_at_station_level`) that are not currently implicitly unlocked but would become so after applying this option's effect:
|
||||||
|
- For a ship or module schematic that would be a **new unlock**, its `materials` are added to the base set per REQ-LOCK-IMPLICIT step 1a before recomputation.
|
||||||
|
- For a ship or module schematic **level-up**, the implicit unlock set is unchanged, so the list is always empty.
|
||||||
|
- For an assembler recipe schematic, its output item is added to the base set per REQ-LOCK-IMPLICIT step 1b before recomputation.
|
||||||
|
|
||||||
|
Item names are deduplicated and sorted alphabetically. If no recipes would be newly unlocked, the list shows "None".
|
||||||
|
|
||||||
|
The player selects one option by clicking it. The selected schematic is applied and the dialog closes:
|
||||||
|
|
||||||
|
For a **ship or module schematic**: if the player does not yet have the schematic, it is unlocked (ship schematics unlock the corresponding shipyard selection; module schematics unlock the module type for placement in the layout configuration dialog (REQ-MOD-UI-DIALOG)). If the player already has it, the schematic's `player_production_level` is incremented by 1 — for ship schematics, subsequent ships of that type are produced at a higher level; for module schematics, all instances of that module type use the higher level in their stat formulas.
|
||||||
|
|
||||||
|
For an **assembler recipe schematic**: the recipe is explicitly unlocked and becomes available in the assembler recipe-selection dropdown (subject to REQ-LOCK-UI-RECIPE). The schematic is removed from the drop pool permanently (REQ-LOCK-EXPLICIT). The implicit unlock set is recomputed (REQ-LOCK-IMPLICIT).
|
||||||
|
|
||||||
|
## Progression & Locking
|
||||||
|
|
||||||
|
- REQ-LOCK-EXPLICIT: Ship schematics, module schematics, and **assembler recipe schematics** (assembler recipes in `recipes.toml` that define `unlock_at_station_level`) are **explicitly** locked or unlocked. A schematic starts unlocked if its `unlock_at_station_level` is -1; all others start locked. Locked schematics are unlocked only by REQ-DEF-SCHEMATIC-DROP. Once unlocked, a schematic is never re-locked within a run; lock states reset to their initial values on Restart (REQ-CFG-RELOAD). Unlike ship and module schematics, an assembler recipe schematic is removed from the drop pool permanently once awarded and cannot be dropped again.
|
||||||
|
|
||||||
|
- REQ-LOCK-IMPLICIT: Item types and miner/assembler recipes are **implicitly** unlocked or locked based on the current set of unlocked ship, module, and assembler recipe schematics. The implicit unlock set is recomputed whenever any schematic changes lock state (on Restart or after REQ-DEF-SCHEMATIC-DROP). Computation:
|
||||||
|
1. Start with the union of: (a) all item types listed in `materials` across all currently unlocked ship schematics and all currently unlocked module schematics, and (b) the output item type of every currently explicitly unlocked assembler recipe schematic (REQ-LOCK-EXPLICIT).
|
||||||
|
2. For each item type in the current set: for every recipe (miner, smelter, or assembler) that produces it — skipping any assembler recipe schematic that defines `unlock_at_station_level` and is not yet explicitly unlocked — add each of that recipe's input item types to the set. If the recipe is a miner recipe or an assembler recipe that does not define `unlock_at_station_level`, mark it as implicitly unlocked. Explicitly unlocked assembler recipe schematics are available in the assembler dropdown by virtue of REQ-LOCK-EXPLICIT; their inputs are also added to the implicit set in this step.
|
||||||
|
3. Repeat step 2 until no new item types are added.
|
||||||
|
Item types and miner/assembler recipes not reached by this process (and not explicitly unlocked) are locked. Smelter recipes participate in the traversal to propagate unlocking to their inputs but are never themselves shown in any UI dropdown.
|
||||||
|
|
||||||
|
- REQ-LOCK-REPROCESSING-POOL: The pool of possible outputs for a Reprocessing Plant cycle (REQ-BLD-REPROCESSING) is restricted to item types that are currently implicitly unlocked (REQ-LOCK-IMPLICIT). Weights are renormalized over the eligible outputs. If no eligible outputs remain, the Reprocessing Plant cannot start a production cycle.
|
||||||
|
|
||||||
|
- REQ-LOCK-UI-RECIPE: Locked miner ore-type recipes and assembler recipes are not shown in their respective recipe-selection dropdowns.
|
||||||
|
|
||||||
|
- REQ-LOCK-UI-SCHEMATIC: Locked ship schematics are not shown in the shipyard's schematic-selection dropdown.
|
||||||
|
|
||||||
|
- REQ-LOCK-UI-SPLITTER: Item types that are not implicitly unlocked are excluded from splitter filter dropdowns (REQ-BLD-SPLITTER).
|
||||||
|
|
||||||
|
- REQ-LOCK-UI-BLUEPRINT: When a blueprint is placed (REQ-UI-BLUEPRINT-PLACE): if a stored recipe ID for a miner or assembler is currently locked, that building's recipe is left unset rather than applied; if a stored splitter filter entry refers to a locked item type, that entry is silently removed. (The analogous rule for locked ship schematics is defined in REQ-UI-BLUEPRINT-PLACE.)
|
||||||
|
|
||||||
## Threat Level & Enemy Waves
|
## Threat Level & Enemy Waves
|
||||||
|
|
||||||
- REQ-WAV-BOSS-COUNTER: A global **boss wave counter** `x` starts at 1 at game start and increments by 1 immediately after each boss wave fires. It represents the current boss wave cycle number and is used as the variable in the threat rate and ship level formulas.
|
- REQ-WAV-BOSS-COUNTER: A global **boss wave counter** `x` starts at 1 at game start and increments by 1 immediately after each boss wave fires. It represents the current boss wave cycle number and is used as the variable in the threat rate and ship level formulas.
|
||||||
- REQ-WAV-THREAT-RATE: A global **threat level** accumulates continuously over real game time. The rate of increase per second is determined by `world.toml [waves].threat_rate_formula` where `x` is the boss wave counter (REQ-WAV-BOSS-COUNTER), clamped to a minimum of 0 (negative formula values are treated as 0). The rate is constant within each boss wave cycle and steps up each time `x` increments. Threat accumulation continues uninterrupted during quiet windows (REQ-WAV-QUIET). Example: `1*x - 30` yields 0 threat/s when x ≤ 30 and increases linearly beyond that.
|
- REQ-WAV-THREAT-RATE: A global **threat level** accumulates continuously over real game time. The rate of increase per second is determined by `world.toml [waves].threat_rate_formula` where `x` is the boss wave counter (REQ-WAV-BOSS-COUNTER), clamped to a minimum of 0 (negative formula values are treated as 0). The rate is constant within each boss wave cycle and steps up each time `x` increments. Threat accumulation is paused during quiet windows (REQ-WAV-QUIET). Example: `1*x - 30` yields 0 threat/s when x ≤ 30 and increases linearly beyond that.
|
||||||
- REQ-WAV-GAP: At game start and immediately after each normal wave is triggered, a random inter-wave gap is drawn uniformly from [`world.toml [waves].gap_min_seconds`, `gap_max_seconds`]. The gap timer does not advance while inside a quiet window (REQ-WAV-QUIET); if a gap would expire inside a quiet window, its expiry is deferred until the quiet window ends.
|
- REQ-WAV-GAP: At game start and immediately after each normal wave is triggered, a random inter-wave gap is drawn uniformly from [`world.toml [waves].gap_min_seconds`, `gap_max_seconds`]. The gap timer does not advance while inside a quiet window (REQ-WAV-QUIET); if a gap would expire inside a quiet window, its expiry is deferred until the quiet window ends.
|
||||||
- REQ-WAV-TRIGGER: When the gap timer expires outside a quiet window, a normal wave is triggered. Ships are selected one at a time: from all schematics whose `threat.cost_formula` evaluates to > 0 at the current enemy ship level, uniformly randomly pick one whose cost fits the remaining threat budget. Repeat until no eligible schematic fits. Any remaining threat carries over to the next normal wave. A longer gap results in a larger wave. Because enemy ship level increases with the boss wave counter (REQ-WAV-SHIP-LEVEL), threat cost per ship rises as the game progresses.
|
- REQ-WAV-TRIGGER: When the gap timer expires outside a quiet window, a normal wave is triggered. Ships are selected one at a time: from all schematics whose threat cost (REQ-MOD-THREAT) is > 0, uniformly randomly pick one whose cost fits the remaining threat budget. For wave ship selection, the threat cost is computed using the schematic's `default_modules` layout (REQ-WAV-DEFAULT-MODULES). Repeat until no eligible schematic fits. Any remaining threat carries over to the next normal wave. A longer gap results in a larger wave.
|
||||||
- REQ-WAV-SHIP-LEVEL: Each wave's (normal and boss) enemy ships are assigned a level determined by `world.toml [waves].ship_level_formula` where `x` is the boss wave counter (REQ-WAV-BOSS-COUNTER). Per-ship stats and threat cost are computed from the ship level via the formulas in `ships.toml` (see REQ-SHP-STATS).
|
- REQ-WAV-SHIP-LEVEL: Each wave's (normal and boss) enemy ships are assigned a level determined by `world.toml [waves].ship_level_formula` where `x` is the boss wave counter (REQ-WAV-BOSS-COUNTER). Per-ship stats are computed from the ship level via the formulas in `ships.toml` (see REQ-SHP-STATS). Threat cost is level-independent (REQ-MOD-THREAT).
|
||||||
- REQ-WAV-BOSS-COUNTDOWN: A **boss countdown** timer starts at `world.toml [waves].boss_countdown_seconds` (default 300) at game start and counts down continuously in real game-time seconds. It is not paused during quiet windows. When it reaches 0, a boss wave is triggered (REQ-WAV-BOSS-TRIGGER). Immediately after the boss wave fires, `x` increments (REQ-WAV-BOSS-COUNTER) and a fresh countdown starts at the same configured value.
|
- REQ-WAV-BOSS-COUNTDOWN: A **boss countdown** timer starts at `world.toml [waves].boss_countdown_seconds` (default 300) at game start and counts down continuously in real game-time seconds. It is not paused during quiet windows. When it reaches 0, a boss wave is triggered (REQ-WAV-BOSS-TRIGGER). Immediately after the boss wave fires, `x` increments (REQ-WAV-BOSS-COUNTER) and a fresh countdown starts at the same configured value.
|
||||||
- REQ-WAV-BOSS-ADVANCE: When the player destroys a set of enemy defence stations, the boss countdown is reduced by `world.toml [push].boss_advance_seconds` (default 60), clamped to a minimum of 0. Threat that would have accumulated during the skipped time is not added. If the countdown reaches 0 by this reduction, the boss wave is triggered immediately.
|
- REQ-WAV-BOSS-ADVANCE: When the player destroys a set of enemy defence stations, the boss countdown is reduced by `world.toml [push].boss_advance_seconds` (default 60), clamped to a minimum of 0. Threat that would have accumulated during the skipped time is not added. If the countdown reaches 0 by this reduction, the boss wave is triggered immediately.
|
||||||
- REQ-WAV-QUIET: A **quiet window** suppresses normal wave spawning around each boss wave. The pre-boss quiet window begins when the boss countdown falls to or below `world.toml [waves].boss_quiet_before_seconds` and ends when the countdown reaches 0. The post-boss quiet window begins immediately when the boss wave fires and lasts `world.toml [waves].boss_quiet_after_seconds` seconds. Threat continues to accumulate during both windows. The normal wave gap timer does not advance during either window (REQ-WAV-GAP). The new boss countdown runs during the post-boss quiet window.
|
- REQ-WAV-QUIET: A **quiet window** suppresses normal wave spawning around each boss wave. The pre-boss quiet window begins when the boss countdown falls to or below `world.toml [waves].boss_quiet_before_seconds` and ends when the countdown reaches 0. The post-boss quiet window begins immediately when the boss wave fires and lasts `world.toml [waves].boss_quiet_after_seconds` seconds. Threat accumulation is paused during both windows. The normal wave gap timer does not advance during either window (REQ-WAV-GAP). The new boss countdown runs during the post-boss quiet window.
|
||||||
- REQ-WAV-BOSS-TRIGGER: When the boss countdown reaches 0, a boss wave is triggered. Its threat budget is the sum of: (a) `world.toml [waves].boss_threat_duration_seconds` (default 60) multiplied by the current threat rate, and (b) all unspent threat carried over from normal waves. Ships are selected using the same random process as normal waves (REQ-WAV-TRIGGER). Any threat remaining unspent after ship selection carries over to the first normal wave of the new cycle.
|
- REQ-WAV-BOSS-TRIGGER: When the boss countdown reaches 0, a boss wave is triggered. Its threat budget is the sum of: (a) `world.toml [waves].boss_threat_duration_seconds` (default 60) multiplied by the current threat rate, and (b) all unspent threat carried over from normal waves. Ships are selected using the same random process as normal waves (REQ-WAV-TRIGGER). Any threat remaining unspent after ship selection carries over to the first normal wave of the new cycle.
|
||||||
- REQ-WAV-DEFAULT-MODULES: Enemy ships spawned by waves use the `default_modules` list defined per schematic in `ships.toml`. The `default_modules` array uses the same format as layout blueprints (see Layout Blueprint TOML Format). If `default_modules` is absent or empty, the ship spawns with no modules. Invalid module instances (unknown type, position outside the grid, position on a non-buildable cell, or overlapping another module) are silently skipped.
|
- REQ-WAV-DEFAULT-MODULES: Enemy ships spawned by waves use the `default_modules` list defined per schematic in `ships.toml`. The `default_modules` array uses the same format as layout blueprints (see Layout Blueprint TOML Format). If `default_modules` is absent or empty, the ship spawns with no modules. Invalid module instances (unknown type, position outside the grid, position on a non-buildable cell, or overlapping another module) are silently skipped.
|
||||||
- REQ-WAV-SPAWN-DURATION: Ships in a wave are spawned one at a time over `world.toml [waves].spawn_duration_seconds`.
|
- REQ-WAV-SPAWN-DURATION: Ships in a wave are spawned one at a time over `world.toml [waves].spawn_duration_seconds`.
|
||||||
@@ -279,27 +349,30 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
|||||||
|
|
||||||
### Layout
|
### Layout
|
||||||
|
|
||||||
The screen is divided into three vertical sections:
|
The screen is divided into two columns: a main column (75% width) containing the header bar and game world, and a side panel column (25% width) containing the three UI panels stacked vertically:
|
||||||
|
|
||||||
```
|
```
|
||||||
+--------------------------------------------------+
|
+--------------------------------------+--------------+
|
||||||
| Header Bar |
|
| Header Bar | |
|
||||||
+--------------------------------------------------+
|
+--------------------------------------+ Selected |
|
||||||
| |
|
| | Building |
|
||||||
| Game World (70%) |
|
| | Panel |
|
||||||
| |
|
| +--------------+
|
||||||
+-----------------+-----------------+--------------+
|
| Game World | Build |
|
||||||
| Selected | Build Button | Blueprint |
|
| | Button |
|
||||||
| Building Panel | Grid | Panel |
|
| | Grid |
|
||||||
| (left) | (center) | (right) |
|
| +--------------+
|
||||||
+-----------------+-----------------+--------------+
|
| | Blueprint |
|
||||||
|
| | Panel |
|
||||||
|
+--------------------------------------+--------------+
|
||||||
|
(75% width) (25% width)
|
||||||
```
|
```
|
||||||
|
|
||||||
- REQ-UI-HEADER: The header bar spans the full width above the game world and always shows the elapsed survival time and the current global building blocks stock on the left, the boss wave counter and boss countdown (REQ-UI-BOSS-STATUS) to the left of the speed buttons, and game speed controls on the right.
|
- REQ-UI-HEADER: The header bar spans the width of the game world column (75% of the screen width) and always shows the elapsed survival time and the current global building blocks stock on the left, the boss wave counter and boss countdown (REQ-UI-BOSS-STATUS) to the left of the speed buttons, and game speed controls on the right.
|
||||||
- REQ-UI-BOSS-STATUS: The header bar displays, to the left of the speed buttons, the current boss wave counter (REQ-WAV-BOSS-COUNTER) and the time remaining on the boss countdown (REQ-WAV-BOSS-COUNTDOWN). The boss wave counter is shown as `Boss Wave #<x>` and the countdown as `Next boss: <M:SS>`, where `<M:SS>` is the remaining seconds formatted as whole minutes and two-digit seconds. Both values update continuously as the simulation runs.
|
- REQ-UI-BOSS-STATUS: The header bar displays, to the left of the speed buttons, the current boss wave counter (REQ-WAV-BOSS-COUNTER) and the time remaining on the boss countdown (REQ-WAV-BOSS-COUNTDOWN). The boss wave counter is shown as `Boss Wave #<x>` and the countdown as `Next boss: <M:SS>`, where `<M:SS>` is the remaining seconds formatted as whole minutes and two-digit seconds. Both values update continuously as the simulation runs.
|
||||||
- REQ-UI-SPEED: The game speed controls in the header bar are buttons for 0×, 0.5×, 1×, 2×, and 4× speed. The currently active speed is shown as selected. All game simulation (production, movement, threat accumulation, wave timing) scales with the selected speed. 0× pauses the game.
|
- REQ-UI-SPEED: The game speed controls in the header bar are buttons for 0×, 0.5×, 1×, 2×, and 4× speed. The currently active speed is shown as selected. All game simulation (production, movement, threat accumulation, wave timing) scales with the selected speed. 0× pauses the game.
|
||||||
- REQ-UI-WORLD-HEIGHT: The game world view occupies 70% of the remaining screen height below the header bar.
|
- REQ-UI-WORLD-SIZE: The game world view occupies the full height below the header bar in the main column (75% of the screen width).
|
||||||
- REQ-UI-PANEL-HEIGHT: The UI panel occupies the remaining 30% of the screen height, split horizontally into a selected building panel (left), a build button grid (center), and a blueprint panel (right).
|
- REQ-UI-PANEL-COLUMN: The side panel column occupies 25% of the screen width and the full screen height. It is divided into three equal-height panels stacked top to bottom: selected building panel (top), build button grid (middle), and blueprint panel (bottom).
|
||||||
|
|
||||||
### Game World
|
### Game World
|
||||||
|
|
||||||
@@ -308,11 +381,6 @@ The screen is divided into three vertical sections:
|
|||||||
- REQ-UI-PORT-GLYPH: Every output port of every building is indicated by a directional glyph drawn on the port's tile. The glyph is a `>` rotated to face the port's exit direction (`>` for East, `^` for North, `<` for West, `v` for South). It is drawn at the midpoint between the tile center and the tile edge that the port exits through (i.e. halfway from center toward the exit edge). The indicator is rendered for all building states: operational buildings, construction sites, and the builder-mode ghost. Buildings with multiple output ports (e.g. splitters) show one indicator per port.
|
- REQ-UI-PORT-GLYPH: Every output port of every building is indicated by a directional glyph drawn on the port's tile. The glyph is a `>` rotated to face the port's exit direction (`>` for East, `^` for North, `<` for West, `v` for South). It is drawn at the midpoint between the tile center and the tile edge that the port exits through (i.e. halfway from center toward the exit edge). The indicator is rendered for all building states: operational buildings, construction sites, and the builder-mode ghost. Buildings with multiple output ports (e.g. splitters) show one indicator per port.
|
||||||
- REQ-UI-HP-BARS: All entities with HP — the HQ, player and enemy defence stations, and player and enemy ships — render an HP bar below them. The bar is always visible regardless of current HP. The bar's filled portion represents the fraction of current HP to maximum HP.
|
- REQ-UI-HP-BARS: All entities with HP — the HQ, player and enemy defence stations, and player and enemy ships — render an HP bar below them. The bar is always visible regardless of current HP. The bar's filled portion represents the fraction of current HP to maximum HP.
|
||||||
- REQ-UI-NO-ZOOM: The view has a fixed zoom level; the player cannot zoom in or out.
|
- REQ-UI-NO-ZOOM: The view has a fixed zoom level; the player cannot zoom in or out.
|
||||||
- REQ-UI-SCHEMATIC-TOAST: When a schematic is unlocked or leveled up (REQ-DEF-SCHEMATIC-DROP), a transient notification toast appears in the top-right corner of the game world view for 4 seconds and then fades out. `<Ship Name>` in the text below is the schematic's `ships.toml [ship.schematic].display_name`. Toast text:
|
|
||||||
- **New unlock**: `Schematic unlocked: <Ship Name>`
|
|
||||||
- **Level-up (duplicate drop)**: `<Ship Name> production level → N` (where N is the new level).
|
|
||||||
|
|
||||||
If multiple toasts arrive in close succession, they stack vertically in a queue (most recent at the top) and each fades out independently after its own 4-second lifetime.
|
|
||||||
- REQ-UI-HOTKEYS: Global keyboard shortcuts:
|
- REQ-UI-HOTKEYS: Global keyboard shortcuts:
|
||||||
- **Space** — toggles pause. Pressing Space pauses (sets speed to 0×) and stores the previously selected non-zero speed; pressing Space again restores that speed.
|
- **Space** — toggles pause. Pressing Space pauses (sets speed to 0×) and stores the previously selected non-zero speed; pressing Space again restores that speed.
|
||||||
- **W** — increases game speed by one step in the sequence 0×, 0.5×, 1×, 2×, 4× (no wrap-around past 4×).
|
- **W** — increases game speed by one step in the sequence 0×, 0.5×, 1×, 2×, 4× (no wrap-around past 4×).
|
||||||
@@ -326,6 +394,13 @@ The screen is divided into three vertical sections:
|
|||||||
|
|
||||||
- REQ-UI-DEBUG-DRAW: A debug draw mode can be toggled on and off with the **M** key (REQ-UI-HOTKEYS). It is inactive by default. While active, the sensor range of every ship — both player and enemy — is drawn as a circle centered on the ship, using that ship schematic's outline color from `visuals.toml`.
|
- REQ-UI-DEBUG-DRAW: A debug draw mode can be toggled on and off with the **M** key (REQ-UI-HOTKEYS). It is inactive by default. While active, the sensor range of every ship — both player and enemy — is drawn as a circle centered on the ship, using that ship schematic's outline color from `visuals.toml`.
|
||||||
|
|
||||||
|
- REQ-UI-DEBUG-OVERLAY: While debug draw mode is active (REQ-UI-DEBUG-DRAW), a text overlay is drawn in the upper left corner of the game world view. The overlay has a semi-transparent black background sized to fit its content. It displays the following lines of text:
|
||||||
|
- `Accumulated Threat Level: <level>` — where `<level>` is the current accumulated threat level (see REQ-WAV-THREAT-RATE).
|
||||||
|
- `Time until Wave: <time_s>` — where `<time_s>` is the remaining time in seconds on the normal-wave inter-wave gap timer (see REQ-WAV-GAP). During a quiet window the gap timer is frozen; the displayed value reflects that frozen state.
|
||||||
|
- `Threat Accumulation Rate: <rate> threat/s` — the rate at which the accumulated threat level is currently increasing (see REQ-WAV-THREAT-RATE). During a quiet window (REQ-WAV-QUIET), this is 0, reflecting that accumulation is currently paused.
|
||||||
|
- `Max Factory Production: <rate> threat/s` — the threat-equivalent of the factory's total possible production: 1 threat/second for each completed (operational, not under construction) miner, smelter, assembler, reprocessing plant, and shipyard. One second of production equals one threat (see REQ-MOD-THREAT).
|
||||||
|
- `Current Factory Production: <rate> threat/s` — the threat-equivalent of the factory's current production: 1 threat/second for each completed miner, smelter, assembler, reprocessing plant, or shipyard that currently has an active production cycle (see REQ-MAT-CYCLE; for shipyards, an in-progress production cycle per REQ-BLD-SHIPYARD).
|
||||||
|
|
||||||
### Escape Menu
|
### Escape Menu
|
||||||
|
|
||||||
- REQ-UI-GAME-MENU: Pressing Escape at any time opens the escape menu as a modal dialog and pauses the simulation (sets speed to 0×). On close, the simulation speed is restored to what it was before the menu was opened — so if the game was already paused, it remains paused. The menu contains three buttons:
|
- REQ-UI-GAME-MENU: Pressing Escape at any time opens the escape menu as a modal dialog and pauses the simulation (sets speed to 0×). On close, the simulation speed is restored to what it was before the menu was opened — so if the game was already paused, it remains paused. The menu contains three buttons:
|
||||||
@@ -343,6 +418,9 @@ The screen is divided into three vertical sections:
|
|||||||
- REQ-UI-MULTI-SELECTION: When multiple buildings are selected, the panel shows how many of each building type are selected. No per-building detail is shown.
|
- REQ-UI-MULTI-SELECTION: When multiple buildings are selected, the panel shows how many of each building type are selected. No per-building detail is shown.
|
||||||
- REQ-UI-CONFIG-INLINE: Recipe, schematic, ship stance, and target priority configuration for a selected building is shown and changed inline within this panel. For shipyards, the panel additionally shows the ship layout preview and "Configure" button below the schematic dropdown (REQ-MOD-UI-PREVIEW).
|
- REQ-UI-CONFIG-INLINE: Recipe, schematic, ship stance, and target priority configuration for a selected building is shown and changed inline within this panel. For shipyards, the panel additionally shows the ship layout preview and "Configure" button below the schematic dropdown (REQ-MOD-UI-PREVIEW).
|
||||||
- REQ-UI-BELT-CLEAR: When one or more belt, splitter, tunnel entry, or tunnel exit tiles are selected, the panel shows a "Clear" button that removes all items from the selected tiles. Clearing a tunnel entry or exit also discards all items currently in transit through that tunnel (REQ-BLD-TUNNEL-TRANSIT). This can be used to resolve stalled belts, splitters, and tunnels.
|
- REQ-UI-BELT-CLEAR: When one or more belt, splitter, tunnel entry, or tunnel exit tiles are selected, the panel shows a "Clear" button that removes all items from the selected tiles. Clearing a tunnel entry or exit also discards all items currently in transit through that tunnel (REQ-BLD-TUNNEL-TRANSIT). This can be used to resolve stalled belts, splitters, and tunnels.
|
||||||
|
- REQ-UI-ENTITY-CLICK-SELECT: The player can click any ship (player or enemy) or any defence station (player or enemy) in the game world to select it. Clicking a ship or defence station clears any existing selection and establishes a single-entity selection containing only that entity. Ships and defence stations cannot participate in multi-select together with buildings. Clicking empty world space (no building, ship, or defence station) clears the selection.
|
||||||
|
- REQ-UI-SHIP-STATS-PANEL: When a single ship is selected (REQ-UI-ENTITY-CLICK-SELECT), the selected building panel shows a **ship stats panel**. The panel structure mirrors REQ-MOD-UI-STATS-PANEL but reflects the ship's actual live state: stats are computed at the ship's actual level with its installed modules per REQ-MOD-STAT-CALC. The panel always shows all hull stats: HP (current / maximum), max linear speed, sensor range, main acceleration, maneuvering acceleration, angular acceleration, and max rotation speed. In addition, capability module summaries are shown conditioned on which module types are installed, using the same aggregation rules as REQ-MOD-UI-STATS-PANEL: weapons (combined DPS, maximum range), salvage (combined collection rate, maximum range), and repair (combined repair rate, maximum range), each section appearing only if at least one instance of that module type is installed. While debug draw mode is active (REQ-UI-DEBUG-DRAW), the panel additionally shows the ship's derived threat cost (REQ-MOD-THREAT).
|
||||||
|
- REQ-UI-STATION-STATS-PANEL: When a single defence station is selected (REQ-UI-ENTITY-CLICK-SELECT), the selected building panel shows a **station stats panel** displaying the station's stats computed at its current level: HP (current / maximum), damage, range, and fire rate.
|
||||||
|
|
||||||
### Build Button Grid
|
### Build Button Grid
|
||||||
|
|
||||||
@@ -363,7 +441,7 @@ The screen is divided into three vertical sections:
|
|||||||
|
|
||||||
- REQ-UI-BLUEPRINT-MODE: In blueprint placement mode a ghost is rendered for every building in the blueprint at the position determined by its stored tile offset from the bounding-box center, which is anchored to the tile under the cursor. Each ghost is rendered individually as valid or invalid, applying REQ-BLD-PLACE-VALID conditions (a) and (b) per building (the other ghosts in the same blueprint do not count as existing buildings for the overlap check). Pressing Q/E rotates the entire constellation 90° counter-clockwise / clockwise: each building's tile offset is rotated around the bounding-box center and each building's own rotation is updated, consistent with REQ-BLD-ROTATE. Blueprint placement mode is exited by right-clicking in the game world. Clicking a different blueprint button exits the current mode and enters blueprint placement mode for the newly clicked blueprint.
|
- REQ-UI-BLUEPRINT-MODE: In blueprint placement mode a ghost is rendered for every building in the blueprint at the position determined by its stored tile offset from the bounding-box center, which is anchored to the tile under the cursor. Each ghost is rendered individually as valid or invalid, applying REQ-BLD-PLACE-VALID conditions (a) and (b) per building (the other ghosts in the same blueprint do not count as existing buildings for the overlap check). Pressing Q/E rotates the entire constellation 90° counter-clockwise / clockwise: each building's tile offset is rotated around the bounding-box center and each building's own rotation is updated, consistent with REQ-BLD-ROTATE. Blueprint placement mode is exited by right-clicking in the game world. Clicking a different blueprint button exits the current mode and enters blueprint placement mode for the newly clicked blueprint.
|
||||||
|
|
||||||
- REQ-UI-BLUEPRINT-PLACE: Left-clicking in blueprint placement mode places the blueprint if (a) every building in the constellation satisfies REQ-BLD-PLACE-VALID conditions (a) and (b) at its resolved tile, and (b) the player has enough building blocks to afford the total cost. If both conditions are met, a construction site is added to the build queue for each building in the blueprint and the full total cost is deducted from the global building blocks stock in one transaction. If a recipe ID is stored for a building, it is applied to the construction site immediately. If a schematic ID is stored, it is applied only if that schematic is currently unlocked; if it is not unlocked, the shipyard's schematic is left unset. After a successful placement the game remains in blueprint placement mode, allowing the player to place the same blueprint again immediately.
|
- REQ-UI-BLUEPRINT-PLACE: Left-clicking in blueprint placement mode places the blueprint if (a) every building in the constellation satisfies REQ-BLD-PLACE-VALID conditions (a) and (b) at its resolved tile, and (b) the player has enough building blocks to afford the total cost. If both conditions are met, a construction site is added to the build queue for each building in the blueprint and the full total cost is deducted from the global building blocks stock in one transaction. If a recipe ID is stored for a building, it is applied to the construction site immediately. If a schematic ID is stored, it is applied only if that schematic is currently unlocked; if it is not unlocked, the shipyard's schematic is left unset. Locked recipe IDs and splitter filter entries for locked item types are handled on placement per REQ-LOCK-UI-BLUEPRINT. After a successful placement the game remains in blueprint placement mode, allowing the player to place the same blueprint again immediately.
|
||||||
|
|
||||||
- REQ-UI-BLUEPRINT-DELETE: Clicking the delete icon ("×") on a blueprint entry immediately removes that blueprint from the list. If the deleted blueprint was active in blueprint placement mode, that mode is exited.
|
- REQ-UI-BLUEPRINT-DELETE: Clicking the delete icon ("×") on a blueprint entry immediately removes that blueprint from the list. If the deleted blueprint was active in blueprint placement mode, that mode is exited.
|
||||||
|
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
# Modular Ships: Remove Ship Roles, Unify Capabilities as Modules
|
|
||||||
|
|
||||||
## Why
|
|
||||||
|
|
||||||
Ships currently have a fixed role (combat, salvage, repair) baked into their definition. This limits ship customization — a ship is either a fighter or a salvage ship, never both. By moving weapon, salvage cargo, and repair tool capabilities into the module system, players can freely compose ship loadouts. A single hull can carry two weapons and a repair tool, or a weapon and a salvage bay, etc.
|
|
||||||
|
|
||||||
## What Changes
|
|
||||||
|
|
||||||
### Ship definitions lose role-specific sections
|
|
||||||
|
|
||||||
`ShipDef` drops `std::optional<ShipCombat>`, `std::optional<ShipSalvage>`, `std::optional<ShipRepair>`. Ships define only hull stats (HP, movement, sensor) and a layout grid. A new `default_modules` list is added per schematic for enemy wave ships (see below).
|
|
||||||
|
|
||||||
### Capability modules replace roles
|
|
||||||
|
|
||||||
New module types in `modules.toml` provide capabilities. A module with base stat formulas (e.g. `damage_formula`) under a capability section (`[module.weapon]`, `[module.salvage]`, `[module.repair]`) is a **capability module** that creates a child entity. A module with only `added_*`/`multiplied_*` formulas is a **passive module** that modifies stats.
|
|
||||||
|
|
||||||
Example capability module:
|
|
||||||
```toml
|
|
||||||
[[module]]
|
|
||||||
id = "laser_turret"
|
|
||||||
[module.weapon]
|
|
||||||
damage_formula = "5 + 2*x" # x = module's player_production_level
|
|
||||||
attack_range_formula = "8 + x"
|
|
||||||
attack_rate_formula = "1.5 + 0.1*x"
|
|
||||||
```
|
|
||||||
|
|
||||||
Example passive module boosting weapons:
|
|
||||||
```toml
|
|
||||||
[[module]]
|
|
||||||
id = "weapon_upgrade"
|
|
||||||
[module.weapon]
|
|
||||||
multiplied_damage_formula = "1.0 + 0.15 * x"
|
|
||||||
```
|
|
||||||
|
|
||||||
Example passive module boosting ship stats:
|
|
||||||
```toml
|
|
||||||
[[module]]
|
|
||||||
id = "armor_plate"
|
|
||||||
[module.health]
|
|
||||||
multiplied_hp_formula = "1.0 + 0.2 * x"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Capability modules become child entities
|
|
||||||
|
|
||||||
Each placed capability module instance becomes its own entt entity with a `ModuleOwnerComponent { entt::entity ship }` linking it to the parent ship. This allows multiple instances of the same type (e.g. three weapons, each with independent stats, cooldown, and target).
|
|
||||||
|
|
||||||
A new `ModuleOwnerComponent` is introduced:
|
|
||||||
```cpp
|
|
||||||
struct ModuleOwnerComponent
|
|
||||||
{
|
|
||||||
entt::entity ship;
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### Passive modifiers apply to both ship and module entities
|
|
||||||
|
|
||||||
During spawn, passive module modifiers are collected and routed by category:
|
|
||||||
- `[module.health]`, `[module.movement]`, `[module.sensor]` modifiers apply to the ship entity's hull stats.
|
|
||||||
- `[module.weapon]` modifiers apply to every weapon child entity on the ship.
|
|
||||||
- `[module.repair]` modifiers apply to every repair child entity on the ship.
|
|
||||||
- `[module.salvage]` modifiers apply to every salvage child entity on the ship.
|
|
||||||
|
|
||||||
Capability module child entities must be created first, then passive modifiers are applied. The formula variable `x` is always the module's `player_production_level`.
|
|
||||||
|
|
||||||
### Behavior components stay on the ship entity
|
|
||||||
|
|
||||||
`ThreatResponseBehaviorComponent`, `SalvageBehaviorComponent`, `RepairBehaviorComponent` remain on the ship entity (they drive movement). They are attached if the ship has at least one module of the corresponding type.
|
|
||||||
|
|
||||||
### Hybrid ships are allowed
|
|
||||||
|
|
||||||
A ship may have modules of different capability types. Movement arbitration currently uses last-writer-wins (the last behavior system ticked sets the intent). This is acceptable for now; dynamic priority-based arbitration will be added later.
|
|
||||||
|
|
||||||
### Systems query module entities
|
|
||||||
|
|
||||||
Weapon, repair, and salvage tick systems query for their component + `ModuleOwnerComponent` and resolve position from the owner ship. Each module instance ticks independently.
|
|
||||||
|
|
||||||
### Despawn cleans up child entities
|
|
||||||
|
|
||||||
`ShipSystem::despawn` destroys the ship entity and all module entities whose `ModuleOwnerComponent::ship` matches it.
|
|
||||||
|
|
||||||
### Enemy wave ships use default modules
|
|
||||||
|
|
||||||
Since weapons are now modules, enemy ships need modules to fight. Each ship schematic in `ships.toml` defines a `default_modules` list (same format as layout blueprints). Wave-spawned enemy ships are instantiated with this module layout. If `default_modules` is absent or empty, the ship spawns with no modules (and therefore no combat/salvage/repair capability).
|
|
||||||
|
|
||||||
### Visuals use per-schematic colors instead of per-role
|
|
||||||
|
|
||||||
`visuals.toml` defines fill/outline colors and glyphs per ship schematic (e.g. fighter, sniper, gunship) rather than per role (combat, salvage, repair). Debug draw sensor circles use the schematic's outline color.
|
|
||||||
@@ -47,6 +47,7 @@ ArenaSimulation::ArenaSimulation(const GameConfig& gameConfig,
|
|||||||
[this]() { return allocateBuildingId(); },
|
[this]() { return allocateBuildingId(); },
|
||||||
[](int) {},
|
[](int) {},
|
||||||
[](const std::string&, QVector2D, const std::optional<ShipLayoutConfig>&) {},
|
[](const std::string&, QVector2D, const std::optional<ShipLayoutConfig>&) {},
|
||||||
|
[](const std::string&) -> bool { return true; },
|
||||||
m_rng);
|
m_rng);
|
||||||
|
|
||||||
m_shipSystem = std::make_unique<ShipSystem>(m_gameConfig, m_admin);
|
m_shipSystem = std::make_unique<ShipSystem>(m_gameConfig, m_admin);
|
||||||
@@ -73,9 +74,9 @@ BuildingId ArenaSimulation::allocateBuildingId()
|
|||||||
|
|
||||||
void ArenaSimulation::placeStructures()
|
void ArenaSimulation::placeStructures()
|
||||||
{
|
{
|
||||||
const int totalWidth = m_arenaConfig.playerBufferWidth
|
const int totalWidth = m_arenaConfig.playerBufferWidth_tiles
|
||||||
+ m_arenaConfig.contestZoneWidth
|
+ m_arenaConfig.contestZoneWidth_tiles
|
||||||
+ m_arenaConfig.enemyBufferWidth;
|
+ m_arenaConfig.enemyBufferWidth_tiles;
|
||||||
const int midY = m_arenaConfig.heightTiles / 2;
|
const int midY = m_arenaConfig.heightTiles / 2;
|
||||||
|
|
||||||
// Team 1 HQ — ECS proxy entity, player faction (isEnemy=false).
|
// Team 1 HQ — ECS proxy entity, player faction (isEnemy=false).
|
||||||
@@ -123,6 +124,7 @@ void ArenaSimulation::placeStructures()
|
|||||||
weapon.cooldownTicks = 0.0f;
|
weapon.cooldownTicks = 0.0f;
|
||||||
weapon.currentTarget = std::nullopt;
|
weapon.currentTarget = std::nullopt;
|
||||||
const double lv = static_cast<double>(entry.level);
|
const double lv = static_cast<double>(entry.level);
|
||||||
|
const float tileSize = static_cast<float>(m_gameConfig.world.tileSize_m);
|
||||||
|
|
||||||
const std::vector<std::string>& mask = isEnemy
|
const std::vector<std::string>& mask = isEnemy
|
||||||
? m_gameConfig.stations.enemyStation.surfaceMask
|
? m_gameConfig.stations.enemyStation.surfaceMask
|
||||||
@@ -134,8 +136,8 @@ void ArenaSimulation::placeStructures()
|
|||||||
m_gameConfig.stations.playerStation.hpFormula.evaluate(lv));
|
m_gameConfig.stations.playerStation.hpFormula.evaluate(lv));
|
||||||
weapon.damage = static_cast<float>(
|
weapon.damage = static_cast<float>(
|
||||||
m_gameConfig.stations.playerStation.damageFormula.evaluate(lv));
|
m_gameConfig.stations.playerStation.damageFormula.evaluate(lv));
|
||||||
weapon.range = static_cast<float>(
|
weapon.range_tiles = static_cast<float>(
|
||||||
m_gameConfig.stations.playerStation.rangeFormula.evaluate(lv));
|
m_gameConfig.stations.playerStation.rangeFormula.evaluate(lv)) / tileSize;
|
||||||
weapon.fireRateHz = static_cast<float>(
|
weapon.fireRateHz = static_cast<float>(
|
||||||
m_gameConfig.stations.playerStation.fireRateFormula.evaluate(lv));
|
m_gameConfig.stations.playerStation.fireRateFormula.evaluate(lv));
|
||||||
}
|
}
|
||||||
@@ -145,8 +147,8 @@ void ArenaSimulation::placeStructures()
|
|||||||
m_gameConfig.stations.enemyStation.hpFormula.evaluate(lv));
|
m_gameConfig.stations.enemyStation.hpFormula.evaluate(lv));
|
||||||
weapon.damage = static_cast<float>(
|
weapon.damage = static_cast<float>(
|
||||||
m_gameConfig.stations.enemyStation.damageFormula.evaluate(lv));
|
m_gameConfig.stations.enemyStation.damageFormula.evaluate(lv));
|
||||||
weapon.range = static_cast<float>(
|
weapon.range_tiles = static_cast<float>(
|
||||||
m_gameConfig.stations.enemyStation.rangeFormula.evaluate(lv));
|
m_gameConfig.stations.enemyStation.rangeFormula.evaluate(lv)) / tileSize;
|
||||||
weapon.fireRateHz = static_cast<float>(
|
weapon.fireRateHz = static_cast<float>(
|
||||||
m_gameConfig.stations.enemyStation.fireRateFormula.evaluate(lv));
|
m_gameConfig.stations.enemyStation.fireRateFormula.evaluate(lv));
|
||||||
}
|
}
|
||||||
@@ -181,9 +183,9 @@ void ArenaSimulation::placeStructures()
|
|||||||
|
|
||||||
void ArenaSimulation::spawnShips()
|
void ArenaSimulation::spawnShips()
|
||||||
{
|
{
|
||||||
const int contestStart = m_arenaConfig.playerBufferWidth;
|
const int contestStart = m_arenaConfig.playerBufferWidth_tiles;
|
||||||
const int team2Start = contestStart + m_arenaConfig.contestZoneWidth;
|
const int team2Start = contestStart + m_arenaConfig.contestZoneWidth_tiles;
|
||||||
const int totalWidth = team2Start + m_arenaConfig.enemyBufferWidth;
|
const int totalWidth = team2Start + m_arenaConfig.enemyBufferWidth_tiles;
|
||||||
|
|
||||||
std::uniform_real_distribution<float> yDist(0.0f,
|
std::uniform_real_distribution<float> yDist(0.0f,
|
||||||
static_cast<float>(m_arenaConfig.heightTiles));
|
static_cast<float>(m_arenaConfig.heightTiles));
|
||||||
@@ -191,7 +193,7 @@ void ArenaSimulation::spawnShips()
|
|||||||
// Team 1: isEnemy=false, spawn in player buffer zone.
|
// Team 1: isEnemy=false, spawn in player buffer zone.
|
||||||
{
|
{
|
||||||
std::uniform_real_distribution<float> xDist(0.0f,
|
std::uniform_real_distribution<float> xDist(0.0f,
|
||||||
static_cast<float>(m_arenaConfig.playerBufferWidth));
|
static_cast<float>(m_arenaConfig.playerBufferWidth_tiles));
|
||||||
|
|
||||||
for (const ArenaShipEntry& entry : m_arenaConfig.teams[0].ships)
|
for (const ArenaShipEntry& entry : m_arenaConfig.teams[0].ships)
|
||||||
{
|
{
|
||||||
@@ -257,9 +259,9 @@ void ArenaSimulation::tick()
|
|||||||
m_aiSystem->tickSalvageBehavior(m_admin, *m_scrapSystem, *m_buildingSystem);
|
m_aiSystem->tickSalvageBehavior(m_admin, *m_scrapSystem, *m_buildingSystem);
|
||||||
|
|
||||||
// Combat resolution (tick step 8).
|
// Combat resolution (tick step 8).
|
||||||
std::vector<FireEvent> fireEvents;
|
std::vector<WeaponFiredEvent> weaponFiredEvents;
|
||||||
m_combatSystem->tick(m_currentTick, m_admin, *m_buildingSystem, fireEvents);
|
m_combatSystem->tick(m_currentTick, m_admin, *m_buildingSystem, weaponFiredEvents);
|
||||||
m_fireEvents.insert(m_fireEvents.end(), fireEvents.begin(), fireEvents.end());
|
m_weaponFiredEvents.insert(m_weaponFiredEvents.end(), weaponFiredEvents.begin(), weaponFiredEvents.end());
|
||||||
m_combatSystem->applyPendingDamage(m_currentTick, m_admin);
|
m_combatSystem->applyPendingDamage(m_currentTick, m_admin);
|
||||||
|
|
||||||
// Deaths (tick step 9, simplified).
|
// Deaths (tick step 9, simplified).
|
||||||
@@ -391,10 +393,10 @@ void ArenaSimulation::tickOnce()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<FireEvent> ArenaSimulation::drainFireEvents()
|
std::vector<WeaponFiredEvent> ArenaSimulation::drainWeaponFiredEvents()
|
||||||
{
|
{
|
||||||
std::vector<FireEvent> result;
|
std::vector<WeaponFiredEvent> result;
|
||||||
result.swap(m_fireEvents);
|
result.swap(m_weaponFiredEvents);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "BuildingId.h"
|
#include "BuildingId.h"
|
||||||
|
|
||||||
#include "entt/entity/entity.hpp"
|
#include "entt/entity/entity.hpp"
|
||||||
#include "FireEvent.h"
|
#include "WeaponFiredEvent.h"
|
||||||
#include "GameConfig.h"
|
#include "GameConfig.h"
|
||||||
#include "Tick.h"
|
#include "Tick.h"
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
void requestStop();
|
void requestStop();
|
||||||
|
|
||||||
void tickOnce();
|
void tickOnce();
|
||||||
std::vector<FireEvent> drainFireEvents();
|
std::vector<WeaponFiredEvent> drainWeaponFiredEvents();
|
||||||
|
|
||||||
ArenaStatus status() const;
|
ArenaStatus status() const;
|
||||||
bool isFinished() const;
|
bool isFinished() const;
|
||||||
@@ -104,7 +104,7 @@ private:
|
|||||||
int m_winnerTeam;
|
int m_winnerTeam;
|
||||||
std::atomic<bool> m_stopRequested;
|
std::atomic<bool> m_stopRequested;
|
||||||
|
|
||||||
std::vector<FireEvent> m_fireEvents;
|
std::vector<WeaponFiredEvent> m_weaponFiredEvents;
|
||||||
|
|
||||||
mutable std::mutex m_statusMutex;
|
mutable std::mutex m_statusMutex;
|
||||||
ArenaStatus m_status;
|
ArenaStatus m_status;
|
||||||
|
|||||||
@@ -4,14 +4,19 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
|
||||||
#include "ArenaSimulation.h"
|
#include "ArenaSimulation.h"
|
||||||
#include "Building.h"
|
#include "Building.h"
|
||||||
#include "BuildingSystem.h"
|
#include "BuildingSystem.h"
|
||||||
|
#include "EntityHitTest.h"
|
||||||
|
#include "EntitySelectedEvent.h"
|
||||||
|
#include "EventManager.h"
|
||||||
#include "FacingComponent.h"
|
#include "FacingComponent.h"
|
||||||
#include "FactionComponent.h"
|
#include "FactionComponent.h"
|
||||||
|
#include "GameSpeedChangedEvent.h"
|
||||||
#include "HealthComponent.h"
|
#include "HealthComponent.h"
|
||||||
#include "PositionComponent.h"
|
#include "PositionComponent.h"
|
||||||
#include "ScrapSystem.h"
|
#include "ScrapSystem.h"
|
||||||
@@ -41,6 +46,13 @@ ArenaView::ArenaView(ArenaSimulation* sim, const VisualsConfig* visuals,
|
|||||||
connect(m_renderTimer, &QTimer::timeout, this, &ArenaView::onFrame);
|
connect(m_renderTimer, &QTimer::timeout, this, &ArenaView::onFrame);
|
||||||
m_renderTimer->start();
|
m_renderTimer->start();
|
||||||
m_frameTimer.start();
|
m_frameTimer.start();
|
||||||
|
|
||||||
|
registerForEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
ArenaView::~ArenaView()
|
||||||
|
{
|
||||||
|
unregisterForEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArenaView::setGameSpeed(double multiplier)
|
void ArenaView::setGameSpeed(double multiplier)
|
||||||
@@ -50,7 +62,8 @@ void ArenaView::setGameSpeed(double multiplier)
|
|||||||
m_prevNonZeroSpeed = multiplier;
|
m_prevNonZeroSpeed = multiplier;
|
||||||
}
|
}
|
||||||
m_gameSpeedMultiplier = multiplier;
|
m_gameSpeedMultiplier = multiplier;
|
||||||
emit speedChanged(multiplier);
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
|
std::make_shared<GameSpeedChangedEvent>(multiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
double ArenaView::gameSpeed() const
|
double ArenaView::gameSpeed() const
|
||||||
@@ -89,34 +102,17 @@ void ArenaView::onFrame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emit fire events via EventManager
|
||||||
{
|
{
|
||||||
const std::vector<FireEvent> fires = m_sim->drainFireEvents();
|
const std::vector<WeaponFiredEvent> fires = m_sim->drainWeaponFiredEvents();
|
||||||
for (const FireEvent& fe : fires)
|
for (const WeaponFiredEvent& fe : fires)
|
||||||
{
|
{
|
||||||
float maxRadius = 0.125f;
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
if (m_sim->admin().isValid(fe.target)
|
std::make_shared<WeaponFiredEvent>(fe));
|
||||||
&& m_sim->admin().hasAll<StationBodyComponent>(fe.target))
|
|
||||||
{
|
|
||||||
const StationBodyComponent& sb = m_sim->admin().get<StationBodyComponent>(fe.target);
|
|
||||||
const int shorter = std::min(sb.footprint.width(),
|
|
||||||
sb.footprint.height());
|
|
||||||
maxRadius = shorter / 2.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::uniform_real_distribution<float> angleDist(0.0f, 6.28318530f);
|
|
||||||
std::uniform_real_distribution<float> radiusDist(0.0f, maxRadius);
|
|
||||||
const float angle = angleDist(m_rng);
|
|
||||||
const float radius = radiusDist(m_rng);
|
|
||||||
|
|
||||||
ActiveBeam beam;
|
|
||||||
beam.event = fe;
|
|
||||||
beam.emittedWallMs = m_wallMs;
|
|
||||||
beam.targetOffset = QVector2D(radius * std::cos(angle),
|
|
||||||
radius * std::sin(angle));
|
|
||||||
m_activeBeams.push_back(beam);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expire old beams
|
||||||
{
|
{
|
||||||
std::vector<ActiveBeam> live;
|
std::vector<ActiveBeam> live;
|
||||||
for (const ActiveBeam& b : m_activeBeams)
|
for (const ActiveBeam& b : m_activeBeams)
|
||||||
@@ -132,12 +128,36 @@ void ArenaView::onFrame()
|
|||||||
if (m_sim->isFinished() && !m_finishedEmitted)
|
if (m_sim->isFinished() && !m_finishedEmitted)
|
||||||
{
|
{
|
||||||
m_finishedEmitted = true;
|
m_finishedEmitted = true;
|
||||||
emit finished();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArenaView::handleEvent(std::shared_ptr<const WeaponFiredEvent> event)
|
||||||
|
{
|
||||||
|
float maxRadius = 0.125f;
|
||||||
|
if (m_sim->admin().isValid(event->target)
|
||||||
|
&& m_sim->admin().hasAll<StationBodyComponent>(event->target))
|
||||||
|
{
|
||||||
|
const StationBodyComponent& sb = m_sim->admin().get<StationBodyComponent>(event->target);
|
||||||
|
const int shorter = std::min(sb.footprint.width(),
|
||||||
|
sb.footprint.height());
|
||||||
|
maxRadius = shorter / 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> angleDist(0.0f, 6.28318530f);
|
||||||
|
std::uniform_real_distribution<float> radiusDist(0.0f, maxRadius);
|
||||||
|
const float angle = angleDist(m_rng);
|
||||||
|
const float radius = radiusDist(m_rng);
|
||||||
|
|
||||||
|
ActiveBeam beam;
|
||||||
|
beam.event = *event;
|
||||||
|
beam.emittedWallMs = m_wallMs;
|
||||||
|
beam.targetOffset = QVector2D(radius * std::cos(angle),
|
||||||
|
radius * std::sin(angle));
|
||||||
|
m_activeBeams.push_back(beam);
|
||||||
|
}
|
||||||
|
|
||||||
void ArenaView::paintGL()
|
void ArenaView::paintGL()
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
@@ -158,9 +178,9 @@ void ArenaView::paintGL()
|
|||||||
float ArenaView::tilePx() const
|
float ArenaView::tilePx() const
|
||||||
{
|
{
|
||||||
const ArenaConfig& ac = m_sim->arenaConfig();
|
const ArenaConfig& ac = m_sim->arenaConfig();
|
||||||
const int totalWidth = ac.playerBufferWidth
|
const int totalWidth = ac.playerBufferWidth_tiles
|
||||||
+ ac.contestZoneWidth
|
+ ac.contestZoneWidth_tiles
|
||||||
+ ac.enemyBufferWidth;
|
+ ac.enemyBufferWidth_tiles;
|
||||||
const int totalHeight = ac.heightTiles;
|
const int totalHeight = ac.heightTiles;
|
||||||
if (totalWidth <= 0 || totalHeight <= 0) { return 1.0f; }
|
if (totalWidth <= 0 || totalHeight <= 0) { return 1.0f; }
|
||||||
|
|
||||||
@@ -198,6 +218,37 @@ std::optional<QVector2D> ArenaView::entityPosition(entt::entity entity) const
|
|||||||
return m_sim->admin().get<PositionComponent>(entity).value;
|
return m_sim->admin().get<PositionComponent>(entity).value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector2D ArenaView::widgetToWorld(QPoint widgetPt) const
|
||||||
|
{
|
||||||
|
const float px = tilePx();
|
||||||
|
if (px < 0.001f) { return QVector2D(0.0f, 0.0f); }
|
||||||
|
return QVector2D(static_cast<float>(widgetPt.x()) / px,
|
||||||
|
static_cast<float>(widgetPt.y()) / px);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArenaView::mousePressEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
const QVector2D worldPos = widgetToWorld(event->pos());
|
||||||
|
entt::entity hit = entityAtWorldPos(m_sim->admin(), worldPos);
|
||||||
|
|
||||||
|
if (hit != entt::null)
|
||||||
|
{
|
||||||
|
m_selectedEntity = hit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_selectedEntity = std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
|
std::make_shared<EntitySelectedEvent>(m_selectedEntity));
|
||||||
|
}
|
||||||
|
|
||||||
|
QOpenGLWidget::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Rendering
|
// Rendering
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -205,9 +256,9 @@ std::optional<QVector2D> ArenaView::entityPosition(entt::entity entity) const
|
|||||||
void ArenaView::drawTiles(QPainter& painter)
|
void ArenaView::drawTiles(QPainter& painter)
|
||||||
{
|
{
|
||||||
const ArenaConfig& ac = m_sim->arenaConfig();
|
const ArenaConfig& ac = m_sim->arenaConfig();
|
||||||
const int totalWidth = ac.playerBufferWidth
|
const int totalWidth = ac.playerBufferWidth_tiles
|
||||||
+ ac.contestZoneWidth
|
+ ac.contestZoneWidth_tiles
|
||||||
+ ac.enemyBufferWidth;
|
+ ac.enemyBufferWidth_tiles;
|
||||||
const int totalHeight = ac.heightTiles;
|
const int totalHeight = ac.heightTiles;
|
||||||
|
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
@@ -268,7 +319,7 @@ void ArenaView::drawScrap(QPainter& painter)
|
|||||||
void ArenaView::drawStations(QPainter& painter)
|
void ArenaView::drawStations(QPainter& painter)
|
||||||
{
|
{
|
||||||
m_sim->admin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
m_sim->admin().forEach<StationBodyComponent, FactionComponent, HealthComponent>(
|
||||||
[&](entt::entity /*e*/, const StationBodyComponent& sb, const FactionComponent& f, const HealthComponent& h)
|
[&](entt::entity e, const StationBodyComponent& sb, const FactionComponent& f, const HealthComponent& h)
|
||||||
{
|
{
|
||||||
const BuildingType visType = f.isEnemy
|
const BuildingType visType = f.isEnemy
|
||||||
? BuildingType::EnemyDefenceStation
|
? BuildingType::EnemyDefenceStation
|
||||||
@@ -304,6 +355,13 @@ void ArenaView::drawStations(QPainter& painter)
|
|||||||
painter.fillRect(QRectF(bboxRect.left(), barY, barW * static_cast<qreal>(fraction), barH),
|
painter.fillRect(QRectF(bboxRect.left(), barY, barW * static_cast<qreal>(fraction), barH),
|
||||||
f.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
f.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_selectedEntity.has_value() && *m_selectedEntity == e)
|
||||||
|
{
|
||||||
|
painter.setPen(QPen(QColor(255, 255, 0), 2));
|
||||||
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
painter.drawRect(bboxRect.adjusted(-2, -2, 2, 2));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +369,7 @@ void ArenaView::drawShips(QPainter& painter)
|
|||||||
{
|
{
|
||||||
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
m_sim->admin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||||
FactionComponent, HealthComponent>(
|
FactionComponent, HealthComponent>(
|
||||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
[&](entt::entity e, const ShipIdentityComponent& si,
|
||||||
const PositionComponent& pos, const FacingComponent& facing,
|
const PositionComponent& pos, const FacingComponent& facing,
|
||||||
const FactionComponent& fac, const HealthComponent& h)
|
const FactionComponent& fac, const HealthComponent& h)
|
||||||
{
|
{
|
||||||
@@ -349,6 +407,14 @@ void ArenaView::drawShips(QPainter& painter)
|
|||||||
painter.fillRect(QRectF(barX, barY, barW * static_cast<qreal>(fraction), barH),
|
painter.fillRect(QRectF(barX, barY, barW * static_cast<qreal>(fraction), barH),
|
||||||
fac.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
fac.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_selectedEntity.has_value() && *m_selectedEntity == e)
|
||||||
|
{
|
||||||
|
const qreal radius = static_cast<qreal>(tilePx()) * 0.55;
|
||||||
|
painter.setPen(QPen(QColor(255, 255, 0), 2));
|
||||||
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
painter.drawEllipse(center, radius, radius);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,4 +430,3 @@ void ArenaView::drawBeams(QPainter& painter)
|
|||||||
worldToWidget(*targetPos + beam.targetOffset));
|
worldToWidget(*targetPos + beam.targetOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -8,9 +9,11 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
|
|
||||||
#include "FireEvent.h"
|
#include "EventHandler.h"
|
||||||
|
#include "WeaponFiredEvent.h"
|
||||||
|
|
||||||
#include "entt/entity/entity.hpp"
|
#include "entt/entity/entity.hpp"
|
||||||
|
#include "EntitySelectedEvent.h"
|
||||||
#include "Tick.h"
|
#include "Tick.h"
|
||||||
#include "TickDriver.h"
|
#include "TickDriver.h"
|
||||||
#include "VisualsConfig.h"
|
#include "VisualsConfig.h"
|
||||||
@@ -18,30 +21,31 @@
|
|||||||
class ArenaSimulation;
|
class ArenaSimulation;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
class ArenaView : public QOpenGLWidget
|
class ArenaView : public QOpenGLWidget,
|
||||||
|
public EventHandler<WeaponFiredEvent>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArenaView(ArenaSimulation* sim, const VisualsConfig* visuals,
|
ArenaView(ArenaSimulation* sim, const VisualsConfig* visuals,
|
||||||
QWidget* parent = nullptr);
|
QWidget* parent = nullptr);
|
||||||
|
~ArenaView() override;
|
||||||
|
|
||||||
void setGameSpeed(double multiplier);
|
void setGameSpeed(double multiplier);
|
||||||
double gameSpeed() const;
|
double gameSpeed() const;
|
||||||
void togglePause();
|
void togglePause();
|
||||||
void stopRendering();
|
void stopRendering();
|
||||||
|
|
||||||
signals:
|
|
||||||
void speedChanged(double multiplier);
|
|
||||||
void finished();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onFrame();
|
void onFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void handleEvent(std::shared_ptr<const WeaponFiredEvent> event) override;
|
||||||
|
|
||||||
void drawTiles(QPainter& painter);
|
void drawTiles(QPainter& painter);
|
||||||
void drawBuildings(QPainter& painter);
|
void drawBuildings(QPainter& painter);
|
||||||
void drawStations(QPainter& painter);
|
void drawStations(QPainter& painter);
|
||||||
@@ -55,10 +59,11 @@ private:
|
|||||||
QRectF tileRect(QPoint tile) const;
|
QRectF tileRect(QPoint tile) const;
|
||||||
|
|
||||||
std::optional<QVector2D> entityPosition(entt::entity entity) const;
|
std::optional<QVector2D> entityPosition(entt::entity entity) const;
|
||||||
|
QVector2D widgetToWorld(QPoint widgetPt) const;
|
||||||
|
|
||||||
struct ActiveBeam
|
struct ActiveBeam
|
||||||
{
|
{
|
||||||
FireEvent event;
|
WeaponFiredEvent event;
|
||||||
qint64 emittedWallMs;
|
qint64 emittedWallMs;
|
||||||
QVector2D targetOffset;
|
QVector2D targetOffset;
|
||||||
};
|
};
|
||||||
@@ -79,4 +84,6 @@ private:
|
|||||||
|
|
||||||
std::vector<ActiveBeam> m_activeBeams;
|
std::vector<ActiveBeam> m_activeBeams;
|
||||||
bool m_finishedEmitted;
|
bool m_finishedEmitted;
|
||||||
|
|
||||||
|
std::optional<entt::entity> m_selectedEntity;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,8 +3,13 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
ArenaWidget::ArenaWidget(const std::string& arenaName, QWidget* parent)
|
#include "ArenaInspectRequestedEvent.h"
|
||||||
|
#include "ArenaStartRequestedEvent.h"
|
||||||
|
#include "EventManager.h"
|
||||||
|
|
||||||
|
ArenaWidget::ArenaWidget(int arenaIndex, const std::string& arenaName, QWidget* parent)
|
||||||
: QFrame(parent)
|
: QFrame(parent)
|
||||||
|
, m_arenaIndex(arenaIndex)
|
||||||
, m_running(false)
|
, m_running(false)
|
||||||
, m_wasFinished(false)
|
, m_wasFinished(false)
|
||||||
{
|
{
|
||||||
@@ -30,12 +35,18 @@ void ArenaWidget::buildLayout(const std::string& arenaName)
|
|||||||
|
|
||||||
titleRow->addStretch();
|
titleRow->addStretch();
|
||||||
|
|
||||||
m_inspectButton = new QPushButton("Inspect", this);
|
m_inspectButton = new QPushButton(tr("Inspect"), this);
|
||||||
connect(m_inspectButton, &QPushButton::clicked, this, &ArenaWidget::inspectRequested);
|
connect(m_inspectButton, &QPushButton::clicked, this, [this]() {
|
||||||
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
|
std::make_shared<ArenaInspectRequestedEvent>(m_arenaIndex));
|
||||||
|
});
|
||||||
titleRow->addWidget(m_inspectButton);
|
titleRow->addWidget(m_inspectButton);
|
||||||
|
|
||||||
m_startButton = new QPushButton("Start", this);
|
m_startButton = new QPushButton(tr("Start"), this);
|
||||||
connect(m_startButton, &QPushButton::clicked, this, &ArenaWidget::startRequested);
|
connect(m_startButton, &QPushButton::clicked, this, [this]() {
|
||||||
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
|
std::make_shared<ArenaStartRequestedEvent>(m_arenaIndex));
|
||||||
|
});
|
||||||
titleRow->addWidget(m_startButton);
|
titleRow->addWidget(m_startButton);
|
||||||
|
|
||||||
outerLayout->addLayout(titleRow);
|
outerLayout->addLayout(titleRow);
|
||||||
@@ -94,7 +105,7 @@ void ArenaWidget::updateStatus(const ArenaStatus& status)
|
|||||||
|
|
||||||
if (status.finished && status.winnerTeam == ti)
|
if (status.finished && status.winnerTeam == ti)
|
||||||
{
|
{
|
||||||
header->setText("[WON] " + QString::fromStdString(team.name));
|
header->setText(tr("[WON] %1").arg(QString::fromStdString(team.name)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,19 +14,16 @@ class ArenaWidget : public QFrame
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ArenaWidget(const std::string& arenaName, QWidget* parent = nullptr);
|
ArenaWidget(int arenaIndex, const std::string& arenaName, QWidget* parent = nullptr);
|
||||||
|
|
||||||
void updateStatus(const ArenaStatus& status);
|
void updateStatus(const ArenaStatus& status);
|
||||||
void startSimulation();
|
void startSimulation();
|
||||||
void resetToGrey();
|
void resetToGrey();
|
||||||
|
|
||||||
signals:
|
|
||||||
void startRequested();
|
|
||||||
void inspectRequested();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildLayout(const std::string& arenaName);
|
void buildLayout(const std::string& arenaName);
|
||||||
|
|
||||||
|
int m_arenaIndex;
|
||||||
QLabel* m_titleLabel;
|
QLabel* m_titleLabel;
|
||||||
QLabel* m_team1Header;
|
QLabel* m_team1Header;
|
||||||
QLabel* m_team2Header;
|
QLabel* m_team2Header;
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ BalancingConfig loadBalancingConfig(const std::string& path)
|
|||||||
arena.name = requireString((*arenaTbl)["name"], prefix + ".name");
|
arena.name = requireString((*arenaTbl)["name"], prefix + ".name");
|
||||||
arena.heightTiles = static_cast<int>(
|
arena.heightTiles = static_cast<int>(
|
||||||
requireInt((*arenaTbl)["height_tiles"], prefix + ".height_tiles"));
|
requireInt((*arenaTbl)["height_tiles"], prefix + ".height_tiles"));
|
||||||
arena.playerBufferWidth = static_cast<int>(
|
arena.playerBufferWidth_tiles = static_cast<int>(
|
||||||
requireInt((*arenaTbl)["player_buffer_width"], prefix + ".player_buffer_width"));
|
requireInt((*arenaTbl)["player_buffer_width_tiles"], prefix + ".player_buffer_width_tiles"));
|
||||||
arena.contestZoneWidth = static_cast<int>(
|
arena.contestZoneWidth_tiles = static_cast<int>(
|
||||||
requireInt((*arenaTbl)["contest_zone_width"], prefix + ".contest_zone_width"));
|
requireInt((*arenaTbl)["contest_zone_width_tiles"], prefix + ".contest_zone_width_tiles"));
|
||||||
arena.enemyBufferWidth = static_cast<int>(
|
arena.enemyBufferWidth_tiles = static_cast<int>(
|
||||||
requireInt((*arenaTbl)["enemy_buffer_width"], prefix + ".enemy_buffer_width"));
|
requireInt((*arenaTbl)["enemy_buffer_width_tiles"], prefix + ".enemy_buffer_width_tiles"));
|
||||||
|
|
||||||
const toml::array* teamArray = (*arenaTbl)["team"].as_array();
|
const toml::array* teamArray = (*arenaTbl)["team"].as_array();
|
||||||
if (!teamArray || teamArray->size() != 2)
|
if (!teamArray || teamArray->size() != 2)
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ struct ArenaConfig
|
|||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
int heightTiles;
|
int heightTiles;
|
||||||
int playerBufferWidth;
|
int playerBufferWidth_tiles;
|
||||||
int contestZoneWidth;
|
int contestZoneWidth_tiles;
|
||||||
int enemyBufferWidth;
|
int enemyBufferWidth_tiles;
|
||||||
ArenaTeamConfig teams[2];
|
ArenaTeamConfig teams[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ BalancingWindow::BalancingWindow(const BalancingConfig& balancingConfig,
|
|||||||
, m_inspectedArenaIndex(-1)
|
, m_inspectedArenaIndex(-1)
|
||||||
{
|
{
|
||||||
m_visuals = VisualsLoader::load(m_configDir + "/visuals.toml");
|
m_visuals = VisualsLoader::load(m_configDir + "/visuals.toml");
|
||||||
setWindowTitle("DotaFactory — Balancing Tool");
|
setWindowTitle(tr("DotaFactory — Balancing Tool"));
|
||||||
resize(800, 600);
|
resize(800, 600);
|
||||||
|
|
||||||
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
||||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
QHBoxLayout* buttonRow = new QHBoxLayout();
|
QHBoxLayout* buttonRow = new QHBoxLayout();
|
||||||
m_reloadButton = new QPushButton("Reload Config", this);
|
m_reloadButton = new QPushButton(tr("Reload Config"), this);
|
||||||
m_startAllButton = new QPushButton("Start All", this);
|
m_startAllButton = new QPushButton(tr("Start All"), this);
|
||||||
buttonRow->addWidget(m_reloadButton);
|
buttonRow->addWidget(m_reloadButton);
|
||||||
buttonRow->addWidget(m_startAllButton);
|
buttonRow->addWidget(m_startAllButton);
|
||||||
buttonRow->addStretch();
|
buttonRow->addStretch();
|
||||||
@@ -48,14 +48,17 @@ BalancingWindow::BalancingWindow(const BalancingConfig& balancingConfig,
|
|||||||
m_pollTimer = new QTimer(this);
|
m_pollTimer = new QTimer(this);
|
||||||
connect(m_pollTimer, &QTimer::timeout, this, &BalancingWindow::pollStatuses);
|
connect(m_pollTimer, &QTimer::timeout, this, &BalancingWindow::pollStatuses);
|
||||||
m_pollTimer->start(100);
|
m_pollTimer->start(100);
|
||||||
|
|
||||||
|
registerForEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
BalancingWindow::~BalancingWindow()
|
BalancingWindow::~BalancingWindow()
|
||||||
{
|
{
|
||||||
|
unregisterForEvents();
|
||||||
|
|
||||||
m_pollTimer->stop();
|
m_pollTimer->stop();
|
||||||
if (m_inspectWindow)
|
if (m_inspectWindow)
|
||||||
{
|
{
|
||||||
m_inspectWindow->disconnect(this);
|
|
||||||
delete m_inspectWindow;
|
delete m_inspectWindow;
|
||||||
m_inspectWindow = nullptr;
|
m_inspectWindow = nullptr;
|
||||||
}
|
}
|
||||||
@@ -81,16 +84,11 @@ void BalancingWindow::populateArenas(const BalancingConfig& balancingConfig)
|
|||||||
entry.config = arenaConfig;
|
entry.config = arenaConfig;
|
||||||
entry.simulation = std::make_unique<ArenaSimulation>(
|
entry.simulation = std::make_unique<ArenaSimulation>(
|
||||||
m_gameConfig, arenaConfig, m_nextSeed++);
|
m_gameConfig, arenaConfig, m_nextSeed++);
|
||||||
entry.widget = new ArenaWidget(arenaConfig.name, scrollContent);
|
entry.widget = new ArenaWidget(index, arenaConfig.name, scrollContent);
|
||||||
contentLayout->addWidget(entry.widget);
|
contentLayout->addWidget(entry.widget);
|
||||||
|
|
||||||
entry.widget->updateStatus(entry.simulation->status());
|
entry.widget->updateStatus(entry.simulation->status());
|
||||||
|
|
||||||
connect(entry.widget, &ArenaWidget::startRequested,
|
|
||||||
this, [this, index]() { startArena(index); });
|
|
||||||
connect(entry.widget, &ArenaWidget::inspectRequested,
|
|
||||||
this, [this, index]() { inspectArena(index); });
|
|
||||||
|
|
||||||
m_arenas.push_back(std::move(entry));
|
m_arenas.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +144,7 @@ void BalancingWindow::reloadConfig()
|
|||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, "Reload Failed", QString::fromStdString(e.what()));
|
QMessageBox::critical(this, tr("Reload Failed"), QString::fromStdString(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +156,21 @@ void BalancingWindow::startAll()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BalancingWindow::handleEvent(std::shared_ptr<const ArenaStartRequestedEvent> event)
|
||||||
|
{
|
||||||
|
startArena(event->arenaIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BalancingWindow::handleEvent(std::shared_ptr<const ArenaInspectRequestedEvent> event)
|
||||||
|
{
|
||||||
|
inspectArena(event->arenaIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BalancingWindow::handleEvent(std::shared_ptr<const InspectWindowClosedEvent> /*event*/)
|
||||||
|
{
|
||||||
|
closeInspectWindow();
|
||||||
|
}
|
||||||
|
|
||||||
void BalancingWindow::startArena(int index)
|
void BalancingWindow::startArena(int index)
|
||||||
{
|
{
|
||||||
ArenaEntry& entry = m_arenas[index];
|
ArenaEntry& entry = m_arenas[index];
|
||||||
@@ -179,7 +192,6 @@ void BalancingWindow::inspectArena(int index)
|
|||||||
{
|
{
|
||||||
if (m_inspectWindow)
|
if (m_inspectWindow)
|
||||||
{
|
{
|
||||||
m_inspectWindow->disconnect(this);
|
|
||||||
delete m_inspectWindow;
|
delete m_inspectWindow;
|
||||||
m_inspectWindow = nullptr;
|
m_inspectWindow = nullptr;
|
||||||
|
|
||||||
@@ -209,9 +221,7 @@ void BalancingWindow::inspectArena(int index)
|
|||||||
entry.widget->updateStatus(m_inspectedSim->status());
|
entry.widget->updateStatus(m_inspectedSim->status());
|
||||||
|
|
||||||
m_inspectWindow = new InspectWindow(
|
m_inspectWindow = new InspectWindow(
|
||||||
m_inspectedSim.get(), &m_visuals, entry.config.name, nullptr);
|
m_inspectedSim.get(), &m_gameConfig, &m_visuals, entry.config.name, nullptr);
|
||||||
connect(m_inspectWindow, &InspectWindow::closed,
|
|
||||||
this, &BalancingWindow::closeInspectWindow);
|
|
||||||
|
|
||||||
setMainControlsEnabled(false);
|
setMainControlsEnabled(false);
|
||||||
m_inspectWindow->show();
|
m_inspectWindow->show();
|
||||||
@@ -224,7 +234,6 @@ void BalancingWindow::closeInspectWindow()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_inspectWindow->disconnect(this);
|
|
||||||
m_inspectWindow->deleteLater();
|
m_inspectWindow->deleteLater();
|
||||||
m_inspectWindow = nullptr;
|
m_inspectWindow = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,22 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "ArenaInspectRequestedEvent.h"
|
||||||
|
#include "ArenaStartRequestedEvent.h"
|
||||||
#include "ArenaWidget.h"
|
#include "ArenaWidget.h"
|
||||||
#include "ArenaSimulation.h"
|
#include "ArenaSimulation.h"
|
||||||
#include "BalancingConfig.h"
|
#include "BalancingConfig.h"
|
||||||
|
#include "EventHandler.h"
|
||||||
#include "GameConfig.h"
|
#include "GameConfig.h"
|
||||||
|
#include "InspectWindowClosedEvent.h"
|
||||||
#include "VisualsConfig.h"
|
#include "VisualsConfig.h"
|
||||||
|
|
||||||
class InspectWindow;
|
class InspectWindow;
|
||||||
|
|
||||||
class BalancingWindow : public QWidget
|
class BalancingWindow : public QWidget,
|
||||||
|
public CombinedEventHandler<ArenaStartRequestedEvent,
|
||||||
|
ArenaInspectRequestedEvent,
|
||||||
|
InspectWindowClosedEvent>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -30,15 +37,20 @@ public:
|
|||||||
QWidget* parent = nullptr);
|
QWidget* parent = nullptr);
|
||||||
~BalancingWindow() override;
|
~BalancingWindow() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleEvent(std::shared_ptr<const ArenaStartRequestedEvent> event) override;
|
||||||
|
void handleEvent(std::shared_ptr<const ArenaInspectRequestedEvent> event) override;
|
||||||
|
void handleEvent(std::shared_ptr<const InspectWindowClosedEvent> event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void pollStatuses();
|
void pollStatuses();
|
||||||
void reloadConfig();
|
void reloadConfig();
|
||||||
void startAll();
|
void startAll();
|
||||||
|
|
||||||
|
private:
|
||||||
void startArena(int index);
|
void startArena(int index);
|
||||||
void inspectArena(int index);
|
void inspectArena(int index);
|
||||||
void closeInspectWindow();
|
void closeInspectWindow();
|
||||||
|
|
||||||
private:
|
|
||||||
void populateArenas(const BalancingConfig& balancingConfig);
|
void populateArenas(const BalancingConfig& balancingConfig);
|
||||||
void stopAllArenas();
|
void stopAllArenas();
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ SET(HDRS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/BalancingConfig.h
|
${CMAKE_CURRENT_SOURCE_DIR}/BalancingConfig.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/BalancingWindow.h
|
${CMAKE_CURRENT_SOURCE_DIR}/BalancingWindow.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/InspectWindow.h
|
${CMAKE_CURRENT_SOURCE_DIR}/InspectWindow.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../ui/ShipStatsPanel.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../ui/VisualsConfig.h
|
${CMAKE_CURRENT_SOURCE_DIR}/../ui/VisualsConfig.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../ui/VisualsLoader.h
|
${CMAKE_CURRENT_SOURCE_DIR}/../ui/VisualsLoader.h
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
@@ -20,6 +21,7 @@ SET(SRCS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/BalancingConfig.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/BalancingConfig.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/BalancingWindow.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/BalancingWindow.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/InspectWindow.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/InspectWindow.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../ui/ShipStatsPanel.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../ui/VisualsLoader.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/../ui/VisualsLoader.cpp
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,16 +9,28 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "ArenaView.h"
|
#include "ArenaView.h"
|
||||||
|
#include "EntityAdmin.h"
|
||||||
|
#include "EventManager.h"
|
||||||
|
#include "HealthComponent.h"
|
||||||
|
#include "InspectWindowClosedEvent.h"
|
||||||
|
#include "ModuleOwnerComponent.h"
|
||||||
|
#include "ShipIdentityComponent.h"
|
||||||
|
#include "ShipStatsCalculator.h"
|
||||||
|
#include "ShipStatsPanel.h"
|
||||||
|
#include "StationBodyComponent.h"
|
||||||
|
#include "WeaponComponent.h"
|
||||||
|
|
||||||
const double InspectWindow::kSpeeds[] = { 0.0, 0.5, 1.0, 2.0, 4.0 };
|
const double InspectWindow::kSpeeds[] = { 0.0, 0.5, 1.0, 2.0, 10.0 };
|
||||||
const int InspectWindow::kSpeedCount = 5;
|
const int InspectWindow::kSpeedCount = 5;
|
||||||
|
|
||||||
InspectWindow::InspectWindow(ArenaSimulation* sim, const VisualsConfig* visuals,
|
InspectWindow::InspectWindow(ArenaSimulation* sim, const GameConfig* config,
|
||||||
|
const VisualsConfig* visuals,
|
||||||
const std::string& arenaName, QWidget* parent)
|
const std::string& arenaName, QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_sim(sim)
|
, m_sim(sim)
|
||||||
|
, m_config(config)
|
||||||
{
|
{
|
||||||
setWindowTitle(QString("Inspect \u2014 %1").arg(QString::fromStdString(arenaName)));
|
setWindowTitle(tr("Inspect \u2014 %1").arg(QString::fromStdString(arenaName)));
|
||||||
resize(900, 700);
|
resize(900, 700);
|
||||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||||
|
|
||||||
@@ -42,7 +54,7 @@ InspectWindow::InspectWindow(ArenaSimulation* sim, const VisualsConfig* visuals,
|
|||||||
|
|
||||||
headerLayout->addStretch();
|
headerLayout->addStretch();
|
||||||
|
|
||||||
const char* labels[] = { "0x", "0.5x", "1x", "2x", "4x" };
|
const char* labels[] = { "0x", "0.5x", "1x", "2x", "10x" };
|
||||||
QSignalMapper* mapper = new QSignalMapper(this);
|
QSignalMapper* mapper = new QSignalMapper(this);
|
||||||
for (int i = 0; i < kSpeedCount; ++i)
|
for (int i = 0; i < kSpeedCount; ++i)
|
||||||
{
|
{
|
||||||
@@ -66,9 +78,6 @@ InspectWindow::InspectWindow(ArenaSimulation* sim, const VisualsConfig* visuals,
|
|||||||
m_arenaView = new ArenaView(sim, visuals, this);
|
m_arenaView = new ArenaView(sim, visuals, this);
|
||||||
mainLayout->addWidget(m_arenaView, 1);
|
mainLayout->addWidget(m_arenaView, 1);
|
||||||
|
|
||||||
connect(m_arenaView, &ArenaView::speedChanged,
|
|
||||||
this, &InspectWindow::onSpeedChanged);
|
|
||||||
|
|
||||||
// Info panel (bottom)
|
// Info panel (bottom)
|
||||||
{
|
{
|
||||||
QWidget* infoPanel = new QWidget(this);
|
QWidget* infoPanel = new QWidget(this);
|
||||||
@@ -96,6 +105,27 @@ InspectWindow::InspectWindow(ArenaSimulation* sim, const VisualsConfig* visuals,
|
|||||||
team2Layout->addStretch();
|
team2Layout->addStretch();
|
||||||
infoLayout->addLayout(team2Layout);
|
infoLayout->addLayout(team2Layout);
|
||||||
|
|
||||||
|
// Entity stats section (right side of info panel)
|
||||||
|
QVBoxLayout* entityLayout = new QVBoxLayout();
|
||||||
|
m_entityTitleLabel = new QLabel(infoPanel);
|
||||||
|
QFont entityTitleFont = m_entityTitleLabel->font();
|
||||||
|
entityTitleFont.setBold(true);
|
||||||
|
m_entityTitleLabel->setFont(entityTitleFont);
|
||||||
|
m_entityTitleLabel->hide();
|
||||||
|
entityLayout->addWidget(m_entityTitleLabel);
|
||||||
|
|
||||||
|
m_entityStatsPanel = new ShipStatsPanel(config, infoPanel);
|
||||||
|
m_entityStatsPanel->hide();
|
||||||
|
entityLayout->addWidget(m_entityStatsPanel);
|
||||||
|
|
||||||
|
m_stationStatsLabel = new QLabel(infoPanel);
|
||||||
|
m_stationStatsLabel->setWordWrap(true);
|
||||||
|
m_stationStatsLabel->hide();
|
||||||
|
entityLayout->addWidget(m_stationStatsLabel);
|
||||||
|
|
||||||
|
entityLayout->addStretch();
|
||||||
|
infoLayout->addLayout(entityLayout);
|
||||||
|
|
||||||
mainLayout->addWidget(infoPanel);
|
mainLayout->addWidget(infoPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,13 +138,21 @@ InspectWindow::InspectWindow(ArenaSimulation* sim, const VisualsConfig* visuals,
|
|||||||
pollStatus();
|
pollStatus();
|
||||||
|
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
||||||
|
registerForEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
InspectWindow::~InspectWindow()
|
||||||
|
{
|
||||||
|
unregisterForEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectWindow::closeEvent(QCloseEvent* event)
|
void InspectWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
m_arenaView->stopRendering();
|
m_arenaView->stopRendering();
|
||||||
m_pollTimer->stop();
|
m_pollTimer->stop();
|
||||||
emit closed();
|
EventManager::getInstance()->sendEventImmediately(
|
||||||
|
std::make_shared<InspectWindowClosedEvent>());
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,11 +176,11 @@ void InspectWindow::onSpeedButton(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectWindow::onSpeedChanged(double multiplier)
|
void InspectWindow::handleEvent(std::shared_ptr<const GameSpeedChangedEvent> event)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < kSpeedCount; ++i)
|
for (int i = 0; i < kSpeedCount; ++i)
|
||||||
{
|
{
|
||||||
const bool active = (std::abs(kSpeeds[i] - multiplier) < 0.001);
|
const bool active = (std::abs(kSpeeds[i] - event->speed) < 0.001);
|
||||||
m_speedButtons[static_cast<std::size_t>(i)]->setChecked(active);
|
m_speedButtons[static_cast<std::size_t>(i)]->setChecked(active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,6 +189,7 @@ void InspectWindow::pollStatus()
|
|||||||
{
|
{
|
||||||
const ArenaStatus status = m_sim->status();
|
const ArenaStatus status = m_sim->status();
|
||||||
updateInfoPanel(status);
|
updateInfoPanel(status);
|
||||||
|
refreshEntityStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectWindow::updateInfoPanel(const ArenaStatus& status)
|
void InspectWindow::updateInfoPanel(const ArenaStatus& status)
|
||||||
@@ -163,7 +202,7 @@ void InspectWindow::updateInfoPanel(const ArenaStatus& status)
|
|||||||
|
|
||||||
if (status.finished && status.winnerTeam == ti)
|
if (status.finished && status.winnerTeam == ti)
|
||||||
{
|
{
|
||||||
header->setText("[WON] " + QString::fromStdString(team.name));
|
header->setText(tr("[WON] %1").arg(QString::fromStdString(team.name)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -186,3 +225,140 @@ void InspectWindow::updateInfoPanel(const ArenaStatus& status)
|
|||||||
content->setText(lines);
|
content->setText(lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectWindow::handleEvent(std::shared_ptr<const EntitySelectedEvent> event)
|
||||||
|
{
|
||||||
|
if (event->entity.has_value())
|
||||||
|
{
|
||||||
|
m_selectedEntity = event->entity;
|
||||||
|
|
||||||
|
EntityAdmin& admin = m_sim->admin();
|
||||||
|
entt::entity entity = *m_selectedEntity;
|
||||||
|
|
||||||
|
if (!admin.isValid(entity))
|
||||||
|
{
|
||||||
|
m_selectedEntity = std::nullopt;
|
||||||
|
m_entityTitleLabel->hide();
|
||||||
|
m_entityStatsPanel->hide();
|
||||||
|
m_stationStatsLabel->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (admin.hasAll<ShipIdentityComponent>(entity))
|
||||||
|
{
|
||||||
|
const ShipIdentityComponent& identity = admin.get<ShipIdentityComponent>(entity);
|
||||||
|
const HealthComponent& health = admin.get<HealthComponent>(entity);
|
||||||
|
|
||||||
|
m_entityTitleLabel->setText(tr("Ship: %1 (Lv %2)")
|
||||||
|
.arg(QString::fromStdString(identity.schematicId))
|
||||||
|
.arg(identity.level));
|
||||||
|
m_entityTitleLabel->show();
|
||||||
|
|
||||||
|
const ShipStats stats = buildShipStatsFromEntity(admin, entity);
|
||||||
|
m_entityStatsPanel->refreshFromLive(stats, health.hp);
|
||||||
|
m_entityStatsPanel->show();
|
||||||
|
m_stationStatsLabel->hide();
|
||||||
|
}
|
||||||
|
else if (admin.hasAll<StationBodyComponent>(entity))
|
||||||
|
{
|
||||||
|
const HealthComponent& health = admin.get<HealthComponent>(entity);
|
||||||
|
|
||||||
|
m_entityTitleLabel->setText(tr("Defence Station"));
|
||||||
|
m_entityTitleLabel->show();
|
||||||
|
|
||||||
|
float totalDps = 0.0f;
|
||||||
|
float maxRange = 0.0f;
|
||||||
|
bool hasWeapons = false;
|
||||||
|
|
||||||
|
admin.forEach<ModuleOwnerComponent, WeaponComponent>(
|
||||||
|
[&](entt::entity /*child*/, const ModuleOwnerComponent& owner, const WeaponComponent& w)
|
||||||
|
{
|
||||||
|
if (owner.owner != entity) { return; }
|
||||||
|
hasWeapons = true;
|
||||||
|
totalDps += w.damage * w.fireRateHz;
|
||||||
|
if (w.range_tiles > maxRange) { maxRange = w.range_tiles; }
|
||||||
|
});
|
||||||
|
|
||||||
|
QString statsText = tr("HP: %1 / %2")
|
||||||
|
.arg(static_cast<int>(health.hp + 0.5f))
|
||||||
|
.arg(static_cast<int>(health.maxHp + 0.5f));
|
||||||
|
|
||||||
|
if (hasWeapons)
|
||||||
|
{
|
||||||
|
statsText += tr("\nDPS: %1").arg(QString::number(static_cast<double>(totalDps), 'f', 1));
|
||||||
|
statsText += tr("\nRange: %1 tiles").arg(QString::number(static_cast<double>(maxRange), 'f', 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_stationStatsLabel->setText(statsText);
|
||||||
|
m_stationStatsLabel->show();
|
||||||
|
m_entityStatsPanel->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_selectedEntity = std::nullopt;
|
||||||
|
m_entityTitleLabel->hide();
|
||||||
|
m_entityStatsPanel->hide();
|
||||||
|
m_stationStatsLabel->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectWindow::refreshEntityStats()
|
||||||
|
{
|
||||||
|
if (!m_selectedEntity.has_value()) { return; }
|
||||||
|
|
||||||
|
EntityAdmin& admin = m_sim->admin();
|
||||||
|
entt::entity entity = *m_selectedEntity;
|
||||||
|
|
||||||
|
if (!admin.isValid(entity))
|
||||||
|
{
|
||||||
|
m_selectedEntity = std::nullopt;
|
||||||
|
m_entityTitleLabel->hide();
|
||||||
|
m_entityStatsPanel->hide();
|
||||||
|
m_stationStatsLabel->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const HealthComponent& health = admin.get<HealthComponent>(entity);
|
||||||
|
if (health.hp <= 0.0f)
|
||||||
|
{
|
||||||
|
m_selectedEntity = std::nullopt;
|
||||||
|
m_entityTitleLabel->hide();
|
||||||
|
m_entityStatsPanel->hide();
|
||||||
|
m_stationStatsLabel->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (admin.hasAll<ShipIdentityComponent>(entity))
|
||||||
|
{
|
||||||
|
const ShipStats stats = buildShipStatsFromEntity(admin, entity);
|
||||||
|
m_entityStatsPanel->refreshFromLive(stats, health.hp);
|
||||||
|
}
|
||||||
|
else if (admin.hasAll<StationBodyComponent>(entity))
|
||||||
|
{
|
||||||
|
float totalDps = 0.0f;
|
||||||
|
float maxRange = 0.0f;
|
||||||
|
bool hasWeapons = false;
|
||||||
|
|
||||||
|
admin.forEach<ModuleOwnerComponent, WeaponComponent>(
|
||||||
|
[&](entt::entity /*child*/, const ModuleOwnerComponent& owner, const WeaponComponent& w)
|
||||||
|
{
|
||||||
|
if (owner.owner != entity) { return; }
|
||||||
|
hasWeapons = true;
|
||||||
|
totalDps += w.damage * w.fireRateHz;
|
||||||
|
if (w.range_tiles > maxRange) { maxRange = w.range_tiles; }
|
||||||
|
});
|
||||||
|
|
||||||
|
QString statsText = tr("HP: %1 / %2")
|
||||||
|
.arg(static_cast<int>(health.hp + 0.5f))
|
||||||
|
.arg(static_cast<int>(health.maxHp + 0.5f));
|
||||||
|
|
||||||
|
if (hasWeapons)
|
||||||
|
{
|
||||||
|
statsText += tr("\nDPS: %1").arg(QString::number(static_cast<double>(totalDps), 'f', 1));
|
||||||
|
statsText += tr("\nRange: %1 tiles").arg(QString::number(static_cast<double>(maxRange), 'f', 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_stationStatsLabel->setText(statsText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -8,36 +9,49 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "entt/entity/entity.hpp"
|
||||||
|
|
||||||
#include "ArenaSimulation.h"
|
#include "ArenaSimulation.h"
|
||||||
|
#include "EntitySelectedEvent.h"
|
||||||
|
#include "EventHandler.h"
|
||||||
|
#include "GameConfig.h"
|
||||||
|
#include "GameSpeedChangedEvent.h"
|
||||||
#include "VisualsConfig.h"
|
#include "VisualsConfig.h"
|
||||||
|
|
||||||
class ArenaView;
|
class ArenaView;
|
||||||
|
class ShipStatsPanel;
|
||||||
|
|
||||||
class InspectWindow : public QWidget
|
class InspectWindow : public QWidget,
|
||||||
|
public CombinedEventHandler<EntitySelectedEvent,
|
||||||
|
GameSpeedChangedEvent>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InspectWindow(ArenaSimulation* sim, const VisualsConfig* visuals,
|
InspectWindow(ArenaSimulation* sim, const GameConfig* config,
|
||||||
|
const VisualsConfig* visuals,
|
||||||
const std::string& arenaName, QWidget* parent = nullptr);
|
const std::string& arenaName, QWidget* parent = nullptr);
|
||||||
|
~InspectWindow() override;
|
||||||
signals:
|
|
||||||
void closed();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleEvent(std::shared_ptr<const EntitySelectedEvent> event) override;
|
||||||
|
void handleEvent(std::shared_ptr<const GameSpeedChangedEvent> event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSpeedButton(int index);
|
void onSpeedButton(int index);
|
||||||
void onSpeedChanged(double multiplier);
|
|
||||||
void pollStatus();
|
void pollStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateInfoPanel(const ArenaStatus& status);
|
void updateInfoPanel(const ArenaStatus& status);
|
||||||
|
void refreshEntityStats();
|
||||||
|
|
||||||
ArenaSimulation* m_sim;
|
ArenaSimulation* m_sim;
|
||||||
ArenaView* m_arenaView;
|
const GameConfig* m_config;
|
||||||
|
ArenaView* m_arenaView;
|
||||||
|
|
||||||
std::vector<QPushButton*> m_speedButtons;
|
std::vector<QPushButton*> m_speedButtons;
|
||||||
QLabel* m_team1Header;
|
QLabel* m_team1Header;
|
||||||
@@ -46,6 +60,11 @@ private:
|
|||||||
QLabel* m_team2Content;
|
QLabel* m_team2Content;
|
||||||
QTimer* m_pollTimer;
|
QTimer* m_pollTimer;
|
||||||
|
|
||||||
|
std::optional<entt::entity> m_selectedEntity;
|
||||||
|
QLabel* m_entityTitleLabel;
|
||||||
|
ShipStatsPanel* m_entityStatsPanel;
|
||||||
|
QLabel* m_stationStatsLabel;
|
||||||
|
|
||||||
static const double kSpeeds[];
|
static const double kSpeeds[];
|
||||||
static const int kSpeedCount;
|
static const int kSpeedCount;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
SET(HDRS)
|
SET(HDRS)
|
||||||
SET(SRCS)
|
SET(SRCS)
|
||||||
|
|
||||||
add_subdirectory(core)
|
|
||||||
add_subdirectory(config)
|
add_subdirectory(config)
|
||||||
|
add_subdirectory(core)
|
||||||
|
add_subdirectory(ecs)
|
||||||
|
add_subdirectory(eventsystem)
|
||||||
add_subdirectory(utility)
|
add_subdirectory(utility)
|
||||||
add_subdirectory(sim)
|
add_subdirectory(sim)
|
||||||
add_subdirectory(ecs)
|
|
||||||
|
|
||||||
SET(HDRS
|
SET(HDRS
|
||||||
${HDRS}
|
${HDRS}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "BuildingType.h"
|
#include "BuildingType.h"
|
||||||
#include "Rotation.h"
|
#include "Rotation.h"
|
||||||
|
#include "ShipLayout.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -50,6 +51,20 @@ std::string serialize(const std::vector<Blueprint>& blueprints)
|
|||||||
bldTbl.insert("offset_x", static_cast<int64_t>(b.offset.x()));
|
bldTbl.insert("offset_x", static_cast<int64_t>(b.offset.x()));
|
||||||
bldTbl.insert("offset_y", static_cast<int64_t>(b.offset.y()));
|
bldTbl.insert("offset_y", static_cast<int64_t>(b.offset.y()));
|
||||||
bldTbl.insert("recipe_id", b.recipeId);
|
bldTbl.insert("recipe_id", b.recipeId);
|
||||||
|
if (b.shipLayout.has_value())
|
||||||
|
{
|
||||||
|
toml::array modArr;
|
||||||
|
for (const PlacedModule& pm : b.shipLayout->placedModules)
|
||||||
|
{
|
||||||
|
toml::table modTbl;
|
||||||
|
modTbl.insert("type", pm.moduleId);
|
||||||
|
modTbl.insert("x", static_cast<int64_t>(pm.position.x()));
|
||||||
|
modTbl.insert("y", static_cast<int64_t>(pm.position.y()));
|
||||||
|
modTbl.insert("rotation", rotationToString(pm.rotation));
|
||||||
|
modArr.push_back(std::move(modTbl));
|
||||||
|
}
|
||||||
|
bldTbl.insert("modules", std::move(modArr));
|
||||||
|
}
|
||||||
bldArr.push_back(std::move(bldTbl));
|
bldArr.push_back(std::move(bldTbl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +138,27 @@ std::vector<Blueprint> deserialize(const std::string& tomlContent)
|
|||||||
bb.offset.setX(static_cast<int>((*bldTbl)["offset_x"].value_or(int64_t{0})));
|
bb.offset.setX(static_cast<int>((*bldTbl)["offset_x"].value_or(int64_t{0})));
|
||||||
bb.offset.setY(static_cast<int>((*bldTbl)["offset_y"].value_or(int64_t{0})));
|
bb.offset.setY(static_cast<int>((*bldTbl)["offset_y"].value_or(int64_t{0})));
|
||||||
bb.recipeId = (*bldTbl)["recipe_id"].value_or(std::string{});
|
bb.recipeId = (*bldTbl)["recipe_id"].value_or(std::string{});
|
||||||
|
const toml::array* modArr = (*bldTbl)["modules"].as_array();
|
||||||
|
if (modArr)
|
||||||
|
{
|
||||||
|
ShipLayoutConfig layout;
|
||||||
|
for (std::size_t k = 0; k < modArr->size(); ++k)
|
||||||
|
{
|
||||||
|
const toml::table* modTbl = (*modArr)[k].as_table();
|
||||||
|
if (!modTbl) { continue; }
|
||||||
|
const std::optional<std::string> modType = (*modTbl)["type"].value<std::string>();
|
||||||
|
const std::optional<int64_t> x = (*modTbl)["x"].value<int64_t>();
|
||||||
|
const std::optional<int64_t> y = (*modTbl)["y"].value<int64_t>();
|
||||||
|
const std::optional<std::string> rotStr = (*modTbl)["rotation"].value<std::string>();
|
||||||
|
if (!modType || !x || !y || !rotStr) { continue; }
|
||||||
|
PlacedModule pm;
|
||||||
|
pm.moduleId = *modType;
|
||||||
|
pm.position = QPoint(static_cast<int>(*x), static_cast<int>(*y));
|
||||||
|
pm.rotation = parseRotation(*rotStr);
|
||||||
|
layout.placedModules.push_back(std::move(pm));
|
||||||
|
}
|
||||||
|
bb.shipLayout = std::move(layout);
|
||||||
|
}
|
||||||
bp.buildings.push_back(std::move(bb));
|
bp.buildings.push_back(std::move(bb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,19 +264,20 @@ WorldConfig ConfigLoader::loadWorld(const std::string& path)
|
|||||||
cfg.refundPercentage = static_cast<int>(requireInt(tbl["world"]["refund_percentage"], file, "world.refund_percentage"));
|
cfg.refundPercentage = static_cast<int>(requireInt(tbl["world"]["refund_percentage"], file, "world.refund_percentage"));
|
||||||
cfg.startingBuildingBlocks = static_cast<int>(requireInt(tbl["world"]["starting_building_blocks"], file, "world.starting_building_blocks"));
|
cfg.startingBuildingBlocks = static_cast<int>(requireInt(tbl["world"]["starting_building_blocks"], file, "world.starting_building_blocks"));
|
||||||
cfg.scrapDespawnSeconds = requireDouble(tbl["world"]["scrap_despawn_seconds"], file, "world.scrap_despawn_seconds");
|
cfg.scrapDespawnSeconds = requireDouble(tbl["world"]["scrap_despawn_seconds"], file, "world.scrap_despawn_seconds");
|
||||||
cfg.beltSpeedTilesPerSecond = requireDouble(tbl["world"]["belt_speed_tiles_per_second"], file, "world.belt_speed_tiles_per_second");
|
cfg.tileSize_m = requireDouble(tbl["world"]["tile_size_m"], file, "world.tile_size_m");
|
||||||
cfg.tunnelMaxDistance = static_cast<int>(requireInt(tbl["world"]["tunnel_max_distance"], file, "world.tunnel_max_distance"));
|
cfg.beltSpeed_tps = requireDouble(tbl["world"]["belt_speed_mps"], file, "world.belt_speed_mps") / cfg.tileSize_m;
|
||||||
|
cfg.tunnelMaxDistance_tiles = static_cast<int>(requireInt(tbl["world"]["tunnel_max_distance_tiles"], file, "world.tunnel_max_distance_tiles"));
|
||||||
cfg.departureIntervalSeconds = requireDouble(tbl["world"]["departure_interval_seconds"], file, "world.departure_interval_seconds");
|
cfg.departureIntervalSeconds = requireDouble(tbl["world"]["departure_interval_seconds"], file, "world.departure_interval_seconds");
|
||||||
|
|
||||||
cfg.regions.asteroidWidth = static_cast<int>(requireInt(tbl["regions"]["asteroid_width"], file, "regions.asteroid_width"));
|
cfg.regions.asteroidWidth_tiles = static_cast<int>(requireInt(tbl["regions"]["asteroid_width_tiles"], file, "regions.asteroid_width_tiles"));
|
||||||
cfg.regions.playerBufferWidth = static_cast<int>(requireInt(tbl["regions"]["player_buffer_width"], file, "regions.player_buffer_width"));
|
cfg.regions.playerBufferWidth_tiles = static_cast<int>(requireInt(tbl["regions"]["player_buffer_width_tiles"], file, "regions.player_buffer_width_tiles"));
|
||||||
cfg.regions.contestZoneWidth = static_cast<int>(requireInt(tbl["regions"]["contest_zone_width"], file, "regions.contest_zone_width"));
|
cfg.regions.contestZoneWidth_tiles = static_cast<int>(requireInt(tbl["regions"]["contest_zone_width_tiles"], file, "regions.contest_zone_width_tiles"));
|
||||||
cfg.regions.enemyBufferWidth = static_cast<int>(requireInt(tbl["regions"]["enemy_buffer_width"], file, "regions.enemy_buffer_width"));
|
cfg.regions.enemyBufferWidth_tiles = static_cast<int>(requireInt(tbl["regions"]["enemy_buffer_width_tiles"], file, "regions.enemy_buffer_width_tiles"));
|
||||||
|
|
||||||
cfg.expansion.columnsPerExpansion = static_cast<int>(requireInt(tbl["expansion"]["columns_per_expansion"], file, "expansion.columns_per_expansion"));
|
cfg.expansion.columnsPerExpansion_tiles = static_cast<int>(requireInt(tbl["expansion"]["columns_per_expansion_tiles"], file, "expansion.columns_per_expansion_tiles"));
|
||||||
cfg.expansion.costBuildingBlocks = static_cast<int>(requireInt(tbl["expansion"]["cost_building_blocks"], file, "expansion.cost_building_blocks"));
|
cfg.expansion.costBuildingBlocks = static_cast<int>(requireInt(tbl["expansion"]["cost_building_blocks"], file, "expansion.cost_building_blocks"));
|
||||||
|
|
||||||
cfg.push.pushExpandColumns = static_cast<int>(requireInt(tbl["push"]["push_expand_columns"], file, "push.push_expand_columns"));
|
cfg.push.pushExpandColumns_tiles = static_cast<int>(requireInt(tbl["push"]["push_expand_columns_tiles"], file, "push.push_expand_columns_tiles"));
|
||||||
cfg.push.bossAdvanceSeconds = requireDouble(tbl["push"]["boss_advance_seconds"], file, "push.boss_advance_seconds");
|
cfg.push.bossAdvanceSeconds = requireDouble(tbl["push"]["boss_advance_seconds"], file, "push.boss_advance_seconds");
|
||||||
|
|
||||||
cfg.waves.threatRateFormula = requireFormula(tbl["waves"]["threat_rate_formula"], file, "waves.threat_rate_formula");
|
cfg.waves.threatRateFormula = requireFormula(tbl["waves"]["threat_rate_formula"], file, "waves.threat_rate_formula");
|
||||||
@@ -366,6 +367,15 @@ RecipesConfig ConfigLoader::loadRecipes(const std::string& path)
|
|||||||
}
|
}
|
||||||
def.building = *parsedType;
|
def.building = *parsedType;
|
||||||
|
|
||||||
|
if (def.building == BuildingType::Assembler)
|
||||||
|
{
|
||||||
|
const auto level = mt["unlock_at_station_level"].value<int64_t>();
|
||||||
|
if (level)
|
||||||
|
{
|
||||||
|
def.unlockAtStationLevel = static_cast<int>(*level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// inputs may be omitted (e.g. miner recipes). An empty array is fine.
|
// inputs may be omitted (e.g. miner recipes). An empty array is fine.
|
||||||
if (mt.contains("inputs"))
|
if (mt.contains("inputs"))
|
||||||
{
|
{
|
||||||
@@ -402,7 +412,7 @@ ShipsConfig ConfigLoader::loadShips(const std::string& path)
|
|||||||
|
|
||||||
ShipDef def;
|
ShipDef def;
|
||||||
def.id = requireString(mt["id"], file, elemPath + ".id");
|
def.id = requireString(mt["id"], file, elemPath + ".id");
|
||||||
def.availableFromStart = requireBool(mt["available_from_start"], file, elemPath + ".available_from_start");
|
def.unlockAtStationLevel = static_cast<int>(requireInt(mt["unlock_at_station_level"], file, elemPath + ".unlock_at_station_level"));
|
||||||
def.layout = requireStringArray(mt["layout"], file, elemPath + ".layout");
|
def.layout = requireStringArray(mt["layout"], file, elemPath + ".layout");
|
||||||
|
|
||||||
// Schematic
|
// Schematic
|
||||||
@@ -419,14 +429,6 @@ ShipsConfig ConfigLoader::loadShips(const std::string& path)
|
|||||||
bpMt["production_time_seconds"], file, bpPath + ".production_time_seconds");
|
bpMt["production_time_seconds"], file, bpPath + ".production_time_seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Threat
|
|
||||||
{
|
|
||||||
const std::string tPath = elemPath + ".threat";
|
|
||||||
const toml::table& tTable = requireTable(mt["threat"], file, tPath);
|
|
||||||
toml::table& tMt = const_cast<toml::table&>(tTable);
|
|
||||||
def.threat.costFormula = requireFormula(tMt["cost_formula"], file, tPath + ".cost_formula");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Health
|
// Health
|
||||||
{
|
{
|
||||||
const std::string hPath = elemPath + ".health";
|
const std::string hPath = elemPath + ".health";
|
||||||
@@ -440,11 +442,11 @@ ShipsConfig ConfigLoader::loadShips(const std::string& path)
|
|||||||
const std::string mPath = elemPath + ".movement";
|
const std::string mPath = elemPath + ".movement";
|
||||||
const toml::table& mTable = requireTable(mt["movement"], file, mPath);
|
const toml::table& mTable = requireTable(mt["movement"], file, mPath);
|
||||||
toml::table& mMt = const_cast<toml::table&>(mTable);
|
toml::table& mMt = const_cast<toml::table&>(mTable);
|
||||||
def.movement.speedFormula = requireFormula(mMt["speed_formula"], file, mPath + ".speed_formula");
|
def.movement.speedFormula = requireFormula(mMt["speed_mps_formula"], file, mPath + ".speed_mps_formula");
|
||||||
def.movement.mainAccelerationFormula = requireFormula(mMt["main_acceleration_formula"], file, mPath + ".main_acceleration_formula");
|
def.movement.mainAccelerationFormula = requireFormula(mMt["main_acceleration_mpss_formula"], file, mPath + ".main_acceleration_mpss_formula");
|
||||||
def.movement.maneuveringAccelerationFormula = requireFormula(mMt["maneuvering_acceleration_formula"], file, mPath + ".maneuvering_acceleration_formula");
|
def.movement.maneuveringAccelerationFormula = requireFormula(mMt["maneuvering_acceleration_mpss_formula"], file, mPath + ".maneuvering_acceleration_mpss_formula");
|
||||||
def.movement.angularAccelerationFormula = requireFormula(mMt["angular_acceleration_formula"], file, mPath + ".angular_acceleration_formula");
|
def.movement.angularAccelerationFormula = requireFormula(mMt["angular_acceleration_radpss_formula"], file, mPath + ".angular_acceleration_radpss_formula");
|
||||||
def.movement.maxRotationSpeedFormula = requireFormula(mMt["max_rotation_speed_formula"], file, mPath + ".max_rotation_speed_formula");
|
def.movement.maxRotationSpeedFormula = requireFormula(mMt["max_rotation_speed_radps_formula"], file, mPath + ".max_rotation_speed_radps_formula");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sensor
|
// Sensor
|
||||||
@@ -452,7 +454,7 @@ ShipsConfig ConfigLoader::loadShips(const std::string& path)
|
|||||||
const std::string snsPath = elemPath + ".sensor";
|
const std::string snsPath = elemPath + ".sensor";
|
||||||
const toml::table& snsTable = requireTable(mt["sensor"], file, snsPath);
|
const toml::table& snsTable = requireTable(mt["sensor"], file, snsPath);
|
||||||
toml::table& snsMt = const_cast<toml::table&>(snsTable);
|
toml::table& snsMt = const_cast<toml::table&>(snsTable);
|
||||||
def.sensor.sensorRangeFormula = requireFormula(snsMt["sensor_range_formula"], file, snsPath + ".sensor_range_formula");
|
def.sensor.sensorRangeFormula = requireFormula(snsMt["sensor_range_m_formula"], file, snsPath + ".sensor_range_m_formula");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loot
|
// Loot
|
||||||
@@ -499,8 +501,8 @@ StationsConfig ConfigLoader::loadStations(const std::string& path)
|
|||||||
cfg.playerStation.level = static_cast<int>(requireInt(tbl[p]["level"], file, p + ".level"));
|
cfg.playerStation.level = static_cast<int>(requireInt(tbl[p]["level"], file, p + ".level"));
|
||||||
cfg.playerStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
cfg.playerStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
||||||
cfg.playerStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
cfg.playerStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
||||||
cfg.playerStation.rangeFormula = requireFormula(tbl[p]["range_formula"], file, p + ".range_formula");
|
cfg.playerStation.rangeFormula = requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
||||||
cfg.playerStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_formula"], file, p + ".fire_rate_formula");
|
cfg.playerStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
||||||
cfg.playerStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
cfg.playerStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,8 +512,8 @@ StationsConfig ConfigLoader::loadStations(const std::string& path)
|
|||||||
cfg.enemyStation.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
cfg.enemyStation.surfaceMask = requireStringArray(tbl[p]["surface_mask"], file, p + ".surface_mask");
|
||||||
cfg.enemyStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
cfg.enemyStation.hpFormula = requireFormula(tbl[p]["hp_formula"], file, p + ".hp_formula");
|
||||||
cfg.enemyStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
cfg.enemyStation.damageFormula = requireFormula(tbl[p]["damage_formula"], file, p + ".damage_formula");
|
||||||
cfg.enemyStation.rangeFormula = requireFormula(tbl[p]["range_formula"], file, p + ".range_formula");
|
cfg.enemyStation.rangeFormula = requireFormula(tbl[p]["range_m_formula"], file, p + ".range_m_formula");
|
||||||
cfg.enemyStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_formula"], file, p + ".fire_rate_formula");
|
cfg.enemyStation.fireRateFormula = requireFormula(tbl[p]["fire_rate_hz_formula"], file, p + ".fire_rate_hz_formula");
|
||||||
cfg.enemyStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
cfg.enemyStation.scrapDropFormula = requireFormula(tbl[p]["scrap_drop_formula"], file, p + ".scrap_drop_formula");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,24 +521,29 @@ StationsConfig ConfigLoader::loadStations(const std::string& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Known category→stat mappings for module stat modifier discovery.
|
// Known category→stat mappings for module stat modifier discovery.
|
||||||
|
// addedKeySuffix: unit suffix appended before "_formula" for additive modifier keys only.
|
||||||
|
// Multiplicative modifier keys are always dimensionless and carry no suffix.
|
||||||
struct StatEntry
|
struct StatEntry
|
||||||
{
|
{
|
||||||
const char* category;
|
const char* category;
|
||||||
const char* stat;
|
const char* stat;
|
||||||
|
const char* addedKeySuffix;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const StatEntry kKnownStats[] = {
|
static const StatEntry kKnownStats[] = {
|
||||||
{"health", "hp"},
|
{"health", "hp", ""},
|
||||||
{"movement", "speed"},
|
{"movement", "speed", "_mps"},
|
||||||
{"sensor", "sensor_range"},
|
{"movement", "main_acceleration", "_mpss"},
|
||||||
{"weapon", "damage"},
|
{"movement", "maneuvering_acceleration", "_mpss"},
|
||||||
{"weapon", "attack_range"},
|
{"sensor", "sensor_range", "_m"},
|
||||||
{"weapon", "attack_rate"},
|
{"weapon", "damage", ""},
|
||||||
{"salvage", "collection_range"},
|
{"weapon", "attack_range", "_m"},
|
||||||
{"salvage", "cargo_capacity"},
|
{"weapon", "attack_rate", "_hz"},
|
||||||
{"salvage", "collection_rate"},
|
{"salvage", "collection_range", "_m"},
|
||||||
{"repair", "repair_rate"},
|
{"salvage", "cargo_capacity", ""},
|
||||||
{"repair", "repair_range"},
|
{"salvage", "collection_rate", "_hz"},
|
||||||
|
{"repair", "repair_rate", "_hz"},
|
||||||
|
{"repair", "repair_range", "_m"},
|
||||||
};
|
};
|
||||||
|
|
||||||
ModulesConfig ConfigLoader::loadModules(const std::string& path)
|
ModulesConfig ConfigLoader::loadModules(const std::string& path)
|
||||||
@@ -564,13 +571,14 @@ ModulesConfig ConfigLoader::loadModules(const std::string& path)
|
|||||||
toml::table& mt = const_cast<toml::table&>(*st);
|
toml::table& mt = const_cast<toml::table&>(*st);
|
||||||
|
|
||||||
ModuleDef def;
|
ModuleDef def;
|
||||||
def.id = requireString(mt["id"], file, elemPath + ".id");
|
def.id = requireString(mt["id"], file, elemPath + ".id");
|
||||||
def.surfaceMask = requireStringArray(mt["surface_mask"], file, elemPath + ".surface_mask");
|
def.unlockAtStationLevel = static_cast<int>(
|
||||||
|
mt["unlock_at_station_level"].value_or<int64_t>(-1));
|
||||||
|
def.surfaceMask = requireStringArray(mt["surface_mask"], file, elemPath + ".surface_mask");
|
||||||
def.playerProductionLevel = static_cast<int>(requireInt(
|
def.playerProductionLevel = static_cast<int>(requireInt(
|
||||||
mt["player_production_level"], file, elemPath + ".player_production_level"));
|
mt["player_production_level"], file, elemPath + ".player_production_level"));
|
||||||
def.productionTimeSeconds = requireDouble(
|
def.productionTimeSeconds = requireDouble(
|
||||||
mt["production_time_seconds"], file, elemPath + ".production_time_seconds");
|
mt["production_time_seconds"], file, elemPath + ".production_time_seconds");
|
||||||
def.threatCost = requireDouble(mt["threat_cost"], file, elemPath + ".threat_cost");
|
|
||||||
def.fillColor = requireString(mt["fill_color"], file, elemPath + ".fill_color");
|
def.fillColor = requireString(mt["fill_color"], file, elemPath + ".fill_color");
|
||||||
def.glyph = requireString(mt["glyph"], file, elemPath + ".glyph");
|
def.glyph = requireString(mt["glyph"], file, elemPath + ".glyph");
|
||||||
|
|
||||||
@@ -591,8 +599,8 @@ ModulesConfig ConfigLoader::loadModules(const std::string& path)
|
|||||||
elemPath + "." + se.category);
|
elemPath + "." + se.category);
|
||||||
toml::table& catMt = const_cast<toml::table&>(catTable);
|
toml::table& catMt = const_cast<toml::table&>(catTable);
|
||||||
|
|
||||||
const std::string addedKey = std::string("added_") + se.stat + "_formula";
|
const std::string addedKey = std::string("added_") + se.stat + se.addedKeySuffix + "_formula";
|
||||||
const std::string multipliedKey = std::string("multiplied_") + se.stat + "_formula";
|
const std::string multipliedKey = std::string("multiplied_") + se.stat + se.addedKeySuffix + "_formula";
|
||||||
|
|
||||||
if (catMt.contains(addedKey))
|
if (catMt.contains(addedKey))
|
||||||
{
|
{
|
||||||
@@ -621,16 +629,16 @@ ModulesConfig ConfigLoader::loadModules(const std::string& path)
|
|||||||
const std::string wPath = elemPath + ".weapon";
|
const std::string wPath = elemPath + ".weapon";
|
||||||
const toml::table& wTable = requireTable(mt["weapon"], file, wPath);
|
const toml::table& wTable = requireTable(mt["weapon"], file, wPath);
|
||||||
toml::table& wMt = const_cast<toml::table&>(wTable);
|
toml::table& wMt = const_cast<toml::table&>(wTable);
|
||||||
if (wMt.contains("damage_formula") || wMt.contains("attack_range_formula")
|
if (wMt.contains("damage_formula") || wMt.contains("attack_range_m_formula")
|
||||||
|| wMt.contains("attack_rate_formula"))
|
|| wMt.contains("attack_rate_hz_formula"))
|
||||||
{
|
{
|
||||||
ModuleWeaponCapability cap;
|
ModuleWeaponCapability cap;
|
||||||
cap.damageFormula = requireFormula(wMt["damage_formula"],
|
cap.damageFormula = requireFormula(wMt["damage_formula"],
|
||||||
file, wPath + ".damage_formula");
|
file, wPath + ".damage_formula");
|
||||||
cap.attackRangeFormula = requireFormula(wMt["attack_range_formula"],
|
cap.attackRangeFormula = requireFormula(wMt["attack_range_m_formula"],
|
||||||
file, wPath + ".attack_range_formula");
|
file, wPath + ".attack_range_m_formula");
|
||||||
cap.attackRateFormula = requireFormula(wMt["attack_rate_formula"],
|
cap.attackRateFormula = requireFormula(wMt["attack_rate_hz_formula"],
|
||||||
file, wPath + ".attack_rate_formula");
|
file, wPath + ".attack_rate_hz_formula");
|
||||||
def.weaponCapability = std::move(cap);
|
def.weaponCapability = std::move(cap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -641,16 +649,16 @@ ModulesConfig ConfigLoader::loadModules(const std::string& path)
|
|||||||
const std::string sPath = elemPath + ".salvage";
|
const std::string sPath = elemPath + ".salvage";
|
||||||
const toml::table& sTable = requireTable(mt["salvage"], file, sPath);
|
const toml::table& sTable = requireTable(mt["salvage"], file, sPath);
|
||||||
toml::table& sMt = const_cast<toml::table&>(sTable);
|
toml::table& sMt = const_cast<toml::table&>(sTable);
|
||||||
if (sMt.contains("collection_range_formula") || sMt.contains("cargo_capacity_formula")
|
if (sMt.contains("collection_range_m_formula") || sMt.contains("cargo_capacity_formula")
|
||||||
|| sMt.contains("collection_rate_formula"))
|
|| sMt.contains("collection_rate_hz_formula"))
|
||||||
{
|
{
|
||||||
ModuleSalvageCapability cap;
|
ModuleSalvageCapability cap;
|
||||||
cap.collectionRangeFormula = requireFormula(sMt["collection_range_formula"],
|
cap.collectionRangeFormula = requireFormula(sMt["collection_range_m_formula"],
|
||||||
file, sPath + ".collection_range_formula");
|
file, sPath + ".collection_range_m_formula");
|
||||||
cap.cargoCapacityFormula = requireFormula(sMt["cargo_capacity_formula"],
|
cap.cargoCapacityFormula = requireFormula(sMt["cargo_capacity_formula"],
|
||||||
file, sPath + ".cargo_capacity_formula");
|
file, sPath + ".cargo_capacity_formula");
|
||||||
cap.collectionRateFormula = requireFormula(sMt["collection_rate_formula"],
|
cap.collectionRateFormula = requireFormula(sMt["collection_rate_hz_formula"],
|
||||||
file, sPath + ".collection_rate_formula");
|
file, sPath + ".collection_rate_hz_formula");
|
||||||
def.salvageCapability = std::move(cap);
|
def.salvageCapability = std::move(cap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -661,13 +669,13 @@ ModulesConfig ConfigLoader::loadModules(const std::string& path)
|
|||||||
const std::string rPath = elemPath + ".repair";
|
const std::string rPath = elemPath + ".repair";
|
||||||
const toml::table& rTable = requireTable(mt["repair"], file, rPath);
|
const toml::table& rTable = requireTable(mt["repair"], file, rPath);
|
||||||
toml::table& rMt = const_cast<toml::table&>(rTable);
|
toml::table& rMt = const_cast<toml::table&>(rTable);
|
||||||
if (rMt.contains("repair_rate_formula") || rMt.contains("repair_range_formula"))
|
if (rMt.contains("repair_rate_hz_formula") || rMt.contains("repair_range_m_formula"))
|
||||||
{
|
{
|
||||||
ModuleRepairCapability cap;
|
ModuleRepairCapability cap;
|
||||||
cap.repairRateFormula = requireFormula(rMt["repair_rate_formula"],
|
cap.repairRateFormula = requireFormula(rMt["repair_rate_hz_formula"],
|
||||||
file, rPath + ".repair_rate_formula");
|
file, rPath + ".repair_rate_hz_formula");
|
||||||
cap.repairRangeFormula = requireFormula(rMt["repair_range_formula"],
|
cap.repairRangeFormula = requireFormula(rMt["repair_range_m_formula"],
|
||||||
file, rPath + ".repair_range_formula");
|
file, rPath + ".repair_range_m_formula");
|
||||||
def.repairCapability = std::move(cap);
|
def.repairCapability = std::move(cap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -687,5 +695,6 @@ GameConfig ConfigLoader::loadFromDirectory(const std::string& configDir)
|
|||||||
cfg.ships = loadShips(configDir + "/ships.toml");
|
cfg.ships = loadShips(configDir + "/ships.toml");
|
||||||
cfg.stations = loadStations(configDir + "/stations.toml");
|
cfg.stations = loadStations(configDir + "/stations.toml");
|
||||||
cfg.modules = loadModules(configDir + "/modules.toml");
|
cfg.modules = loadModules(configDir + "/modules.toml");
|
||||||
|
cfg.threatCosts = computeThreatCostTable(cfg);
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "ShipsConfig.h"
|
#include "ShipsConfig.h"
|
||||||
#include "StationsConfig.h"
|
#include "StationsConfig.h"
|
||||||
#include "ModulesConfig.h"
|
#include "ModulesConfig.h"
|
||||||
|
#include "ThreatCostCalculator.h"
|
||||||
|
|
||||||
// Aggregate of all simulation config files. Loaded at startup and reloaded
|
// Aggregate of all simulation config files. Loaded at startup and reloaded
|
||||||
// from disk on each game restart (REQ-CFG-RELOAD). See architecture.md "Config Loading".
|
// from disk on each game restart (REQ-CFG-RELOAD). See architecture.md "Config Loading".
|
||||||
@@ -17,4 +18,5 @@ struct GameConfig
|
|||||||
ShipsConfig ships;
|
ShipsConfig ships;
|
||||||
StationsConfig stations;
|
StationsConfig stations;
|
||||||
ModulesConfig modules;
|
ModulesConfig modules;
|
||||||
|
ThreatCostTable threatCosts;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ struct ModuleRepairCapability
|
|||||||
struct ModuleDef
|
struct ModuleDef
|
||||||
{
|
{
|
||||||
std::string id;
|
std::string id;
|
||||||
|
int unlockAtStationLevel;
|
||||||
std::vector<std::string> surfaceMask;
|
std::vector<std::string> surfaceMask;
|
||||||
std::vector<RecipeIngredient> materials;
|
std::vector<RecipeIngredient> materials;
|
||||||
int playerProductionLevel;
|
int playerProductionLevel;
|
||||||
double productionTimeSeconds;
|
double productionTimeSeconds;
|
||||||
double threatCost;
|
|
||||||
std::string fillColor;
|
std::string fillColor;
|
||||||
std::string glyph;
|
std::string glyph;
|
||||||
std::vector<ModuleStatModifier> statModifiers;
|
std::vector<ModuleStatModifier> statModifiers;
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ struct RecipeDef
|
|||||||
std::vector<RecipeIngredient> inputs;
|
std::vector<RecipeIngredient> inputs;
|
||||||
std::vector<RecipeOutput> outputs;
|
std::vector<RecipeOutput> outputs;
|
||||||
double durationSeconds;
|
double durationSeconds;
|
||||||
|
// Assembler only. nullopt = implicit-only locking. -1 = explicitly unlocked
|
||||||
|
// at game start. >= 0 = locked; schematic enters drop pool at that station
|
||||||
|
// level once the output item is implicitly unlocked (REQ-LOCK-EXPLICIT).
|
||||||
|
std::optional<int> unlockAtStationLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RecipesConfig
|
struct RecipesConfig
|
||||||
|
|||||||
@@ -16,13 +16,6 @@ struct ShipSchematic
|
|||||||
double productionTimeSeconds;
|
double productionTimeSeconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wave scheduling cost (REQ-WAV-THREAT-COST). Ships with cost_formula that
|
|
||||||
// always evaluates to 0 are ineligible as wave picks.
|
|
||||||
struct ShipThreat
|
|
||||||
{
|
|
||||||
Formula costFormula;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ShipHealth
|
struct ShipHealth
|
||||||
{
|
{
|
||||||
Formula hpFormula; // REQ-SHP-STATS
|
Formula hpFormula; // REQ-SHP-STATS
|
||||||
@@ -51,11 +44,10 @@ struct ShipLoot
|
|||||||
struct ShipDef
|
struct ShipDef
|
||||||
{
|
{
|
||||||
std::string id;
|
std::string id;
|
||||||
bool availableFromStart;
|
int unlockAtStationLevel;
|
||||||
std::vector<std::string> layout;
|
std::vector<std::string> layout;
|
||||||
|
|
||||||
ShipSchematic schematic;
|
ShipSchematic schematic;
|
||||||
ShipThreat threat;
|
|
||||||
ShipHealth health;
|
ShipHealth health;
|
||||||
ShipMovement movement;
|
ShipMovement movement;
|
||||||
ShipSensor sensor;
|
ShipSensor sensor;
|
||||||
|
|||||||
@@ -5,23 +5,23 @@
|
|||||||
// Region widths are in tiles (REQ-GW-REGIONS).
|
// Region widths are in tiles (REQ-GW-REGIONS).
|
||||||
struct WorldRegions
|
struct WorldRegions
|
||||||
{
|
{
|
||||||
int asteroidWidth;
|
int asteroidWidth_tiles;
|
||||||
int playerBufferWidth;
|
int playerBufferWidth_tiles;
|
||||||
int contestZoneWidth;
|
int contestZoneWidth_tiles;
|
||||||
int enemyBufferWidth;
|
int enemyBufferWidth_tiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Asteroid expansion (REQ-EXP-UNLOCK, REQ-EXP-COST).
|
// Asteroid expansion (REQ-EXP-UNLOCK, REQ-EXP-COST).
|
||||||
struct WorldExpansion
|
struct WorldExpansion
|
||||||
{
|
{
|
||||||
int columnsPerExpansion;
|
int columnsPerExpansion_tiles;
|
||||||
int costBuildingBlocks;
|
int costBuildingBlocks;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Push effects (REQ-PSH-*, REQ-WAV-BOSS-ADVANCE).
|
// Push effects (REQ-PSH-*, REQ-WAV-BOSS-ADVANCE).
|
||||||
struct WorldPush
|
struct WorldPush
|
||||||
{
|
{
|
||||||
int pushExpandColumns;
|
int pushExpandColumns_tiles;
|
||||||
double bossAdvanceSeconds; // boss countdown advanced by this much per push
|
double bossAdvanceSeconds; // boss countdown advanced by this much per push
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,8 +45,9 @@ struct WorldConfig
|
|||||||
int refundPercentage; // REQ-BLD-DEMOLISH
|
int refundPercentage; // REQ-BLD-DEMOLISH
|
||||||
int startingBuildingBlocks; // REQ-HQ-STARTING-BLOCKS
|
int startingBuildingBlocks; // REQ-HQ-STARTING-BLOCKS
|
||||||
double scrapDespawnSeconds; // REQ-RES-SCRAP-DROP
|
double scrapDespawnSeconds; // REQ-RES-SCRAP-DROP
|
||||||
double beltSpeedTilesPerSecond; // REQ-GW-BELT-SPEED
|
double tileSize_m; // metres per tile (REQ-GW-TILE-SIZE)
|
||||||
int tunnelMaxDistance; // REQ-BLD-TUNNEL-PAIR
|
double beltSpeed_tps; // REQ-GW-BELT-SPEED (tiles/s, converted from m/s in config)
|
||||||
|
int tunnelMaxDistance_tiles; // REQ-BLD-TUNNEL-PAIR
|
||||||
double departureIntervalSeconds; // REQ-SHP-RALLY
|
double departureIntervalSeconds; // REQ-SHP-RALLY
|
||||||
|
|
||||||
WorldRegions regions;
|
WorldRegions regions;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -8,6 +9,7 @@
|
|||||||
|
|
||||||
#include "BuildingType.h"
|
#include "BuildingType.h"
|
||||||
#include "Rotation.h"
|
#include "Rotation.h"
|
||||||
|
#include "ShipLayout.h"
|
||||||
|
|
||||||
struct BlueprintBuilding
|
struct BlueprintBuilding
|
||||||
{
|
{
|
||||||
@@ -15,6 +17,7 @@ struct BlueprintBuilding
|
|||||||
Rotation rotation;
|
Rotation rotation;
|
||||||
QPoint offset; // tile offset from bounding-box center (floor for even sizes)
|
QPoint offset; // tile offset from bounding-box center (floor for even sizes)
|
||||||
std::string recipeId; // empty = none selected
|
std::string recipeId; // empty = none selected
|
||||||
|
std::optional<ShipLayoutConfig> shipLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Blueprint
|
struct Blueprint
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ SET(HDRS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/EntityAdmin.h
|
${CMAKE_CURRENT_SOURCE_DIR}/EntityAdmin.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Blueprint.h
|
${CMAKE_CURRENT_SOURCE_DIR}/Blueprint.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/BuildingId.h
|
${CMAKE_CURRENT_SOURCE_DIR}/BuildingId.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/FireEvent.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ItemType.h
|
${CMAKE_CURRENT_SOURCE_DIR}/ItemType.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Item.h
|
${CMAKE_CURRENT_SOURCE_DIR}/Item.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Port.h
|
${CMAKE_CURRENT_SOURCE_DIR}/Port.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/SchematicDropEvent.h
|
${CMAKE_CURRENT_SOURCE_DIR}/SchematicChoiceOption.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/DisplayName.h
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ SET(SRCS
|
|||||||
${SRCS}
|
${SRCS}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/BuildingType.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/BuildingType.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/EntityAdmin.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/EntityAdmin.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/DisplayName.cpp
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
27
src/lib/core/DisplayName.cpp
Normal file
27
src/lib/core/DisplayName.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include "DisplayName.h"
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
|
std::string toDisplayName(const std::string& id)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
bool nextUpper = true;
|
||||||
|
for (char c : id)
|
||||||
|
{
|
||||||
|
if (c == '_')
|
||||||
|
{
|
||||||
|
result += ' ';
|
||||||
|
nextUpper = true;
|
||||||
|
}
|
||||||
|
else if (nextUpper)
|
||||||
|
{
|
||||||
|
result += static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
|
||||||
|
nextUpper = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
5
src/lib/core/DisplayName.h
Normal file
5
src/lib/core/DisplayName.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
std::string toDisplayName(const std::string& id);
|
||||||
@@ -39,9 +39,9 @@ void EntityAdmin::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
entt::entity EntityAdmin::spawnShip(QVector2D position, float hp, float maxHp,
|
entt::entity EntityAdmin::spawnShip(QVector2D position, float hp, float maxHp,
|
||||||
float maxSpeedPerTick, float mainAccelPerTick,
|
float maxSpeed_tpt, float mainAcceleration_tptt,
|
||||||
float maneuveringAccelPerTick, float angularAccelPerTick,
|
float maneuveringAcceleration_tptt, float maxAngularAcceleration_rptt,
|
||||||
float maxRotationSpeedPerTick, float sensorRange,
|
float maxRotationSpeed_rpt, float sensorRange_tiles,
|
||||||
int level, const std::string& schematicId, bool isEnemy)
|
int level, const std::string& schematicId, bool isEnemy)
|
||||||
{
|
{
|
||||||
entt::entity entity = createEntity();
|
entt::entity entity = createEntity();
|
||||||
@@ -50,17 +50,17 @@ entt::entity EntityAdmin::spawnShip(QVector2D position, float hp, float maxHp,
|
|||||||
add<FactionComponent>(entity, FactionComponent{isEnemy});
|
add<FactionComponent>(entity, FactionComponent{isEnemy});
|
||||||
add<FacingComponent>(entity, FacingComponent{0.0f});
|
add<FacingComponent>(entity, FacingComponent{0.0f});
|
||||||
add<DynamicBodyComponent>(entity, DynamicBodyComponent{
|
add<DynamicBodyComponent>(entity, DynamicBodyComponent{
|
||||||
maxSpeedPerTick,
|
maxSpeed_tpt,
|
||||||
mainAccelPerTick,
|
mainAcceleration_tptt,
|
||||||
maneuveringAccelPerTick,
|
maneuveringAcceleration_tptt,
|
||||||
angularAccelPerTick,
|
maxAngularAcceleration_rptt,
|
||||||
maxRotationSpeedPerTick,
|
maxRotationSpeed_rpt,
|
||||||
QVector2D(0.0f, 0.0f), // velocity
|
QVector2D(0.0f, 0.0f), // velocity_tpt
|
||||||
0.0f, // angularVelocity
|
0.0f, // angularVelocity_rpt
|
||||||
QVector2D(0.0f, 0.0f), // linearAcceleration
|
QVector2D(0.0f, 0.0f), // linearAcceleration_tptt
|
||||||
0.0f // angularAcceleration
|
0.0f // angularAcceleration_rptt
|
||||||
});
|
});
|
||||||
add<SensorRangeComponent>(entity, SensorRangeComponent{sensorRange});
|
add<SensorRangeComponent>(entity, SensorRangeComponent{sensorRange_tiles});
|
||||||
add<ShipIdentityComponent>(entity, ShipIdentityComponent{level, schematicId});
|
add<ShipIdentityComponent>(entity, ShipIdentityComponent{level, schematicId});
|
||||||
add<MovementIntentComponent>(entity, MovementIntentComponent{0, QVector2D(0.0f, 0.0f)});
|
add<MovementIntentComponent>(entity, MovementIntentComponent{0, QVector2D(0.0f, 0.0f)});
|
||||||
return entity;
|
return entity;
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ public:
|
|||||||
// -- Factory methods ----------------------------------------------------
|
// -- Factory methods ----------------------------------------------------
|
||||||
|
|
||||||
entt::entity spawnShip(QVector2D position, float hp, float maxHp,
|
entt::entity spawnShip(QVector2D position, float hp, float maxHp,
|
||||||
float maxSpeedPerTick, float mainAccelPerTick,
|
float maxSpeed_tpt, float mainAcceleration_tptt,
|
||||||
float maneuveringAccelPerTick, float angularAccelPerTick,
|
float maneuveringAcceleration_tptt, float maxAngularAcceleration_rptt,
|
||||||
float maxRotationSpeedPerTick, float sensorRange,
|
float maxRotationSpeed_rpt, float sensorRange_tiles,
|
||||||
int level, const std::string& schematicId, bool isEnemy);
|
int level, const std::string& schematicId, bool isEnemy);
|
||||||
|
|
||||||
entt::entity spawnStation(QPoint anchor, QSize footprint,
|
entt::entity spawnStation(QPoint anchor, QSize footprint,
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Tick.h"
|
|
||||||
|
|
||||||
#include "entt/entity/entity.hpp"
|
|
||||||
|
|
||||||
// Transient record emitted each time a weapon fires (REQ-SHP-FIRING,
|
|
||||||
// REQ-SHP-FIRING-BEAM). Buffered in a sim-owned queue and drained by the
|
|
||||||
// renderer each frame to draw the 0.3-second laser beam.
|
|
||||||
struct FireEvent
|
|
||||||
{
|
|
||||||
entt::entity shooter;
|
|
||||||
entt::entity target;
|
|
||||||
Tick emittedAt;
|
|
||||||
};
|
|
||||||
28
src/lib/core/SchematicChoiceOption.h
Normal file
28
src/lib/core/SchematicChoiceOption.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
enum class SchematicType
|
||||||
|
{
|
||||||
|
Ship,
|
||||||
|
Module,
|
||||||
|
Recipe
|
||||||
|
};
|
||||||
|
|
||||||
|
// One option presented to the player in the schematic choice dialog
|
||||||
|
// (REQ-DEF-SCHEMATIC-DROP). Built by the simulation when enemy stations are
|
||||||
|
// destroyed; the UI reads these to populate the dialog.
|
||||||
|
struct SchematicChoiceOption
|
||||||
|
{
|
||||||
|
std::string schematicId;
|
||||||
|
SchematicType type;
|
||||||
|
std::string displayName;
|
||||||
|
bool isNewUnlock;
|
||||||
|
int targetLevel;
|
||||||
|
|
||||||
|
// Display names of items produced by recipes that would newly become
|
||||||
|
// implicitly unlocked (REQ-LOCK-IMPLICIT) if this option is selected.
|
||||||
|
// Deduplicated and sorted alphabetically; empty if none.
|
||||||
|
std::vector<std::string> newlyUnlockedItemNames;
|
||||||
|
};
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// Emitted in tick step 9 (Deaths & loot) when a destroyed enemy-defence-station
|
|
||||||
// set awards a schematic (REQ-DEF-SCHEMATIC-DROP). The UI renders a toast
|
|
||||||
// (REQ-UI-SCHEMATIC-TOAST); wasNewUnlock chooses between the "unlocked" and
|
|
||||||
// "level -> N" wording.
|
|
||||||
struct SchematicDropEvent
|
|
||||||
{
|
|
||||||
std::string schematicId; // matches ShipDef::id in the config.
|
|
||||||
int newLevel;
|
|
||||||
bool wasNewUnlock;
|
|
||||||
};
|
|
||||||
@@ -4,18 +4,18 @@
|
|||||||
|
|
||||||
struct DynamicBodyComponent
|
struct DynamicBodyComponent
|
||||||
{
|
{
|
||||||
// --- dynamics parameters (formerly ShipDynamics) ---
|
// --- dynamics parameters ---
|
||||||
float maxSpeedPerTick;
|
float maxSpeed_tpt; // tiles/tick
|
||||||
float mainAccelerationPerTick;
|
float mainAcceleration_tptt; // tiles/tick²
|
||||||
float maneuveringAccelerationPerTick;
|
float maneuveringAcceleration_tptt; // tiles/tick²
|
||||||
float angularAccelerationPerTick;
|
float maxAngularAcceleration_rptt; // rad/tick²
|
||||||
float maxRotationSpeedPerTick;
|
float maxRotationSpeed_rpt; // rad/tick
|
||||||
|
|
||||||
// --- integrated state ---
|
// --- integrated state ---
|
||||||
QVector2D velocity;
|
QVector2D velocity_tpt; // tiles/tick
|
||||||
float angularVelocity;
|
float angularVelocity_rpt; // rad/tick
|
||||||
|
|
||||||
// --- written each tick by MovementIntentSystem, consumed by DynamicBodySystem ---
|
// --- written each tick by MovementIntentSystem, consumed by DynamicBodySystem ---
|
||||||
QVector2D linearAcceleration;
|
QVector2D linearAcceleration_tptt; // tiles/tick²
|
||||||
float angularAcceleration;
|
float angularAcceleration_rptt; // rad/tick²
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,5 +7,5 @@
|
|||||||
struct RepairBehaviorComponent
|
struct RepairBehaviorComponent
|
||||||
{
|
{
|
||||||
std::optional<entt::entity> currentTarget;
|
std::optional<entt::entity> currentTarget;
|
||||||
float maxRepairRange = 0.0f;
|
float maxRepairRange_tiles = 0.0f;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
struct RepairToolComponent
|
struct RepairToolComponent
|
||||||
{
|
{
|
||||||
float ratePerTick;
|
float ratePerTick;
|
||||||
float range;
|
float range_tiles;
|
||||||
std::optional<entt::entity> currentTarget;
|
std::optional<entt::entity> currentTarget;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ struct SalvageBehaviorComponent
|
|||||||
{
|
{
|
||||||
std::optional<QVector2D> scrapTarget;
|
std::optional<QVector2D> scrapTarget;
|
||||||
BuildingId deliveryBay; // kInvalidBuildingId until assigned at a salvage bay
|
BuildingId deliveryBay; // kInvalidBuildingId until assigned at a salvage bay
|
||||||
float maxCollectionRange = 0.0f;
|
float maxCollectionRange_tiles = 0.0f;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ struct SalvageCargoComponent
|
|||||||
{
|
{
|
||||||
int capacity;
|
int capacity;
|
||||||
int current;
|
int current;
|
||||||
float collectionRange;
|
float collectionRange_tiles;
|
||||||
int collectionIntervalTicks;
|
int collectionIntervalTicks;
|
||||||
int cooldownTicksRemaining;
|
int cooldownTicksRemaining;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
struct SensorRangeComponent
|
struct SensorRangeComponent
|
||||||
{
|
{
|
||||||
float value;
|
float value_tiles;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
struct WeaponComponent
|
struct WeaponComponent
|
||||||
{
|
{
|
||||||
float damage;
|
float damage;
|
||||||
float range;
|
float range_tiles;
|
||||||
float fireRateHz;
|
float fireRateHz;
|
||||||
float cooldownTicks;
|
float cooldownTicks;
|
||||||
std::optional<entt::entity> currentTarget;
|
std::optional<entt::entity> currentTarget;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "ShipIdentityComponent.h"
|
#include "ShipIdentityComponent.h"
|
||||||
#include "StationBodyComponent.h"
|
#include "StationBodyComponent.h"
|
||||||
#include "ThreatResponseBehaviorComponent.h"
|
#include "ThreatResponseBehaviorComponent.h"
|
||||||
|
#include "tracing.h"
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Shared helpers for repair targeting
|
// Shared helpers for repair targeting
|
||||||
@@ -72,6 +73,7 @@ static std::vector<RepairableInfo> buildRepairables(EntityAdmin& admin)
|
|||||||
|
|
||||||
void AiSystem::tickHomeReturnBehavior(EntityAdmin& admin)
|
void AiSystem::tickHomeReturnBehavior(EntityAdmin& admin)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
admin.forEach<HomeReturnBehaviorComponent, HealthComponent, MovementIntentComponent>(
|
admin.forEach<HomeReturnBehaviorComponent, HealthComponent, MovementIntentComponent>(
|
||||||
[](entt::entity /*e*/, const HomeReturnBehaviorComponent& homeReturnBehavior,
|
[](entt::entity /*e*/, const HomeReturnBehaviorComponent& homeReturnBehavior,
|
||||||
const HealthComponent& h, MovementIntentComponent& intent)
|
const HealthComponent& h, MovementIntentComponent& intent)
|
||||||
@@ -92,6 +94,7 @@ void AiSystem::tickHomeReturnBehavior(EntityAdmin& admin)
|
|||||||
|
|
||||||
void AiSystem::tickThreatResponseBehavior(EntityAdmin& admin, const BuildingSystem& buildings)
|
void AiSystem::tickThreatResponseBehavior(EntityAdmin& admin, const BuildingSystem& buildings)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
// Snapshot all combatant entities for target acquisition.
|
// Snapshot all combatant entities for target acquisition.
|
||||||
struct CombatantInfo
|
struct CombatantInfo
|
||||||
{
|
{
|
||||||
@@ -129,7 +132,7 @@ void AiSystem::tickThreatResponseBehavior(EntityAdmin& admin, const BuildingSyst
|
|||||||
PositionComponent& pos, FactionComponent& faction,
|
PositionComponent& pos, FactionComponent& faction,
|
||||||
SensorRangeComponent& sensor, MovementIntentComponent& intent)
|
SensorRangeComponent& sensor, MovementIntentComponent& intent)
|
||||||
{
|
{
|
||||||
const float range = sensor.value;
|
const float range = sensor.value_tiles;
|
||||||
|
|
||||||
// Validate current target.
|
// Validate current target.
|
||||||
bool targetValid = false;
|
bool targetValid = false;
|
||||||
@@ -219,6 +222,7 @@ void AiSystem::tickThreatResponseBehavior(EntityAdmin& admin, const BuildingSyst
|
|||||||
|
|
||||||
void AiSystem::tickRepairBehavior(EntityAdmin& admin, BuildingSystem& buildings)
|
void AiSystem::tickRepairBehavior(EntityAdmin& admin, BuildingSystem& buildings)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
std::vector<RepairableInfo> repairables = buildRepairables(admin);
|
std::vector<RepairableInfo> repairables = buildRepairables(admin);
|
||||||
|
|
||||||
// Snapshot enemy ships for threat detection.
|
// Snapshot enemy ships for threat detection.
|
||||||
@@ -247,7 +251,7 @@ void AiSystem::tickRepairBehavior(EntityAdmin& admin, BuildingSystem& buildings)
|
|||||||
bool enemyNearby = false;
|
bool enemyNearby = false;
|
||||||
for (const EnemyInfo& enemy : enemies)
|
for (const EnemyInfo& enemy : enemies)
|
||||||
{
|
{
|
||||||
if ((enemy.position - pos.value).length() <= sensor.value)
|
if ((enemy.position - pos.value).length() <= sensor.value_tiles)
|
||||||
{
|
{
|
||||||
enemyNearby = true;
|
enemyNearby = true;
|
||||||
break;
|
break;
|
||||||
@@ -281,7 +285,7 @@ void AiSystem::tickRepairBehavior(EntityAdmin& admin, BuildingSystem& buildings)
|
|||||||
if (!targetValid)
|
if (!targetValid)
|
||||||
{
|
{
|
||||||
rb.currentTarget = std::nullopt;
|
rb.currentTarget = std::nullopt;
|
||||||
float bestDist = sensor.value;
|
float bestDist = sensor.value_tiles;
|
||||||
|
|
||||||
for (const RepairableInfo& r : repairables)
|
for (const RepairableInfo& r : repairables)
|
||||||
{
|
{
|
||||||
@@ -327,6 +331,7 @@ void AiSystem::tickRepairBehavior(EntityAdmin& admin, BuildingSystem& buildings)
|
|||||||
|
|
||||||
void AiSystem::tickRepairTools(EntityAdmin& admin)
|
void AiSystem::tickRepairTools(EntityAdmin& admin)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
const std::vector<RepairableInfo> repairables = buildRepairables(admin);
|
const std::vector<RepairableInfo> repairables = buildRepairables(admin);
|
||||||
|
|
||||||
admin.forEach<RepairToolComponent, ModuleOwnerComponent>(
|
admin.forEach<RepairToolComponent, ModuleOwnerComponent>(
|
||||||
@@ -350,7 +355,7 @@ void AiSystem::tickRepairTools(EntityAdmin& admin)
|
|||||||
const float dist =
|
const float dist =
|
||||||
(admin.get<PositionComponent>(preferred).value
|
(admin.get<PositionComponent>(preferred).value
|
||||||
- ownerPos.value).length();
|
- ownerPos.value).length();
|
||||||
if (th.hp > 0.0f && th.hp < th.maxHp && dist <= rt.range)
|
if (th.hp > 0.0f && th.hp < th.maxHp && dist <= rt.range_tiles)
|
||||||
{
|
{
|
||||||
rt.currentTarget = rb.currentTarget;
|
rt.currentTarget = rb.currentTarget;
|
||||||
th.hp = std::min(th.hp + rt.ratePerTick, th.maxHp);
|
th.hp = std::min(th.hp + rt.ratePerTick, th.maxHp);
|
||||||
@@ -361,7 +366,7 @@ void AiSystem::tickRepairTools(EntityAdmin& admin)
|
|||||||
|
|
||||||
// Preferred target unavailable; scan for nearest damaged friendly in range.
|
// Preferred target unavailable; scan for nearest damaged friendly in range.
|
||||||
rt.currentTarget = std::nullopt;
|
rt.currentTarget = std::nullopt;
|
||||||
float bestDist = rt.range;
|
float bestDist = rt.range_tiles;
|
||||||
for (const RepairableInfo& r : repairables)
|
for (const RepairableInfo& r : repairables)
|
||||||
{
|
{
|
||||||
if (r.isEnemy) { continue; }
|
if (r.isEnemy) { continue; }
|
||||||
@@ -389,6 +394,7 @@ void AiSystem::tickRepairTools(EntityAdmin& admin)
|
|||||||
void AiSystem::tickSalvageBehavior(EntityAdmin& admin, ScrapSystem& scraps,
|
void AiSystem::tickSalvageBehavior(EntityAdmin& admin, ScrapSystem& scraps,
|
||||||
BuildingSystem& buildings)
|
BuildingSystem& buildings)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
// Snapshot enemy ships for threat detection.
|
// Snapshot enemy ships for threat detection.
|
||||||
struct EnemyShipPos
|
struct EnemyShipPos
|
||||||
{
|
{
|
||||||
@@ -435,7 +441,7 @@ void AiSystem::tickSalvageBehavior(EntityAdmin& admin, ScrapSystem& scraps,
|
|||||||
PositionComponent& pos,
|
PositionComponent& pos,
|
||||||
SensorRangeComponent& sensor, MovementIntentComponent& intent)
|
SensorRangeComponent& sensor, MovementIntentComponent& intent)
|
||||||
{
|
{
|
||||||
const float collectRange = salvageBehavior.maxCollectionRange;
|
const float collectRange = salvageBehavior.maxCollectionRange_tiles;
|
||||||
const AggregatedCargo& cargoState = cargoByShip[e];
|
const AggregatedCargo& cargoState = cargoByShip[e];
|
||||||
|
|
||||||
// Assign nearest SalvageBay if needed.
|
// Assign nearest SalvageBay if needed.
|
||||||
@@ -524,7 +530,7 @@ void AiSystem::tickSalvageBehavior(EntityAdmin& admin, ScrapSystem& scraps,
|
|||||||
}
|
}
|
||||||
for (const ScrapInfo& si : allScrap)
|
for (const ScrapInfo& si : allScrap)
|
||||||
{
|
{
|
||||||
if ((si.position - pos.value).length() > c.collectionRange) { continue; }
|
if ((si.position - pos.value).length() > c.collectionRange_tiles) { continue; }
|
||||||
if (scraps.consume(si.entity))
|
if (scraps.consume(si.entity))
|
||||||
{
|
{
|
||||||
++c.current;
|
++c.current;
|
||||||
@@ -549,7 +555,7 @@ void AiSystem::tickSalvageBehavior(EntityAdmin& admin, ScrapSystem& scraps,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float bestDist = sensor.value;
|
float bestDist = sensor.value_tiles;
|
||||||
std::optional<QVector2D> bestPos;
|
std::optional<QVector2D> bestPos;
|
||||||
for (const ScrapInfo& si : allScrap)
|
for (const ScrapInfo& si : allScrap)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "SensorRangeComponent.h"
|
#include "SensorRangeComponent.h"
|
||||||
#include "ShipIdentityComponent.h"
|
#include "ShipIdentityComponent.h"
|
||||||
#include "ThreatResponseBehaviorComponent.h"
|
#include "ThreatResponseBehaviorComponent.h"
|
||||||
|
#include "tracing.h"
|
||||||
#include "WeaponComponent.h"
|
#include "WeaponComponent.h"
|
||||||
|
|
||||||
static constexpr Tick kWeaponImpactDelayTicks = 5;
|
static constexpr Tick kWeaponImpactDelayTicks = 5;
|
||||||
@@ -20,8 +21,9 @@ CombatSystem::CombatSystem(const GameConfig& config)
|
|||||||
void CombatSystem::tick(Tick currentTick,
|
void CombatSystem::tick(Tick currentTick,
|
||||||
EntityAdmin& admin,
|
EntityAdmin& admin,
|
||||||
BuildingSystem& /*buildings*/,
|
BuildingSystem& /*buildings*/,
|
||||||
std::vector<FireEvent>& outFireEvents)
|
std::vector<WeaponFiredEvent>& outWeaponFiredEvents)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
// All weapons (ships and stations) are child entities linked via ModuleOwnerComponent.
|
// All weapons (ships and stations) are child entities linked via ModuleOwnerComponent.
|
||||||
admin.forEach<WeaponComponent, ModuleOwnerComponent>(
|
admin.forEach<WeaponComponent, ModuleOwnerComponent>(
|
||||||
[&](entt::entity /*e*/, WeaponComponent& weapon, const ModuleOwnerComponent& owner)
|
[&](entt::entity /*e*/, WeaponComponent& weapon, const ModuleOwnerComponent& owner)
|
||||||
@@ -33,7 +35,7 @@ void CombatSystem::tick(Tick currentTick,
|
|||||||
}
|
}
|
||||||
const PositionComponent& pos = admin.get<PositionComponent>(owner.owner);
|
const PositionComponent& pos = admin.get<PositionComponent>(owner.owner);
|
||||||
const FactionComponent& faction = admin.get<FactionComponent>(owner.owner);
|
const FactionComponent& faction = admin.get<FactionComponent>(owner.owner);
|
||||||
resolveWeapon(owner.owner, weapon, pos, faction, currentTick, admin, outFireEvents);
|
resolveWeapon(owner.owner, weapon, pos, faction, currentTick, admin, outWeaponFiredEvents);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +46,7 @@ void CombatSystem::resolveWeapon(
|
|||||||
const FactionComponent& ownFaction,
|
const FactionComponent& ownFaction,
|
||||||
Tick currentTick,
|
Tick currentTick,
|
||||||
EntityAdmin& admin,
|
EntityAdmin& admin,
|
||||||
std::vector<FireEvent>& out)
|
std::vector<WeaponFiredEvent>& out)
|
||||||
{
|
{
|
||||||
if (weapon.cooldownTicks > 0.0f)
|
if (weapon.cooldownTicks > 0.0f)
|
||||||
{
|
{
|
||||||
@@ -67,7 +69,7 @@ void CombatSystem::resolveWeapon(
|
|||||||
{
|
{
|
||||||
const float distanceSquared =
|
const float distanceSquared =
|
||||||
(ownPos.value - admin.get<PositionComponent>(t).value).lengthSquared();
|
(ownPos.value - admin.get<PositionComponent>(t).value).lengthSquared();
|
||||||
if (distanceSquared > weapon.range * weapon.range)
|
if (distanceSquared > weapon.range_tiles * weapon.range_tiles)
|
||||||
{
|
{
|
||||||
weapon.currentTarget = std::nullopt;
|
weapon.currentTarget = std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -79,8 +81,8 @@ void CombatSystem::resolveWeapon(
|
|||||||
if (!weapon.currentTarget)
|
if (!weapon.currentTarget)
|
||||||
{
|
{
|
||||||
const float acquisitionRange = admin.hasAll<SensorRangeComponent>(shipEntity)
|
const float acquisitionRange = admin.hasAll<SensorRangeComponent>(shipEntity)
|
||||||
? admin.get<SensorRangeComponent>(shipEntity).value
|
? admin.get<SensorRangeComponent>(shipEntity).value_tiles
|
||||||
: weapon.range;
|
: weapon.range_tiles;
|
||||||
float bestDistanceSquared = acquisitionRange * acquisitionRange;
|
float bestDistanceSquared = acquisitionRange * acquisitionRange;
|
||||||
admin.forEach<ShipIdentityComponent, PositionComponent, FactionComponent>(
|
admin.forEach<ShipIdentityComponent, PositionComponent, FactionComponent>(
|
||||||
[&](entt::entity candidate, const ShipIdentityComponent& /*si*/,
|
[&](entt::entity candidate, const ShipIdentityComponent& /*si*/,
|
||||||
@@ -113,7 +115,7 @@ void CombatSystem::resolveWeapon(
|
|||||||
m_pendingDamage.push_back({targetEntity, weapon.damage,
|
m_pendingDamage.push_back({targetEntity, weapon.damage,
|
||||||
currentTick + kWeaponImpactDelayTicks});
|
currentTick + kWeaponImpactDelayTicks});
|
||||||
|
|
||||||
FireEvent evt;
|
WeaponFiredEvent evt;
|
||||||
evt.shooter = shipEntity;
|
evt.shooter = shipEntity;
|
||||||
evt.target = targetEntity;
|
evt.target = targetEntity;
|
||||||
evt.emittedAt = currentTick;
|
evt.emittedAt = currentTick;
|
||||||
@@ -124,6 +126,7 @@ void CombatSystem::resolveWeapon(
|
|||||||
|
|
||||||
void CombatSystem::applyPendingDamage(Tick currentTick, EntityAdmin& admin)
|
void CombatSystem::applyPendingDamage(Tick currentTick, EntityAdmin& admin)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
std::vector<PendingDamage>::iterator it = m_pendingDamage.begin();
|
std::vector<PendingDamage>::iterator it = m_pendingDamage.begin();
|
||||||
while (it != m_pendingDamage.end())
|
while (it != m_pendingDamage.end())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "Building.h"
|
#include "Building.h"
|
||||||
#include "FactionComponent.h"
|
#include "FactionComponent.h"
|
||||||
#include "FireEvent.h"
|
#include "WeaponFiredEvent.h"
|
||||||
#include "GameConfig.h"
|
#include "GameConfig.h"
|
||||||
#include "PositionComponent.h"
|
#include "PositionComponent.h"
|
||||||
#include "Tick.h"
|
#include "Tick.h"
|
||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
void tick(Tick currentTick,
|
void tick(Tick currentTick,
|
||||||
EntityAdmin& admin,
|
EntityAdmin& admin,
|
||||||
BuildingSystem& buildings,
|
BuildingSystem& buildings,
|
||||||
std::vector<FireEvent>& outFireEvents);
|
std::vector<WeaponFiredEvent>& outWeaponFiredEvents);
|
||||||
|
|
||||||
void applyPendingDamage(Tick currentTick, EntityAdmin& admin);
|
void applyPendingDamage(Tick currentTick, EntityAdmin& admin);
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ private:
|
|||||||
const FactionComponent& ownFaction,
|
const FactionComponent& ownFaction,
|
||||||
Tick currentTick,
|
Tick currentTick,
|
||||||
EntityAdmin& admin,
|
EntityAdmin& admin,
|
||||||
std::vector<FireEvent>& out);
|
std::vector<WeaponFiredEvent>& out);
|
||||||
|
|
||||||
const GameConfig& m_config;
|
const GameConfig& m_config;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "EntityAdmin.h"
|
#include "EntityAdmin.h"
|
||||||
#include "FacingComponent.h"
|
#include "FacingComponent.h"
|
||||||
#include "PositionComponent.h"
|
#include "PositionComponent.h"
|
||||||
|
#include "tracing.h"
|
||||||
|
|
||||||
static float wrapAngle(float a)
|
static float wrapAngle(float a)
|
||||||
{
|
{
|
||||||
@@ -21,31 +22,33 @@ static float wrapAngle(float a)
|
|||||||
|
|
||||||
void DynamicBodySystem::tick(EntityAdmin& admin)
|
void DynamicBodySystem::tick(EntityAdmin& admin)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
admin.forEach<PositionComponent, FacingComponent, DynamicBodyComponent>(
|
admin.forEach<PositionComponent, FacingComponent, DynamicBodyComponent>(
|
||||||
[](entt::entity /*e*/, PositionComponent& pos, FacingComponent& facing,
|
[](entt::entity /*e*/, PositionComponent& pos, FacingComponent& facing,
|
||||||
DynamicBodyComponent& body)
|
DynamicBodyComponent& body)
|
||||||
{
|
{
|
||||||
// Integrate angular velocity, clamp to max rotation speed, then advance facing.
|
// Integrate angular velocity, clamp to max rotation speed, then advance facing.
|
||||||
body.angularVelocity += body.angularAcceleration;
|
body.angularVelocity_rpt += body.angularAcceleration_rptt;
|
||||||
body.angularVelocity = std::max(-body.maxRotationSpeedPerTick,
|
body.angularVelocity_rpt = std::max(-body.maxRotationSpeed_rpt,
|
||||||
std::min(body.angularVelocity,
|
std::min(body.angularVelocity_rpt,
|
||||||
body.maxRotationSpeedPerTick));
|
body.maxRotationSpeed_rpt));
|
||||||
facing.radians = wrapAngle(facing.radians + body.angularVelocity);
|
facing.radians = wrapAngle(facing.radians + body.angularVelocity_rpt);
|
||||||
|
|
||||||
// Integrate linear velocity and cap to max speed.
|
// Integrate linear velocity and cap to max speed.
|
||||||
body.velocity += body.linearAcceleration;
|
body.velocity_tpt += body.linearAcceleration_tptt;
|
||||||
const float speed = body.velocity.length();
|
const float speed = body.velocity_tpt.length();
|
||||||
if (speed > body.maxSpeedPerTick)
|
if (speed > body.maxSpeed_tpt)
|
||||||
{
|
{
|
||||||
body.velocity = body.velocity.normalized() * body.maxSpeedPerTick;
|
body.velocity_tpt = body.velocity_tpt.normalized() * body.maxSpeed_tpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance position.
|
// Advance position.
|
||||||
pos.value += body.velocity;
|
pos.value += body.velocity_tpt;
|
||||||
|
|
||||||
// Reset per-tick fields so stale values don't linger if the intent
|
// Reset per-tick fields so stale values don't linger if the intent
|
||||||
// system is skipped for this entity in a future tick.
|
// system is skipped for this entity in a future tick.
|
||||||
body.linearAcceleration = QVector2D(0.0f, 0.0f);
|
body.linearAcceleration_tptt = QVector2D(0.0f, 0.0f);
|
||||||
body.angularAcceleration = 0.0f;
|
body.angularAcceleration_rptt = 0.0f;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "FacingComponent.h"
|
#include "FacingComponent.h"
|
||||||
#include "MovementIntentComponent.h"
|
#include "MovementIntentComponent.h"
|
||||||
#include "PositionComponent.h"
|
#include "PositionComponent.h"
|
||||||
|
#include "tracing.h"
|
||||||
|
|
||||||
static float wrapAngle(float a)
|
static float wrapAngle(float a)
|
||||||
{
|
{
|
||||||
@@ -22,6 +23,7 @@ static float wrapAngle(float a)
|
|||||||
|
|
||||||
void MovementIntentSystem::tick(EntityAdmin& admin)
|
void MovementIntentSystem::tick(EntityAdmin& admin)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
admin.forEach<PositionComponent, FacingComponent, DynamicBodyComponent,
|
admin.forEach<PositionComponent, FacingComponent, DynamicBodyComponent,
|
||||||
MovementIntentComponent>(
|
MovementIntentComponent>(
|
||||||
[](entt::entity /*e*/, const PositionComponent& pos, const FacingComponent& facing,
|
[](entt::entity /*e*/, const PositionComponent& pos, const FacingComponent& facing,
|
||||||
@@ -30,16 +32,16 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
|
|||||||
if (intent.priority == 0)
|
if (intent.priority == 0)
|
||||||
{
|
{
|
||||||
// No movement intent: brake using available thrust.
|
// No movement intent: brake using available thrust.
|
||||||
const float linearBraking = std::min(body.velocity.length(),
|
const float linearBraking = std::min(body.velocity_tpt.length(),
|
||||||
body.maneuveringAccelerationPerTick);
|
body.maneuveringAcceleration_tptt);
|
||||||
body.linearAcceleration = (body.velocity.length() > 0.0001f)
|
body.linearAcceleration_tptt = (body.velocity_tpt.length() > 0.0001f)
|
||||||
? -body.velocity.normalized() * linearBraking
|
? -body.velocity_tpt.normalized() * linearBraking
|
||||||
: QVector2D(0.0f, 0.0f);
|
: QVector2D(0.0f, 0.0f);
|
||||||
|
|
||||||
const float angBraking = std::min(std::abs(body.angularVelocity),
|
const float angBraking = std::min(std::abs(body.angularVelocity_rpt),
|
||||||
body.angularAccelerationPerTick);
|
body.maxAngularAcceleration_rptt);
|
||||||
body.angularAcceleration =
|
body.angularAcceleration_rptt =
|
||||||
(body.angularVelocity >= 0.0f) ? -angBraking : angBraking;
|
(body.angularVelocity_rpt >= 0.0f) ? -angBraking : angBraking;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +52,8 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
|
|||||||
{
|
{
|
||||||
// Already at target: no new thrust. The ship drifts; it will
|
// Already at target: no new thrust. The ship drifts; it will
|
||||||
// re-approach next tick once it has moved away.
|
// re-approach next tick once it has moved away.
|
||||||
body.linearAcceleration = QVector2D(0.0f, 0.0f);
|
body.linearAcceleration_tptt = QVector2D(0.0f, 0.0f);
|
||||||
body.angularAcceleration = 0.0f;
|
body.angularAcceleration_rptt = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,11 +62,11 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
|
|||||||
const float desiredAngle = std::atan2(delta.y(), delta.x());
|
const float desiredAngle = std::atan2(delta.y(), delta.x());
|
||||||
const float angleDiff = wrapAngle(desiredAngle - facing.radians);
|
const float angleDiff = wrapAngle(desiredAngle - facing.radians);
|
||||||
|
|
||||||
const float rotDelta = std::max(-body.angularAccelerationPerTick,
|
const float rotDelta = std::max(-body.maxAngularAcceleration_rptt,
|
||||||
std::min(angleDiff,
|
std::min(angleDiff,
|
||||||
body.angularAccelerationPerTick));
|
body.maxAngularAcceleration_rptt));
|
||||||
|
|
||||||
float newAngVel = body.angularVelocity + rotDelta;
|
float newAngVel = body.angularVelocity_rpt + rotDelta;
|
||||||
|
|
||||||
// Overshoot prevention: if the accumulated angular velocity already
|
// Overshoot prevention: if the accumulated angular velocity already
|
||||||
// exceeds the remaining angle, snap it to exactly that angle so the
|
// exceeds the remaining angle, snap it to exactly that angle so the
|
||||||
@@ -75,8 +77,8 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
|
|||||||
newAngVel = angleDiff;
|
newAngVel = angleDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.angularAcceleration = newAngVel - body.angularVelocity;
|
body.angularAcceleration_rptt = newAngVel - body.angularVelocity_rpt;
|
||||||
// DynamicBodySystem applies the clamp to maxRotationSpeedPerTick after
|
// DynamicBodySystem applies the clamp to maxRotationSpeed_rpt after
|
||||||
// integrating, so we do not clamp here.
|
// integrating, so we do not clamp here.
|
||||||
|
|
||||||
// --- Linear acceleration ---
|
// --- Linear acceleration ---
|
||||||
@@ -88,22 +90,22 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
|
|||||||
const QVector2D facingVec(std::cos(projectedRadians),
|
const QVector2D facingVec(std::cos(projectedRadians),
|
||||||
std::sin(projectedRadians));
|
std::sin(projectedRadians));
|
||||||
|
|
||||||
const float manAccel = body.maneuveringAccelerationPerTick;
|
const float manAccel = body.maneuveringAcceleration_tptt;
|
||||||
const float stoppingDist = (body.maxSpeedPerTick * body.maxSpeedPerTick)
|
const float stoppingDist = (body.maxSpeed_tpt * body.maxSpeed_tpt)
|
||||||
/ (2.0f * manAccel);
|
/ (2.0f * manAccel);
|
||||||
// Cap to dist so the ship never overshoots the target in a single tick.
|
// Cap to dist so the ship never overshoots the target in a single tick.
|
||||||
const float baseDesiredSpeed = (dist <= stoppingDist)
|
const float baseDesiredSpeed = (dist <= stoppingDist)
|
||||||
? std::sqrt(2.0f * manAccel * dist)
|
? std::sqrt(2.0f * manAccel * dist)
|
||||||
: body.maxSpeedPerTick;
|
: body.maxSpeed_tpt;
|
||||||
const float desiredSpeed = std::min(dist, baseDesiredSpeed);
|
const float desiredSpeed = std::min(dist, baseDesiredSpeed);
|
||||||
|
|
||||||
const QVector2D desiredVel = delta.normalized() * desiredSpeed;
|
const QVector2D desiredVel = delta.normalized() * desiredSpeed;
|
||||||
const QVector2D velError = desiredVel - body.velocity;
|
const QVector2D velError = desiredVel - body.velocity_tpt;
|
||||||
|
|
||||||
const float mainAligned = std::max(0.0f,
|
const float mainAligned = std::max(0.0f,
|
||||||
QVector2D::dotProduct(velError, facingVec));
|
QVector2D::dotProduct(velError, facingVec));
|
||||||
const float mainApplied = std::min(mainAligned,
|
const float mainApplied = std::min(mainAligned,
|
||||||
body.mainAccelerationPerTick);
|
body.mainAcceleration_tptt);
|
||||||
const QVector2D mainDelta = facingVec * mainApplied;
|
const QVector2D mainDelta = facingVec * mainApplied;
|
||||||
|
|
||||||
const QVector2D remaining = velError - mainDelta;
|
const QVector2D remaining = velError - mainDelta;
|
||||||
@@ -112,6 +114,7 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
|
|||||||
? remaining.normalized() * manAccel
|
? remaining.normalized() * manAccel
|
||||||
: remaining;
|
: remaining;
|
||||||
|
|
||||||
body.linearAcceleration = mainDelta + maneuverDelta;
|
body.linearAcceleration_tptt = mainDelta + maneuverDelta;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "EntityAdmin.h"
|
#include "EntityAdmin.h"
|
||||||
#include "PositionComponent.h"
|
#include "PositionComponent.h"
|
||||||
#include "ScrapDataComponent.h"
|
#include "ScrapDataComponent.h"
|
||||||
|
#include "tracing.h"
|
||||||
|
|
||||||
ScrapSystem::ScrapSystem(EntityAdmin& admin)
|
ScrapSystem::ScrapSystem(EntityAdmin& admin)
|
||||||
: m_admin(admin)
|
: m_admin(admin)
|
||||||
@@ -17,6 +18,7 @@ entt::entity ScrapSystem::spawn(QVector2D position, int amount, Tick despawnAt)
|
|||||||
|
|
||||||
void ScrapSystem::tickDespawn(Tick currentTick)
|
void ScrapSystem::tickDespawn(Tick currentTick)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
std::vector<entt::entity> expired;
|
std::vector<entt::entity> expired;
|
||||||
m_admin.forEach<DespawnAtComponent>(
|
m_admin.forEach<DespawnAtComponent>(
|
||||||
[&expired, currentTick](entt::entity e, DespawnAtComponent& d)
|
[&expired, currentTick](entt::entity e, DespawnAtComponent& d)
|
||||||
@@ -54,3 +56,4 @@ std::vector<ScrapInfo> ScrapSystem::allScrapInfo() const
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
#include "SensorRangeComponent.h"
|
#include "SensorRangeComponent.h"
|
||||||
#include "Tick.h"
|
#include "Tick.h"
|
||||||
#include "ThreatResponseBehaviorComponent.h"
|
#include "ThreatResponseBehaviorComponent.h"
|
||||||
|
#include "tracing.h"
|
||||||
#include "WeaponComponent.h"
|
#include "WeaponComponent.h"
|
||||||
|
|
||||||
ShipSystem::ShipSystem(const GameConfig& config, EntityAdmin& admin)
|
ShipSystem::ShipSystem(const GameConfig& config, EntityAdmin& admin)
|
||||||
@@ -54,37 +56,40 @@ const ModuleDef* ShipSystem::findModuleDef(const std::string& id) const
|
|||||||
|
|
||||||
entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
||||||
QVector2D position, bool isEnemy,
|
QVector2D position, bool isEnemy,
|
||||||
const std::optional<ShipLayoutConfig>& layout)
|
const std::optional<ShipLayoutConfig>& layout,
|
||||||
|
const std::map<std::string, int>& moduleLevelOverrides)
|
||||||
{
|
{
|
||||||
const ShipDef* def = findShipDef(schematicId);
|
const ShipDef* def = findShipDef(schematicId);
|
||||||
assert(def != nullptr);
|
assert(def != nullptr);
|
||||||
|
|
||||||
const double x = static_cast<double>(level);
|
const double x = static_cast<double>(level);
|
||||||
const float tickRate = static_cast<float>(kTickRateHz);
|
const float tickRate = static_cast<float>(kTickRateHz);
|
||||||
|
const float tileSize = static_cast<float>(m_config.world.tileSize_m);
|
||||||
|
|
||||||
float hp = static_cast<float>(def->health.hpFormula.evaluate(x));
|
float hp = static_cast<float>(def->health.hpFormula.evaluate(x));
|
||||||
float maxHp = hp;
|
float maxHp = hp;
|
||||||
float maxSpeedPerTick = static_cast<float>(def->movement.speedFormula.evaluate(x))
|
float maxSpeed_tpt = static_cast<float>(def->movement.speedFormula.evaluate(x))
|
||||||
/ tickRate;
|
/ tileSize / tickRate;
|
||||||
float mainAccelPerTick = static_cast<float>(
|
float mainAcceleration_tptt = static_cast<float>(
|
||||||
def->movement.mainAccelerationFormula.evaluate(x))
|
def->movement.mainAccelerationFormula.evaluate(x))
|
||||||
/ tickRate;
|
/ tileSize / tickRate;
|
||||||
float maneuveringAccelPerTick = static_cast<float>(
|
float maneuveringAcceleration_tptt = static_cast<float>(
|
||||||
def->movement.maneuveringAccelerationFormula.evaluate(x))
|
def->movement.maneuveringAccelerationFormula.evaluate(x))
|
||||||
/ tickRate;
|
/ tileSize / tickRate;
|
||||||
float angularAccelPerTick = static_cast<float>(
|
float maxAngularAcceleration_rptt = static_cast<float>(
|
||||||
def->movement.angularAccelerationFormula.evaluate(x))
|
def->movement.angularAccelerationFormula.evaluate(x))
|
||||||
/ tickRate;
|
/ tickRate;
|
||||||
float maxRotationSpeedPerTick = static_cast<float>(
|
float maxRotationSpeed_rpt = static_cast<float>(
|
||||||
def->movement.maxRotationSpeedFormula.evaluate(x))
|
def->movement.maxRotationSpeedFormula.evaluate(x))
|
||||||
/ tickRate;
|
/ tickRate;
|
||||||
float sensorRange = static_cast<float>(
|
float sensorRange_tiles = static_cast<float>(
|
||||||
def->sensor.sensorRangeFormula.evaluate(x));
|
def->sensor.sensorRangeFormula.evaluate(x))
|
||||||
|
/ tileSize;
|
||||||
|
|
||||||
entt::entity entity = m_admin.spawnShip(
|
entt::entity entity = m_admin.spawnShip(
|
||||||
position, hp, maxHp,
|
position, hp, maxHp,
|
||||||
maxSpeedPerTick, mainAccelPerTick, maneuveringAccelPerTick,
|
maxSpeed_tpt, mainAcceleration_tptt, maneuveringAcceleration_tptt,
|
||||||
angularAccelPerTick, maxRotationSpeedPerTick, sensorRange,
|
maxAngularAcceleration_rptt, maxRotationSpeed_rpt, sensorRange_tiles,
|
||||||
level, schematicId, isEnemy);
|
level, schematicId, isEnemy);
|
||||||
|
|
||||||
// Determine module list: configured layout takes precedence over default.
|
// Determine module list: configured layout takes precedence over default.
|
||||||
@@ -99,17 +104,19 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
for (const PlacedModule& pm : modules)
|
for (const PlacedModule& pm : modules)
|
||||||
{
|
{
|
||||||
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
||||||
if (!modDef) { continue; }
|
if (!modDef) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||||
|
|
||||||
const double mx = static_cast<double>(modDef->playerProductionLevel);
|
const auto overIt = moduleLevelOverrides.find(pm.moduleId);
|
||||||
|
const double mx = static_cast<double>(
|
||||||
|
overIt != moduleLevelOverrides.end() ? overIt->second : modDef->playerProductionLevel);
|
||||||
|
|
||||||
if (modDef->weaponCapability)
|
if (modDef->weaponCapability)
|
||||||
{
|
{
|
||||||
WeaponComponent w;
|
WeaponComponent w;
|
||||||
w.damage = static_cast<float>(
|
w.damage = static_cast<float>(
|
||||||
modDef->weaponCapability->damageFormula.evaluate(mx));
|
modDef->weaponCapability->damageFormula.evaluate(mx));
|
||||||
w.range = static_cast<float>(
|
w.range_tiles = static_cast<float>(
|
||||||
modDef->weaponCapability->attackRangeFormula.evaluate(mx));
|
modDef->weaponCapability->attackRangeFormula.evaluate(mx)) / tileSize;
|
||||||
w.fireRateHz = static_cast<float>(
|
w.fireRateHz = static_cast<float>(
|
||||||
modDef->weaponCapability->attackRateFormula.evaluate(mx));
|
modDef->weaponCapability->attackRateFormula.evaluate(mx));
|
||||||
w.cooldownTicks = 0.0f;
|
w.cooldownTicks = 0.0f;
|
||||||
@@ -127,8 +134,8 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
cargo.capacity = static_cast<int>(
|
cargo.capacity = static_cast<int>(
|
||||||
modDef->salvageCapability->cargoCapacityFormula.evaluate(mx));
|
modDef->salvageCapability->cargoCapacityFormula.evaluate(mx));
|
||||||
cargo.current = 0;
|
cargo.current = 0;
|
||||||
cargo.collectionRange = static_cast<float>(
|
cargo.collectionRange_tiles = static_cast<float>(
|
||||||
modDef->salvageCapability->collectionRangeFormula.evaluate(mx));
|
modDef->salvageCapability->collectionRangeFormula.evaluate(mx)) / tileSize;
|
||||||
const double rate = modDef->salvageCapability->collectionRateFormula.evaluate(mx);
|
const double rate = modDef->salvageCapability->collectionRateFormula.evaluate(mx);
|
||||||
cargo.collectionIntervalTicks = (rate > 0.0)
|
cargo.collectionIntervalTicks = (rate > 0.0)
|
||||||
? static_cast<int>(kTickRateHz / rate + 0.5)
|
? static_cast<int>(kTickRateHz / rate + 0.5)
|
||||||
@@ -147,8 +154,8 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
rt.ratePerTick = static_cast<float>(
|
rt.ratePerTick = static_cast<float>(
|
||||||
modDef->repairCapability->repairRateFormula.evaluate(mx))
|
modDef->repairCapability->repairRateFormula.evaluate(mx))
|
||||||
/ static_cast<float>(kTickRateHz);
|
/ static_cast<float>(kTickRateHz);
|
||||||
rt.range = static_cast<float>(
|
rt.range_tiles = static_cast<float>(
|
||||||
modDef->repairCapability->repairRangeFormula.evaluate(mx));
|
modDef->repairCapability->repairRangeFormula.evaluate(mx)) / tileSize;
|
||||||
rt.currentTarget = std::nullopt;
|
rt.currentTarget = std::nullopt;
|
||||||
|
|
||||||
entt::entity child = m_admin.createModuleEntity();
|
entt::entity child = m_admin.createModuleEntity();
|
||||||
@@ -170,9 +177,11 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
for (const PlacedModule& pm : modules)
|
for (const PlacedModule& pm : modules)
|
||||||
{
|
{
|
||||||
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
const ModuleDef* modDef = findModuleDef(pm.moduleId);
|
||||||
if (!modDef) { continue; }
|
if (!modDef) { throw std::runtime_error("unknown module id '" + pm.moduleId + "'"); }
|
||||||
|
|
||||||
const double mx = static_cast<double>(modDef->playerProductionLevel);
|
const auto overIt2 = moduleLevelOverrides.find(pm.moduleId);
|
||||||
|
const double mx = static_cast<double>(
|
||||||
|
overIt2 != moduleLevelOverrides.end() ? overIt2->second : modDef->playerProductionLevel);
|
||||||
|
|
||||||
for (const ModuleStatModifier& sm : modDef->statModifiers)
|
for (const ModuleStatModifier& sm : modDef->statModifiers)
|
||||||
{
|
{
|
||||||
@@ -206,6 +215,44 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Range stat additive modifiers are expressed in metres in config; convert to tiles.
|
||||||
|
const double tileSizeD = static_cast<double>(m_config.world.tileSize_m);
|
||||||
|
const double tickRateD = static_cast<double>(kTickRateHz);
|
||||||
|
const char* const kRangeStats[] = {
|
||||||
|
"sensor_range", "attack_range", "collection_range", "repair_range"
|
||||||
|
};
|
||||||
|
std::map<std::string, std::pair<double, double>>* allModMaps[] = {
|
||||||
|
&hullMods, &weaponMods, &salvageMods, &repairMods
|
||||||
|
};
|
||||||
|
for (const char* stat : kRangeStats)
|
||||||
|
{
|
||||||
|
for (std::map<std::string, std::pair<double, double>>* mods : allModMaps)
|
||||||
|
{
|
||||||
|
std::map<std::string, std::pair<double, double>>::iterator it = mods->find(stat);
|
||||||
|
if (it != mods->end())
|
||||||
|
{
|
||||||
|
it->second.second /= tileSizeD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acceleration additive modifiers are in m/s² in config; convert to tiles/tick
|
||||||
|
// (same as the base spawn conversion: / tileSize / tickRate).
|
||||||
|
const char* const kAccelerationStats[] = {
|
||||||
|
"main_acceleration", "maneuvering_acceleration"
|
||||||
|
};
|
||||||
|
for (const char* stat : kAccelerationStats)
|
||||||
|
{
|
||||||
|
for (std::map<std::string, std::pair<double, double>>* mods : allModMaps)
|
||||||
|
{
|
||||||
|
std::map<std::string, std::pair<double, double>>::iterator it = mods->find(stat);
|
||||||
|
if (it != mods->end())
|
||||||
|
{
|
||||||
|
it->second.second /= tileSizeD * tickRateD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Helper: apply a modifier map to a float stat.
|
// Helper: apply a modifier map to a float stat.
|
||||||
auto applyMod = [](float& stat, const std::string& name,
|
auto applyMod = [](float& stat, const std::string& name,
|
||||||
const std::map<std::string, std::pair<double, double>>& mods)
|
const std::map<std::string, std::pair<double, double>>& mods)
|
||||||
@@ -225,30 +272,30 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
DynamicBodyComponent& dynamics = m_admin.get<DynamicBodyComponent>(entity);
|
DynamicBodyComponent& dynamics = m_admin.get<DynamicBodyComponent>(entity);
|
||||||
SensorRangeComponent& sensor = m_admin.get<SensorRangeComponent>(entity);
|
SensorRangeComponent& sensor = m_admin.get<SensorRangeComponent>(entity);
|
||||||
|
|
||||||
applyMod(health.maxHp, "hp", hullMods);
|
applyMod(health.maxHp, "hp", hullMods);
|
||||||
health.hp = health.maxHp;
|
health.hp = health.maxHp;
|
||||||
applyMod(dynamics.maxSpeedPerTick, "speed", hullMods);
|
applyMod(dynamics.maxSpeed_tpt, "speed", hullMods);
|
||||||
applyMod(dynamics.mainAccelerationPerTick, "main_acceleration", hullMods);
|
applyMod(dynamics.mainAcceleration_tptt, "main_acceleration", hullMods);
|
||||||
applyMod(dynamics.maneuveringAccelerationPerTick, "maneuvering_acceleration", hullMods);
|
applyMod(dynamics.maneuveringAcceleration_tptt, "maneuvering_acceleration", hullMods);
|
||||||
applyMod(dynamics.angularAccelerationPerTick, "angular_acceleration", hullMods);
|
applyMod(dynamics.maxAngularAcceleration_rptt, "angular_acceleration", hullMods);
|
||||||
applyMod(dynamics.maxRotationSpeedPerTick, "max_rotation_speed", hullMods);
|
applyMod(dynamics.maxRotationSpeed_rpt, "max_rotation_speed", hullMods);
|
||||||
applyMod(sensor.value, "sensor_range", hullMods);
|
applyMod(sensor.value_tiles, "sensor_range", hullMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply weapon modifiers to each weapon child.
|
// Apply weapon modifiers to each weapon child.
|
||||||
for (entt::entity child : weaponChildren)
|
for (entt::entity child : weaponChildren)
|
||||||
{
|
{
|
||||||
WeaponComponent& w = m_admin.get<WeaponComponent>(child);
|
WeaponComponent& w = m_admin.get<WeaponComponent>(child);
|
||||||
applyMod(w.damage, "damage", weaponMods);
|
applyMod(w.damage, "damage", weaponMods);
|
||||||
applyMod(w.range, "attack_range", weaponMods);
|
applyMod(w.range_tiles, "attack_range", weaponMods);
|
||||||
applyMod(w.fireRateHz, "attack_rate", weaponMods);
|
applyMod(w.fireRateHz, "attack_rate", weaponMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply salvage modifiers to each salvage child.
|
// Apply salvage modifiers to each salvage child.
|
||||||
for (entt::entity child : salvageChildren)
|
for (entt::entity child : salvageChildren)
|
||||||
{
|
{
|
||||||
SalvageCargoComponent& c = m_admin.get<SalvageCargoComponent>(child);
|
SalvageCargoComponent& c = m_admin.get<SalvageCargoComponent>(child);
|
||||||
float fRange = c.collectionRange;
|
float fRange = c.collectionRange_tiles;
|
||||||
float fCapacity = static_cast<float>(c.capacity);
|
float fCapacity = static_cast<float>(c.capacity);
|
||||||
// Apply rate modifier: compute rate from interval, apply multiplier, convert back.
|
// Apply rate modifier: compute rate from interval, apply multiplier, convert back.
|
||||||
float fRate = (c.collectionIntervalTicks > 0)
|
float fRate = (c.collectionIntervalTicks > 0)
|
||||||
@@ -257,7 +304,7 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
applyMod(fRange, "collection_range", salvageMods);
|
applyMod(fRange, "collection_range", salvageMods);
|
||||||
applyMod(fCapacity, "cargo_capacity", salvageMods);
|
applyMod(fCapacity, "cargo_capacity", salvageMods);
|
||||||
applyMod(fRate, "collection_rate", salvageMods);
|
applyMod(fRate, "collection_rate", salvageMods);
|
||||||
c.collectionRange = fRange;
|
c.collectionRange_tiles = fRange;
|
||||||
c.capacity = static_cast<int>(fCapacity + 0.5f);
|
c.capacity = static_cast<int>(fCapacity + 0.5f);
|
||||||
c.collectionIntervalTicks = (fRate > 0.0f)
|
c.collectionIntervalTicks = (fRate > 0.0f)
|
||||||
? static_cast<int>(static_cast<float>(kTickRateHz) / fRate + 0.5f)
|
? static_cast<int>(static_cast<float>(kTickRateHz) / fRate + 0.5f)
|
||||||
@@ -268,8 +315,8 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
for (entt::entity child : repairChildren)
|
for (entt::entity child : repairChildren)
|
||||||
{
|
{
|
||||||
RepairToolComponent& rt = m_admin.get<RepairToolComponent>(child);
|
RepairToolComponent& rt = m_admin.get<RepairToolComponent>(child);
|
||||||
applyMod(rt.ratePerTick, "repair_rate", repairMods);
|
applyMod(rt.ratePerTick, "repair_rate", repairMods);
|
||||||
applyMod(rt.range, "repair_range", repairMods);
|
applyMod(rt.range_tiles, "repair_range", repairMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Pass 3: attach behavior components based on capability presence -----
|
// --- Pass 3: attach behavior components based on capability presence -----
|
||||||
@@ -291,14 +338,14 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
float maxCollRange = 0.0f;
|
float maxCollRange = 0.0f;
|
||||||
for (entt::entity child : salvageChildren)
|
for (entt::entity child : salvageChildren)
|
||||||
{
|
{
|
||||||
const float r = m_admin.get<SalvageCargoComponent>(child).collectionRange;
|
const float r = m_admin.get<SalvageCargoComponent>(child).collectionRange_tiles;
|
||||||
if (r > maxCollRange) { maxCollRange = r; }
|
if (r > maxCollRange) { maxCollRange = r; }
|
||||||
}
|
}
|
||||||
|
|
||||||
SalvageBehaviorComponent sb;
|
SalvageBehaviorComponent sb;
|
||||||
sb.scrapTarget = std::nullopt;
|
sb.scrapTarget = std::nullopt;
|
||||||
sb.deliveryBay = kInvalidBuildingId;
|
sb.deliveryBay = kInvalidBuildingId;
|
||||||
sb.maxCollectionRange = maxCollRange;
|
sb.maxCollectionRange_tiles = maxCollRange;
|
||||||
m_admin.addComponent<SalvageBehaviorComponent>(entity, sb);
|
m_admin.addComponent<SalvageBehaviorComponent>(entity, sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,13 +354,13 @@ entt::entity ShipSystem::spawn(const std::string& schematicId, int level,
|
|||||||
float maxRepairRange = 0.0f;
|
float maxRepairRange = 0.0f;
|
||||||
for (entt::entity child : repairChildren)
|
for (entt::entity child : repairChildren)
|
||||||
{
|
{
|
||||||
const float r = m_admin.get<RepairToolComponent>(child).range;
|
const float r = m_admin.get<RepairToolComponent>(child).range_tiles;
|
||||||
if (r > maxRepairRange) { maxRepairRange = r; }
|
if (r > maxRepairRange) { maxRepairRange = r; }
|
||||||
}
|
}
|
||||||
|
|
||||||
RepairBehaviorComponent rb;
|
RepairBehaviorComponent rb;
|
||||||
rb.currentTarget = std::nullopt;
|
rb.currentTarget = std::nullopt;
|
||||||
rb.maxRepairRange = maxRepairRange;
|
rb.maxRepairRange_tiles = maxRepairRange;
|
||||||
m_admin.addComponent<RepairBehaviorComponent>(entity, rb);
|
m_admin.addComponent<RepairBehaviorComponent>(entity, rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,6 +381,7 @@ void ShipSystem::despawn(entt::entity entity)
|
|||||||
|
|
||||||
void ShipSystem::clearMovementIntents()
|
void ShipSystem::clearMovementIntents()
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
m_admin.forEach<MovementIntentComponent>(
|
m_admin.forEach<MovementIntentComponent>(
|
||||||
[](entt::entity /*e*/, MovementIntentComponent& i)
|
[](entt::entity /*e*/, MovementIntentComponent& i)
|
||||||
{
|
{
|
||||||
@@ -348,6 +396,7 @@ void ShipSystem::setRallyPoint(QVector2D point)
|
|||||||
|
|
||||||
void ShipSystem::triggerRallyDeparture()
|
void ShipSystem::triggerRallyDeparture()
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
std::vector<entt::entity> toRemove;
|
std::vector<entt::entity> toRemove;
|
||||||
m_admin.forEach<RallyBehaviorComponent, FactionComponent>(
|
m_admin.forEach<RallyBehaviorComponent, FactionComponent>(
|
||||||
[&toRemove](entt::entity e, const RallyBehaviorComponent& /*rb*/,
|
[&toRemove](entt::entity e, const RallyBehaviorComponent& /*rb*/,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -19,7 +20,8 @@ public:
|
|||||||
|
|
||||||
entt::entity spawn(const std::string& schematicId, int level, QVector2D position,
|
entt::entity spawn(const std::string& schematicId, int level, QVector2D position,
|
||||||
bool isEnemy = false,
|
bool isEnemy = false,
|
||||||
const std::optional<ShipLayoutConfig>& layout = std::nullopt);
|
const std::optional<ShipLayoutConfig>& layout = std::nullopt,
|
||||||
|
const std::map<std::string, int>& moduleLevelOverrides = {});
|
||||||
void despawn(entt::entity entity);
|
void despawn(entt::entity entity);
|
||||||
|
|
||||||
// Reset all movement intents to priority 0 before behavior systems run.
|
// Reset all movement intents to priority 0 before behavior systems run.
|
||||||
|
|||||||
23
src/lib/eventsystem/CMakeLists.txt
Normal file
23
src/lib/eventsystem/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
add_subdirectory(event)
|
||||||
|
|
||||||
|
SET(HDRS
|
||||||
|
${HDRS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Event.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/EventHandler.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/EventHandlerBase.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/EventManager.h
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(SRCS
|
||||||
|
${SRCS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/EventHandlerBase.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/EventManager.cpp
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(LIB_INCLUDE_PATH
|
||||||
|
${LIB_INCLUDE_PATH}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
10
src/lib/eventsystem/Event.h
Normal file
10
src/lib/eventsystem/Event.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef EVENT_H
|
||||||
|
#define EVENT_H
|
||||||
|
|
||||||
|
class Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Event() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EVENT_H
|
||||||
80
src/lib/eventsystem/EventHandler.h
Normal file
80
src/lib/eventsystem/EventHandler.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#ifndef EVENT_HANDLER_H
|
||||||
|
#define EVENT_HANDLER_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "EventHandlerBase.h"
|
||||||
|
#include "EventManager.h"
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class EventHandler: public EventHandlerBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void registerForEvent()
|
||||||
|
{
|
||||||
|
EventManager::getInstance()->registerEventHandler(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void unregisterForEvent()
|
||||||
|
{
|
||||||
|
EventManager::getInstance()->unregisterEventHandler(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleBaseEvent(std::shared_ptr<const Event> event) override
|
||||||
|
{
|
||||||
|
std::shared_ptr<const T> specificEvent = std::dynamic_pointer_cast<const T>(event);
|
||||||
|
if (specificEvent)
|
||||||
|
{
|
||||||
|
handleEvent(specificEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void handleEvent(std::shared_ptr<const T> event) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename... Ts> class CombinedEventHandlerHelper
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void registerForEventsHelper() {}
|
||||||
|
void unregisterForEventsHelper() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename... Ts>
|
||||||
|
class CombinedEventHandlerHelper<T, Ts...>
|
||||||
|
: public EventHandler<T>
|
||||||
|
, public CombinedEventHandlerHelper<Ts...>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void registerForEventsHelper()
|
||||||
|
{
|
||||||
|
EventHandler<T>::registerForEvent();
|
||||||
|
CombinedEventHandlerHelper<Ts...>::registerForEventsHelper();
|
||||||
|
}
|
||||||
|
|
||||||
|
void unregisterForEventsHelper()
|
||||||
|
{
|
||||||
|
EventHandler<T>::unregisterForEvent();
|
||||||
|
CombinedEventHandlerHelper<Ts...>::unregisterForEventsHelper();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename... Ts>
|
||||||
|
class CombinedEventHandler: public CombinedEventHandlerHelper<Ts...>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void registerForEvents()
|
||||||
|
{
|
||||||
|
CombinedEventHandlerHelper<Ts...>::registerForEventsHelper();
|
||||||
|
}
|
||||||
|
|
||||||
|
void unregisterForEvents()
|
||||||
|
{
|
||||||
|
CombinedEventHandlerHelper<Ts...>::unregisterForEventsHelper();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EVENT_HANDLER_H
|
||||||
7
src/lib/eventsystem/EventHandlerBase.cpp
Normal file
7
src/lib/eventsystem/EventHandlerBase.cpp
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include "EventHandlerBase.h"
|
||||||
|
|
||||||
|
unsigned int EventHandlerBase::s_nextId = 0;
|
||||||
|
|
||||||
|
EventHandlerBase::EventHandlerBase(): m_id(s_nextId++)
|
||||||
|
{
|
||||||
|
}
|
||||||
25
src/lib/eventsystem/EventHandlerBase.h
Normal file
25
src/lib/eventsystem/EventHandlerBase.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef EVENT_HANDLER_BASE_H
|
||||||
|
#define EVENT_HANDLER_BASE_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class Event;
|
||||||
|
class EventManager;
|
||||||
|
|
||||||
|
class EventHandlerBase
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static unsigned int s_nextId;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EventHandlerBase();
|
||||||
|
virtual ~EventHandlerBase() = default;
|
||||||
|
virtual void handleBaseEvent(std::shared_ptr<const Event> event) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const unsigned int m_id;
|
||||||
|
|
||||||
|
friend EventManager;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EVENT_HANDLER_BASE_H
|
||||||
129
src/lib/eventsystem/EventManager.cpp
Normal file
129
src/lib/eventsystem/EventManager.cpp
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
#include "EventManager.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "EventHandlerBase.h"
|
||||||
|
|
||||||
|
std::shared_ptr<EventManager> EventManager::getInstance()
|
||||||
|
{
|
||||||
|
if (!s_instance)
|
||||||
|
{
|
||||||
|
s_instance = std::shared_ptr<EventManager>(new EventManager());
|
||||||
|
}
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventManager::destroyInstance()
|
||||||
|
{
|
||||||
|
if (s_instance)
|
||||||
|
{
|
||||||
|
s_instance.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<EventManager> EventManager::s_instance = std::shared_ptr<EventManager>();
|
||||||
|
|
||||||
|
void EventManager::registerEventHandler(EventHandlerBase *eventHandler)
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventHandlersMutex);
|
||||||
|
m_eventHandlers[eventHandler->m_id] = eventHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventManager::unregisterEventHandler(EventHandlerBase *eventHandler)
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventHandlersMutex);
|
||||||
|
m_eventHandlers.erase(eventHandler->m_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventManager::sendEventImmediately(std::shared_ptr<Event> event)
|
||||||
|
{
|
||||||
|
if (event)
|
||||||
|
{
|
||||||
|
std::set<unsigned int> eventHandlerIds;
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventHandlersMutex);
|
||||||
|
for (auto it : m_eventHandlers)
|
||||||
|
{
|
||||||
|
eventHandlerIds.insert(it.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int id : eventHandlerIds)
|
||||||
|
{
|
||||||
|
// this is necessary to allow HandleBaseEvent() to remove event handlers without causing a crash
|
||||||
|
EventHandlerBase *eventHandler = nullptr;
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventHandlersMutex);
|
||||||
|
auto it = m_eventHandlers.find(id);
|
||||||
|
if (it != m_eventHandlers.end())
|
||||||
|
{
|
||||||
|
eventHandler = it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventHandler)
|
||||||
|
{
|
||||||
|
eventHandler->handleBaseEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventManager::addEvent(std::shared_ptr<Event> event)
|
||||||
|
{
|
||||||
|
if (event)
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventsMutex);
|
||||||
|
m_events.push_back(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventManager::processEvents()
|
||||||
|
{
|
||||||
|
std::vector<std::shared_ptr<Event>> events;
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventsMutex);
|
||||||
|
events = m_events;
|
||||||
|
m_events.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<unsigned int> eventHandlerIds;
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventHandlersMutex);
|
||||||
|
for (auto it : m_eventHandlers)
|
||||||
|
{
|
||||||
|
eventHandlerIds.insert(it.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::shared_ptr<Event> event : events)
|
||||||
|
{
|
||||||
|
for (unsigned int id : eventHandlerIds)
|
||||||
|
{
|
||||||
|
// this is necessary to allow HandleBaseEvent() to remove event handlers without causing a crash
|
||||||
|
EventHandlerBase *eventHandler = nullptr;
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventHandlersMutex);
|
||||||
|
auto it = m_eventHandlers.find(id);
|
||||||
|
if (it != m_eventHandlers.end())
|
||||||
|
{
|
||||||
|
eventHandler = it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventHandler)
|
||||||
|
{
|
||||||
|
eventHandler->handleBaseEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventManager::clearEvents()
|
||||||
|
{
|
||||||
|
std::scoped_lock<std::mutex> lock(m_eventsMutex);
|
||||||
|
m_events.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventManager::hasEvents() const
|
||||||
|
{
|
||||||
|
return !m_events.empty();
|
||||||
|
}
|
||||||
44
src/lib/eventsystem/EventManager.h
Normal file
44
src/lib/eventsystem/EventManager.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef EVENT_MANAGER_H
|
||||||
|
#define EVENT_MANAGER_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class EventHandlerBase;
|
||||||
|
|
||||||
|
class EventManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static std::shared_ptr<EventManager> getInstance();
|
||||||
|
static void destroyInstance();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::shared_ptr<EventManager> s_instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EventManager(EventManager const &) = delete;
|
||||||
|
void operator=(EventManager const &) = delete;
|
||||||
|
|
||||||
|
void registerEventHandler(EventHandlerBase *eventHandler);
|
||||||
|
void unregisterEventHandler(EventHandlerBase *eventHandler);
|
||||||
|
void sendEventImmediately(std::shared_ptr<Event> event);
|
||||||
|
void addEvent(std::shared_ptr<Event> event);
|
||||||
|
void processEvents();
|
||||||
|
void clearEvents();
|
||||||
|
|
||||||
|
bool hasEvents() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
EventManager() = default;
|
||||||
|
|
||||||
|
std::map<unsigned int, EventHandlerBase *> m_eventHandlers;
|
||||||
|
std::vector<std::shared_ptr<Event>> m_events;
|
||||||
|
std::mutex m_eventHandlersMutex;
|
||||||
|
std::mutex m_eventsMutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EVENT_MANAGER_H
|
||||||
10
src/lib/eventsystem/event/ArenaInspectRequestedEvent.h
Normal file
10
src/lib/eventsystem/event/ArenaInspectRequestedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class ArenaInspectRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ArenaInspectRequestedEvent(int arenaIndex) : arenaIndex(arenaIndex) {}
|
||||||
|
const int arenaIndex;
|
||||||
|
};
|
||||||
10
src/lib/eventsystem/event/ArenaStartRequestedEvent.h
Normal file
10
src/lib/eventsystem/event/ArenaStartRequestedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class ArenaStartRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ArenaStartRequestedEvent(int arenaIndex) : arenaIndex(arenaIndex) {}
|
||||||
|
const int arenaIndex;
|
||||||
|
};
|
||||||
7
src/lib/eventsystem/event/BlueprintModeExitedEvent.h
Normal file
7
src/lib/eventsystem/event/BlueprintModeExitedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class BlueprintModeExitedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
12
src/lib/eventsystem/event/BlueprintPlacementRequestedEvent.h
Normal file
12
src/lib/eventsystem/event/BlueprintPlacementRequestedEvent.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Blueprint.h"
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class BlueprintPlacementRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit BlueprintPlacementRequestedEvent(Blueprint blueprint)
|
||||||
|
: blueprint(std::move(blueprint)) {}
|
||||||
|
const Blueprint blueprint;
|
||||||
|
};
|
||||||
17
src/lib/eventsystem/event/BossWaveUpdatedEvent.h
Normal file
17
src/lib/eventsystem/event/BossWaveUpdatedEvent.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef BOSS_WAVE_UPDATED_EVENT_H
|
||||||
|
#define BOSS_WAVE_UPDATED_EVENT_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
#include "Tick.h"
|
||||||
|
|
||||||
|
class BossWaveUpdatedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BossWaveUpdatedEvent(int counter, Tick countdownTicks)
|
||||||
|
: counter(counter), countdownTicks(countdownTicks) {}
|
||||||
|
const int counter;
|
||||||
|
const Tick countdownTicks;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BOSS_WAVE_UPDATED_EVENT_H
|
||||||
|
|
||||||
7
src/lib/eventsystem/event/BuilderModeExitedEvent.h
Normal file
7
src/lib/eventsystem/event/BuilderModeExitedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class BuilderModeExitedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
14
src/lib/eventsystem/event/BuildingBlocksChangedEvent.h
Normal file
14
src/lib/eventsystem/event/BuildingBlocksChangedEvent.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef BUILDING_BLOCKS_CHANGED_EVENT_H
|
||||||
|
#define BUILDING_BLOCKS_CHANGED_EVENT_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class BuildingBlocksChangedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit BuildingBlocksChangedEvent(int blocks) : blocks(blocks) {}
|
||||||
|
const int blocks;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_BLOCKS_CHANGED_EVENT_H
|
||||||
|
|
||||||
11
src/lib/eventsystem/event/BuildingTypeSelectedEvent.h
Normal file
11
src/lib/eventsystem/event/BuildingTypeSelectedEvent.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BuildingType.h"
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class BuildingTypeSelectedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit BuildingTypeSelectedEvent(BuildingType type) : type(type) {}
|
||||||
|
const BuildingType type;
|
||||||
|
};
|
||||||
41
src/lib/eventsystem/event/CMakeLists.txt
Normal file
41
src/lib/eventsystem/event/CMakeLists.txt
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
SET(HDRS
|
||||||
|
${HDRS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/TracePrintRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/TickAdvancedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/BuildingBlocksChangedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/EntitySelectedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/GameSpeedChangedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/BossWaveUpdatedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/SchematicChoicesAvailableEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/SelectionChangedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/GameOverEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/BuilderModeExitedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/BlueprintModeExitedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/EscapeMenuRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/DemolishModeChangedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/BuildingTypeSelectedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ExitBuilderModeRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/DemolishModeToggleRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/BlueprintPlacementRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ExitBlueprintModeRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/SpeedChangeRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/LayoutDialogRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/InspectWindowClosedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ArenaStartRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ArenaInspectRequestedEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/WeaponFiredEvent.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/DebugDrawToggledEvent.h
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(SRCS
|
||||||
|
${SRCS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/TracePrintRequestedEvent.cpp
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
set(LIB_INCLUDE_PATH
|
||||||
|
${LIB_INCLUDE_PATH}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
14
src/lib/eventsystem/event/DebugDrawToggledEvent.h
Normal file
14
src/lib/eventsystem/event/DebugDrawToggledEvent.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class DebugDrawToggledEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DebugDrawToggledEvent(bool active)
|
||||||
|
: active(active)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool active;
|
||||||
|
};
|
||||||
10
src/lib/eventsystem/event/DemolishModeChangedEvent.h
Normal file
10
src/lib/eventsystem/event/DemolishModeChangedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class DemolishModeChangedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DemolishModeChangedEvent(bool active) : active(active) {}
|
||||||
|
const bool active;
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class DemolishModeToggleRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
21
src/lib/eventsystem/event/EntitySelectedEvent.h
Normal file
21
src/lib/eventsystem/event/EntitySelectedEvent.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef ENTITY_SELECTED_EVENT_H
|
||||||
|
#define ENTITY_SELECTED_EVENT_H
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include "entt/entity/entity.hpp"
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class EntitySelectedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit EntitySelectedEvent(std::optional<entt::entity> entity)
|
||||||
|
: entity(entity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::optional<entt::entity> entity;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ENTITY_SELECTED_EVENT_H
|
||||||
7
src/lib/eventsystem/event/EscapeMenuRequestedEvent.h
Normal file
7
src/lib/eventsystem/event/EscapeMenuRequestedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class EscapeMenuRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class ExitBlueprintModeRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class ExitBuilderModeRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
7
src/lib/eventsystem/event/GameOverEvent.h
Normal file
7
src/lib/eventsystem/event/GameOverEvent.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class GameOverEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
14
src/lib/eventsystem/event/GameSpeedChangedEvent.h
Normal file
14
src/lib/eventsystem/event/GameSpeedChangedEvent.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef GAME_SPEED_CHANGED_EVENT_H
|
||||||
|
#define GAME_SPEED_CHANGED_EVENT_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class GameSpeedChangedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit GameSpeedChangedEvent(double speed) : speed(speed) {}
|
||||||
|
const double speed;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GAME_SPEED_CHANGED_EVENT_H
|
||||||
|
|
||||||
7
src/lib/eventsystem/event/InspectWindowClosedEvent.h
Normal file
7
src/lib/eventsystem/event/InspectWindowClosedEvent.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class InspectWindowClosedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
12
src/lib/eventsystem/event/LayoutDialogRequestedEvent.h
Normal file
12
src/lib/eventsystem/event/LayoutDialogRequestedEvent.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BuildingId.h"
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class LayoutDialogRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit LayoutDialogRequestedEvent(BuildingId shipyardId)
|
||||||
|
: shipyardId(shipyardId) {}
|
||||||
|
const BuildingId shipyardId;
|
||||||
|
};
|
||||||
14
src/lib/eventsystem/event/SchematicChoicesAvailableEvent.h
Normal file
14
src/lib/eventsystem/event/SchematicChoicesAvailableEvent.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
#include "SchematicChoiceOption.h"
|
||||||
|
|
||||||
|
class SchematicChoicesAvailableEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SchematicChoicesAvailableEvent(std::vector<SchematicChoiceOption> choices)
|
||||||
|
: choices(std::move(choices)) {}
|
||||||
|
const std::vector<SchematicChoiceOption> choices;
|
||||||
|
};
|
||||||
14
src/lib/eventsystem/event/SelectionChangedEvent.h
Normal file
14
src/lib/eventsystem/event/SelectionChangedEvent.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "BuildingId.h"
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class SelectionChangedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SelectionChangedEvent(std::vector<BuildingId> ids)
|
||||||
|
: ids(std::move(ids)) {}
|
||||||
|
const std::vector<BuildingId> ids;
|
||||||
|
};
|
||||||
10
src/lib/eventsystem/event/SpeedChangeRequestedEvent.h
Normal file
10
src/lib/eventsystem/event/SpeedChangeRequestedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class SpeedChangeRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SpeedChangeRequestedEvent(double multiplier) : multiplier(multiplier) {}
|
||||||
|
const double multiplier;
|
||||||
|
};
|
||||||
15
src/lib/eventsystem/event/TickAdvancedEvent.h
Normal file
15
src/lib/eventsystem/event/TickAdvancedEvent.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef TICK_ADVANCED_EVENT_H
|
||||||
|
#define TICK_ADVANCED_EVENT_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
#include "Tick.h"
|
||||||
|
|
||||||
|
class TickAdvancedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit TickAdvancedEvent(Tick tick) : tick(tick) {}
|
||||||
|
const Tick tick;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TICK_ADVANCED_EVENT_H
|
||||||
|
|
||||||
1
src/lib/eventsystem/event/TracePrintRequestedEvent.cpp
Normal file
1
src/lib/eventsystem/event/TracePrintRequestedEvent.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "TracePrintRequestedEvent.h"
|
||||||
10
src/lib/eventsystem/event/TracePrintRequestedEvent.h
Normal file
10
src/lib/eventsystem/event/TracePrintRequestedEvent.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef TRACE_PRINT_REQUESTED_EVENT_H
|
||||||
|
#define TRACE_PRINT_REQUESTED_EVENT_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class TracePrintRequestedEvent : public Event
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRACE_PRINT_REQUESTED_EVENT_H
|
||||||
17
src/lib/eventsystem/event/WeaponFiredEvent.h
Normal file
17
src/lib/eventsystem/event/WeaponFiredEvent.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
#include "Tick.h"
|
||||||
|
|
||||||
|
#include "entt/entity/entity.hpp"
|
||||||
|
|
||||||
|
struct WeaponFiredEvent : public Event
|
||||||
|
{
|
||||||
|
WeaponFiredEvent() = default;
|
||||||
|
WeaponFiredEvent(entt::entity shooter, entt::entity target, Tick emittedAt)
|
||||||
|
: shooter(shooter), target(target), emittedAt(emittedAt) {}
|
||||||
|
|
||||||
|
entt::entity shooter = entt::null;
|
||||||
|
entt::entity target = entt::null;
|
||||||
|
Tick emittedAt = 0;
|
||||||
|
};
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Tick.h"
|
#include "Tick.h"
|
||||||
|
#include "tracing.h"
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Helpers
|
// Helpers
|
||||||
@@ -46,8 +47,8 @@ QPointF BeltSystem::slotWorldPos(QPoint tile, Rotation dir, double progress)
|
|||||||
// Construction / placement
|
// Construction / placement
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
BeltSystem::BeltSystem(double beltSpeedTilesPerSecond)
|
BeltSystem::BeltSystem(double beltSpeed_tps)
|
||||||
: m_progressPerTick(beltSpeedTilesPerSecond * kTickDurationSeconds)
|
: m_progressPerTick_tpt(beltSpeed_tps * kTickDurationSeconds)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,6 +397,7 @@ void BeltSystem::clearTiles(const std::vector<QPoint>& tiles)
|
|||||||
|
|
||||||
void BeltSystem::tick()
|
void BeltSystem::tick()
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
advanceProgress();
|
advanceProgress();
|
||||||
advanceTunnelProgress();
|
advanceTunnelProgress();
|
||||||
moveItemsToNextTile();
|
moveItemsToNextTile();
|
||||||
@@ -412,7 +414,7 @@ void BeltSystem::advanceProgress()
|
|||||||
|
|
||||||
for (std::size_t i = 0; i < bt.itemSlots.size(); ++i)
|
for (std::size_t i = 0; i < bt.itemSlots.size(); ++i)
|
||||||
{
|
{
|
||||||
bt.itemSlots[i].progress += m_progressPerTick;
|
bt.itemSlots[i].progress += m_progressPerTick_tpt;
|
||||||
|
|
||||||
// Absolute cap: slot i cannot exceed 1.0 - i * 0.25.
|
// Absolute cap: slot i cannot exceed 1.0 - i * 0.25.
|
||||||
const double absoluteCap = 1.0 - i * 0.25;
|
const double absoluteCap = 1.0 - i * 0.25;
|
||||||
@@ -440,7 +442,7 @@ void BeltSystem::advanceProgress()
|
|||||||
|
|
||||||
for (std::size_t i = 0; i < st.back.size(); ++i)
|
for (std::size_t i = 0; i < st.back.size(); ++i)
|
||||||
{
|
{
|
||||||
st.back[i].progress += m_progressPerTick;
|
st.back[i].progress += m_progressPerTick_tpt;
|
||||||
const double absoluteCap = 0.5 - i * 0.25;
|
const double absoluteCap = 0.5 - i * 0.25;
|
||||||
if (st.back[i].progress > absoluteCap)
|
if (st.back[i].progress > absoluteCap)
|
||||||
{
|
{
|
||||||
@@ -463,7 +465,7 @@ void BeltSystem::advanceProgress()
|
|||||||
|
|
||||||
if (st.frontA)
|
if (st.frontA)
|
||||||
{
|
{
|
||||||
st.frontA->progress += m_progressPerTick;
|
st.frontA->progress += m_progressPerTick_tpt;
|
||||||
if (st.frontA->progress > 1.0)
|
if (st.frontA->progress > 1.0)
|
||||||
{
|
{
|
||||||
st.frontA->progress = 1.0;
|
st.frontA->progress = 1.0;
|
||||||
@@ -472,7 +474,7 @@ void BeltSystem::advanceProgress()
|
|||||||
|
|
||||||
if (st.frontB)
|
if (st.frontB)
|
||||||
{
|
{
|
||||||
st.frontB->progress += m_progressPerTick;
|
st.frontB->progress += m_progressPerTick_tpt;
|
||||||
if (st.frontB->progress > 1.0)
|
if (st.frontB->progress > 1.0)
|
||||||
{
|
{
|
||||||
st.frontB->progress = 1.0;
|
st.frontB->progress = 1.0;
|
||||||
@@ -490,7 +492,7 @@ void BeltSystem::advanceTunnelProgress()
|
|||||||
|
|
||||||
for (std::size_t i = 0; i < te.itemSlots.size(); ++i)
|
for (std::size_t i = 0; i < te.itemSlots.size(); ++i)
|
||||||
{
|
{
|
||||||
te.itemSlots[i].progress += m_progressPerTick;
|
te.itemSlots[i].progress += m_progressPerTick_tpt;
|
||||||
|
|
||||||
const double absoluteCap = 1.0 - i * 0.25;
|
const double absoluteCap = 1.0 - i * 0.25;
|
||||||
if (te.itemSlots[i].progress > absoluteCap)
|
if (te.itemSlots[i].progress > absoluteCap)
|
||||||
@@ -516,7 +518,7 @@ void BeltSystem::advanceTunnelProgress()
|
|||||||
|
|
||||||
for (std::size_t i = 0; i < tx.itemSlots.size(); ++i)
|
for (std::size_t i = 0; i < tx.itemSlots.size(); ++i)
|
||||||
{
|
{
|
||||||
tx.itemSlots[i].progress += m_progressPerTick;
|
tx.itemSlots[i].progress += m_progressPerTick_tpt;
|
||||||
|
|
||||||
const double absoluteCap = 1.0 - i * 0.25;
|
const double absoluteCap = 1.0 - i * 0.25;
|
||||||
if (tx.itemSlots[i].progress > absoluteCap)
|
if (tx.itemSlots[i].progress > absoluteCap)
|
||||||
@@ -540,7 +542,7 @@ void BeltSystem::advanceTunnelProgress()
|
|||||||
for (std::size_t i = 0; i < link.items.size(); ++i)
|
for (std::size_t i = 0; i < link.items.size(); ++i)
|
||||||
{
|
{
|
||||||
TunnelTransitItem& ti = link.items[i];
|
TunnelTransitItem& ti = link.items[i];
|
||||||
ti.progress += m_progressPerTick;
|
ti.progress += m_progressPerTick_tpt;
|
||||||
if (ti.progress > link.length)
|
if (ti.progress > link.length)
|
||||||
{
|
{
|
||||||
ti.progress = link.length;
|
ti.progress = link.length;
|
||||||
@@ -754,13 +756,13 @@ void BeltSystem::routeSplitterItems()
|
|||||||
else if (preferA && !st.frontB)
|
else if (preferA && !st.frontB)
|
||||||
{
|
{
|
||||||
// Preferred (A) is full — fall back to B; nextOutputIsA stays.
|
// Preferred (A) is full — fall back to B; nextOutputIsA stays.
|
||||||
st.frontB = BeltItemSlot{item, 0.0};
|
st.frontB = BeltItemSlot{item, 0.75};
|
||||||
routed = true;
|
routed = true;
|
||||||
}
|
}
|
||||||
else if (!preferA && !st.frontA)
|
else if (!preferA && !st.frontA)
|
||||||
{
|
{
|
||||||
// Preferred (B) is full — fall back to A; nextOutputIsA stays.
|
// Preferred (B) is full — fall back to A; nextOutputIsA stays.
|
||||||
st.frontA = BeltItemSlot{item, 0.0};
|
st.frontA = BeltItemSlot{item, 0.75};
|
||||||
routed = true;
|
routed = true;
|
||||||
}
|
}
|
||||||
// else both fronts occupied — back stays.
|
// else both fronts occupied — back stays.
|
||||||
@@ -960,3 +962,5 @@ void BeltSystem::forEachVisualItem(QRect viewportTiles,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct VisualItem
|
|||||||
class BeltSystem
|
class BeltSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit BeltSystem(double beltSpeedTilesPerSecond);
|
explicit BeltSystem(double beltSpeed_tps);
|
||||||
|
|
||||||
// -- Placement -----------------------------------------------------------
|
// -- Placement -----------------------------------------------------------
|
||||||
// Register a new belt tile. Any items already on this tile are cleared.
|
// Register a new belt tile. Any items already on this tile are cleared.
|
||||||
@@ -170,7 +170,7 @@ private:
|
|||||||
std::vector<TunnelTransitItem> items; // front (highest progress) to back
|
std::vector<TunnelTransitItem> items; // front (highest progress) to back
|
||||||
};
|
};
|
||||||
|
|
||||||
double m_progressPerTick; // beltSpeedTilesPerSecond / kTickRateHz
|
double m_progressPerTick_tpt; // beltSpeed_tps / kTickRateHz
|
||||||
|
|
||||||
std::map<std::pair<int, int>, BeltTile> m_belts;
|
std::map<std::pair<int, int>, BeltTile> m_belts;
|
||||||
std::map<std::pair<int, int>, SplitterTile> m_splitters;
|
std::map<std::pair<int, int>, SplitterTile> m_splitters;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "SurfaceMask.h"
|
#include "SurfaceMask.h"
|
||||||
|
#include "tracing.h"
|
||||||
|
|
||||||
BuildingSystem::BuildingSystem(const GameConfig& config,
|
BuildingSystem::BuildingSystem(const GameConfig& config,
|
||||||
BeltSystem& belts,
|
BeltSystem& belts,
|
||||||
@@ -13,12 +14,14 @@ BuildingSystem::BuildingSystem(const GameConfig& config,
|
|||||||
std::function<void(int)> addBuildingBlocks,
|
std::function<void(int)> addBuildingBlocks,
|
||||||
std::function<void(const std::string&, QVector2D,
|
std::function<void(const std::string&, QVector2D,
|
||||||
const std::optional<ShipLayoutConfig>&)> spawnShip,
|
const std::optional<ShipLayoutConfig>&)> spawnShip,
|
||||||
|
std::function<bool(const std::string&)> isItemUnlocked,
|
||||||
std::mt19937& rng)
|
std::mt19937& rng)
|
||||||
: m_config(config)
|
: m_config(config)
|
||||||
, m_belts(belts)
|
, m_belts(belts)
|
||||||
, m_allocateBuildingId(std::move(allocateBuildingId))
|
, m_allocateBuildingId(std::move(allocateBuildingId))
|
||||||
, m_addBuildingBlocks(std::move(addBuildingBlocks))
|
, m_addBuildingBlocks(std::move(addBuildingBlocks))
|
||||||
, m_spawnShip(std::move(spawnShip))
|
, m_spawnShip(std::move(spawnShip))
|
||||||
|
, m_isItemUnlocked(std::move(isItemUnlocked))
|
||||||
, m_rng(rng)
|
, m_rng(rng)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -202,17 +205,19 @@ std::vector<Port> BuildingSystem::computeInputPorts(const Building& b) const
|
|||||||
|
|
||||||
std::vector<Item> BuildingSystem::rollReprocessingOutput(const RecipeDef& recipe)
|
std::vector<Item> BuildingSystem::rollReprocessingOutput(const RecipeDef& recipe)
|
||||||
{
|
{
|
||||||
|
std::vector<const RecipeOutput*> eligible;
|
||||||
std::vector<double> weights;
|
std::vector<double> weights;
|
||||||
weights.reserve(recipe.outputs.size());
|
|
||||||
for (const RecipeOutput& out : recipe.outputs)
|
for (const RecipeOutput& out : recipe.outputs)
|
||||||
{
|
{
|
||||||
|
if (!m_isItemUnlocked(out.item)) { continue; }
|
||||||
|
eligible.push_back(&out);
|
||||||
weights.push_back(out.probability.value_or(1.0));
|
weights.push_back(out.probability.value_or(1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::discrete_distribution<int> dist(weights.begin(), weights.end());
|
if (eligible.empty()) { return {}; }
|
||||||
const int idx = dist(m_rng);
|
|
||||||
|
|
||||||
const RecipeOutput& chosen = recipe.outputs[static_cast<std::size_t>(idx)];
|
std::discrete_distribution<int> dist(weights.begin(), weights.end());
|
||||||
|
const RecipeOutput& chosen = *eligible[static_cast<std::size_t>(dist(m_rng))];
|
||||||
std::vector<Item> result;
|
std::vector<Item> result;
|
||||||
Item item;
|
Item item;
|
||||||
item.type.id = chosen.item;
|
item.type.id = chosen.item;
|
||||||
@@ -410,6 +415,7 @@ void BuildingSystem::setShipLayout(BuildingId id, const ShipLayoutConfig& layout
|
|||||||
|
|
||||||
void BuildingSystem::tickConstruction(Tick currentTick)
|
void BuildingSystem::tickConstruction(Tick currentTick)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
if (m_constructionQueue.empty())
|
if (m_constructionQueue.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -491,7 +497,7 @@ void BuildingSystem::tickConstruction(Tick currentTick)
|
|||||||
}
|
}
|
||||||
else if (front.type == BuildingType::TunnelEntry)
|
else if (front.type == BuildingType::TunnelEntry)
|
||||||
{
|
{
|
||||||
m_belts.placeTunnelEntry(front.anchor, front.rotation, m_config.world.tunnelMaxDistance);
|
m_belts.placeTunnelEntry(front.anchor, front.rotation, m_config.world.tunnelMaxDistance_tiles);
|
||||||
}
|
}
|
||||||
else if (front.type == BuildingType::TunnelExit)
|
else if (front.type == BuildingType::TunnelExit)
|
||||||
{
|
{
|
||||||
@@ -516,6 +522,7 @@ void BuildingSystem::tickConstruction(Tick currentTick)
|
|||||||
|
|
||||||
void BuildingSystem::tickBeltPull()
|
void BuildingSystem::tickBeltPull()
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
for (Building& building : m_buildings)
|
for (Building& building : m_buildings)
|
||||||
{
|
{
|
||||||
// HQ: pull building_block items and add to global stock.
|
// HQ: pull building_block items and add to global stock.
|
||||||
@@ -591,6 +598,7 @@ void BuildingSystem::tickBeltPull()
|
|||||||
|
|
||||||
void BuildingSystem::tickProduction(Tick currentTick)
|
void BuildingSystem::tickProduction(Tick currentTick)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
for (Building& building : m_buildings)
|
for (Building& building : m_buildings)
|
||||||
{
|
{
|
||||||
// Skip types without a recipe-based production loop.
|
// Skip types without a recipe-based production loop.
|
||||||
@@ -656,6 +664,7 @@ void BuildingSystem::tickProduction(Tick currentTick)
|
|||||||
if (building.type == BuildingType::ReprocessingPlant)
|
if (building.type == BuildingType::ReprocessingPlant)
|
||||||
{
|
{
|
||||||
chosen = rollReprocessingOutput(*recipe);
|
chosen = rollReprocessingOutput(*recipe);
|
||||||
|
if (chosen.empty()) { continue; }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -694,6 +703,7 @@ void BuildingSystem::tickProduction(Tick currentTick)
|
|||||||
|
|
||||||
void BuildingSystem::tickShipyardProduction(Tick currentTick)
|
void BuildingSystem::tickShipyardProduction(Tick currentTick)
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
for (Building& building : m_buildings)
|
for (Building& building : m_buildings)
|
||||||
{
|
{
|
||||||
if (building.type != BuildingType::Shipyard)
|
if (building.type != BuildingType::Shipyard)
|
||||||
@@ -795,6 +805,7 @@ void BuildingSystem::tickShipyardProduction(Tick currentTick)
|
|||||||
|
|
||||||
void BuildingSystem::tickBeltPush()
|
void BuildingSystem::tickBeltPush()
|
||||||
{
|
{
|
||||||
|
TRACE();
|
||||||
for (Building& building : m_buildings)
|
for (Building& building : m_buildings)
|
||||||
{
|
{
|
||||||
if (building.outputBuffer.items.empty())
|
if (building.outputBuffer.items.empty())
|
||||||
@@ -856,6 +867,44 @@ std::vector<ConstructionSite> BuildingSystem::allSites() const
|
|||||||
m_constructionQueue.end());
|
m_constructionQueue.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
bool isProductionBuildingType(BuildingType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BuildingType::Miner:
|
||||||
|
case BuildingType::Smelter:
|
||||||
|
case BuildingType::Assembler:
|
||||||
|
case BuildingType::ReprocessingPlant:
|
||||||
|
case BuildingType::Shipyard:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int BuildingSystem::productionBuildingCount() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (const Building& b : m_buildings)
|
||||||
|
{
|
||||||
|
if (isProductionBuildingType(b.type)) { ++count; }
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BuildingSystem::activeProductionBuildingCount() const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (const Building& b : m_buildings)
|
||||||
|
{
|
||||||
|
if (isProductionBuildingType(b.type) && b.production.has_value()) { ++count; }
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<BuildingSystem::BeltTileInfo> BuildingSystem::allBeltTiles() const
|
std::vector<BuildingSystem::BeltTileInfo> BuildingSystem::allBeltTiles() const
|
||||||
{
|
{
|
||||||
std::vector<BeltTileInfo> result;
|
std::vector<BeltTileInfo> result;
|
||||||
@@ -987,7 +1036,7 @@ void BuildingSystem::rotateInPlace(BuildingId id, Rotation newRotation)
|
|||||||
else if (b.type == BuildingType::TunnelEntry)
|
else if (b.type == BuildingType::TunnelEntry)
|
||||||
{
|
{
|
||||||
m_belts.removeTile(b.anchor);
|
m_belts.removeTile(b.anchor);
|
||||||
m_belts.placeTunnelEntry(b.anchor, newRotation, m_config.world.tunnelMaxDistance);
|
m_belts.placeTunnelEntry(b.anchor, newRotation, m_config.world.tunnelMaxDistance_tiles);
|
||||||
}
|
}
|
||||||
else if (b.type == BuildingType::TunnelExit)
|
else if (b.type == BuildingType::TunnelExit)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
std::function<void(int)> addBuildingBlocks,
|
std::function<void(int)> addBuildingBlocks,
|
||||||
std::function<void(const std::string&, QVector2D,
|
std::function<void(const std::string&, QVector2D,
|
||||||
const std::optional<ShipLayoutConfig>&)> spawnShip,
|
const std::optional<ShipLayoutConfig>&)> spawnShip,
|
||||||
|
std::function<bool(const std::string&)> isItemUnlocked,
|
||||||
std::mt19937& rng);
|
std::mt19937& rng);
|
||||||
|
|
||||||
// -- Placement / demolish ------------------------------------------------
|
// -- Placement / demolish ------------------------------------------------
|
||||||
@@ -78,6 +79,14 @@ public:
|
|||||||
const ConstructionSite* findSite(BuildingId id) const;
|
const ConstructionSite* findSite(BuildingId id) const;
|
||||||
std::vector<Building> allBuildings() const;
|
std::vector<Building> allBuildings() const;
|
||||||
std::vector<ConstructionSite> allSites() const;
|
std::vector<ConstructionSite> allSites() const;
|
||||||
|
|
||||||
|
// REQ-UI-DEBUG-OVERLAY "Max Factory Production": count of completed
|
||||||
|
// (operational) Miner/Smelter/Assembler/ReprocessingPlant/Shipyard buildings.
|
||||||
|
int productionBuildingCount() const;
|
||||||
|
|
||||||
|
// REQ-UI-DEBUG-OVERLAY "Current Factory Production": subset of the above
|
||||||
|
// that currently has an active production cycle.
|
||||||
|
int activeProductionBuildingCount() const;
|
||||||
std::vector<BeltTileInfo> allBeltTiles() const;
|
std::vector<BeltTileInfo> allBeltTiles() const;
|
||||||
bool isTileOccupied(QPoint tile) const;
|
bool isTileOccupied(QPoint tile) const;
|
||||||
|
|
||||||
@@ -134,6 +143,7 @@ private:
|
|||||||
std::function<void(int)> m_addBuildingBlocks;
|
std::function<void(int)> m_addBuildingBlocks;
|
||||||
std::function<void(const std::string&, QVector2D,
|
std::function<void(const std::string&, QVector2D,
|
||||||
const std::optional<ShipLayoutConfig>&)> m_spawnShip;
|
const std::optional<ShipLayoutConfig>&)> m_spawnShip;
|
||||||
|
std::function<bool(const std::string&)> m_isItemUnlocked;
|
||||||
std::mt19937& m_rng;
|
std::mt19937& m_rng;
|
||||||
|
|
||||||
std::vector<Building> m_buildings;
|
std::vector<Building> m_buildings;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user