Class DungeonRooms
Reads a dungeon's saved rooms through ValheimCLI's valheim.observe/dungeon-rooms on the
server, and checks that every room lies inside its location's zone. In Valheim 1.0.16 the game gives a dungeon interior
its environment with a 64 m wide box centred on the location's zone (5000 m above the location), so the part of a room
outside that zone loses the interior environment; the generator itself keeps rooms inside the zone of its own position.
public static class DungeonRooms
- Inheritance
-
objectDungeonRooms
Fields
Source
public const string Source = "dungeon-rooms"
Field Value
- string
ZoneSize
Valheim's zone width in metres; zone (i, j) covers x in [64i - 32, 64i + 32] and z likewise.
public const float ZoneSize = 64
Field Value
- float
Methods
OutsideZone(SavedDungeon, IReadOnlyDictionary<string, RoomSize>?, float)
Every reason dungeon's rooms are not all inside its location's zone: no location, no saved rooms,
a generator in another zone, or a room reaching past the zone's edge by more than tolerance
metres. A room whose size is in sizes (by room prefab name) is checked by its footprint turned by
its yaw (rotation about y; pitch and roll are not applied); any other room by its centre only, which cannot see a
room that is too large. Empty when every room is inside.
public static IReadOnlyList<DungeonRoomProblem> OutsideZone(SavedDungeon dungeon, IReadOnlyDictionary<string, RoomSize>? sizes = null, float tolerance = 0.01)
Parameters
dungeonSavedDungeonsizesIReadOnlyDictionary<string, RoomSize>tolerancefloat
Returns
- IReadOnlyList<DungeonRoomProblem>
Parse(JsonElement)
Parses the adapter's data, decoding each generator's rooms; anything malformed or inconsistent throws.
public static IReadOnlyList<SavedDungeon> Parse(JsonElement data)
Parameters
dataJsonElement
Returns
- IReadOnlyList<SavedDungeon>
ParseRoomData(byte[])
Decodes Valheim 1.0's roomData byte array: a little-endian int32 room count, then per room an int32 hash, the
position as three float32 and the rotation as three float32 Euler angles. A negative count, a short array or bytes
left over throw.
public static IReadOnlyList<DungeonRoom> ParseRoomData(byte[] data)
Parameters
databyte[]
Returns
- IReadOnlyList<DungeonRoom>
Read(GameActor, string, float, float, float)
The dungeon generators saved within radius metres (horizontally, at most 256) of
(x, z), through capabilityPath (for example
mymod.testing/dungeon-rooms), each with the location nearest (x, z). Give the location's ground position. A
dungeon has no saved generator until its zone has been generated, so an unvisited dungeon reads as an empty list.
public static IReadOnlyList<SavedDungeon> Read(GameActor actor, string capabilityPath, float x, float z, float radius = 64)
Parameters
actorGameActorcapabilityPathstringxfloatzfloatradiusfloat
Returns
- IReadOnlyList<SavedDungeon>
RequireWithinZone(SavedDungeon, IReadOnlyDictionary<string, RoomSize>?, float)
Throws unless OutsideZone(SavedDungeon, IReadOnlyDictionary<string, RoomSize>?, float) finds nothing, naming every problem.
public static void RequireWithinZone(SavedDungeon dungeon, IReadOnlyDictionary<string, RoomSize>? sizes = null, float tolerance = 0.01)
Parameters
dungeonSavedDungeonsizesIReadOnlyDictionary<string, RoomSize>tolerancefloat