Mythic Realm API reference

What a game calls, by component. Everything is in the MythicRealm namespace (assembly MythicRealm.Runtime). The Manual explains the features behind it; Building a game on it shows how the pieces fit.

WorldManager #

The streamed world. One per scene; WorldManager.Instance is the active one.

Setup (Inspector fields)

Member Meaning
profile A WorldProfile whose settings replace the inline settings at start.
settings The world's WorldSettings (seed, terrain, climate, props, streaming, drawing). Change them through ApplySettings.
viewer, viewCamera What the world streams around and draws for. Default: the view camera, then Camera.main.
driveFogAndClipPlane Keep the camera's far plane and the linear fog matched to what is drawn.
snapViewerToLandOnStart, snapHeightAboveGround Move the viewer to the nearest dry land on start.
followQualityLevel Take the drawing distances from the quality level's WorldQuality tier.
chunkLayer Physics layer of the terrain colliders.
buildOnWorkerThreads, buildBudgetMs Build chunks on worker threads, and the main-thread milliseconds per frame for starting jobs and uploading results.

Readiness and streaming events

Member Meaning
event Action WorldReady Raised once the area around the viewer has streamed in with its colliders, and again after settings that change the land.
bool IsWorldReady True after WorldReady until the land changes.
void WhenReady(Action action) Runs action when the world is ready (at once if it is).
event Action<WorldChunk> ChunkLoaded A chunk's terrain and props are in.
event Action<WorldChunk> ChunkCollidersReady A chunk's colliders are attached.
event Action<WorldChunk> ChunkUnloading A chunk is about to go. Every ChunkLoaded is followed by exactly one of these.
event Action SettingsApplied Settings were applied (ApplySettings, ApplyProfile).
bool Ready Nothing is left to build or cook around the viewer.
bool ChunkLoadedAt(float x, float z) The chunk under a point is loaded.

Queries (they work from the first frame, even in another script's Awake)

Member Meaning
float HeightAt(float x, float z) Ground height in metres (rivers carved in).
float GroundAt(float x, float z) Ground height, or sea level where that is higher.
bool TryGround(float x, float z, out float height, out bool water) Height and whether the point is under water.
Biome BiomeAt(float x, float z) The biome at a point.
bool FindSpawnPoint(Vector3 near, out Vector3 point, float radius = 200, float maxSlope = 0.35) Dry, gentle ground clear of trees and rocks, searched outward from near.
int FindSites(Bounds area, List<Vector3> results, int maxCount, float spacing = ...) Good places in an area on a jittered grid; the same every time for the same area.
bool FindNearestProp(Vector3 from, bool treesOnly, out PropKind kind, out Vector3 position, bool rocksOnly = false) The nearest tree or rock in the loaded chunks.
bool RaycastTree(Ray ray, float maxDist, out PropKind kind, out Vector3 position, out float scale), bool RaycastRock(...) The first tree or rock a ray hits.
float VisibleRange Metres to which land is drawn.

Changing the world

Member Meaning
void ApplySettings(WorldSettings settings) Apply new settings; the land is rebuilt only if they change it.
void ApplyProfile(WorldProfile profile) Switch to a profile's settings.
bool SaveToProfile() Write the current settings into the assigned profile (editor).
bool RemoveProp(PropKind kind, Vector3 position) Take a tree (it leaves a stump) or a rock away for good.
void GetEdits(out long[] mined, out long[] felled), void SetEdits(long[] mined, long[] felled) The trees felled and rocks mined; SetEdits with empty arrays starts a new game.
void SetQualityLevel(int level) Switch Unity's quality level and, with followQualityLevel, the world's drawing tier.
void SnapViewerToLand(float heightAboveGround) Move the viewer to the nearest dry land.
static void ReleaseSharedCaches() Free the meshes, materials and textures every world shares; call a frame after destroying the last world.

WorldEnvironment #

Sun and moon, sky, ambient light, fog, weather, sound and waterfall spray for the scene's world.

Member Meaning
world The world to light (default: the one on this GameObject, then WorldManager.Instance).
sun The directional light driven as the sun and moon (default: the scene's sun, else its first directional light, else one is made).
sound, waterfalls, demoLook Add the sound, the spray, and (in a Linear project) a post-processing look.
Atmosphere, Ambience, Waterfalls The parts it added.
static Instance The active environment.

WorldAtmosphere #

Day and night and weather (added by WorldEnvironment).

Member Meaning
timeOfDay, dayLengthMinutes Hour of the day (0 to 24) and the length of a day (0 freezes time).
void SetWeather(WeatherKind kind, bool instant = false), weather, autoWeather, weatherChangeMinutes Clear, Cloudy, Rain or Storm; autoWeather changes it by itself.
precipitation Rain, snow, or decided by the temperature at the camera.
clouds, cloudHeight, windYaw, starsAndMoon, valleyMist The cloud layer, its height and drift, the night sky and the valley mist.
Cover, Precipitation, Daylight, Wetness, SnowCover, IsSnow The current state (read only).
void SetGround(float wet, float snow), groundEffects Set the ground's wetness and snow yourself.
Action<float> Lightning A lightning flash, with its distance in metres.

WorldAmbience #

The synthesised sound of the world: volume, mute.

WorldFauna #

Wildlife. Add it to a GameObject in the scene (the demo rig does).

Member Meaning
IReadOnlyList<Animal> Animals The animals around the viewer.
List<ResourceStack> Harvest(Animal animal) Harvest an animal: it falls and its loot goes into Bag.
event Action<Animal, List<ResourceStack>> Harvested An animal was harvested.
ResourceBag Bag What has been harvested.
Animal Target The animal in front of the viewer, within harvestRange.
void SetSpeciesEnabled(Species s, bool on), bool IsSpeciesEnabled(Species s) Switch a species on or off.
hud, interactKey The demo's prompt and E key (off unless you turn them on).
animalModels Draw the wolf from its shipped model (off: built in code).
respawnMinutes Minutes before a harvested animal's place holds an animal again.

WorldMining #

Mining rocks and felling trees.

Member Meaning
List<ResourceStack> Hit(PropKind kind, Vector3 position), HitTree(kind, position, scale) One strike; returns the loot when it breaks or falls (else empty).
List<ResourceStack> Break(...), Fell(...) Break a rock or fell a tree outright.
event Mined, Felled, Struck A rock broke, a tree fell, a strike landed.
toolTier, axeTier, mineRange The best ore the pick and the hardest wood the axe can take, and the reach.
ResourceBag Bag, fauna Where loot goes (the demo shares the wildlife bag), and the wildlife to avoid striking.
HasTarget, TargetKind, TargetPosition, TargetIsTree What is in front of the viewer.

WorldSave #

A save game: the player's changes, as small JSON.

Member Meaning
static WorldSave Capture(WorldManager world, ResourceBag bag = null, WorldAtmosphere atmosphere = null, Transform player = null) Record the edits and, where given, the bag, the sky and the player.
void Restore(WorldManager world, ResourceBag bag = null, WorldAtmosphere atmosphere = null, Transform player = null) Put it back; the loaded chunks are rebuilt to show it.
string ToJson(bool pretty = false), static WorldSave FromJson(string json) To and from JSON.

Settings and data #

Type Meaning
WorldSettings Every setting of a world. GenKey() identifies the ones that shape the land; generatorVersion pins the generation rules.
WorldProfile A ScriptableObject holding a WorldSettings (Assets > Create > Mythic Realm > World Profile).
WorldPresets The world styles: Names, Descriptions, Apply(name, settings).
WorldQuality, WorldQualityTier Drawing tiers per quality level: Current, ForLevel(level), ApplyTo(settings).
WorldChunk A chunk in the streaming events: Coord, Bounds.
ResourceBag, ResourceStack, ResourceType, ResourceInfo Loot: counts per resource, and what each is good for.
Biome, PropKind, WeatherKind, Species Enumerations and the species table.

Input #

WorldInput.Provider (an IWorldInputProvider: Move, LookDelta, IsHeld, WasPressed) feeds the demo controller and panel. The old Input Manager and the Input System both work without setup; assign your own provider to drive them from your input.