Table of Contents

Class PlaceableIdGenerator

Namespace
MoonBark.GridPlacement.Core.Catalog
Assembly
MoonBark.GridPlacement.Core.dll

Utility class for generating stable, deterministic IDs for placeables. Extracts ID generation logic from Godot Placeable resources.

public static class PlaceableIdGenerator
Inheritance
PlaceableIdGenerator
Inherited Members

Methods

EnsureValidId(string)

Ensures an ID is valid by normalizing it or generating a new one.

public static string EnsureValidId(string id)

Parameters

id string

The ID to ensure is valid.

Returns

string

A valid ID string.

ExtractCategoryFromId(string)

Extracts the category from an ID.

public static string ExtractCategoryFromId(string id)

Parameters

id string

The ID to extract the category from.

Returns

string

The category part of the ID, or the full ID if no category is present.

ExtractNameFromId(string)

Extracts the name from an ID.

public static string ExtractNameFromId(string id)

Parameters

id string

The ID to extract the name from.

Returns

string

The name part of the ID, or the full ID if no category is present.

GenerateCategoryId(string, string)

Generates a category-specific ID.

public static string GenerateCategoryId(string category, string name)

Parameters

category string

The category name.

name string

The item name.

Returns

string

A category-specific ID string.

GenerateFromDisplayName(string)

Generates a stable ID from a display name.

public static string GenerateFromDisplayName(string displayName)

Parameters

displayName string

The display name (e.g., "Building Placeable").

Returns

string

A stable ID string, or empty string if the name is invalid.

GenerateFromPath(string)

Generates a stable ID from an asset path.

public static string GenerateFromPath(string resourcePath)

Parameters

resourcePath string

The asset path (e.g., "content://placeables/placeable_building.asset").

Returns

string

A stable ID string, or empty string if the path is invalid.

GenerateFromPathOrName(string, string)

Generates a stable ID from an asset path, falling back to display name.

public static string GenerateFromPathOrName(string resourcePath, string displayName)

Parameters

resourcePath string

The resource path.

displayName string

The display name to use as fallback.

Returns

string

A stable ID string.

GenerateFromValues(params string[])

Generates a deterministic ID from a combination of values.

public static string GenerateFromValues(params string[] values)

Parameters

values string[]

The values to combine.

Returns

string

A deterministic ID string.

GenerateUniqueId()

Generates a unique ID using a GUID.

public static string GenerateUniqueId()

Returns

string

A unique ID string.

IsValidId(string)

Validates if a string is a valid stable ID.

public static bool IsValidId(string id)

Parameters

id string

The ID to validate.

Returns

bool

True if the ID is valid, false otherwise.

NormalizeId(string)

Normalizes a string to a stable ID format.

public static string NormalizeId(string value)

Parameters

value string

The value to normalize.

Returns

string

A normalized ID string, or empty string if the value is invalid.