Files
airdef/tools/airdef_assets/registry.py
T
chexit 8550de16f8 Finish the optical post's network cue and edge cases (#136)
- a radar's fresh track reaches a post as a cue only: it points the head
  but never enters the post's tracks, seen or own set
- a searching post's sector follows the turning head, not the fixed base
  heading; switching contacts drops the old contact's picture
- dead and blinded posts spend no probe budget and never observe
- the icon alias is part of the generator, so the placeholder item uses
  the radar texture without a duplicate PNG or a hand-written asset
- part diagnostics read "Опт" for a passive post's sensor
- tests: cue wiring, turning sector, contact switch, dead post, graphics
  preset; generator alias

Cherry-picked from 3697a1764aec7a7bdc6311918453dd51e26ecabf onto the
#132/#133/#134 base: the cue-wiring test's track literal now carries the
shared class/source/product/quality contract instead of a DroneKind.

Co-Authored-By: Kimi Code <noreply@moonshot.ai>
2026-11-20 23:38:32 +03:00

43 lines
2.3 KiB
Python

"""Resource registrations and localization, independent of geometry and raster generation."""
import json
import os
def write_json(path, obj):
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w", encoding="utf-8") as f:
json.dump(obj, f, ensure_ascii=False, indent=1)
def write_registry(out, namespace, models, items, camera_models, icon_aliases=None):
a = os.path.join(out, "assets", namespace)
d = os.path.join(out, "data", namespace, "horizon")
lang = {}
NS = namespace
for name, title in models:
write_json(os.path.join(a, "blockstates", name + ".json"), {"variants": {"": {"model": f"{NS}:block/{name}"}}})
write_json(os.path.join(d, "block", name + ".json"),
{"template": "minecraft:stone", "item": False})
lang[f"block.{NS}.{name}"] = title
icon_aliases = icon_aliases or {}
for name, title, _ in items:
icon = icon_aliases.get(name, name)
write_json(os.path.join(a, "models", "item", name + ".json"),
{"parent": "minecraft:item/generated", "textures": {"layer0": f"{NS}:item/{icon}"}})
write_json(os.path.join(a, "items", name + ".json"),
{"model": {"type": "minecraft:model", "model": f"{NS}:item/{name}"}})
write_json(os.path.join(d, "item", name + ".json"), {"template": "minecraft:stick", "max_stack_size": 1})
lang[f"item.{NS}.{name}"] = title
# Предметы-иконки для камеры монитора: 3D-модель цели в интерфейсе.
for name in camera_models:
title = dict(models)[name]
write_json(os.path.join(a, "models", "item", "cam_" + name + ".json"),
{"parent": f"{NS}:block/{name}",
"display": {"gui": {"rotation": [20, 145, 0], "translation": [0, 0, 0], "scale": [0.36, 0.36, 0.36]}}})
write_json(os.path.join(a, "items", "cam_" + name + ".json"),
{"model": {"type": "minecraft:model", "model": f"{NS}:item/cam_{name}"}})
write_json(os.path.join(d, "item", "cam_" + name + ".json"), {"template": "minecraft:stick", "max_stack_size": 1})
lang[f"item.{NS}.cam_{name}"] = title
write_json(os.path.join(a, "lang", "en_us.json"), lang)
write_json(os.path.join(a, "lang", "ru_ru.json"), lang)