Anvil
Loading...
Searching...
No Matches
Anvil.API.NwArea Class Referencesealed

An environment/game level. More...

+ Inheritance diagram for Anvil.API.NwArea:
+ Collaboration diagram for Anvil.API.NwArea:

Public Member Functions

void ApplyEnvironmentPreset (EnvironmentPreset preset)
 
NwAreaClone ()
 Creates a copy of this area, including everything inside of it (except players).
 
EnvironmentPreset CreateEnvironmentPreset ()
 
AreaDestroyResult Destroy ()
 Destroys this area and anything within it.
 
IEnumerable< T > FindObjectsOfTypeInArea< T > ()
 Locates all objects of the specified type.
 
int GetAreaLightColor (AreaLightColor colorType)
 Gets a light color in this area.
 
Vector3 GetAreaLightDirection (AreaLightDirection lightType)
 Gets the light direction for the specified light type.
 
TileInfo GetTileInfo (int tileX, int tileY)
 Gets the tile info at the specified position in the area.
 
TileInfo GetTileInfoByIndex (int index)
 Gets the specified tile info by its index.
 
override? Guid PeekUUID ()
 
void PlayAmbient ()
 Begins playback of ambient sounds in this area.
 
void PlayBackgroundMusic ()
 Begins playback of background music in this area.
 
void PlayBattleMusic ()
 Begins playback of battle music for this area.
 
void RecomputeStaticLighting ()
 Notifies all clients in this area to recompute static lighting.
This can be used to update the lighting after changing any tile lights or if placeables with lights have been added/deleted.
 
void ReloadAreaBorder ()
 Notifies all clients in this area to reload the inaccesible border tiles.
This can be used to update the edge tiles after changing a tile with SetTile().
 
void ReloadAreaGrass ()
 Notifies all clients in this area to recalculate grass.
This can be used to update the grass of an area after changing a tile with SetTile() that will have or used to have grass.
 
void RemoveAreaGrassOverride (SurfaceMaterialTableEntry material)
 Remove a grass override from this area that was set with SetAreaGrassOverride.
 
unsafe? byte[] SerializeARE (string? areaName=null, string? resRef=null)
 
byte?[] SerializeGIT (ObjectTypes objectFilter=ObjectTypes.All, ICollection< NwGameObject >? exclusionList=null, bool exportVarTable=true, bool exportUUID=true, string? resRef=null)
 
void SetAreaDefaultGrassDisabled (bool disabled)
 Set if the default grass of this area should be disabled.
 
void SetAreaGrassOverride (SurfaceMaterialTableEntry material, string texture, float density, float height, Color ambientColor, Color diffuseColor)
 Sets a grass override for a specific material in this area.
 
void SetAreaLightColor (AreaLightColor colorType, int color, TimeSpan fadeTime=default)
 Sets a light color in this area.
 
void SetAreaLightDirection (AreaLightDirection lightType, Vector3 direction, TimeSpan fadeTime=default)
 Sets the light direction for the specified light type.
 
void SetAreaTileBorderDisabled (bool disabled)
 Set to true to disable the inaccessible tile border in this area. Requires clients to reload the area to take effect.
 
void SetAreaWind (Vector3 direction, float magnitude, float yaw, float pitch)
 Sets the detailed wind data for this area.
 
void SetFogAmount (FogType fogType, int fogAmount)
 Sets the fog amount for this area, at the specified time of day.
 
void SetFogColor (FogType fogType, FogColor fogColor, TimeSpan fadeTime=default)
 Sets the fog color for this area, at the specified time of day.
 
void SetTiles (List< TileData > data, SettleFlags flags=SettleFlags.RecomputeLighting, string tileSet="")
 Bulk change a set of tiles in this area.
 
void StopAmbient ()
 Stops playback of any ambient sounds in this area.
 
void StopBackgroundMusic ()
 Stops playback of any running background music in this area.
 
void StopBattleMusic ()
 Stops playback of any running battle music in this area.
 

Static Public Member Functions

static ? NwArea Create (string resRef, string newTag="", string newName="")
 Creates a new area from the specified resource reference.
 
static ? NwArea Deserialize (byte[] serializedARE, byte[] serializedGIT, string newTag="", string newName="")
 
static ? NwArea Deserialize (string resRef, byte[] serializedARE, byte[] serializedGIT, string newTag="", string newName="")
 Creates an area from the specified serialized area data.
 
static implicit operator CNWSArea? (NwArea? area)
 
- Static Public Member Functions inherited from Anvil.API.NwObject
static IEnumerable< T > FindObjectsOfType< T > ()
 Locates all objects of the specified type.
 
static IEnumerable< NwObjectFindObjectsWithTag (params string[] tags)
 Locates all objects of that have the specified tag.
 
static IEnumerable< T > FindObjectsWithTag< T > (params string[] tags)
 Locates all objects of the specified type that have the specified tag.
 

Properties

int AmbientDayTrack [set]
 Sets the daytime ambient track for this area.
See "ambientsound.2da" for track numbers.
 
int AmbientDayVolume [set]
 Sets the daytime ambient track volume for this area.
 
int AmbientNightTrack [set]
 Sets the night ambient track for this area.
See "ambientsound.2da" for track numbers.
 
int AmbientNightVolume [set]
 Sets the night ambient track volume for this area.
 
AreaFlags AreaFlags [get, set]
 Gets or sets area terrain metadata flags.
 
DayNightMode DayNightMode [get, set]
 Gets or sets the day/night mode to use for this area.
 
float FogClipDistance [get, set]
 Gets or sets the fog clip distance in the area.
 
bool IsAboveGround [get, set]
 Gets or sets whether this area is considered above ground and not under ground.
 
bool IsBattleMusicPlaying [get]
 Gets a value indicating whether battle music is currently playing in the area.
 
bool IsExterior [get, set]
 Gets or sets whether this area is considered an as exterior, and not an interior.
 
bool IsInterior [get, set]
 Gets or sets whether this area is considered an as interior, and not an exterior.
 
bool IsMusicPlaying [get]
 Gets a value indicating whether ambient music is currently playing in the area.
 
bool IsNatural [get, set]
 Gets or sets whether this area is considered natural and non-urban.
 
bool IsUnderGround [get, set]
 Gets or sets whether this area is considered under ground and not above ground.
 
bool IsUrban [get, set]
 Gets or sets whether this area is considered urban and not natural.
 
NwGameObjectLastEntered [get]
 Gets the last object that entered this area.
 
NwGameObjectLastLeft [get]
 Gets the last object that left this area.
 
int LightningChance [get, set]
 Gets or sets the percentage value (0-100) that lightning may occur.
 
int ListenModifier [get, set]
 Gets or sets the listen modifier for this area.
 
LoadScreenTableEntry LoadScreen [get, set]
 Gets or sets the load screen for this area.
 
Color MoonAmbientColor [get, set]
 Gets or sets the area ambient color during night time.
 
Color MoonDiffuseColor [get, set]
 Gets or sets the area diffuse color during night time.
 
int MoonFogAmount [get, set]
 Gets or sets the fog density during night time.
 
Color MoonFogColor [get, set]
 Gets or sets the area fog color during night time.
 
bool MoonShadows [get, set]
 Gets or sets whether shadows are cast during night time.
 
int MusicBackgroundDayTrack [get, set]
 Gets or sets the daytime background track index for this area.
See "Resources > Sounds and Music > Music" in the toolset for track numbers.
 
int MusicBackgroundNightTrack [get, set]
 Gets or sets the nighttime background track index for this area.
Refer to Resources > Sounds and Music > Music in the toolset for track numbers.
 
int MusicBattleTrack [get, set]
 Gets or sets the combat track index for this area.
Refer to Resources > Sounds and Music > Music in the toolset for track numbers.
 
IEnumerable< NwGameObjectObjects [get]
 Gets all Objects currently in this area.
 
int PlayerCount [get]
 Gets the number of players in this area.
 
PVPSetting PVPSetting [get, set]
 Gets or sets the PvP setting for this area.
 
int RainChance [get, set]
 Gets or sets the percentage value (0-100) that rain may occur.
 
bool RestingAllowed [get, set]
 Gets or sets whether resting is allowed in this area.
 
byte ShadowOpacity [get, set]
 Gets or sets the shadow opacity for this area (0-100).
 
Vector2Int Size [get]
 Gets the size of this area.

Returns
The number of tiles that the area is wide/high.

 
Skybox SkyBox [get, set]
 Gets or sets the current skybox for this area.
 
int SnowChance [get, set]
 Gets or sets the percentage value (0-100) that snow may occur.
 
int SpotModifier [get, set]
 Gets or sets the spot modifier for this area.
 
Color SunAmbientColor [get, set]
 Gets or sets the area ambient color during day time.
 
Color SunDiffuseColor [get, set]
 Gets or sets the area diffuse color during day time.
 
int SunFogAmount [get, set]
 Gets or sets the fog density during day time.
 
Color SunFogColor [get, set]
 Gets or sets the area fog color during day time.
 
bool SunShadows [get, set]
 Gets or sets whether shadows are cast during day time.
 
IReadOnlyList< TileInfoTileInfo [get]
 Gets an array containing all tile data/structures for the area.
 
string Tileset [get]
 Gets the tileset (.set) resource name used for this area.
 
WeatherType Weather [get, set]
 Gets or sets the current weather conditions for this area.
 
byte WindPower [get, set]
 Gets or sets the wind power for this area.
Set to 0, 1 or 2.
 

Events

Action< AreaEvents.OnEnterOnEnter [add, remove]
 
Action< AreaEvents.OnExitOnExit [add, remove]
 
Action< AreaEvents.OnHeartbeatOnHeartbeat [add, remove]
 
Action< AreaEvents.OnUserDefinedOnUserDefined [add, remove]
 

Detailed Description

An environment/game level.

Member Function Documentation

◆ Clone()

NwArea? Anvil.API.NwArea.Clone ( )
inline

Creates a copy of this area, including everything inside of it (except players).

Returns
The new cloned area instance.

◆ Create()

static ? NwArea Anvil.API.NwArea.Create ( string resRef,
string newTag = "",
string newName = "" )
inlinestatic

Creates a new area from the specified resource reference.

Parameters
resRefThe area resource to create this area from.
newTagA new tag for this area. Defaults to the tag set in the toolset.
newNameA new name for this area. Defaults to the name set in the toolset.
Returns
The created area.

◆ Deserialize()

static ? NwArea Anvil.API.NwArea.Deserialize ( string resRef,
byte[] serializedARE,
byte[] serializedGIT,
string newTag = "",
string newName = "" )
inlinestatic

Creates an area from the specified serialized area data.

Parameters
resRefThe base resref name to use (e.g. area001). Overrides previous areas with the same resref (excl. development folder areas).
serializedAREThe serialized static area information (.are).
serializedGITThe serialized dynamic area information (.git).
newTagA new tag for this area. Defaults to the tag set in the toolset.
newNameA new name for this area. Defaults to the name set in the toolset.
Returns
The created area.

◆ Destroy()

AreaDestroyResult Anvil.API.NwArea.Destroy ( )
inline

Destroys this area and anything within it.

Returns
The result of this destroy action.

◆ FindObjectsOfTypeInArea< T >()

IEnumerable< T > Anvil.API.NwArea.FindObjectsOfTypeInArea< T > ( )
inline

Locates all objects of the specified type.

Template Parameters
TThe type of objects to search.
Returns
An enumeration containing all objects of the specified type.
Type Constraints
T :NwObject 

◆ GetAreaLightColor()

int Anvil.API.NwArea.GetAreaLightColor ( AreaLightColor colorType)
inline

Gets a light color in this area.

Parameters
colorTypeThe color type to get.

◆ GetAreaLightDirection()

Vector3 Anvil.API.NwArea.GetAreaLightDirection ( AreaLightDirection lightType)
inline

Gets the light direction for the specified light type.

Parameters
lightTypeThe type of light to get the direction from.
Returns
A Vector3 representing the light direction.

◆ GetTileInfo()

TileInfo Anvil.API.NwArea.GetTileInfo ( int tileX,
int tileY )
inline

Gets the tile info at the specified position in the area.

Parameters
tileXThe x coordinate of the tile to get info.
tileYThe y coordinate of the tile to get info.
Returns
A structure containing the associated tile info.
Exceptions
ArgumentOutOfRangeExceptionThrown if the tile coordinates are larger than the area size.

◆ GetTileInfoByIndex()

TileInfo Anvil.API.NwArea.GetTileInfoByIndex ( int index)
inline

Gets the specified tile info by its index.

For example, a 3x3 area has the following tile indexes:
6 7 8
3 4 5
0 1 2

Parameters
indexThe tile index to query.
Returns
A structure containing the associated tile info.

◆ RemoveAreaGrassOverride()

void Anvil.API.NwArea.RemoveAreaGrassOverride ( SurfaceMaterialTableEntry material)
inline

Remove a grass override from this area that was set with SetAreaGrassOverride.

Parameters
materialThe modified material to reset.

◆ SetAreaDefaultGrassDisabled()

void Anvil.API.NwArea.SetAreaDefaultGrassDisabled ( bool disabled)
inline

Set if the default grass of this area should be disabled.

Parameters
disabledThe new disabled state.

◆ SetAreaGrassOverride()

void Anvil.API.NwArea.SetAreaGrassOverride ( SurfaceMaterialTableEntry material,
string texture,
float density,
float height,
Color ambientColor,
Color diffuseColor )
inline

Sets a grass override for a specific material in this area.

Parameters
materialThe material to override.
textureThe replacement grass texture
densityThe density of the grass.
heightThe height of the grass.
ambientColorThe ambient color of the grass. Alpha channel is ignored.
diffuseColorThe diffuse color of the grass. Alpha channel is ignored.

◆ SetAreaLightColor()

void Anvil.API.NwArea.SetAreaLightColor ( AreaLightColor colorType,
int color,
TimeSpan fadeTime = default )
inline

Sets a light color in this area.

Parameters
colorTypeThe type of color to set.
colorThe new color to set.
fadeTimeThe time to fade the new color.

◆ SetAreaLightDirection()

void Anvil.API.NwArea.SetAreaLightDirection ( AreaLightDirection lightType,
Vector3 direction,
TimeSpan fadeTime = default )
inline

Sets the light direction for the specified light type.

Parameters
lightTypeThe type of light to get the direction from.
directionThe new direction for the light.
fadeTimeThe time to fade in the new light direction.
Returns
A Vector3 representing the light direction.

◆ SetAreaTileBorderDisabled()

void Anvil.API.NwArea.SetAreaTileBorderDisabled ( bool disabled)
inline

Set to true to disable the inaccessible tile border in this area. Requires clients to reload the area to take effect.

Parameters
disabledTrue to disable tile borders, false to enable.

◆ SetAreaWind()

void Anvil.API.NwArea.SetAreaWind ( Vector3 direction,
float magnitude,
float yaw,
float pitch )
inline

Sets the detailed wind data for this area.

The predefined values in the toolset are:
NONE: direction=(1.0, 1.0, 0.0), magnitude=0.0, yaw=0.0, pitch=0.0
LIGHT: direction=(1.0, 1.0, 0.0), magnitude=1.0, yaw=100.0, pitch=3.0
HEAVY: direction=(1.0, 1.0, 0.0), magnitude=2.0, yaw=150.0, pitch=5.0

Parameters
directionThe direction of the wind.
magnitudeThe magnitude/intensity of the wind.
yawThe yaw value of the wind.
pitchThe pitch value of the wind.

◆ SetTiles()

void Anvil.API.NwArea.SetTiles ( List< TileData > data,
SettleFlags flags = SettleFlags::RecomputeLighting,
string tileSet = "" )
inline

Bulk change a set of tiles in this area.

Parameters
dataThe updated tile data.
flagsFlags/behaviours to apply once the tiles have been set.
tileSetIf specified, also changes the area's tileset. Warning: only use this if you really know what you're doing, it's very easy to break things badly.

Property Documentation

◆ IsInterior

bool Anvil.API.NwArea.IsInterior
getset

Gets or sets whether this area is considered an as interior, and not an exterior.

Unlike the equivalent NwScript function NWScript.GetIsAreaInterior, this function will only return true if the API.AreaFlags.Interior flag is set.
An area that is simply underground is not considered an interior.

Use IsInterior || IsUnderGround together to replicate the existing function.


The documentation for this class was generated from the following files: