Barotrauma Client Doc
Barotrauma.Level Class Reference
Inheritance diagram for Barotrauma.Level:
Barotrauma.Entity Barotrauma.Networking.IServerSerializable Barotrauma.ISpatialEntity Barotrauma.Networking.INetSerializable

Classes

class  AbyssIsland
 
class  Cave
 
struct  ClusterLocation
 
struct  InterestingPosition
 
struct  PathPoint
 
class  Tunnel
 

Public Types

enum class  PlacementType { Top , Bottom }
 
enum class  EventType { SingleDestructibleWall , GlobalDestructibleWall }
 
enum class  PositionType {
  None = 0 , MainPath = 0x1 , SidePath = 0x2 , Cave = 0x4 ,
  Ruin = 0x8 , Wreck = 0x10 , BeaconStation = 0x20 , Abyss = 0x40 ,
  AbyssCave = 0x80 , Outpost = 0x100
}
 
enum class  TunnelType { MainPath , SidePath , Cave }
 
enum class  LevelGenStage {
  LevelGenParams , Size , GenStart , TunnelGen1 ,
  TunnelGen2 , AbyssGen , CaveGen , VoronoiGen ,
  VoronoiGen2 , VoronoiGen3 , Ruins , Outposts ,
  FloatingIce , LevelBodies , IceSpires , TopAndBottom ,
  PlaceLevelObjects , GenerateItems , Finish
}
 Random integers generated during the level generation. If these values differ between clients/server, it means the levels aren't identical for some reason and there will most likely be major ID mismatches. More...
 

Public Member Functions

bool ShouldSpawnCrewInsideOutpost ()
 
List< VoronoiCellGetTooCloseCells (Vector2 position, float minDistance)
 
List< ItemGenerateMissionResources (ItemPrefab prefab, int requiredAmount, PositionType positionType, IEnumerable< Cave > targetCaves=null)
 
Parameters
rotationUsed by clients to set the rotation for the resources
More...
 
Vector2 GetRandomItemPos (PositionType spawnPosType, float randomSpread, float minDistFromSubs, float offsetFromWall=10.0f, Func< InterestingPosition, bool > filter=null)
 
bool TryGetInterestingPositionAwayFromPoint (bool useSyncedRand, PositionType positionType, float minDistFromSubs, out InterestingPosition position, Vector2 awayPoint, float minDistFromPoint, Func< InterestingPosition, bool > filter=null)
 
bool TryGetInterestingPosition (bool useSyncedRand, PositionType positionType, float minDistFromSubs, out InterestingPosition position, Func< InterestingPosition, bool > filter=null, bool suppressWarning=false)
 
bool TryGetInterestingPosition (bool useSyncedRand, PositionType positionType, float minDistFromSubs, out InterestingPosition position, Vector2 awayPoint, float minDistFromPoint=0f, Func< InterestingPosition, bool > filter=null, bool suppressWarning=false)
 
bool IsPositionInsideWall (Vector2 worldPosition)
 
void Update (float deltaTime, Camera cam)
 
Vector2 GetBottomPosition (float xPosition)
 
List< VoronoiCellGetAllCells ()
 
List< VoronoiCellGetCells (Vector2 worldPos, int searchDepth=2)
 
VoronoiCell GetClosestCell (Vector2 worldPos)
 
bool IsCloseToStart (Vector2 position, float minDist)
 
bool IsCloseToEnd (Vector2 position, float minDist)
 
bool IsCloseToStart (Point position, float minDist)
 
bool IsCloseToEnd (Point position, float minDist)
 
void PrepareBeaconStation ()
 
bool CheckBeaconActive ()
 
void SpawnCorpses ()
 
void SpawnNPCs ()
 
float GetRealWorldDepth (float worldPositionY)
 Calculate the "real" depth in meters from the surface of Europa More...
 
void DebugSetStartLocation (Location newStartLocation)
 
void DebugSetEndLocation (Location newEndLocation)
 
override void Remove ()
 
void ReloadTextures ()
 
void DrawDebugOverlay (SpriteBatch spriteBatch, Camera cam)
 
void DrawBack (GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
 
void DrawFront (SpriteBatch spriteBatch, Camera cam)
 
void ClientEventRead (IReadMessage msg, float sendingTime)
 
- Public Member Functions inherited from Barotrauma.Entity
 Entity (Submarine submarine, ushort id)
 
void FreeID ()
 Removes the entity from the entity dictionary and frees up the ID it was using. More...
 

Static Public Member Functions

static Level Generate (LevelData levelData, bool mirror, Location startLocation, Location endLocation, SubmarineInfo startOutpost=null, SubmarineInfo endOutpost=null)
 
- Static Public Member Functions inherited from Barotrauma.Entity
static IReadOnlyCollection< EntityGetEntities ()
 
static int FindFreeIdBlock (int minBlockSize)
 Finds a contiguous block of free IDs of at least the given size More...
 
static Entity FindEntityByID (ushort ID)
 Find an entity based on the ID More...
 
static void RemoveAll ()
 
static void DumpIds (int count, string filename)
 

Public Attributes

List< AbyssIslandAbyssIslands = new List<AbyssIsland>()
 
List< double > siteCoordsX
 
List<(Point point, double distance)> distanceField
 
readonly LevelData LevelData
 
- Public Attributes inherited from Barotrauma.Entity
readonly ushort ID
 Unique, but non-persistent identifier. Stays the same if the entities are created in the exactly same order, but doesn't persist e.g. between the rounds. More...
 
readonly string CreationStackTrace
 
readonly UInt64 CreationIndex
 

Static Public Attributes

const int MaxEntityDepth = -1000000
 
const float ShaftHeight = 1000.0f
 
const float OutsideBoundsCurrentMargin = 30000.0f
 How far outside the boundaries of the level the water current that pushes subs towards the level starts More...
 
const float OutsideBoundsCurrentMarginExponential = 150000.0f
 How far outside the boundaries of the level the strength of the current starts to increase exponentially More...
 
const float OutsideBoundsCurrentHardLimit = 200000.0f
 How far outside the boundaries of the level the current stops submarines entirely More...
 
const int MaxSubmarineWidth = 16000
 The level generator won't try to adjust the width of the main path above this limit. More...
 
const float ExitDistance = 6000.0f
 
const int GridCellSize = 2000
 
const float DefaultRealWorldCrushDepth = 3500.0f
 
static ? float ForcedDifficulty
 
- Static Public Attributes inherited from Barotrauma.Entity
const ushort NullEntityID = 0
 
const ushort EntitySpawnerID = ushort.MaxValue
 
const ushort RespawnManagerID = ushort.MaxValue - 1
 
const ushort DummyID = ushort.MaxValue - 2
 
const ushort ReservedIDStart = ushort.MaxValue - 3
 
const ushort MaxEntityCount = ushort.MaxValue - 4
 
static EntitySpawner Spawner
 

Properties

static LevelLoaded [get]
 
Rectangle AbyssArea [get]
 
int AbyssStart [get]
 
int AbyssEnd [get]
 
Vector2 StartPosition [get]
 
Vector2 StartExitPosition [get]
 
Point Size [get]
 
Vector2 EndPosition [get]
 
Vector2 EndExitPosition [get]
 
int BottomPos [get]
 
int SeaFloorTopPos [get]
 
float CrushDepth [get]
 The crush depth of a non-upgraded submarine in in-game coordinates. Note that this can be above the top of the level! More...
 
float RealWorldCrushDepth [get]
 The crush depth of a non-upgraded submarine in "real world units" (meters from the surface of Europa). Note that this can be above the top of the level! More...
 
LevelWall SeaFloor [get]
 
List< RuinRuins [get]
 
List< SubmarineWrecks [get]
 
Submarine BeaconStation [get]
 
List< LevelWallExtraWalls [get]
 
List< LevelWallUnsyncedExtraWalls [get]
 
List< TunnelTunnels = new List<Tunnel>() [get]
 
List< CaveCaves = new List<Cave>() [get]
 
List< InterestingPositionPositionsOfInterest [get]
 
Submarine StartOutpost [get]
 
Submarine EndOutpost [get]
 
IReadOnlyDictionary< LevelGenStage, int > EqualityCheckValues [get]
 
List< EntityEntitiesBeforeGenerate = new List<Entity>() [get]
 
int EntityCountBeforeGenerate [get]
 
int EntityCountAfterGenerate [get]
 
Body TopBarrier [get]
 
Body BottomBarrier [get]
 
LevelObjectManager LevelObjectManager [get]
 
bool Generating [get]
 
Location StartLocation [get]
 
Location EndLocation [get]
 
bool Mirrored [get]
 
string Seed [get]
 
float?? Difficulty [get]
 
LevelData.LevelType Type [get]
 
bool IsEndBiome [get]
 
static bool IsLoadedOutpost [get]
 Is there a loaded level set and is it an outpost? More...
 
static bool IsLoadedFriendlyOutpost [get]
 Is there a loaded level set, and is it a friendly outpost (FriendlyNPC or Team1). Does not take reputation into account. More...
 
LevelGenerationParams GenerationParams [get]
 
Color BackgroundTextureColor [get]
 
Color BackgroundColor [get]
 
Color WallColor [get]
 
List< PathPointPathPoints = new List<PathPoint>() [get]
 
List< ClusterLocationAbyssResources = new List<ClusterLocation>() [get]
 
BackgroundCreatureManager BackgroundCreatureManager [get]
 
LevelRenderer Renderer [get]
 
- Properties inherited from Barotrauma.Entity
static int EntityCount [get]
 
bool Removed [get]
 
bool IdFreed [get]
 
virtual Vector2 SimPosition [get]
 
virtual Vector2 Position [get]
 
virtual Vector2 WorldPosition [get]
 
virtual Vector2 DrawPosition [get]
 
Submarine Submarine [get, set]
 
AITarget AiTarget [get]
 
bool InDetectable [get, set]
 
double SpawnTime [get]
 
string ErrorLine [get]
 
- Properties inherited from Barotrauma.ISpatialEntity
Vector2 Position [get]
 
Vector2 WorldPosition [get]
 
Vector2 SimPosition [get]
 
Submarine Submarine [get]
 

Additional Inherited Members

- Protected Member Functions inherited from Barotrauma.Entity
virtual ushort DetermineID (ushort id, Submarine submarine)
 
- Protected Attributes inherited from Barotrauma.Entity
AITarget aiTarget
 

Detailed Description

Member Enumeration Documentation

◆ EventType

Enumerator
SingleDestructibleWall 
GlobalDestructibleWall 

Definition at line 24 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ LevelGenStage

Random integers generated during the level generation. If these values differ between clients/server, it means the levels aren't identical for some reason and there will most likely be major ID mismatches.

Enumerator
LevelGenParams 
Size 
GenStart 
TunnelGen1 
TunnelGen2 
AbyssGen 
CaveGen 
VoronoiGen 
VoronoiGen2 
VoronoiGen3 
Ruins 
Outposts 
FloatingIce 
LevelBodies 
IceSpires 
TopAndBottom 
PlaceLevelObjects 
GenerateItems 
Finish 

Definition at line 346 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ PlacementType

Enumerator
Top 
Bottom 

Definition at line 19 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ PositionType

Enumerator
None 
MainPath 
SidePath 
Cave 
Ruin 
Wreck 
BeaconStation 
Abyss 
AbyssCave 
Outpost 

Definition at line 67 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ TunnelType

Enumerator
MainPath 
SidePath 
Cave 

Definition at line 134 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

Member Function Documentation

◆ CheckBeaconActive()

bool Barotrauma.Level.CheckBeaconActive ( )

◆ ClientEventRead()

void Barotrauma.Level.ClientEventRead ( IReadMessage  msg,
float  sendingTime 
)

◆ DebugSetEndLocation()

void Barotrauma.Level.DebugSetEndLocation ( Location  newEndLocation)

◆ DebugSetStartLocation()

void Barotrauma.Level.DebugSetStartLocation ( Location  newStartLocation)

◆ DrawBack()

void Barotrauma.Level.DrawBack ( GraphicsDevice  graphics,
SpriteBatch  spriteBatch,
Camera  cam 
)

◆ DrawDebugOverlay()

void Barotrauma.Level.DrawDebugOverlay ( SpriteBatch  spriteBatch,
Camera  cam 
)

◆ DrawFront()

void Barotrauma.Level.DrawFront ( SpriteBatch  spriteBatch,
Camera  cam 
)

◆ Generate()

static Level Barotrauma.Level.Generate ( LevelData  levelData,
bool  mirror,
Location  startLocation,
Location  endLocation,
SubmarineInfo  startOutpost = null,
SubmarineInfo  endOutpost = null 
)
static

◆ GenerateMissionResources()

List<Item> Barotrauma.Level.GenerateMissionResources ( ItemPrefab  prefab,
int  requiredAmount,
PositionType  positionType,
IEnumerable< Cave targetCaves = null 
)

Parameters
rotationUsed by clients to set the rotation for the resources

Definition at line 3049 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ GetAllCells()

List<VoronoiCell> Barotrauma.Level.GetAllCells ( )

◆ GetBottomPosition()

Vector2 Barotrauma.Level.GetBottomPosition ( float  xPosition)

◆ GetCells()

List<VoronoiCell> Barotrauma.Level.GetCells ( Vector2  worldPos,
int  searchDepth = 2 
)

◆ GetClosestCell()

VoronoiCell Barotrauma.Level.GetClosestCell ( Vector2  worldPos)

◆ GetRandomItemPos()

Vector2 Barotrauma.Level.GetRandomItemPos ( PositionType  spawnPosType,
float  randomSpread,
float  minDistFromSubs,
float  offsetFromWall = 10.0f,
Func< InterestingPosition, bool >  filter = null 
)

◆ GetRealWorldDepth()

float Barotrauma.Level.GetRealWorldDepth ( float  worldPositionY)

Calculate the "real" depth in meters from the surface of Europa

Definition at line 4634 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ GetTooCloseCells()

List<VoronoiCell> Barotrauma.Level.GetTooCloseCells ( Vector2  position,
float  minDistance 
)

◆ IsCloseToEnd() [1/2]

bool Barotrauma.Level.IsCloseToEnd ( Point  position,
float  minDist 
)

◆ IsCloseToEnd() [2/2]

bool Barotrauma.Level.IsCloseToEnd ( Vector2  position,
float  minDist 
)

◆ IsCloseToStart() [1/2]

bool Barotrauma.Level.IsCloseToStart ( Point  position,
float  minDist 
)

◆ IsCloseToStart() [2/2]

bool Barotrauma.Level.IsCloseToStart ( Vector2  position,
float  minDist 
)

◆ IsPositionInsideWall()

bool Barotrauma.Level.IsPositionInsideWall ( Vector2  worldPosition)

◆ PrepareBeaconStation()

void Barotrauma.Level.PrepareBeaconStation ( )

◆ ReloadTextures()

void Barotrauma.Level.ReloadTextures ( )

◆ Remove()

override void Barotrauma.Level.Remove ( )
virtual

Reimplemented from Barotrauma.Entity.

Definition at line 4657 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ ShouldSpawnCrewInsideOutpost()

bool Barotrauma.Level.ShouldSpawnCrewInsideOutpost ( )

◆ SpawnCorpses()

void Barotrauma.Level.SpawnCorpses ( )

◆ SpawnNPCs()

void Barotrauma.Level.SpawnNPCs ( )

◆ TryGetInterestingPosition() [1/2]

bool Barotrauma.Level.TryGetInterestingPosition ( bool  useSyncedRand,
PositionType  positionType,
float  minDistFromSubs,
out InterestingPosition  position,
Func< InterestingPosition, bool >  filter = null,
bool  suppressWarning = false 
)

◆ TryGetInterestingPosition() [2/2]

bool Barotrauma.Level.TryGetInterestingPosition ( bool  useSyncedRand,
PositionType  positionType,
float  minDistFromSubs,
out InterestingPosition  position,
Vector2  awayPoint,
float  minDistFromPoint = 0f,
Func< InterestingPosition, bool >  filter = null,
bool  suppressWarning = false 
)

◆ TryGetInterestingPositionAwayFromPoint()

bool Barotrauma.Level.TryGetInterestingPositionAwayFromPoint ( bool  useSyncedRand,
PositionType  positionType,
float  minDistFromSubs,
out InterestingPosition  position,
Vector2  awayPoint,
float  minDistFromPoint,
Func< InterestingPosition, bool >  filter = null 
)

◆ Update()

void Barotrauma.Level.Update ( float  deltaTime,
Camera  cam 
)

Member Data Documentation

◆ AbyssIslands

List<AbyssIsland> Barotrauma.Level.AbyssIslands = new List<AbyssIsland>()

◆ DefaultRealWorldCrushDepth

const float Barotrauma.Level.DefaultRealWorldCrushDepth = 3500.0f
static

◆ distanceField

List<(Point point, double distance)> Barotrauma.Level.distanceField

◆ ExitDistance

const float Barotrauma.Level.ExitDistance = 6000.0f
static

◆ ForcedDifficulty

? float Barotrauma.Level.ForcedDifficulty
static

◆ GridCellSize

const int Barotrauma.Level.GridCellSize = 2000
static

◆ LevelData

readonly LevelData Barotrauma.Level.LevelData

◆ MaxEntityDepth

const int Barotrauma.Level.MaxEntityDepth = -1000000
static

◆ MaxSubmarineWidth

const int Barotrauma.Level.MaxSubmarineWidth = 16000
static

The level generator won't try to adjust the width of the main path above this limit.

Definition at line 52 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ OutsideBoundsCurrentHardLimit

const float Barotrauma.Level.OutsideBoundsCurrentHardLimit = 200000.0f
static

How far outside the boundaries of the level the current stops submarines entirely

Definition at line 47 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ OutsideBoundsCurrentMargin

const float Barotrauma.Level.OutsideBoundsCurrentMargin = 30000.0f
static

How far outside the boundaries of the level the water current that pushes subs towards the level starts

Definition at line 37 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ OutsideBoundsCurrentMarginExponential

const float Barotrauma.Level.OutsideBoundsCurrentMarginExponential = 150000.0f
static

How far outside the boundaries of the level the strength of the current starts to increase exponentially

Definition at line 42 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ ShaftHeight

const float Barotrauma.Level.ShaftHeight = 1000.0f
static

◆ siteCoordsX

List<double> Barotrauma.Level.siteCoordsX

Property Documentation

◆ AbyssArea

Rectangle Barotrauma.Level.AbyssArea
get

◆ AbyssEnd

int Barotrauma.Level.AbyssEnd
get

◆ AbyssResources

List<ClusterLocation> Barotrauma.Level.AbyssResources = new List<ClusterLocation>()
get

◆ AbyssStart

int Barotrauma.Level.AbyssStart
get

◆ BackgroundColor

Color Barotrauma.Level.BackgroundColor
get

◆ BackgroundCreatureManager

BackgroundCreatureManager Barotrauma.Level.BackgroundCreatureManager
get

◆ BackgroundTextureColor

Color Barotrauma.Level.BackgroundTextureColor
get

◆ BeaconStation

Submarine Barotrauma.Level.BeaconStation
get

◆ BottomBarrier

Body Barotrauma.Level.BottomBarrier
get

◆ BottomPos

int Barotrauma.Level.BottomPos
get

◆ Caves

List<Cave> Barotrauma.Level.Caves = new List<Cave>()
get

◆ CrushDepth

float Barotrauma.Level.CrushDepth
get

The crush depth of a non-upgraded submarine in in-game coordinates. Note that this can be above the top of the level!

Definition at line 296 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ Difficulty

float?? Barotrauma.Level.Difficulty
get

◆ EndExitPosition

Vector2 Barotrauma.Level.EndExitPosition
get

◆ EndLocation

Location Barotrauma.Level.EndLocation
get

◆ EndOutpost

Submarine Barotrauma.Level.EndOutpost
get

◆ EndPosition

Vector2 Barotrauma.Level.EndPosition
get

◆ EntitiesBeforeGenerate

List<Entity> Barotrauma.Level.EntitiesBeforeGenerate = new List<Entity>()
get

◆ EntityCountAfterGenerate

int Barotrauma.Level.EntityCountAfterGenerate
get

◆ EntityCountBeforeGenerate

int Barotrauma.Level.EntityCountBeforeGenerate
get

◆ EqualityCheckValues

IReadOnlyDictionary<LevelGenStage, int> Barotrauma.Level.EqualityCheckValues
get

◆ ExtraWalls

List<LevelWall> Barotrauma.Level.ExtraWalls
get

◆ Generating

bool Barotrauma.Level.Generating
get

◆ GenerationParams

LevelGenerationParams Barotrauma.Level.GenerationParams
get

◆ IsEndBiome

bool Barotrauma.Level.IsEndBiome
get

◆ IsLoadedFriendlyOutpost

bool Barotrauma.Level.IsLoadedFriendlyOutpost
staticget

Is there a loaded level set, and is it a friendly outpost (FriendlyNPC or Team1). Does not take reputation into account.

Definition at line 450 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ IsLoadedOutpost

bool Barotrauma.Level.IsLoadedOutpost
staticget

Is there a loaded level set and is it an outpost?

Definition at line 445 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ LevelObjectManager

LevelObjectManager Barotrauma.Level.LevelObjectManager
get

◆ Loaded

Level? Barotrauma.Level.Loaded
staticget

◆ Mirrored

bool Barotrauma.Level.Mirrored
get

◆ PathPoints

List<PathPoint> Barotrauma.Level.PathPoints = new List<PathPoint>()
get

◆ PositionsOfInterest

List<InterestingPosition> Barotrauma.Level.PositionsOfInterest
get

◆ RealWorldCrushDepth

float Barotrauma.Level.RealWorldCrushDepth
get

The crush depth of a non-upgraded submarine in "real world units" (meters from the surface of Europa). Note that this can be above the top of the level!

Definition at line 307 of file BarotraumaShared/SharedSource/Map/Levels/Level.cs.

◆ Renderer

LevelRenderer Barotrauma.Level.Renderer
get

◆ Ruins

List<Ruin> Barotrauma.Level.Ruins
get

◆ SeaFloor

LevelWall Barotrauma.Level.SeaFloor
get

◆ SeaFloorTopPos

int Barotrauma.Level.SeaFloorTopPos
get

◆ Seed

string Barotrauma.Level.Seed
get

◆ Size

Point Barotrauma.Level.Size
get

◆ StartExitPosition

Vector2 Barotrauma.Level.StartExitPosition
get

◆ StartLocation

Location Barotrauma.Level.StartLocation
get

◆ StartOutpost

Submarine Barotrauma.Level.StartOutpost
get

◆ StartPosition

Vector2 Barotrauma.Level.StartPosition
get

◆ TopBarrier

Body Barotrauma.Level.TopBarrier
get

◆ Tunnels

List<Tunnel> Barotrauma.Level.Tunnels = new List<Tunnel>()
get

◆ Type

LevelData.LevelType Barotrauma.Level.Type
get

◆ UnsyncedExtraWalls

List<LevelWall> Barotrauma.Level.UnsyncedExtraWalls
get

◆ WallColor

Color Barotrauma.Level.WallColor
get

◆ Wrecks

List<Submarine> Barotrauma.Level.Wrecks
get