Table of Contents

Class BuildableExtensions

Namespace
Uncreated.Warfare.Util
Assembly
Uncreated.Warfare.dll
public static class BuildableExtensions
Inheritance
BuildableExtensions
Inherited Members

Methods

Destroy(IBuildable)

Destroy the structure or barricade.

public static bool Destroy(this IBuildable buildable)

Parameters

buildable IBuildable

Returns

bool

Exceptions

ArgumentNullException
NotSupportedException

Not on main thread.

DropBuildable(ItemPlaceableAsset, Vector3, Quaternion, CSteamID, CSteamID, int, byte[]?)

Places a non-planted barricade or structure.

public static IBuildable DropBuildable(ItemPlaceableAsset asset, Vector3 position, Quaternion rotation, CSteamID owner = default, CSteamID group = default, int health = -1, byte[]? state = null)

Parameters

asset ItemPlaceableAsset

SDG.Unturned.ItemBarricadeAsset or SDG.Unturned.ItemStructureAsset to spawn.

position Vector3

Position to spawn the buildable at.

rotation Quaternion

Rotation to spawn the buildable at.

owner CSteamID

Steam ID of the owner of the buildable, if any.

group CSteamID

Steam ID of the group of the buildable, if any.

health int

Starting health of the barricade. If -1, the maximum health will be used.

state byte[]

Optional starting state for barricades.

Returns

IBuildable

The newly-created buildable.

Exceptions

ArgumentNullException
ArgumentOutOfRangeException

Position is not inside a valid region.

InvalidOperationException

SDG.Unturned.BarricadeManager or SDG.Unturned.StructureManager is not loaded yet.

InvalidBarricadeStateException

The given state is not valid.

ArgumentException

Asset is not a structure or barricade.

GameThreadException
Exception

Failed to place buildable for some reason.

GetBuildableFromRootTransform(Transform)

Creates a IBuildable from a root transform of a barricade or structure.

public static IBuildable? GetBuildableFromRootTransform(Transform transform)

Parameters

transform Transform

Returns

IBuildable

Exceptions

GameThreadException

ReplaceBuildable(IBuildable, ItemPlaceableAsset, bool, int, byte[]?)

Places a non-planted barricade or structure at the same position as buildable after optionally destroying it. Planted barricades are supported.

public static IBuildable ReplaceBuildable(this IBuildable buildable, ItemPlaceableAsset asset, bool destroyOld = true, int health = -1, byte[]? state = null)

Parameters

buildable IBuildable
asset ItemPlaceableAsset

SDG.Unturned.ItemBarricadeAsset or SDG.Unturned.ItemStructureAsset to spawn.

destroyOld bool
health int

Starting health of the barricade. If -1, the maximum health will be used.

state byte[]

Optional starting state for barricades.

Returns

IBuildable

The newly-created buildable.

Exceptions

ArgumentNullException
InvalidOperationException

SDG.Unturned.BarricadeManager or SDG.Unturned.StructureManager is not loaded yet.

InvalidBarricadeStateException

The given state is not valid.

ArgumentException

Asset is not a structure or barricade.

GameThreadException
Exception

Failed to place buildable for some reason.

SetOwnerOrGroup(IBuildable, IServiceProvider, CSteamID?, CSteamID?)

Set the owner or group of a buildable.

public static bool SetOwnerOrGroup(this IBuildable obj, IServiceProvider serviceProvider, CSteamID? owner = null, CSteamID? group = null)

Parameters

obj IBuildable
serviceProvider IServiceProvider
owner CSteamID?
group CSteamID?

Returns

bool

true if the barricade state was replicated, otherwise false.

TryGetBuildableBounds(ItemPlaceableAsset, out Bounds)

Get the local bounds for a buildable asset type. Cached after first use for each asset type.

public static bool TryGetBuildableBounds(ItemPlaceableAsset buildableAsset, out Bounds localBounds)

Parameters

buildableAsset ItemPlaceableAsset
localBounds Bounds

Returns

bool

Remarks

Note that these bounds are rotated so that up is actually up.