### Setup Content Pipeline Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt Installs the content pipeline package to enable loading LDtk files through the MonoGame content pipeline. ```bash # Step 1: Install package to cache the DLL dotnet add package LDtkMonogame.ContentPipeline # Step 2: Remove from project (only needed for content build) dotnet remove package LDtkMonogame.ContentPipeline # Step 3: Find the cached DLL path # Windows: C:/Users//.nuget/packages/ldtkmonogame.contentpipeline//lib/net8.0/ # Linux/Mac: ~/.nuget/packages/ldtkmonogame.contentpipeline//lib/net8.0/ ``` -------------------------------- ### Install LDtkMonogame.Codegen Tool Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Documentation/codegen.md Install the LDtkMonogame.Codegen tool globally using the .NET CLI. Use 'update' to get the latest version. ```shell dotnet tool install --global LDtkMonogame.Codegen ``` ```shell dotnet tool update LDtkMonogame.Codegen --global ``` -------------------------------- ### Create Example Renderer Source: https://github.com/irishbruse/ldtkmonogame/blob/main/README.md Create an instance of the ExampleRenderer in Initialize. It can be initialized with or without a SpriteBatch. ```csharp ExampleRenderer renderer = new ExampleRenderer(spriteBatch, Content); ExampleRenderer renderer = new ExampleRenderer(spriteBatch); ``` -------------------------------- ### Property: ExampleRenderer.SpriteBatch Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/SpriteBatch.md Gets or sets the SpriteBatch instance utilized by the ExampleRenderer for rendering tasks. ```APIDOC ## Property: ExampleRenderer.SpriteBatch ### Description Gets or sets the SpriteBatch used for rendering with this Renderer. ### Definition `public SpriteBatch SpriteBatch { get; set; }` ### Namespace LDtk.Renderer ``` -------------------------------- ### Initialize GridPoint Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/GridPoint/GridPoint.md Use the default constructor to create a new instance of GridPoint. No specific setup is required. ```csharp public GridPoint() ``` -------------------------------- ### Accessing LayerDefinition.GuideGridHei Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LayerDefinition/GuideGridHei.md Defines the height of the guide grid in pixels. ```csharp public int GuideGridHei { get; set; } ``` -------------------------------- ### LDtkWorld.LoadLevel (by Guid) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkWorld/LoadLevel.md Loads an LDtk level using its unique identifier (Guid). ```APIDOC ## GET /api/ldtkworld/level ### Description Loads an LDtk level using its unique identifier (Guid). ### Method GET ### Endpoint /api/ldtkworld/level ### Query Parameters - **iid** (Guid) - Required - The unique identifier of the level to load. ### Response #### Success Response (200) - **LDtkLevel** (object) - The loaded LDtkLevel object. #### Response Example ```json { "levelData": "..." } ``` ``` -------------------------------- ### Install LDtkMonogame Content Pipeline Package Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Documentation/content.md Adds the content pipeline package to the project to cache the necessary DLLs. ```shell dotnet add package LDtkMonogame.ContentPipeline ``` -------------------------------- ### Initialize IntGridValueInstance Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/IntGridValueInstance/IntGridValueInstance.md Use the default constructor to create a new instance of IntGridValueInstance. No specific setup is required. ```csharp public IntGridValueInstance() ``` -------------------------------- ### Reference DLL in content.mgcb Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Documentation/content.md Example of adding the LDtk.ContentPipeline.dll reference to the content.mgcb file. ```sh #-------------------------------- References --------------------------------# /reference:C:/Users/IrishBruse/.nuget/packages/ldtkmonogame.contentpipeline/1.8.0/lib/net8.0/LDtk.ContentPipeline.dll #---------------------------------- Content ---------------------------------# ``` -------------------------------- ### Initialize ExampleRenderer in C# Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt Sets up the renderer for either direct file loading or content pipeline integration. Prerendering levels is recommended for performance optimization. ```csharp using LDtk; using LDtk.Renderer; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; // For direct file loading (textures loaded from filesystem) ExampleRenderer renderer = new ExampleRenderer(spriteBatch); // For content pipeline loading (textures loaded via ContentManager) ExampleRenderer renderer = new ExampleRenderer(spriteBatch, Content); // Prerender all levels for optimal performance foreach (LDtkLevel level in world.Levels) { renderer.PrerenderLevel(level); } ``` -------------------------------- ### ExampleRenderer Constructor (Direct File Loading) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/ExampleRenderer.md Initializes the ExampleRenderer for use with direct file loading. ```APIDOC ## Constructor: ExampleRenderer(SpriteBatch) ### Description Initializes a new instance of the ExampleRenderer class for use with direct file loading. ### Parameters #### Path Parameters - **spriteBatch** (SpriteBatch) - Required - The SpriteBatch instance used for rendering. ``` -------------------------------- ### LDtkIntGrid.WorldPosition Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkIntGrid/WorldPosition.md Gets or sets the worldspace start Position of the int grid. ```APIDOC ## LDtkIntGrid.WorldPosition Property ### Description Gets or sets the worldspace start Position of the int grid. ### Method GET/SET ### Endpoint N/A (Property of a class) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **WorldPosition** (Point) - The worldspace start position of the int grid. #### Response Example ```csharp public Point WorldPosition { get; set; } ``` ``` -------------------------------- ### Get or Set World File Path - LDtkLevel Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel/WorldFilePath.md Use this property to get or set the absolute filepath to the world associated with an LDtkLevel. No specific setup or constraints are mentioned. ```csharp public string WorldFilePath { get; set; } ``` -------------------------------- ### ExampleRenderer Constructor (Content Pipeline) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/ExampleRenderer.md Initializes the ExampleRenderer for use with the Content Pipeline. ```APIDOC ## Constructor: ExampleRenderer(SpriteBatch, ContentManager) ### Description Initializes a new instance of the ExampleRenderer class for use with the Content Pipeline. ### Parameters #### Path Parameters - **spriteBatch** (SpriteBatch) - Required - The SpriteBatch instance used for rendering. - **content** (ContentManager) - Optional - The ContentManager instance. ``` -------------------------------- ### AutoRuleDef YOffset Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/AutoRuleDef/YOffset.md Sets or gets the Y cell start offset for an AutoRuleDef. This property is part of the LDtk.Full namespace within the LDtkMonogame library. ```csharp public int YOffset { get; set; } ``` -------------------------------- ### Define Entity Class Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Documentation/README.md Example structure for an entity class inheriting from ILDtkEntity. ```csharp public class Gun_Pickup : ILDtkEntity { public System.Guid Iid { get; set; } public long Uid { get; set; } public string Identifier { get; set; } public Vector2 Size { get; set; } public Vector2 Position { get; set; } public Vector2 Pivot { get; set; } public Rectangle Tile { get; set; } public Color SmartColor { get; set; } public EntityRef Test { get; set; } ... } ``` -------------------------------- ### Initialize ExampleRenderer for Direct File Loading Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/ExampleRenderer.md Use this constructor to initialize the renderer for direct file loading. Requires a SpriteBatch instance. ```csharp public ExampleRenderer(SpriteBatch spriteBatch) ``` -------------------------------- ### Access Default JsonSerializerContext Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LDtkJsonFullSourceGenerator/Default.md Use this property to get the default JsonSerializerContext for LDtk JSON serialization. No specific setup or imports are required beyond the class definition. ```csharp public static LDtkJsonFullSourceGenerator Default { get; } ``` -------------------------------- ### Initialize ExampleRenderer for Content Pipeline Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/ExampleRenderer.md Use this constructor to initialize the renderer for use with the content pipeline. Requires a SpriteBatch and an optional ContentManager. ```csharp public ExampleRenderer(SpriteBatch spriteBatch, ContentManager content) ``` -------------------------------- ### GET LDtkFile.WorldLayout Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkFile/WorldLayout.md Retrieves the current layout configuration for the LDtk project levels. ```APIDOC ## GET LDtkFile.WorldLayout ### Description Returns an enum describing how levels are organized in the project. Note: This field is subject to change to a 'worlds' array in future updates. ### Method GET ### Endpoint LDtkFile.WorldLayout ### Response #### Success Response (200) - **WorldLayout** (enum) - The current layout type. Possible values: Free, GridVania, LinearHorizontal, LinearVertical, or null. ``` -------------------------------- ### LayerDefinition.GuideGridHei Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LayerDefinition/GuideGridHei.md Defines the height of the optional guide grid in pixels for a layer definition. ```APIDOC ## Property: LayerDefinition.GuideGridHei ### Description Gets or sets the height of the optional "guide" grid in pixels. ### Type int ### Definition ```csharp public int GuideGridHei { get; set; } ``` ### See Also - Class: LayerDefinition - Namespace: LDtk.Full ``` -------------------------------- ### Accessing the Guid serialization contract Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkJsonSourceGenerator/Guid.md Retrieves the JsonTypeInfo metadata for the Guid type used in JSON serialization. ```csharp public JsonTypeInfo Guid { get; } ``` -------------------------------- ### Initialize LDtkFileFull instance Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LDtkFileFull/LDtkFileFull.md Use this default constructor to create a new instance of the LDtkFileFull class. ```csharp public LDtkFileFull() ``` -------------------------------- ### Definitions Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/Definitions/Definitions.md The default constructor for the Definitions class. No specific setup or imports are required beyond the class definition itself. ```csharp public Definitions() ``` -------------------------------- ### ExampleRenderer Class Overview Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer.md This section provides an overview of the ExampleRenderer class and its public members. ```APIDOC ## Class: ExampleRenderer Renderer for the ldtkWorld, ldtkLevel, intgrids and entities. This can all be done in your own class if you want to reimplement it and customize it differently this one is mostly here to get you up and running quickly. ```csharp public class ExampleRenderer : IDisposable ``` ### Public Members * **ExampleRenderer(params)**: Initializes a new instance of the `ExampleRenderer` class. Used for direct file loading. * **SpriteBatch { get; set; }**: Gets or sets the spritebatch used for rendering. * **Dispose()**: Disposes of the renderer resources. * **PrerenderLevel(params)**: Prerenders the level to textures for optimized rendering. * **RenderEntity(params)**: Renders the entity with its associated tile. (4 overloads) * **RenderIntGrid(params)**: Renders intgrids by displaying them as solid color squares. * **RenderLevel(params)**: Renders the level directly without prerendering, which is slower. * **RenderPrerenderedLevel(params)**: Renders a level that has been prerendered using `PrerenderLevel()`. ``` -------------------------------- ### Get Entity from Reference Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets an entity from a reference, converted to type T. This method is part of the LDtkLevel class. ```csharp public T GetEntityRef(EntityReference reference) ``` -------------------------------- ### Get Level Background Color Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the background color of the level. This property is part of the LDtkLevel class. ```csharp public Color _BgColor { get; set; } ``` -------------------------------- ### Initialize TileInstance with default constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/TileInstance/TileInstance.md Use this constructor to create a new instance of the TileInstance class. ```csharp public TileInstance() ``` -------------------------------- ### Get Level World Size Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets the world size of the level in pixels. This property is part of the LDtkLevel class. ```csharp public Vector2 Size { get; } ``` -------------------------------- ### Get Level Pixel Width Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the width of the level in pixels. This property is part of the LDtkLevel class. ```csharp public int PxWid { get; set; } ``` -------------------------------- ### Loading LDtk Files Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt Demonstrates how to load LDtk project files using direct file access or the MonoGame content pipeline. ```APIDOC ## Loading LDtk Files The `LDtkFile.FromFile()` method loads an LDtk project file from disk. It supports both direct file loading and content pipeline loading, and automatically validates the file version and required flags. ### Method `LDtkFile.FromFile(string filePath, ContentManager contentManager = null)` ### Parameters #### Path Parameters - **filePath** (string) - Required - The path to the LDtk project file. - **contentManager** (ContentManager) - Optional - The MonoGame ContentManager to use for loading. ### Request Example ```csharp // Direct file loading (without content pipeline) LDtkFile file = LDtkFile.FromFile("Content/World.ldtk"); // Loading via MonoGame content pipeline LDtkFile file = LDtkFile.FromFile("World", Content); // Using reflection-based deserializer (slower but may be needed for edge cases) LDtkFile fileReflection = LDtkFile.FromFileReflection("Content/World.ldtk"); ``` ``` -------------------------------- ### Get Level Pixel Height Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the height of the level in pixels. This property is part of the LDtkLevel class. ```csharp public int PxHei { get; set; } ``` -------------------------------- ### ExampleRenderer.RenderIntGrid Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/RenderIntGrid.md Renders LDtk IntGrids by displaying them as solid color squares. ```APIDOC ## RenderIntGrid ### Description Render intgrids by displaying the intgrid as solidcolor squares. ### Method `public void RenderIntGrid(LDtkIntGrid intGrid)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get Level World Position Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets the world position of the level in pixels. This property is part of the LDtkLevel class. ```csharp public Vector2 Position { get; } ``` -------------------------------- ### TileCustomMetadata Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/TileCustomMetadata/TileCustomMetadata.md Initializes a new instance of the TileCustomMetadata class. ```APIDOC ## Constructor: TileCustomMetadata() ### Description The default constructor for the TileCustomMetadata class. ### Method Constructor ### Endpoint LDtk.TileCustomMetadata.TileCustomMetadata() ``` -------------------------------- ### Get Level Identifier Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the user-defined unique identifier for the level. This property is part of the LDtkLevel class. ```csharp public string Identifier { get; set; } ``` -------------------------------- ### Get Level Unique Identifier Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the unique integer identifier for the level. This property is part of the LDtkLevel class. ```csharp public int Uid { get; set; } ``` -------------------------------- ### Configure Content.mgcb for LDtk Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt Add these references and build instructions to your Content.mgcb file to enable the LDtk content pipeline. ```text #-------------------------------- References --------------------------------# /reference:C:/Users/YourName/.nuget/packages/ldtkmonogame.contentpipeline/1.8.0/lib/net8.0/LDtk.ContentPipeline.dll #---------------------------------- Content ---------------------------------# /importer:LDtkFileImporter /processor:LDtkFileProcessor /build:World.ldtk ``` -------------------------------- ### Get Level Instance Identifier Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the unique instance identifier for the level. This property is part of the LDtkLevel class. ```csharp public string Iid { get; set; } ``` -------------------------------- ### Import Namespace Source: https://github.com/irishbruse/ldtkmonogame/blob/main/README.md Import the necessary LDtk namespace. The LDtk.Renderer namespace is optional for using the premade renderer. ```csharp using LDtk; // Optional using LDtk.Renderer; ``` -------------------------------- ### Get IntGrid Layer Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets an IntGrid layer within the LDtkLevel, identified by its string identifier. This method is part of the LDtkLevel class. ```csharp public IntGrid GetIntGrid(string identifier) ``` -------------------------------- ### Get Entities of Specific Type Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets an array of entities of type T within the current level. This method is part of the LDtkLevel class. ```csharp public T[] GetEntities() ``` -------------------------------- ### TilesetDefinition Default Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/TilesetDefinition/TilesetDefinition.md Use this constructor to create a new instance of TilesetDefinition with default values. No specific setup is required beyond this call. ```csharp public TilesetDefinition() ``` -------------------------------- ### Initialize and Render LDtk Project in MonoGame Source: https://github.com/irishbruse/ldtkmonogame/wiki/Quick Start/Nuget-Package Demonstrates loading an LDtk project file during initialization and rendering specific layers during the draw call. ```C# Project projectFile; override void Initialize() { projectFile = new Project(spriteBatch, "PATH TO THE LDTK FILE"); projectFile.Render(0); base.Initialize(); } override void Draw(GameTime gameTime) { Level level = projectFile.Levels[0]; GraphicsDevice.Clear(level.BgColor); spriteBatch.Begin(samplerState: SamplerState.PointClamp); { for(int i = level.layers.Length - 1; i >= 0; i--) { if(activeLayers[i] == true) { spriteBatch.Draw(level.layers[i], Vector2.Zero, Color.White); } } } spriteBatch.End(); base.Draw(gameTime); } ``` -------------------------------- ### Get Level Absolute File Path Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the absolute file path to the level. This property is part of the LDtkLevel class. ```csharp public string FilePath { get; set; } ``` -------------------------------- ### Initialize CustomCommand Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/CustomCommand/CustomCommand.md The default constructor for the CustomCommand class. ```csharp public CustomCommand() ``` -------------------------------- ### Get World File Path Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the absolute file path to the world containing this level. This property is part of the LDtkLevel class. ```csharp public string WorldFilePath { get; set; } ``` -------------------------------- ### IntGridValueGroupDefinition Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/IntGridValueGroupDefinition/IntGridValueGroupDefinition.md Initializes a new instance of the IntGridValueGroupDefinition class with default values. No specific setup is required. ```csharp public IntGridValueGroupDefinition() ``` -------------------------------- ### Get Level Custom Field Instances Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets an array containing the custom field values for this level. This property is part of the LDtkLevel class. ```csharp public FieldInstance[] FieldInstances { get; set; } ``` -------------------------------- ### Initialize LDtkFileReader Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.ContentPipeline/LDtkFileReader/LDtkFileReader.md Instantiates a new instance of the LDtkFileReader class using the default constructor. ```csharp public LDtkFileReader() ``` -------------------------------- ### Get Custom Fields of Specific Type Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets the custom fields of the level, strongly typed to a specific type T. This method is part of the LDtkLevel class. ```csharp public T[] GetCustomFields() ``` -------------------------------- ### Get Level Background Position Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the position information for the level's background image, if one exists. This property is part of the LDtkLevel class. ```csharp public BgPosInfo _BgPos { get; set; } ``` -------------------------------- ### LDtkFile Class Methods Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkFile.md Methods for loading LDtk project files from disk. ```APIDOC ## static FromFile(...) ### Description Loads the ldtk world file from disk directly using json source generator. ## static FromFileReflection(...) ### Description Loads the ldtk world file from disk directly. ## LoadSingleWorld() ### Description Loads the one and only ldtkl world file from disk directly or from the embeded one depending on if the file uses externalworlds. ## LoadWorld(...) ### Description Loads the ldtkl world file from disk directly or from the embeded one depending on if the file uses externalworlds. ``` -------------------------------- ### Initialize EnumValueDefinition Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/EnumValueDefinition/EnumValueDefinition.md Creates a new instance of the EnumValueDefinition class using its default constructor. No specific setup is required beyond having the class available. ```csharp public EnumValueDefinition() ``` -------------------------------- ### Get Level Background Image Path Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the optional relative path to the level's background image. This property is part of the LDtkLevel class. ```csharp public string BgRelPath { get; set; } ``` -------------------------------- ### Definitions Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/Definitions/Definitions.md Initializes a new instance of the Definitions class. ```APIDOC ## Definitions Constructor ### Description The default constructor for the Definitions class. ### Method Constructor ### Endpoint LDtk.Definitions() ### Request Example new Definitions(); ``` -------------------------------- ### Get or Set ContentManager for LDtkFile Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkFile/Content.md Use this property to get or set the ContentManager instance. This is required when loading LDtk project files through the Monogame content pipeline. ```csharp public ContentManager? Content { get; set; } ``` -------------------------------- ### Static Method: LDtkFileFull.FromFile Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LDtkFileFull/FromFile.md Loads an LDtk world file from a specified file path on disk. ```APIDOC ## Static Method: LDtkFileFull.FromFile ### Description Loads the ldtk world file from disk directly using json source generator. ### Method Static Method ### Parameters #### Path Parameters - **filePath** (string) - Required - Path to the .ldtk file. ### Return Value Returns the file loaded from the path. ``` -------------------------------- ### TutorialDesc Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LDtkFileFull/TutorialDesc.md This optional string property is used by LDtk Samples to display information and instructions. ```csharp public string? TutorialDesc { get; set; } ``` -------------------------------- ### Get Level Neighbors Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets an array listing all other levels touching this one on the world map. Only relevant for manual world layouts. This property is part of the LDtkLevel class. ```csharp public Neighbor[] _Neighbours { get; set; } ``` -------------------------------- ### Initialize TileCustomMetadata Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/TileCustomMetadata/TileCustomMetadata.md The default constructor for the TileCustomMetadata class. ```csharp public TileCustomMetadata() ``` -------------------------------- ### Get Single Entity of Specific Type Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets a single entity of type T in the current level. Best used when there's a constraint of one entity per level. This method is part of the LDtkLevel class. ```csharp public T GetEntity() ``` -------------------------------- ### IntGridValueDefinition Default Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/IntGridValueDefinition/IntGridValueDefinition.md Initializes a new instance of the IntGridValueDefinition class with default values. No specific setup is required. ```csharp public IntGridValueDefinition() ``` -------------------------------- ### LevelBackgroundPosition Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LevelBackgroundPosition/LevelBackgroundPosition.md Initializes a new instance of the LevelBackgroundPosition class with default values. No specific setup is required beyond the class definition. ```csharp public LevelBackgroundPosition() ``` -------------------------------- ### Prerender Levels Source: https://github.com/irishbruse/ldtkmonogame/blob/main/README.md Prerender all levels in the loaded world using the ExampleRenderer before drawing. ```csharp foreach (LDtkLevel level in world.Levels) { renderer.PrerenderLevel(level); } ``` -------------------------------- ### Get Level World Y Coordinate Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the world Y coordinate in pixels. Only relevant for manual world layouts (GridVania, Free). For Horizontal/Vertical layouts, this is always -1. This property is part of the LDtkLevel class. ```csharp public int WorldY { get; set; } ``` -------------------------------- ### LDtkFileFull.TutorialDesc Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LDtkFileFull/TutorialDesc.md Details regarding the TutorialDesc property used for providing tutorial information in LDtk files. ```APIDOC ## Property: LDtkFileFull.TutorialDesc ### Description This optional description is used by LDtk Samples to show information and instructions. ### Property Definition `public string? TutorialDesc { get; set; }` ### Namespace LDtk.Full ### Class LDtkFileFull ``` -------------------------------- ### Get Level World Depth Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the index representing the 'depth' of the level in the world. Higher values mean 'above', lower values mean 'below'. This property is part of the LDtkLevel class. ```csharp public int WorldDepth { get; set; } ``` -------------------------------- ### Get External Level File Path Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the relative path to the level's JSON file if the project option 'Save levels separately' is enabled. This property is part of the LDtkLevel class. ```csharp public string ExternalRelPath { get; set; } ``` -------------------------------- ### Render Entities with LDtkMonogame Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt Demonstrates rendering entities with support for flipping, animation frames, and manual sprite batch drawing. ```csharp using LDtk; using LDtk.Renderer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; Texture2D enemyTexture = Content.Load("Characters"); // Simple entity rendering renderer.RenderEntity(enemy, enemyTexture); // Render with horizontal flip renderer.RenderEntity(enemy, enemyTexture, SpriteEffects.FlipHorizontally); // Render with animation frame (frames must be horizontal in tileset) int currentFrame = (int)(totalTime * 10) % 4; // 4 frames at 10fps renderer.RenderEntity(enemy, enemyTexture, currentFrame); // Render with flip and animation renderer.RenderEntity( enemy, enemyTexture, SpriteEffects.FlipHorizontally, animationFrame: currentFrame ); // Manual entity rendering using entity properties spriteBatch.Draw( texture: playerTexture, position: player.Position, sourceRectangle: player.Tile, color: Color.White, rotation: 0f, origin: player.Pivot * player.Size, scale: 1f, effects: player.Flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth: 0.2f ); ``` -------------------------------- ### Get Level Layer Instances Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets an array containing all layer instances for the level, sorted in display order. If 'Save levels separately' is enabled, this field will be null. This property is part of the LDtkLevel class. ```csharp public LayerInstance[] LayerInstances { get; set; } ``` -------------------------------- ### Define ExampleRenderer class Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer.md The base class definition for the ExampleRenderer, which implements IDisposable for resource management. ```csharp public class ExampleRenderer : IDisposable ``` -------------------------------- ### ExampleRenderer.RenderLevel Method Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/RenderLevel.md Renders the level directly without prerendering the layers, which is slower than prerendering. ```APIDOC ## RenderLevel Method ### Description Render the level directly without prerendering the layers alot slower than prerendering. ### Method `public void RenderLevel(LDtkLevel level)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ### See Also * class [LDtkLevel](../../LDtk/LDtkLevel.md) * class [ExampleRenderer](../ExampleRenderer.md) * namespace [LDtk.Renderer](../../LDtkMonogame.md) ``` -------------------------------- ### Get Level World X Coordinate Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel.md Gets or sets the world X coordinate in pixels. Only relevant for manual world layouts (GridVania, Free). For Horizontal/Vertical layouts, this is always -1. This property is part of the LDtkLevel class. ```csharp public int WorldX { get; set; } ``` -------------------------------- ### Implement LDtk Game Integration Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt A complete Game class implementation demonstrating world loading, level switching, entity management, and rendering. ```csharp using LDtk; using LDtk.Renderer; using LDtkTypes.Platformer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; public class PlatformerGame : Game { private SpriteBatch spriteBatch; private LDtkWorld world; private LDtkLevel currentLevel; private ExampleRenderer renderer; private List enemies = new(); private List collectibles = new(); private Player player; private LDtkIntGrid collisionGrid; private Texture2D playerTexture; private Texture2D enemyTexture; private Texture2D collectibleTexture; protected override void Initialize() { // Load LDtk file and world LDtkFile file = LDtkFile.FromFile("World", Content); world = file.LoadWorld(Worlds.World.Iid); // Initialize renderer spriteBatch = new SpriteBatch(GraphicsDevice); renderer = new ExampleRenderer(spriteBatch, Content); // Prerender all levels foreach (LDtkLevel level in world.Levels) { renderer.PrerenderLevel(level); } // Load initial level LoadLevel("Level1"); base.Initialize(); } private void LoadLevel(string levelId) { currentLevel = world.LoadLevel(levelId); // Clear and reload entities enemies.Clear(); collectibles.Clear(); enemies.AddRange(currentLevel.GetEntities()); collectibles.AddRange(currentLevel.GetEntities()); // Get collision grid collisionGrid = currentLevel.GetIntGrid("Collisions"); // Get spawn point PlayerSpawn spawn = currentLevel.GetEntity(); player.Position = spawn.Position; } protected override void Update(GameTime gameTime) { float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; // Update player with collision UpdatePlayerMovement(deltaTime); // Check collectible collision for (int i = collectibles.Count - 1; i >= 0; i--) { if (Vector2.Distance(player.Position, collectibles[i].Position) < 16) { collectibles.RemoveAt(i); } } // Check level transitions foreach (Door door in currentLevel.GetEntities()) { if (Vector2.Distance(player.Position, door.Position) < 32) { LoadLevel(door.LevelIdentifier); break; } } base.Update(gameTime); } private void UpdatePlayerMovement(float deltaTime) { Vector2 newPosition = player.Position + player.Velocity * deltaTime; Point gridPos = collisionGrid.FromWorldToGridSpace(newPosition); if (collisionGrid.GetValueAt(gridPos) == 0) // 0 = empty { player.Position = newPosition; } } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(currentLevel._BgColor); spriteBatch.Begin(samplerState: SamplerState.PointClamp); // Render level tiles renderer.RenderPrerenderedLevel(currentLevel); // Render entities foreach (Enemy enemy in enemies) { renderer.RenderEntity(enemy, enemyTexture); } foreach (Collectible collectible in collectibles) { int frame = (int)(gameTime.TotalGameTime.TotalSeconds * 8) % 4; renderer.RenderEntity(collectible, collectibleTexture, frame); } // Render player renderer.RenderEntity(player, playerTexture, player.FacingLeft ? SpriteEffects.FlipHorizontally : SpriteEffects.None); spriteBatch.End(); base.Draw(gameTime); } } ``` -------------------------------- ### ILDtkEntity.SmartColor Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/ILDtkEntity/SmartColor.md Gets or sets the editorVisualColor for an entity. ```APIDOC ## ILDtkEntity.SmartColor Property ### Description Gets or sets editorVisualColor. ### Method GET, SET ### Endpoint N/A (Property of an interface) ### Parameters N/A ### Request Example ```csharp // To get the color: Color entityColor = entity.SmartColor; // To set the color: entity.SmartColor = Color.Red; ``` ### Response N/A (Property of an interface) ``` -------------------------------- ### Static Method: LDtkLevel.FromFile (Direct) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel/FromFile.md Loads an LDtk world file from disk using a JSON source generator. ```APIDOC ## STATIC METHOD LDtkLevel.FromFile ### Description Loads the ldtk world file from disk directly using json source generator. ### Method STATIC ### Parameters #### Path Parameters - **filePath** (string) - Required - Path to the .ldtk file. ### Response - **LDtkLevel?** - Returns the loaded LDtkLevel object or null if loading fails. ``` -------------------------------- ### ILDtkEntity.Position Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/ILDtkEntity/Position.md Gets or sets the position of an entity. ```APIDOC ## ILDtkEntity.Position Property ### Description Gets or sets position. ### Method Property (Get/Set) ### Endpoint N/A (This is a property, not an API endpoint) ### Parameters N/A ### Request Example N/A ### Response N/A ### Code Example ```csharp public Vector2 Position { get; set; } ``` ``` -------------------------------- ### Static Method: LDtkLevel.FromFile (ContentManager) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel/FromFile.md Loads an LDtk world file from disk using the MonoGame ContentManager. ```APIDOC ## STATIC METHOD LDtkLevel.FromFile ### Description Loads the ldtk world file from disk directly using the content pipeline. ### Method STATIC ### Parameters #### Path Parameters - **filePath** (string) - Required - Path to the .ldtk file excluding file extension. - **content** (ContentManager) - Required - The optional content manager if you are using the content pipeline. ### Response - **LDtkLevel?** - Returns the loaded LDtkLevel object or null if loading fails. ``` -------------------------------- ### Retrieve Entity Reference Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Documentation/README.md Get an entity reference from a level. ```csharp Gun_Pickup level1 = level0.GetEntityRef();// Guid/Iid ``` -------------------------------- ### LDtkWorld.WorldGridSize Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkWorld/WorldGridSize.md Gets the size of the world grid in pixels. ```APIDOC ## LDtkWorld.WorldGridSize Property ### Description Gets the size of the world grid in pixels. ### Method GET ### Endpoint N/A (This is a property, not an API endpoint) ### Parameters None ### Request Body None ### Response #### Success Response (200) - **WorldGridSize** (Point) - The size of the world grid in pixels. ### Response Example ```json { "WorldGridSize": { "X": 1024, "Y": 768 } } ``` ``` -------------------------------- ### LDtkFile.FromFile(string filePath, ContentManager content) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkFile/FromFile.md Loads the ldtk world file from disk directly. ```APIDOC ## LDtkFile.FromFile(string filePath, ContentManager content) ### Description Loads the ldtk world file from disk directly. ### Method static ### Endpoint N/A (static method) ### Parameters #### Path Parameters - **filePath** (string) - Required - Path to the .ldtk file excluding file extension. - **content** (ContentManager) - Optional - The optional content manager if you are using the content pipeline. ### Response #### Success Response (200) - **LDtkFile** (object) - Returns the file loaded from the path. ### See Also * class [LDtkFile](../LDtkFile.md) * namespace [LDtk](../../LDtkMonogame.md) ``` -------------------------------- ### LDtkWorld.FilePath Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkWorld/FilePath.md Gets or sets the absolute filepath to the world. ```APIDOC ## LDtkWorld.FilePath Property ### Description Gets or sets the absolute filepath to the world. ### Method Property (Get/Set) ### Endpoint N/A (Class Property) ### Parameters N/A ### Request Example N/A ### Response N/A ### See Also * class [LDtkWorld](../LDtkWorld.md) * namespace [LDtk](../../LDtkMonogame.md) ``` -------------------------------- ### Load LDtk file from disk Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LDtkFileFull/FromFile.md Use this method to load an .ldtk file by providing its file path. It returns the loaded LDtkFileFull object. ```csharp public static LDtkFileFull FromFile(string filePath) ``` -------------------------------- ### LDtkLevel.Size Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel/Size.md Gets the world size of the level in pixels. ```APIDOC ## LDtkLevel.Size Property ### Description Gets the world size of the level in pixels. ### Method GET ### Endpoint N/A (Property access) ### Parameters None ### Request Body None ### Response #### Success Response (200) - **Size** (Point) - The world size of the level in pixels. ### Response Example ```json { "Size": { "X": 1024, "Y": 768 } } ``` ``` -------------------------------- ### LDtkFileFull.CustomCommands Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LDtkFileFull/CustomCommands.md Represents an array of command lines that can be executed manually by the user. ```APIDOC ## LDtkFileFull.CustomCommands Property ### Description An array of command lines that can be ran manually by the user. ### Property `CustomCommands` (CustomCommand[]) - An array of custom command lines. ### See Also * class `CustomCommand` * class `LDtkFileFull` * namespace `LDtk.Full` ``` -------------------------------- ### ILDtkEntity.Tile Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/ILDtkEntity/Tile.md Gets or sets the tile associated with an entity. ```APIDOC ## ILDtkEntity.Tile Property ### Description Gets or sets the tile associated with an entity. ### Method Not Applicable (Property) ### Endpoint Not Applicable (Property) ### Parameters Not Applicable (Property) ### Request Example Not Applicable (Property) ### Response #### Success Response (200) - **Tile** (Rectangle) - The tile data. #### Response Example ```csharp public Rectangle Tile { get; set; } ``` ``` -------------------------------- ### Load LDtk Level from File using Reflection Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel/FromFileReflection.md Use this method to load an LDtk level file directly from disk. Ensure the file path is correct. ```csharp public static LDtkLevel? FromFileReflection(string filePath) ``` -------------------------------- ### LDtkLevel.GetEntityRef Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkLevel/GetEntityRef.md Gets an entity from an entity reference, converted to type T. ```APIDOC ## LDtkLevel.GetEntityRef ### Description Gets an entity from an *reference* converted to *T*. ### Method `public T GetEntityRef(EntityReference reference) where T : new()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **T** (type) - The entity of type T retrieved from the reference. #### Response Example None ### Exceptions - **LDtkException**: Thrown when an error occurs during entity retrieval. ``` -------------------------------- ### LDtkFileReader Constructor Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.ContentPipeline/LDtkFileReader/LDtkFileReader.md Initializes a new instance of the LDtkFileReader class with default settings. ```APIDOC ## LDtkFileReader() ### Description The default constructor for the LDtkFileReader class. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters N/A ### Request Body N/A ### Response N/A ### See Also * class LDtkFileReader * namespace LDtk.ContentPipeline ``` -------------------------------- ### LDtkIntGrid.Values Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkIntGrid/Values.md Gets or sets the underlying values of the int grid. ```APIDOC ## LDtkIntGrid.Values Property ### Description Gets or sets the underlying values of the int grid. ### Property Type `int[]` ### Access Modifiers `public` ``` -------------------------------- ### Accessing EntityReference.WorldIid Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/EntityReference/WorldIid.md Defines the WorldIid property as a Guid within the EntityReference class. ```csharp public Guid WorldIid { get; set; } ``` -------------------------------- ### Initialize EntityDefinition Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/EntityDefinition/EntityDefinition.md Use this default constructor to create a new instance of the EntityDefinition class. ```csharp public EntityDefinition() ``` -------------------------------- ### LDtkWorld.GetEntityRef Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkWorld/GetEntityRef.md Gets an entity from an entity reference, converted to a specified type T. ```APIDOC ## LDtkWorld.GetEntityRef ### Description Gets an entity from an *reference* converted to *T*. ### Method `public T GetEntityRef(EntityReference reference) where T : new() ` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **T** (type) - The entity of type T retrieved from the reference. #### Response Example None ### See Also * class [EntityReference](../EntityReference.md) * class [LDtkWorld](../LDtkWorld.md) * namespace [LDtk](../../LDtkMonogame.md) ``` -------------------------------- ### ExampleRenderer.PrerenderLevel Method Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/PrerenderLevel.md Prerenders a level to textures to optimize the rendering process. ```APIDOC ## Method: PrerenderLevel ### Description Prerender out the level to textures to optimize the rendering process. ### Signature `public RenderedLevel PrerenderLevel(LDtkLevel level)` ### Parameters - **level** (LDtkLevel) - Required - The level to prerender. ### Return Value - **RenderedLevel** - The prerendered level. ### Exceptions - **Exception** - Thrown if the level has already been prerendered. ``` -------------------------------- ### ExampleRenderer.RenderEntity (3 of 4) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/RenderEntity.md Renders an entity with its associated tile, using a provided texture and sprite effects for flipping. ```APIDOC ## POST /ExampleRenderer/RenderEntity ### Description Renders the entity with the tile it includes. ### Method POST ### Endpoint /ExampleRenderer/RenderEntity ### Parameters #### Request Body - **entity** (T) - Required - The entity you want to render. - **texture** (Texture2D) - Required - The spritesheet/texture for rendering the entity. - **flipDirection** (SpriteEffects) - Required - The direction to flip the entity when rendering. ### Response #### Success Response (200) - **None** #### Response Example null ``` -------------------------------- ### Initialize LDtkIntGrid instance Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkIntGrid/LDtkIntGrid.md This constructor is reserved for internal JSON deserialization processes. Do not use this constructor in application code. ```csharp public LDtkIntGrid() ``` -------------------------------- ### Get and Set DefaultOverride.Id Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/DefaultOverride/Id.md Access or modify the string identifier for a DefaultOverride instance. ```csharp public string Id { get; set; } ``` -------------------------------- ### Use ldtkgen Command-Line Tool Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt Generates type-safe C# classes from LDtk project files. ```bash # Install the tool globally dotnet tool install --global LDtkMonogame.Codegen # Update to latest version dotnet tool update LDtkMonogame.Codegen --global # Basic usage - generates to LDtkTypes/ folder ldtkgen -i Content/World.ldtk # Specify output folder and namespace ldtkgen -i Content/World.ldtk -o Generated/ -n MyGame.LDtkTypes # Generate Vector2 instead of Point for Point fields ldtkgen -i Content/World.ldtk --PointAsVector2 # Custom level class name ldtkgen -i Content/World.ldtk --LevelClassName MyLevelData # All options ldtkgen -i Content/World.ldtk \ -o LDtkTypes/ \ -n LDtkTypes \ --LevelClassName LDtkLevelData \ --PointAsVector2 \ --EntityInterface true ``` -------------------------------- ### Initialize EntityReference Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/EntityReference/EntityReference.md The default constructor for the EntityReference class. ```csharp public EntityReference() ``` -------------------------------- ### Load LDtk File Source: https://github.com/irishbruse/ldtkmonogame/blob/main/README.md Load an LDtk file in the Initialize method. You can load from a file path or a content asset name. ```csharp LDtkFile file = LDtkFile.FromFile("World", Content); LDtkFile file = LDtkFile.FromFile("Data/World.ldtk"); ``` -------------------------------- ### Accessing AutoRuleDef.XOffset Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/AutoRuleDef/XOffset.md Defines the X cell start offset for an AutoRuleDef instance. ```csharp public int XOffset { get; set; } ``` -------------------------------- ### Loading Worlds Source: https://context7.com/irishbruse/ldtkmonogame/llms.txt Explains how to load a specific world from an LDtk file, supporting multi-world projects. ```APIDOC ## Loading Worlds The `LDtkFile.LoadWorld()` method loads a world from the LDtk file by its unique IID. LDtk files with the MultiWorlds flag enabled can contain multiple worlds. ### Method `LDtkWorld LoadWorld(string worldIid)` `LDtkWorld LoadSingleWorld()` ### Parameters #### Path Parameters - **worldIid** (string) - Required - The IID of the world to load. ### Request Example ```csharp // Load a specific world using generated IID constants LDtkFile file = LDtkFile.FromFile("World", Content); LDtkWorld world = file.LoadWorld(Worlds.World.Iid); // Load a single world (throws if multiple worlds exist) LDtkWorld singleWorld = file.LoadSingleWorld(); // Access world properties Point worldSize = world.WorldGridSize; string worldName = world.Identifier; WorldLayout? layout = world.WorldLayout; ``` ``` -------------------------------- ### LayerDefinition.GuideGridWid Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Full/LayerDefinition/GuideGridWid.md The GuideGridWid property represents the width of the optional guide grid in pixels. ```APIDOC ## LayerDefinition.GuideGridWid Property ### Description Width of the optional "guide" grid in pixels. ### Property `GuideGridWid` ### Type `int` ### Access `public int { get; set; }` ### See Also * class [LayerDefinition](../LayerDefinition.md) * namespace [LDtk.Full](../../LDtkMonogame.md) ``` -------------------------------- ### ExampleRenderer.RenderEntity (4 of 4) Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk.Renderer/ExampleRenderer/RenderEntity.md Renders an entity with its associated tile, using a provided texture, sprite effects for flipping, and an animation frame. ```APIDOC ## POST /ExampleRenderer/RenderEntity ### Description Renders the entity with the tile it includes. ### Method POST ### Endpoint /ExampleRenderer/RenderEntity ### Parameters #### Request Body - **entity** (T) - Required - The entity you want to render. - **texture** (Texture2D) - Required - The spritesheet/texture for rendering the entity. - **flipDirection** (SpriteEffects) - Required - The direction to flip the entity when rendering. - **animationFrame** (int) - Required - The current frame of animation. Is a very basic entity animation frames must be to the right of them and be the same size. ### Response #### Success Response (200) - **None** #### Response Example null ``` -------------------------------- ### LDtkJsonSourceGenerator.Guid Property Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkJsonSourceGenerator/Guid.md Retrieves the source-generated JSON serialization contract metadata for the Guid type. ```APIDOC ## Property: Guid ### Description Defines the source generated JSON serialization contract metadata for a given type. ### Definition `public JsonTypeInfo Guid { get; }` ### Namespace LDtk ``` -------------------------------- ### LDtkIntGrid Class Overview Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/LDtkIntGrid.md Provides an overview of the LDtkIntGrid class, including its purpose and key members. ```APIDOC ## LDtkIntGrid Class LDtk IntGrid. ```csharp public class LDtkIntGrid ``` ### Public Members | name | description | | --- | --- | | [LDtkIntGrid](LDtkIntGrid/LDtkIntGrid.md)() | Initializes a new instance of the [`LDtkIntGrid`](./LDtkIntGrid.md) class. Used by json deserializer not for use by user!. | | [GridSize](LDtkIntGrid/GridSize.md) { get; set; } | Gets or sets the size of the int grid in tiles. | | [TileSize](LDtkIntGrid/TileSize.md) { get; set; } | Gets or sets the size of a tile in pixels. | | [Values](LDtkIntGrid/Values.md) { get; set; } | Gets or sets the underlying values of the int grid. | | [WorldPosition](LDtkIntGrid/WorldPosition.md) { get; set; } | Gets or sets the worldspace start Position of the int grid. | | [Contains](LDtkIntGrid/Contains.md)(…) | Check if point is inside of a grid. (2 methods) | | [FromWorldToGridSpace](LDtkIntGrid/FromWorldToGridSpace.md)(…) | Convert from world pixel space to int grid space. Floors the value based on [`TileSize`](./LDtkIntGrid/TileSize.md) to an Integer. (2 methods) | | [GetValueAt](LDtkIntGrid/GetValueAt.md)(…) | Gets the int value at location and return 0 if out of bounds. (3 methods) | ### See Also * namespace [LDtk](../LDtkMonogame.md) ``` -------------------------------- ### Initialize TilesetRectangle Source: https://github.com/irishbruse/ldtkmonogame/blob/main/docs/Api/LDtk/TilesetRectangle/TilesetRectangle.md Default constructor for creating a new instance of the TilesetRectangle class. ```csharp public TilesetRectangle() ```