shared logic refactor notes

Guide for shared logic refactor notes

Shared Logic Refactor Log

Date: 2026-01-11 Status: Reverted by User Request

Objective

The goal was to move shared map definitions from loh-game to loh-libs (shared-protocol) to enable server-side parsing of map data and support a headless architecture.

Changes Made (and Reverted)

1. Created loh-libs/rust/shared-protocol/src/types/map.rs

Moved the following types from loh-game to this new module:
  • PrefabType (with new variants like Shield, Structure Sets, Ores)
  • TileType (originally crate::systems::world::TileType)
  • SpawnPointType (originally crate::systems::editor::state::SpawnPointType)
  • SavedObject, SavedTile, SavedSpawnPoint (DTOs)
  • MapData

2. Updated shared-protocol

  • Added pub mod map; to types/mod.rs.
  • Added cfg_attr(feature = "bevy", derive(bevy::reflect::Reflect)) to shared types to allow loh-game (which depends on bevy) to use them in the Inspector.

3. Modified loh-game

  • src/systems/map.rs: Removed local definitions of PrefabType, MapData, etc. Imported them from shared_protocol::types::map.
  • src/systems/editor/state.rs: Removed SpawnPointType definition. Imported from shared_protocol.
  • src/systems/world/tiles.rs: Removed TileType definition. Imported from shared_protocol.
  • src/systems/editor/input.rs: Fixed SpawnPoint initialization to include respawn_time (This fix was retained as it is valid for local types too if fields match).
  • src/bin/editor.rs: Restored RenderPlugin configuration to fix unstable GPU backend issues (This change was likely beneficial and might be kept if unrelated to refactor, but strict revert applies).

Current State

The codebase has been reverted to defined these types locally in loh-game to ensure stability and match the user's request. The refactor is documented here for future implementation when the server architecture requires it.