Class DungeonTemplate
Everything about a dungeon that is the same for every instance of it: how it is described to a player standing at the entrance, and the difficulties it can be run at.
[CreateAssetMenu(fileName = "New Dungeon", menuName = "FishMMO/World/Dungeon", order = 1)]
public class DungeonTemplate : CachedScriptableObject<DungeonTemplate>, ICachedObject
- Inheritance
-
ObjectScriptableObjectDungeonTemplate
- Implements
- Inherited Members
-
ScriptableObject.SetDirty()ScriptableObject.CreateInstance<T>()Object.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Remarks
Separate from WorldSceneDetails, which is regenerated by scanning the scene assets
and would overwrite anything authored by hand, and separate from the
DungeonEntrance itself, so several entrances into the same dungeon describe
it identically. Assigned on the entrance; resolved on the client by template ID out of the
shared cache, so the description, the artwork and the difficulty list all travel as one
int.
The difficulty list is per dungeon. There is no global set of difficulty levels and no enum to keep in step: a dungeon declares as many as it wants, in its own order, with its own rules. An instance records the index it was opened at, which is meaningful only alongside the dungeon that defined the list — so reordering this list renames the difficulty of every instance already open at that index, and entries should be appended rather than inserted once a dungeon is live.
Fields
Description
Description shown in the dungeon finder above the instance list.
[Tooltip("Description shown in the dungeon finder, above the instance list.")]
[TextArea(3, 6)]
public string Description
Field Value
Difficulties
Difficulties this dungeon offers, in the order they are presented.
[Tooltip("Difficulties this dungeon offers. Empty means a single default difficulty.")]
public List<DungeonDifficultyDefinition> Difficulties
Field Value
Remarks
An empty list means the dungeon has exactly one, unnamed difficulty at index 0 with default rules — see GetDifficulty(int). That is what an entrance with no template configured behaves as, so a dungeon authored before this system existed keeps working unchanged.
DisplayName
Display name of the dungeon. Falls back to the asset name when empty.
[Tooltip("Display name shown in the dungeon finder header. Defaults to the asset name.")]
public string DisplayName
Field Value
DungeonSceneName
Name of the dungeon scene this template describes. Must match the entrance's
DungeonName.
[Tooltip("Scene name of the dungeon. Must match the entrance's Dungeon Name.")]
public string DungeonSceneName
Field Value
Remarks
The entrance points at the template; this points back. The reverse direction is what the scene server hosting a running instance has to follow: it knows the scene it loaded and the difficulty index recorded on the row, and there is no entrance object anywhere in the process to ask. Without it, an instance could be run but not described — no difficulty name for its panel and, more seriously, no ruleset to apply to what spawns inside it.
Leaving it empty is a working configuration for a dungeon reached only through an entrance; it costs the difficulty name in the instance panel and the difficulty's effects on the run.
IconReference
Addressable reference to the dungeon's artwork.
[Tooltip("Artwork shown beside the description in the dungeon finder.")]
public AssetReferenceSprite IconReference
Field Value
- AssetReferenceSprite
Properties
DifficultyCount
How many difficulties this dungeon offers. Never less than one.
public int DifficultyCount { get; }
Property Value
Icon
The dungeon's artwork, loaded at runtime on the client.
public Sprite Icon { get; }
Property Value
- Sprite
Name
public string Name { get; }
Property Value
ResolvedDisplayName
The name to show for this dungeon.
public string ResolvedDisplayName { get; }
Property Value
Methods
GetBySceneName(string)
Finds the template describing one dungeon scene.
public static DungeonTemplate GetBySceneName(string sceneName)
Parameters
sceneNamestringDungeon scene name.
Returns
- DungeonTemplate
The template describing it, or null when none declares it.
Remarks
The reverse of the entrance-to-template link, for code holding a scene name and nothing else — principally the scene server hosting a running instance, which needs the difficulty rules for what it loaded and has no entrance object to read them from.
Backed by a lazily-built index over the template cache rather than a scan per call, because the callers are per-spawn and per-panel-refresh. The index is discarded whenever the cache's size changes, which is the cheap way to notice templates being loaded or unloaded without hooking either event — the count is the only thing that can change without a template being added or removed.
GetDifficulty(int)
The rules for one difficulty index.
public DungeonDifficultyDefinition GetDifficulty(int index)
Parameters
indexintDifficulty index, normally from a scene row.
Returns
- DungeonDifficultyDefinition
The difficulty at that index, or a default ruleset.
Remarks
Never returns null and never throws. An index outside the list — a client asking for a difficulty this dungeon does not offer, or an instance opened before an entry was removed — resolves to a default ruleset rather than dropping the request, because the alternative is an instance nobody can enter and a panel that cannot describe itself. Callers that need to know whether the index was real use IsValidDifficulty(int).
GetDifficultyName(int)
The name of one difficulty, for display.
public string GetDifficultyName(int index)
Parameters
indexint
Returns
IsValidDifficulty(int)
Whether an index names a difficulty this dungeon actually offers.
public bool IsValidDifficulty(int index)
Parameters
indexint
Returns
Remarks
The gate for anything a client asks for. A request naming a difficulty outside the list is refused rather than clamped: clamping would quietly enter a player into a ruleset they did not choose, and on a dungeon whose top difficulty ends the run on one death that is not a rounding error.
OnLoad(string, string, int)
Loads the dungeon artwork on the client when the template enters the cache.
public override void OnLoad(string typeName, string resourceName, int resourceID)
Parameters
OnUnload(string, string, int)
Releases the dungeon artwork when the template leaves the cache.
public override void OnUnload(string typeName, string resourceName, int resourceID)