Doodad Namespace Ideas #45

Open
opened 2021-08-09 19:15:59 +00:00 by kirsle · 0 comments

Currently Doodads are namespaced by their file name, like "door-red.doodad" or "boy.doodad"

Levels refer to actors by their filename, and custom user doodads take priority over built-in doodads of the same name.

When the emphasis on custom user content in this game, namespacing should be handled in a more robust way to minimize conflict not only between built-in and user doodads but also between user doodads made by different authors.

Mechanism

An ID property can be added to the Doodad JSON format. A default (random) ID can be generated when a new doodad is created in-game, with a UI for the player to enter a custom ID value.

The doodad CLI tool can set an ID value when creating/converting doodads, for the built-ins.

Level data would name an actor by its ID instead of its filename.

Concern: for the game to know where each doodad is it may need to load every doodad JSON to parse their ID strings out.

Naming Convention Ideas

The ID strings will ultimately be arbitrary values but some ideas for recommended guidelines could be:

  • Java-style: com.sketchymaze.Door.Red
  • Simpler: namespace.doodad like builtin.Door.Red or builtin.Trapdoor.Down

Built-in doodads would be named with a prefix like builtin. or core. or com.sketchymaze. and third-party user doodads would be encouraged to choose a good and distinct namespace (Java-style is best).

Prioritization/Overrides

The built-in doodads should have a higher priority against being overridden by user doodads as they currently are.

The search order for doodads should be:

  1. Embedded doodads inside the level file.
  2. Built-in doodads embedded in the game executable.
  3. External (system-wide) doodads in the game's directory.
  4. User doodads in the player's profile directory.

Backfill/Migration

The set of built-in doodads is known. When a new namespace scheme is rolled out, the game engine will translate between the old (legacy) names and the new names, e.g. "door-red.doodad" is translated to "com.sketchymaze.Door.Red" or whatever the naming convention is.

Existing maps created by older versions of the game will be readable with this translation layer. New maps saved by new versions of the game will use the new names for all doodads. Old maps can be "upgraded" by just opening and re-saving them with the newer game version.

Currently Doodads are namespaced by their file name, like "door-red.doodad" or "boy.doodad" Levels refer to actors by their filename, and custom user doodads take priority over built-in doodads of the same name. When the emphasis on custom user content in this game, namespacing should be handled in a more robust way to minimize conflict not only between built-in and user doodads but also between user doodads made by different authors. ## Mechanism An `ID` property can be added to the Doodad JSON format. A default (random) ID can be generated when a new doodad is created in-game, with a UI for the player to enter a custom ID value. The doodad CLI tool can set an ID value when creating/converting doodads, for the built-ins. Level data would name an actor by its ID instead of its filename. **Concern:** for the game to know where each doodad is it may need to load every doodad JSON to parse their ID strings out. ## Naming Convention Ideas The ID strings will ultimately be arbitrary values but some ideas for recommended guidelines could be: * Java-style: `com.sketchymaze.Door.Red` * Simpler: `namespace.doodad` like `builtin.Door.Red` or `builtin.Trapdoor.Down` Built-in doodads would be named with a prefix like `builtin.` or `core.` or `com.sketchymaze.` and third-party user doodads would be encouraged to choose a good and distinct namespace (Java-style is best). ## Prioritization/Overrides The built-in doodads should have a higher priority against being overridden by user doodads as they currently are. The search order for doodads should be: 1. Embedded doodads inside the level file. 2. Built-in doodads embedded in the game executable. 3. External (system-wide) doodads in the game's directory. 4. User doodads in the player's profile directory. ## Backfill/Migration The set of built-in doodads is known. When a new namespace scheme is rolled out, the game engine will translate between the old (legacy) names and the new names, e.g. "door-red.doodad" is translated to "com.sketchymaze.Door.Red" or whatever the naming convention is. Existing maps created by older versions of the game will be readable with this translation layer. New maps saved by new versions of the game will use the new names for all doodads. Old maps can be "upgraded" by just opening and re-saving them with the newer game version.
kirsle added the
doodad
enhancement
labels 2021-08-09 19:16:04 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SketchyMaze/doodle#45
There is no content yet.