Class VoxelDestructor
- Namespace
- VoxelPlayground.Destruction
- Assembly
- GamePlay.dll
public class VoxelDestructor : MonoBehaviour, IVoxelDestructible
- Inheritance
-
objectVoxelDestructor
- Implements
- Extension Methods
Fields
bindPosBone_deprecated
[HideInInspector]
public Transform bindPosBone_deprecated
Field Value
blackList
public List<Collider> blackList
Field Value
- List<Collider>
EnableCreateFragmentObjects
public static bool EnableCreateFragmentObjects
Field Value
- bool
entityConnectors
[HideInInspector]
public List<EntityConnector> entityConnectors
Field Value
- List<EntityConnector>
indestructiable
public bool indestructiable
Field Value
- bool
invincibleCollision
[NonSerialized]
[ShowInInspector]
public bool invincibleCollision
Field Value
- bool
isFireImmune
public bool isFireImmune
Field Value
- bool
isFortified
public bool isFortified
Field Value
- bool
isPoisonImmune
public bool isPoisonImmune
Field Value
- bool
massDensity
public float massDensity
Field Value
- float
onCollisionEnterAction
public Action<Collision> onCollisionEnterAction
Field Value
- Action<Collision>
OnExplodeToParts
public Action OnExplodeToParts
Field Value
- Action
OnFragmentCreated
public Action<VoxelDestructor, VoxelDestructor, NativeSlice<int>> OnFragmentCreated
Field Value
- Action<VoxelDestructor, VoxelDestructor, NativeSlice<int>>
ownerEntity
public Entity ownerEntity
Field Value
prefabName
public string prefabName
Field Value
- string
preventsImpactDestructOther
public bool preventsImpactDestructOther
Field Value
- bool
protector
public VoxelDestructor protector
Field Value
rb
public Rigidbody rb
Field Value
registerFragmentEvents
[InfoBox("Use for non-character big object", InfoMessageType.Info, null)]
public bool registerFragmentEvents
Field Value
- bool
unyielding
public bool unyielding
Field Value
- bool
voxelData
[InfoBox("voxelData,ownerEntity,rigidBody会自己找到引用", InfoMessageType.Info, null)]
public VoxelVolume voxelData
Field Value
Properties
IsHeatDissolved
public bool IsHeatDissolved { get; }
Property Value
- bool
IsIndestructible
public bool IsIndestructible { get; }
Property Value
- bool
VoxelData
public VoxelVolume VoxelData { get; }
Property Value
Methods
BoxSweepClear(Vector3, Vector3, Vector3, Matrix4x4, VoxelChunk, bool, float)
Clears voxels within a box-shaped area that sweeps between two points.
public void BoxSweepClear(Vector3 end1, Vector3 end2, Vector3 halfBox, Matrix4x4 boxLocalToWorld, VoxelChunk voxelChunkToClears, bool isByEasyKinematicPenetration = false, float hardnessCap = -1)
Parameters
end1Vector3World space position of the first endpoint of the sweep
end2Vector3World space position of the second endpoint of the sweep
halfBoxVector3Half-extents of the box in local box space
boxLocalToWorldMatrix4x4Matrix that transforms from box local space to world space
voxelChunkToClearsVoxelChunkThe specific voxel chunk to clear
isByEasyKinematicPenetrationboolif true (i.e. damager is e.g. Mech, GiantZombie), then creates lesser Fragments since these kind of damage always produce too much frags that make phys slow
hardnessCapfloat
ControlledTick()
public void ControlledTick()
CylinderClear(Vector3, Vector3, float)
public void CylinderClear(Vector3 end1, Vector3 end2, float radius)
Parameters
DemolishAreaSphere(Vector3, float, float, Vector3, float, int, float, Action<int>)
Demolishes a spherical area of the voxel object, create fragments from demolished area.
public void DemolishAreaSphere(Vector3 center, float radius, float force = 0, Vector3 explodeDirection = default, float spreadAngle = 3.14159, int maxFragments = 30, float hardnessCap = 8, Action<int> onModified = null)
Parameters
centerVector3World space position of the sphere center
radiusfloatRadius of the sphere in world space
forcefloatOptional force to apply to created fragments
explodeDirectionVector3Optional direction for the explosion force
spreadAnglefloatOptional angle to spread the explosion force, in radians. Default is PI (180 degrees). If spreadAngle is PI, the force will be applied in a random direction. If spreadAngle is 0, the force will be applied in the direction of the explosion.
maxFragmentsinthardnessCapfloatwon't modify if the voxel's hardness >= hardnessCap (fac=0), easier modify if voxel's hardness is lesser than hardnessCap
onModifiedAction<int>
DemolishAtRandomPoint(float, VoxelVolume)
public Vector3 DemolishAtRandomPoint(float radius, VoxelVolume _voxelData = null)
Parameters
radiusfloat_voxelDataVoxelVolume
Returns
DissolveContactPlane(Vector3, Vector3)
Construct a plane, center at hitPoint and face normal; empty everything under this plane
This should only be used for COLLAPSE TO GROUND, but not for other usecases like hand hit
public void DissolveContactPlane(Vector3 hitPoint, Vector3 normal)
Parameters
ExplodeToPartsAndDestroy(VoxelVolume, MonoBehaviour, bool, bool)
public static void ExplodeToPartsAndDestroy(VoxelVolume mc, MonoBehaviour coroutineCarrier, bool specialEffect = false, bool randomRemoval = true)
Parameters
mcVoxelVolumecoroutineCarrierMonoBehaviourspecialEffectboolrandomRemovalbool
ExplodeToPartsAndDestroySelf(bool, bool)
[Button("Test ExplodeToParts")]
public void ExplodeToPartsAndDestroySelf(bool specialEffect = false, bool randomRemoval = true)
Parameters
specialEffectboolrandomRemovalbool
IncrementalHeatDissolve()
public void IncrementalHeatDissolve()
Init(VoxelVolume, Entity)
public void Init(VoxelVolume voxelData, Entity entity)
Parameters
voxelDataVoxelVolumeentityEntity
IOnFragmentCreated(IVoxelDestructible, IVoxelDestructible, NativeSlice<int>)
public void IOnFragmentCreated(IVoxelDestructible source, IVoxelDestructible target, NativeSlice<int> fragmentIndices)
Parameters
sourceIVoxelDestructibletargetIVoxelDestructiblefragmentIndicesNativeSlice<int>
IsCharacter()
public bool IsCharacter()
Returns
- bool
ModifyAtPos(Vector3, float, Action<int>)
public void ModifyAtPos(Vector3 center_worldSpace, float radius, Action<int> onModified = null)
Parameters
center_worldSpaceVector3radiusfloatonModifiedAction<int>
ModifyAtPos(Vector3, float, float, Vector3, float, int, float, Action<int>)
public void ModifyAtPos(Vector3 center_worldSpace, float radius, float force = 0, Vector3 explodeDirection = default, float spreadAngle = 3.14159, int maxFragments = 20, float hardnessCap = -1, Action<int> onModified = null)
Parameters
center_worldSpaceVector3radiusfloatforcefloatexplodeDirectionVector3spreadAnglefloatmaxFragmentsinthardnessCapfloatonModifiedAction<int>
ModifyAtRandomPoint(float)
public Vector3 ModifyAtRandomPoint(float radius = 0.13)
Parameters
radiusfloat
Returns
ModifyPropertyAtPos(Vector3, float, Property, int)
public void ModifyPropertyAtPos(Vector3 center_worldSpace, float radius, PointDataV2.Property property = Property.Water, int step = 1)
Parameters
center_worldSpaceVector3radiusfloatpropertyPointDataV2.Propertystepint
ModifyToBulletHoleColor(float3, float)
public PointDataV2 ModifyToBulletHoleColor(float3 center_WS, float radius_WS = 0.01875)
Parameters
center_WSfloat3radius_WSfloat
Returns
OnFragmentDetected(NativeList<PointDataV2>, NativeList<int3>, NativeList<int>, NativeSlice<int>, List<NativeSlice<int>>, NativeArray<bool>, bool, VoxelVolume)
public void OnFragmentDetected(NativeList<PointDataV2> fragsSource, NativeList<int3> boundsSource, NativeList<int> solidCountsSource, NativeSlice<int> mainIslandIdSource, List<NativeSlice<int>> islandsSource, NativeArray<bool> unyieldingFragSource, bool unyieldingMainland, VoxelVolume mc)
Parameters
fragsSourceNativeList<PointDataV2>boundsSourceNativeList<int3>solidCountsSourceNativeList<int>mainIslandIdSourceNativeSlice<int>islandsSourceList<NativeSlice<int>>unyieldingFragSourceNativeArray<bool>unyieldingMainlandboolmcVoxelVolume
PlaneCut(Vector3, Vector3, Vector3)
plane cut a voxel
YEnd ++++++++ ++++++++ ++++++++ ++++++++ ++++++++ O XEnd
public void PlaneCut(Vector3 originWorldSpace, Vector3 xDirectionWorldSpace, Vector3 yDirectionWorldSpace)
Parameters
originWorldSpaceVector3Above O point in world space
xDirectionWorldSpaceVector3Above XEnd-O vector in worldspace
yDirectionWorldSpaceVector3Above YEnd-O vector in worldspace
ProjectTexture(Vector3, float, NativeArray<Color32>, int, Vector3, float, SplatType, float)
public void ProjectTexture(Vector3 center, float radius, NativeArray<Color32> projectTexture, int textureDim, Vector3 projectDirection, float projectDepth, SplatType splatType = SplatType.Blood, float opacity = 1)
Parameters
centerVector3radiusfloatprojectTextureNativeArray<Color32>textureDimintprojectDirectionVector3projectDepthfloatsplatTypeSplatTypeopacityfloat
RaycastWithProtector(Vector3, Vector3, ref RaycastHitVoxel)
public bool RaycastWithProtector(Vector3 origin, Vector3 direction, ref RaycastHitVoxel raycastHitVoxel)
Parameters
originVector3directionVector3raycastHitVoxelRaycastHitVoxel
Returns
- bool
RestoreColorStep()
public void RestoreColorStep()
ScreenSpaceLineClear(Vector2, Vector2, Matrix4x4, VoxelChunk, float)
public void ScreenSpaceLineClear(Vector2 screenSpacePos1, Vector2 screenSpacePos2, Matrix4x4 worldToScreen, VoxelChunk chunkToClear, float thicknessInPixel = 8)
Parameters
screenSpacePos1Vector2screenSpacePos2Vector2worldToScreenMatrix4x4chunkToClearVoxelChunkthicknessInPixelfloat
SetColliderIgnore(Collider, bool)
public void SetColliderIgnore(Collider collider, bool ignore)
Parameters
colliderColliderignorebool
SetUnyieldingAndIskinematic(bool)
public void SetUnyieldingAndIskinematic(bool value)
Parameters
valuebool
ShockWaveCrack(Vector3, Vector3, float, CrackType)
Generate cracks inside voxels There are two types of cracks, depends on crackType param
- CrackType.SurfaceShatter, generate a spider web like crack, on hit point surface, image you throw a pebble onto glass window, it generate crack on surface
- CrackType.VerticalCrack, generate a vertical crack on side of hit plane, image you throw a rock onto ground, crack does not appear on contact plane, but on its side
public void ShockWaveCrack(Vector3 hitPoint, Vector3 hitDirection, float radiusWorldSpace, VoxelDestructor.CrackType crackType)
Parameters
hitPointVector3collision point
hitDirectionVector3collision impulse direction. for CrackType.SurfaceShatter, it is the plane normal. for CrackType.VerticalCrack, it is where crack grows
radiusWorldSpacefloatcrack affected size in world space unit
crackTypeVoxelDestructor.CrackTypesee above explanation and CrackType enum docs
ShockWavePeelOffPiece(float, int)
Generate some random holes all around the volume
public void ShockWavePeelOffPiece(float pieceRadiusWorldSpace, int pieceCounts = 10)
Parameters
pieceRadiusWorldSpacefloatmax radius of piece in world space, actual piece will range in half of this radius to radius
pieceCountsintnum of holes to remove
SmashPartInsideVolume(Vector3, Vector3, Matrix4x4, out GameObject)
For smasher, voxels inside a volume of the original marching cube will be emptied, and flatte to make an new object
+Z +Y | / | / |/ C-------- +X
public void SmashPartInsideVolume(Vector3 smashVolumeStartWorld, Vector3 smashVolumeWorldSize, Matrix4x4 smashVolumeLocalToWorld, out GameObject smashedFragment)
Parameters
smashVolumeStartWorldVector3Above C position, volume bottom center
smashVolumeWorldSizeVector3x, y, z: in above illustration
smashVolumeLocalToWorldMatrix4x4x, y, z: in above illustration
smashedFragmentGameObject
SphereSweepClear(Vector3, Vector3, float)
public void SphereSweepClear(Vector3 end1World, Vector3 end2World, float radiusWorld)