Class BuildableExtensions
public static class BuildableExtensions
- Inheritance
-
BuildableExtensions
- Inherited Members
Methods
Destroy(IBuildable)
Destroy the structure or barricade.
public static bool Destroy(this IBuildable buildable)
Parameters
buildableIBuildable
Returns
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
assetItemPlaceableAssetSDG.Unturned.ItemBarricadeAsset or SDG.Unturned.ItemStructureAsset to spawn.
positionVector3Position to spawn the buildable at.
rotationQuaternionRotation to spawn the buildable at.
ownerCSteamIDSteam ID of the owner of the buildable, if any.
groupCSteamIDSteam ID of the group of the buildable, if any.
healthintStarting health of the barricade. If -1, the maximum health will be used.
statebyte[]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
transformTransform
Returns
Exceptions
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
buildableIBuildableassetItemPlaceableAssetSDG.Unturned.ItemBarricadeAsset or SDG.Unturned.ItemStructureAsset to spawn.
destroyOldboolhealthintStarting health of the barricade. If -1, the maximum health will be used.
statebyte[]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
objIBuildableserviceProviderIServiceProviderownerCSteamID?groupCSteamID?
Returns
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
buildableAssetItemPlaceableAssetlocalBoundsBounds
Returns
Remarks
Note that these bounds are rotated so that up is actually up.