makepad/libs/game/script/examples/compose_probe.rs
andodeki 435135ed50 feat(arcade): port makepad game libs + arcade from makepad-internal onto the fork
Reintroduce apps/arcade and the ten game crates that were ripped out of
the fork (assets, audio, blocks, coedit, gen, net, pkg, render, script,
session), from makepad-internal/dev. Reconcile against the fork's layout:

- makepad-game-sim/math come from the fork's existing libs/sim + sim/math;
  the copied internal libs/game/{sim,math} are dropped and the kept game
  crates plus arcade point at ../../sim and ../../sim/math.
- arcade AI is rewritten off the removed makepad-ai agent API onto the
  makepad-ai-hub headless ChatProvider worker (example/cad pattern):
  AiWorker{send,cancel,poll}, ai_worker_loop driving
  ClaudeApiChatProvider(ClaudeCli), AiWorkerEvent availability/delta/
  done/error mapped into the chat feed and authoring land_edit, with
  main.rs send_message/cancel_request/event-drain rebuilt around it.
- the game-script sandbox is adapted to the fork's jailed splash storage:
  every isolate gets mod.fs = splash_storage jail; splaes splash_storage
  set_root_for_heap is now public so the ScriptHost (or Splash) can grant
  a per-game jail root. ENT font: build.rs/dispatch.rs entities fill new
  fork sim Entity/Part fields via ..Default::default(); world_raycast now
  borrows mutably and returns the material id.

cargo check -p makepad-arcade and the game + arcade test suites pass.
2026-09-05 05:49:12 +03:00

36 lines
1.7 KiB
Rust

use makepad_game_gen::*;
use makepad_game_script::compose::{kit_from_index, level_placements, KitUse};
fn main() {
let idx = makepad_game_assets::AssetIndex::build(&std::path::PathBuf::from("apps/arcade/resources"));
println!("library: {} entries", idx.len());
let roads = kit_from_index(&idx, "city-kit-roads", KitUse::Structure).unwrap();
let houses = kit_from_index(&idx, "city-kit-suburban", KitUse::Buildings).unwrap();
println!(
"roads {} tiles, houses {} tiles ({} classed Building)",
roads.tiles.len(),
houses.tiles.len(),
houses.by_role(TileRole::Building).len()
);
let t0 = std::time::Instant::now();
let level = town(&roads, &TownParams {
seed: 11, extent: (18, 18), block: 6, density: 0.7,
buildings: Some(&houses), props: None,
});
let us = t0.elapsed().as_micros();
let kits = [roads.clone(), houses.clone()];
let placed = level_placements(&level, &kits);
let buildings = placed.iter().filter(|p| p.model.contains("suburban")).count();
println!("town: {} tiles in {us}us — {} buildings, {} road", placed.len(), buildings, placed.len() - buildings);
let d = kit_from_index(&idx, "modular-dungeon-kit", KitUse::Structure).unwrap();
let dl = dungeon(&d, &DungeonParams { seed: 11, extent: (20, 20), min_room: 5, depth: 4 });
let dp = level_placements(&dl, std::slice::from_ref(&d));
println!("dungeon: {} tiles, entrance {:?}", dp.len(), dl.entrance.is_some());
println!("adjacency errors: {}", level.layers.iter().map(|l| {
adjacency_errors(&TileLayout { kit_id: l.kit_id.clone(), tile_size: l.tile_size,
placements: l.placements.clone(), open_cells: vec![], entrance: None, exit: None }).len()
}).sum::<usize>());
}