### Navigate and Start Docusaurus Development Server
Source: https://docs.dungeonarchitect.dev/demo/intro
Change to your new website's directory and start the local development server. The site will reload automatically on changes.
```bash
cd my-website
```
```bash
npm run start
```
--------------------------------
### Game Mode Blueprint Setup
Source: https://docs.dungeonarchitect.dev/unreal/grid-flow/gridflow-setup-gameplay
Create a blueprint deriving from GameMode (not GameModeBase) for custom gameplay logic. This example shows setting up a boolean flag to control game start.
```Blueprint
Create a blueprint that derives from `GameMode` (not `GameModeBase`)
```
```Blueprint
Create a bool variable to control when the game starts. Call this `CanStartGame` and set the default value to false
```
```Blueprint
Place this logic in BeginPlay. Here we randomize the seed and build the dungoen. Before that, we hook on to the `OnDungeonBuildComplete` event so we get notified when it is fully built. When that happens, we set the boolean flag to true, which would then start the game (logic for that later below)
```
--------------------------------
### Example: Emit Marker at Room Centers
Source: https://docs.dungeonarchitect.dev/unreal/advanced-dungeons/advdungeon-marker-emitters
This example demonstrates querying the dungeon model to emit a marker at the center of all rooms. The blueprint for this logic can be found at DungeonArchitect > Content > Showcase > Legacy > Samples > DA_TutorialGame > Blueprints > MyCustomEmitter.
```blueprint
This marker emitter queries the dungeon model and emits a marker at the center of all the rooms
```
--------------------------------
### Pattern Rule Graph Example
Source: https://docs.dungeonarchitect.dev/unreal/pattern-matcher/pattern-matcher-getting-started
Define the conditions for a pattern rule using a graph. This example checks for the presence of a ground marker.
```text
Selection Condition
On Pattern Selected
```
--------------------------------
### Custom Selector Rule Example
Source: https://docs.dungeonarchitect.dev/unity/advanced-theming/advtheme-selection-rule
Implement a custom selector rule to control object placement. This example selects alternate cells based on their grid position to prevent overcrowding.
```csharp
using UnityEngine;
using System.Collections;
using DungeonArchitect;
public class AlternateSelectionRule : SelectorRule {
public override bool CanSelect(PropSocket socket, Matrix4x4 propTransform, DungeonModel model, System.Random random) {
return (socket.gridPosition.x + socket.gridPosition.z) % 2 == 0;
}
}
```
--------------------------------
### Basic Dungeon Listener Setup
Source: https://docs.dungeonarchitect.dev/unity/advanced-dungeons/dungeon-listener
Create a custom listener by inheriting from DungeonEventListener and overriding the OnPostDungeonBuild method. This script should be attached to the dungeon game object.
```csharp
using UnityEngine;
using DungeonArchitect;
public class MyDungeonListener : DungeonEventListener
{
public override void OnPostDungeonBuild(Dungeon dungeon, DungeonModel model)
{
Debug.Log("Dungeon build complete");
// Write your logic here
}
}
```
--------------------------------
### Start Localized Development Server
Source: https://docs.dungeonarchitect.dev/demo/tutorial-extras/translate-your-site
Run the development server for a specific locale to preview your translated site. Note: Only one locale can be used at a time in development.
```bash
npm run start -- --locale fr
```
--------------------------------
### Markdown Link Example (URL Path)
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/markdown-features
Regular Markdown links using URL paths are supported.
```markdown
Let's see how to [Create a page](/create-a-page).
```
--------------------------------
### Markdown Link Example (Relative File Path)
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/markdown-features
Regular Markdown links using relative file paths are supported.
```markdown
Let's see how to [Create a page](./create-a-page.md).
```
--------------------------------
### Example: Curved Roof Creation
Source: https://docs.dungeonarchitect.dev/unreal/advanced-dungeons/advdungeon-marker-emitters
Marker emitters can be used to create complex architectural elements, such as a curved roof over a room. This example showcases the versatility of marker emitters in shaping the dungeon's appearance.
```blueprint
Heres another example of a curved roof created over a room using marker emitters
```
--------------------------------
### Markdown Image Example (Static Directory)
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/markdown-features
Markdown images can reference absolute paths to images in the static directory.
```markdown

```
--------------------------------
### Configure Async Build Settings
Source: https://docs.dungeonarchitect.dev/unreal/grid-flow/gridflow-setup-gameplay
Set the 'Async Build' property to a non-zero value to allow the dungeon to build over multiple frames, preventing the game from stalling. This example allows up to 64ms per frame for mesh spawning.
```Blueprint
If you want your dungeon to build over multiple frames and not stall for a bit while the meshes spawn in, set it to a non-zero value.
Here, I allow the system to use up a max of 64ms per frame to spawn in the meshes. It will spread out the mesh spawns over multiple frames.
```
--------------------------------
### Basic Runtime Dungeon Builder Script
Source: https://docs.dungeonarchitect.dev/unity/advanced-dungeons/runtime-dungeons
This script builds a dungeon when the game starts. It requires a public 'Dungeon' component to be assigned in the Unity Inspector.
```csharp
using DungeonArchitect;
using UnityEngine;
public class MyDungeonBuilder : MonoBehaviour
{
public Dungeon dungeon;
void Start()
{
if (dungeon != null)
{
dungeon.Build();
}
}
}
```
--------------------------------
### Custom Item Spawn Listener Implementation
Source: https://docs.dungeonarchitect.dev/unity/advanced-theming/advtheme-item-spawn-listener
An example of a custom item spawn listener script that inherits from `DungeonItemSpawnListener` and adds a component to the spawned GameObject.
```csharp
using DungeonArchitect;
using UnityEngine;
public class FlowItemMetadataHandler : DungeonItemSpawnListener
{
public override void SetMetadata(GameObject dungeonItem, DungeonNodeSpawnData spawnData)
{
if (dungeonItem != null)
{
dungeonItem.AddComponent<...>();
}
}
}
```
--------------------------------
### Docusaurus Admonition Examples
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/markdown-features
Docusaurus supports special syntax for creating admonitions like tips and warnings.
```markdown
:::tip[My tip]
Use this awesome feature option
:::
:::danger[Take care]
This action is dangerous
:::
```
--------------------------------
### Generate a New Docusaurus Site
Source: https://docs.dungeonarchitect.dev/demo/intro
Use this command to create a new Docusaurus website with the classic template. It installs all necessary dependencies.
```bash
npm init docusaurus@latest my-website classic
```
--------------------------------
### Markdown Image Example (Relative Path)
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/markdown-features
Markdown images can reference images relative to the current file, useful for co-locating images.
```markdown

```
--------------------------------
### Runtime Dungeon Builder with Randomization
Source: https://docs.dungeonarchitect.dev/unity/advanced-dungeons/runtime-dungeons
This script builds a dungeon at runtime with a randomized seed. Assign the 'Dungeon' component in the Inspector and the dungeon will be built with a new layout on Start.
```csharp
using DungeonArchitect;
using UnityEngine;
public class MyDungeonBuilder : MonoBehaviour
{
public Dungeon dungeon;
void Start()
{
if (dungeon != null)
{
dungeon.Config.Seed = (uint)(Random.value * int.MaxValue);
dungeon.Build();
}
}
}
```
--------------------------------
### Setup Player Controller for HUD
Source: https://docs.dungeonarchitect.dev/unreal/grid-flow/gridflow-setup-gameplay
Create a Player Controller blueprint and assign it in your Game Mode asset to enable the display of the inventory HUD. This allows for custom UI elements.
```Blueprint
Create a Player Controller so we can display the inventory HUD, that comes along with the sample.
Open up the Game Mode asset and assign the new player controller, so it picks it up
```
--------------------------------
### Override ReadToStartMatch Function
Source: https://docs.dungeonarchitect.dev/unreal/grid-flow/gridflow-setup-gameplay
Override the 'Read to Start Match' function in your Game Mode blueprint to control when the game begins. Return the 'CanStartGame' boolean variable.
```Blueprint
Override the function `Read to Start Match`
Return the `Can Start Game` bool variable value.
```
--------------------------------
### Custom Snap Module Constraint Script
Source: https://docs.dungeonarchitect.dev/unity/snap-grid-flow/sgf-scripting
Implement ISGFLayoutNodeCategoryConstraint to define custom module selection logic for path nodes. This example places a boss room last, a shop or health room before it, larger rooms on alternate nodes, and normal rooms otherwise. Ensure room names are registered in the module database.
```csharp
using DungeonArchitect;
using UnityEngine;
public class MySGFModConstraint : ScriptableObject, ISGFLayoutNodeCategoryConstraint
{
public string[] GetModuleCategoriesAtNode(int currentPathPosition, int pathLength)
{
// Place a boss room in the last node
if (currentPathPosition == pathLength - 1)
{
return new string[] { "Boss" };
}
// Use a shop or health room before the boss room
if (currentPathPosition == pathLength - 2)
{
return new string[] { "Shop", "HealthFountain" };
}
// Use a large room for every alternate node
if (currentPathPosition % 2 == 0)
{
return new string[] { "RoomLarge" };
}
// use a normal room
return new string[] { "Room" };
}
}
```
--------------------------------
### Example: Adjacent Cell Emitter for Cave System
Source: https://docs.dungeonarchitect.dev/unreal/advanced-dungeons/advdungeon-marker-emitters
The Hell Forge demo uses a marker emitter blueprint (BPM_AdjacentCellEmitter) to place rocks in empty spaces away from walls and fences. This allows for progressive scaling of rocks based on distance from the ground, creating a natural elevation effect for cave-like systems.
```blueprint
This is done with a marker emitter blueprint `DA_InfinityBlade_Fire/Dungeons/Rules/MarkerEmitter/BPM_AdjacentCellEmitter`
```
--------------------------------
### Override FindPlayerStart Function
Source: https://docs.dungeonarchitect.dev/unreal/grid-flow/gridflow-setup-gameplay
Override the 'FindPlayerStart' function in your Game Mode blueprint to specify which player start actor to use. This is crucial for ensuring the player spawns correctly, especially when custom Player Starts are placed.
```Blueprint
Override the `FindPlayerStart` function in your game mode blueprint
```
--------------------------------
### Serve Production Build Locally
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/deploy-your-site
Use this command to test your production build locally before deploying. It serves the contents of the 'build' folder at http://localhost:3000/.
```bash
npm run serve
```
--------------------------------
### Prepare French Documentation Directory
Source: https://docs.dungeonarchitect.dev/demo/tutorial-extras/translate-your-site
Create the necessary directory structure for French documentation and copy the original English document into the correct location.
```bash
mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/
cp docs/intro.md i18n/fr/docusaurus-plugin-content-docs/current/intro.md
```
--------------------------------
### Create a Docs Version
Source: https://docs.dungeonarchitect.dev/demo/tutorial-extras/manage-docs-versions
Use this command to create a new version of your documentation. This copies the current docs into a versioned folder and updates the versions.json file.
```bash
npm run docusaurus docs:version 1.0
```
--------------------------------
### Front Matter Example
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/markdown-features
Documents can include metadata at the top called Front Matter, enclosed in triple dashes.
```markdown
---
id: my-doc-id
title: My document title
description: My document description
slug: /my-custom-url
---
## Markdown heading
Markdown text with [links](./hello.md)
```
--------------------------------
### Build Your Site for Production
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/deploy-your-site
Run this command to generate static HTML, JavaScript, and CSS files for your Docusaurus site. The output is placed in the 'build' folder.
```bash
npm run build
```
--------------------------------
### Configure Marker Emitter for Theme Preview
Source: https://docs.dungeonarchitect.dev/unreal/advanced-dungeons/advdungeon-marker-emitters
To preview your Marker Emitter logic in the Theme Editor's 3D Preview, navigate to the theme editor's properties, find the Dungeon section, and add your Marker Emitter blueprint there.
```blueprint
Navigate to the theme editor's 3D Viewport > Properties > Dungeon
This will open up the dungeon properties. Add your marker emitter there and the preview viewport will pick up the markers emitted by your Marker Emitter blueprint script and show it in the preview viewport
```
--------------------------------
### MDX with React Component for Interactivity
Source: https://docs.dungeonarchitect.dev/demo/tutorial-basics/markdown-features
MDX allows embedding React components within Markdown for interactive content. This example defines and uses a Highlight component.
```jsx
export const Highlight = ({children, color}) => (
{
alert(`You clicked the color ${color} with label ${children}`)
}}>
{children}
);
This is Docusaurus green !
This is Facebook blue !
```
--------------------------------
### Configure Spawn Items Node Paths
Source: https://docs.dungeonarchitect.dev/unreal/snap-grid-flow/sgf-placeable-markers
Assign the IDs of the main and alternate paths to the Paths array in the Spawn Items node properties.
```blueprint
Paths:
- main
- alt
```
--------------------------------
### Create Placeable Marker Asset
Source: https://docs.dungeonarchitect.dev/unreal/snap-grid-flow/sgf-placeable-markers
Create a new Placeable Marker asset in the content browser. This asset will define the types of markers that can be spawned.
```content_browser
Right click on the Content Browser and choose `Dungeon Architect > Placeable Marker`
Rename the asset to `PM_Enemies`
```
--------------------------------
### Query Path Name with SelectorRule
Source: https://docs.dungeonarchitect.dev/unity/grid-flow/gridflow-query-interface
This script shows how to create a SelectorRule to decorate dungeon elements based on their path name. It checks if the current marker location belongs to paths named 'main', 'main_start', or 'main'.
```csharp
using UnityEngine;
using DungeonArchitect;
using DungeonArchitect.Builders.GridFlow;
using DungeonArchitect.Flow.Impl.GridFlow;
using DungeonArchitect.Utils;
public class GridFlowPathSelector_MainPath : SelectorRule
{
public override bool CanSelect(PropSocket socket, Matrix4x4 propTransform, DungeonModel model, System.Random random)
{
var gridFlowModel = model as GridFlowDungeonModel;
if (gridFlowModel == null) return false;
var query = gridFlowModel.Query;
if (query == null) return false;
var markerLocation = Matrix.GetTranslation(ref propTransform);
var pathName = query.GetPathName(markerLocation);
// Select nodes with the specified path (this was defined in the grid flow editor's `Create Path` node)
return pathName == "main"
|| pathName == "main_start"
|| pathName == "main";
}
}
```