fix: carry signals as NetworkValue, not NetworkToggle

v1.0.0 loaded cleanly and did nothing in game. Every vanilla use of
NetworkToggle and NetworkToggleReceiver -- all three of them -- sets
IncludeInPhysical = false. They are blueprint stat-display plumbing and
carry no signal on a real ship, so the receivers always read off, the
vent gate stayed open, and radiators behaved exactly as in vanilla.

Broadcast 1/0 through NetworkValue and threshold it back into a toggle
on the receiving side. That is what the thermal amplification pump uses
to drive physical behaviour, and vanilla never sets IncludeInPhysical on
it anywhere.

Also repoint the radiator's power indicator at the gate, so an auto-idled
radiator is visibly idle instead of looking identical to a working one.

Tests grow a guard against the blueprint-only types, plus a check that
re-verifies that premise against the installed game data so the guard
cannot go stale, and a name-collision check against vanilla components.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011oLWY1G6S8U35bi2FxVWni
This commit is contained in:
2026-08-28 23:37:21 +02:00
co-authored by Claude Opus 5
parent 831a628b53
commit 3ad03d7964
7 changed files with 250 additions and 73 deletions
+87 -2
View File
@@ -231,7 +231,19 @@ def test_component_references_resolve():
toggles = component.get("Toggles")
if toggles is not None and toggles.kind == "list":
for key in toggles.order:
ref = toggles.children[key].value.strip()
entry = toggles.children[key]
if entry.kind == "group":
# Inline form: { Toggle = Something; Invert = true }
inner = entry.get("Toggle")
ref = inner.value.strip() if inner is not None else None
check(
ref is not None,
f"{name}: {component_name}.Toggles has an inline entry with no Toggle",
)
else:
ref = entry.value.strip()
if ref is None:
continue
check(
ref in known,
f"{name}: {component_name}.Toggles references unknown component '{ref}'",
@@ -280,7 +292,80 @@ def test_component_types_exist():
# ---------------------------------------------------------------------------
# 5. The mod manifest must declare the fields Cosmoteer requires.
# 5. Signals must use a mechanism that works on a physical ship.
# Regression guard: version 1.0.0 broadcast with NetworkToggle, which loaded
# without error and did nothing in game. Every NetworkToggle and
# NetworkToggleReceiver in vanilla sets IncludeInPhysical = false -- they are
# blueprint stat-display plumbing only. NetworkValue carries the signal on a
# real ship, and is what vanilla's thermal amplification pump uses.
# ---------------------------------------------------------------------------
BLUEPRINT_ONLY_TYPES = {"NetworkToggle", "NetworkToggleReceiver"}
def test_no_blueprint_only_signal_types():
for mod_file, _ in added_component_sets():
added = rules_parser.parse_file(mod_file)
name = os.path.basename(mod_file)
for component_name in added.order:
component = added.children[component_name]
if component.kind != "group":
continue
type_node = component.get("Type")
if type_node is None:
continue
check(
type_node.value not in BLUEPRINT_ONLY_TYPES,
f"{name}: {component_name} uses '{type_node.value}', which vanilla only ever "
f"uses with IncludeInPhysical = false and which carries no signal in game",
)
def test_vanilla_marks_those_types_blueprint_only():
"""The premise of the guard above, re-checked against the installed game."""
pattern = re.compile(
r"Type\s*=\s*(NetworkToggle|NetworkToggleReceiver)\b(.*?)(?=\n\s*\})",
re.DOTALL,
)
sites = 0
physical_false = 0
for root, _dirs, files in os.walk(DATA):
for filename in files:
if not filename.endswith(".rules"):
continue
with open(os.path.join(root, filename), "r", encoding="utf-8", errors="replace") as handle:
for match in pattern.finditer(handle.read()):
sites += 1
if "IncludeInPhysical = false" in match.group(2):
physical_false += 1
check(sites > 0, "expected vanilla to use NetworkToggle somewhere")
check(
sites == physical_false,
f"premise broken: {sites - physical_false} of {sites} vanilla NetworkToggle sites "
f"are physical, so the guard in test_no_blueprint_only_signal_types may be wrong",
)
# ---------------------------------------------------------------------------
# 6. Added components must not silently overwrite a vanilla component.
# ---------------------------------------------------------------------------
def test_no_name_collisions_with_vanilla():
for mod_file, vanilla_components in added_component_sets():
if vanilla_components is None:
continue
added = rules_parser.parse_file(mod_file)
name = os.path.basename(mod_file)
for component_name in added.order:
check(
component_name not in vanilla_components.children,
f"{name}: '{component_name}' already exists on the vanilla part and would "
f"be overwritten",
)
# ---------------------------------------------------------------------------
# 7. The mod manifest must declare the fields Cosmoteer requires.
# ---------------------------------------------------------------------------
def test_manifest_is_well_formed():