GameModeInfo
Assembly:
Game
Namespace: Game.Prefabs.Modes
Type:
public class
Base:
System.Object, implements IJsonWritable
Summary:
Represents metadata for a game mode prefab (identifier, image paths and localized descriptions) and provides JSON serialization logic via IJsonWritable. Typically used when exporting or persisting prefab mode information for the game's UI or data files. Properties map directly to JSON properties written by the Write method.
Fields
- None.
This type exposes state via public auto-implemented properties; there are no explicit private fields declared in the source.
Properties
-
public string id { get; set; }
Identifier for the game mode (e.g., a short name or key used to reference the mode). -
public string image { get; set; }
Path or resource key for the primary image representing the game mode. -
public string decorateImage { get; set; }
Path or resource key for an additional/decorative image associated with the mode. -
public LocalizedString[] descriptions { get; set; }
Array of localized strings providing descriptive text for the mode. LocalizedString comes from Game.UI.Localization and is used to support multiple languages.
Constructors
public GameModeInfo()
The default parameterless constructor is provided implicitly. Create an instance and set properties directly.
Methods
public void Write(IJsonWriter writer)
Serializes the GameModeInfo instance into JSON using the provided IJsonWriter. The method:- Calls writer.TypeBegin with the full type name.
- Writes "id", "image", "decorateImage" properties and their values.
- Writes the "descriptions" property by casting the descriptions array to IList
and writing it through the writer. - Calls writer.TypeEnd to finish the object.
This method assumes the writer understands how to serialize LocalizedString and IList
.
Usage Example
// Create and populate
var mode = new GameModeInfo {
id = "sandbox",
image = "Textures/Modes/sandbox.png",
decorateImage = "Textures/Modes/sandbox_decor.png",
descriptions = new LocalizedString[] {
new LocalizedString("mode.sandbox.desc", "Sandbox mode with unlimited money"),
// additional localized entries...
}
};
// Serialize with an IJsonWriter implementation
IJsonWriter writer = GetJsonWriter(); // obtain from surrounding code/framework
mode.Write(writer);
Additional notes:
- Ensure the IJsonWriter implementation used supports writing IList