Class GameUtilities
- Namespace
- VoxelPlayground.Utility
- Assembly
- GamePlay.dll
public static class GameUtilities
- Inheritance
-
object
GameUtilities
Fields
ASSUMED_ONE_SECOND_FRAME_COUNT
public const int ASSUMED_ONE_SECOND_FRAME_COUNT = 72
Field Value
- int
AXES
public static readonly Vector3[] AXES
Field Value
- Vector3[]
CubeVertices
public static Vector3[] CubeVertices
Field Value
- Vector3[]
USE_PX5
public const bool USE_PX5 = false
Field Value
- bool
Properties
CollidersPool
public static Collider[] CollidersPool { get; }
Property Value
- Collider[]
Methods
abs(float)
public static float abs(this float v)
Parameters
v float
Returns
- float
AddClonedComponent<T>(GameObject, T)
public static T AddClonedComponent<T>(this GameObject uo, T comp) where T : Component
Parameters
uo GameObject
comp T
Returns
- T
Type Parameters
T
AddComponentIfNull<T>(GameObject)
public static T AddComponentIfNull<T>(this GameObject gameObject) where T : Component
Parameters
gameObject GameObject
Returns
- T
Type Parameters
T
public static RectTransform AsRect(this Transform transform)
Parameters
transform Transform
Returns
- RectTransform
AtFrameInterval(int)
public static bool AtFrameInterval(int interval)
Parameters
interval int
Returns
- bool
AtInterval(float)
public static bool AtInterval(float interval)
Parameters
interval float
Returns
- bool
CalcCurrentDesiredTargetPosition(ConfigurableJoint)
public static Vector3 CalcCurrentDesiredTargetPosition(this ConfigurableJoint joint)
Parameters
joint ConfigurableJoint
Returns
- Vector3
CalculateMass(VoxelVolume, float)
public static float CalculateMass(VoxelVolume voxelColume, float density = 1)
Parameters
voxelColume VoxelVolume
density float
Returns
- float
CastDownFloorLocation(Vector3)
public static Vector3 CastDownFloorLocation(Vector3 position)
Parameters
position Vector3
Returns
- Vector3
CheckDirectLineOfSight(Vector3, Vector3, EntityCharacter, EntityCharacter)
public static bool CheckDirectLineOfSight(Vector3 from, Vector3 to, EntityCharacter fromEntity, EntityCharacter toEntity)
Parameters
from Vector3
to Vector3
fromEntity EntityCharacter
toEntity EntityCharacter
Returns
- bool
CheckDirectLineOfSight(Vector3, EntityCharacter)
public static bool CheckDirectLineOfSight(Vector3 from, EntityCharacter targetEntity)
Parameters
from Vector3
targetEntity EntityCharacter
Returns
- bool
CheckDirectLineOfSight(EntityCharacter, Entity)
public static bool CheckDirectLineOfSight(EntityCharacter fromEntity, Entity toEntity)
Parameters
fromEntity EntityCharacter
toEntity Entity
Returns
- bool
CopyAllProperties<T>(T, T)
public static T CopyAllProperties<T>(this T comp, T other) where T : Component
Parameters
comp T
other T
Returns
- T
Type Parameters
T
public static GameObject CreateCollisionEffect(CollisionHitType hitType, Transform hitTransform, Vector3 position, float duration = -1, bool checkCooldown = false)
Parameters
hitType CollisionHitType
hitTransform Transform
position Vector3
duration float
checkCooldown bool
Returns
- GameObject
CreateCollisionEffect(CollisionHitType, CollisionMatType, Vector3, float, bool)
public static GameObject CreateCollisionEffect(CollisionHitType hitType, CollisionMatType matType, Vector3 position, float duration = -1, bool checkCooldown = false)
Parameters
hitType CollisionHitType
matType CollisionMatType
position Vector3
duration float
checkCooldown bool
Returns
- GameObject
CurveCast(Vector3, Vector3, int, float, List<Vector3>, out RaycastHit, out bool, Func<Collider, bool>, int)
public static bool CurveCast(Vector3 startPos, Vector3 direction, int num, float velocity, List<Vector3> curveVecs, out RaycastHit hit, out bool outIsRaycast, Func<Collider, bool> filter, int layerMask)
Parameters
startPos Vector3
direction Vector3
num int
velocity float
curveVecs List<Vector3>
hit RaycastHit
outIsRaycast bool
filter Func<Collider, bool>
layerMask int
Returns
- bool
DebugDrawCube(Vector3, Quaternion, Vector3, Color, float)
public static void DebugDrawCube(Vector3 position, Quaternion rotation, Vector3 scale, Color color, float duration = 0)
Parameters
position Vector3
rotation Quaternion
scale Vector3
color Color
duration float
DebugObject(string, Vector3)
public static void DebugObject(string name, Vector3 position)
Parameters
name string
position Vector3
DestoryAllEntities()
public static void DestoryAllEntities()
public static void DestroyChildren(this Transform obj, bool immediately = false, Func<Transform, bool> delIf = null, bool includeSelf = false)
Parameters
obj Transform
immediately bool
delIf Func<Transform, bool>
includeSelf bool
Distance(Collider, Vector3)
public static Vector3 Distance(this Collider collider, Vector3 point)
Parameters
collider Collider
point Vector3
Returns
- Vector3
DrawLine(string, Vector3, Vector3)
public static void DrawLine(string name, Vector3 startPoint, Vector3 endPoint)
Parameters
name string
startPoint Vector3
endPoint Vector3
public static void DrawSkeleton(this Transform bone, Color color, Predicate<Transform> isSkeletonBone = null)
Parameters
bone Transform
color Color
isSkeletonBone Predicate<Transform>
FindClosestTypedEntity<T>(Vector3, float, Func<T, bool>)
public static T FindClosestTypedEntity<T>(Vector3 center, float radius, Func<T, bool> filter = null) where T : Entity
Parameters
center Vector3
radius float
filter Func<T, bool>
Returns
- T
Type Parameters
T
FindFreePlaceForCharacter(Vector3, bool, int, float, float)
public static Vector3 FindFreePlaceForCharacter(Vector3 center, bool toGroundPos = true, int maxTries = 40, float maxRadius = 6, float freeRadius = 0.35)
Parameters
center Vector3
toGroundPos bool
maxTries int
maxRadius float
freeRadius float
Returns
- Vector3
FindFreeSpace(Vector3, float)
public static Vector3 FindFreeSpace(Vector3 centerPos, float circleDistanceFactor = 1)
Parameters
centerPos Vector3
circleDistanceFactor float
Returns
- Vector3
public static T FindMonoFromParent<T>(Transform self) where T : MonoBehaviour
Parameters
self Transform
Returns
- T
Type Parameters
T
Floor(float, float)
public static float Floor(this float v, float unit)
Parameters
v float
unit float
Returns
- float
Floor(Vector3)
public static Vector3 Floor(this Vector3 v)
Parameters
v Vector3
Returns
- Vector3
FollowPosition(Rigidbody, Vector3, float, float)
public static void FollowPosition(Rigidbody follower, Vector3 targetPos, float speed = 1, float maxVelocityDelta = 10)
Parameters
follower Rigidbody
targetPos Vector3
speed float
maxVelocityDelta float
FollowRotation(Rigidbody, Quaternion, float, float)
public static void FollowRotation(Rigidbody follower, Quaternion targetRot, float speed = 1, float maxVelocityDelta = 10)
Parameters
follower Rigidbody
targetRot Quaternion
speed float
maxVelocityDelta float
public static void ForChildren(this Transform obj, Action<Transform> visitor)
Parameters
obj Transform
visitor Action<Transform>
public static void ForChildrenRecursive(this Transform obj, Action<Transform> visitor)
Parameters
obj Transform
visitor Action<Transform>
public static void ForChildrenRev(this Transform obj, Action<Transform> visitor)
Parameters
obj Transform
visitor Action<Transform>
FrametimeIntervals(float)
public static int FrametimeIntervals(float interval)
Parameters
interval float
Returns
- int
public static List<Vector3> GenerateRandomPointsAroundEntity(Transform bodyTrans, float searchRadius)
Parameters
bodyTrans Transform
searchRadius float
Returns
- List<Vector3>
GetClosest<T>(Vector3, IEnumerable<T>, Func<T, Vector3>, Func<T, bool>)
public static T GetClosest<T>(Vector3 p, IEnumerable<T> ls, Func<T, Vector3> fnPos, Func<T, bool> filter = null)
Parameters
p Vector3
ls IEnumerable<T>
fnPos Func<T, Vector3>
filter Func<T, bool>
Returns
- T
Type Parameters
T
GetClosestRigidbodyEntity(Vector3, float, out Entity, out Rigidbody, out Collider, Func<Collider, Rigidbody, Entity, bool>)
public static float GetClosestRigidbodyEntity(Vector3 center, float radius, out Entity outClosestEntity, out Rigidbody outClosestRigidbody, out Collider outCollider, Func<Collider, Rigidbody, Entity, bool> filter = null)
Parameters
center Vector3
radius float
outClosestEntity Entity
outClosestRigidbody Rigidbody
outCollider Collider
filter Func<Collider, Rigidbody, Entity, bool>
Returns
- float
GetComponentIfNull<T>(GameObject, ref T)
public static void GetComponentIfNull<T>(this GameObject gameObject, ref T component) where T : Component
Parameters
gameObject GameObject
component T
Type Parameters
T
GetDirectories(string)
public static string[] GetDirectories(this string path)
Parameters
path string
Returns
- string[]
GetEntityCharacter(Rigidbody, out EntityCharacter, out VoxelDestructor)
public static bool GetEntityCharacter(Rigidbody rb, out EntityCharacter entityCharacter, out VoxelDestructor voxelCollider)
Parameters
rb Rigidbody
entityCharacter EntityCharacter
voxelCollider VoxelDestructor
Returns
- bool
GetEntityCharacter(Rigidbody, out EntityCharacter)
public static bool GetEntityCharacter(Rigidbody rb, out EntityCharacter entityCharacter)
Parameters
rb Rigidbody
entityCharacter EntityCharacter
Returns
- bool
GetEntityCharacter(VoxelDestructor, out EntityCharacter)
public static bool GetEntityCharacter(VoxelDestructor voxelCollider, out EntityCharacter entityCharacter)
Parameters
voxelCollider VoxelDestructor
entityCharacter EntityCharacter
Returns
- bool
public static string GetHierarchyPath(Transform from, Func<Transform, bool> cond = null)
Parameters
from Transform
cond Func<Transform, bool>
Returns
- string
public static T GetOrAddComponent<T>(this Transform uo) where T : Component
Parameters
uo Transform
Returns
- T
Type Parameters
T
GetPointVelocity(Rigidbody, Vector3)
public static Vector3 GetPointVelocity(this Rigidbody rb, Vector3 worldPoint)
Parameters
rb Rigidbody
worldPoint Vector3
Returns
- Vector3
GetPrimaryVolumeCollider(Rigidbody)
public static Collider GetPrimaryVolumeCollider(Rigidbody rb)
Parameters
rb Rigidbody
Returns
- Collider
GetVoxelCollider(Rigidbody, out VoxelDestructor)
public static bool GetVoxelCollider(Rigidbody rb, out VoxelDestructor voxelCollider)
Parameters
rb Rigidbody
voxelCollider VoxelDestructor
Returns
- bool
GetVoxelData(Rigidbody, out VoxelVolume)
public static bool GetVoxelData(Rigidbody rb, out VoxelVolume vdat)
Parameters
rb Rigidbody
vdat VoxelVolume
Returns
- bool
HideLine(string)
public static void HideLine(string name)
Parameters
name string
IgnoreChildrenCollisions(GameObject, GameObject, bool)
public static void IgnoreChildrenCollisions(GameObject rbA, GameObject rbB, bool ignore)
Parameters
rbA GameObject
rbB GameObject
ignore bool
IgnoreCollision(Rigidbody, Rigidbody, bool)
public static void IgnoreCollision(Rigidbody rbA, Rigidbody rbB, bool ignore)
Parameters
rbA Rigidbody
rbB Rigidbody
ignore bool
InDistance(Vector3, Vector3, float)
public static bool InDistance(this Vector3 a, Vector3 b, float distance)
Parameters
a Vector3
b Vector3
distance float
Returns
- bool
IsFreePlaceForCharacter(Vector3, out Vector3, float)
public static bool IsFreePlaceForCharacter(Vector3 p, out Vector3 floorPoint, float rad = 0.2)
Parameters
p Vector3
floorPoint Vector3
rad float
Returns
- bool
IsPointInFrustum(Camera, Vector3)
public static bool IsPointInFrustum(this Camera camera, Vector3 worldPosition)
Parameters
camera Camera
worldPosition Vector3
Returns
- bool
IsPointInside(Collider, Vector3, float)
public static bool IsPointInside(this Collider collider, Vector3 point, float tolerance = 0.1)
Parameters
collider Collider
point Vector3
tolerance float
Returns
- bool
IsTagFloor(GameObject)
public static bool IsTagFloor(this GameObject obj)
Parameters
obj GameObject
Returns
- bool
IsVertical(Vector3)
public static bool IsVertical(this Vector3 v)
Parameters
v Vector3
Returns
- bool
IsVoxelDataReady(VoxelVolume)
public static bool IsVoxelDataReady(this VoxelVolume voxeldata)
Parameters
voxeldata VoxelVolume
Returns
- bool
IterateVoxels(int, Action<int3>)
public static void IterateVoxels(int radiusCubical, Action<int3> visitor)
Parameters
radiusCubical int
visitor Action<int3>
IterateVoxels(int3, int3, Action<int3>)
public static void IterateVoxels(int3 min, int3 max, Action<int3> visitor)
Parameters
min int3
max int3
visitor Action<int3>
IterateVoxelsSpherical(int, Action<int3, float>)
public static void IterateVoxelsSpherical(int rad, Action<int3, float> visitor)
Parameters
rad int
visitor Action<int3, float>
LoadSceneAdditive(string)
public static void LoadSceneAdditive(string sceneName)
Parameters
sceneName string
MatchToNearestValidPathfindingNode(Vector3, PathFinderGrid)
public static Vector3 MatchToNearestValidPathfindingNode(Vector3 worldPos, PathFinderGrid pathFinderGrid)
Parameters
worldPos Vector3
pathFinderGrid PathFinderGrid
Returns
- Vector3
MirrorRotationAlongZ(Quaternion)
public static Quaternion MirrorRotationAlongZ(Quaternion original)
Parameters
original Quaternion
Returns
- Quaternion
OrNull<T>(T)
public static T OrNull<T>(this T obj) where T : Object
Parameters
obj T
Returns
- T
Type Parameters
T
OverlapSphere(float3, float, Action<Collider>, int, QueryTriggerInteraction)
public static void OverlapSphere(float3 position, float radius, Action<Collider> visitor, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
Parameters
position float3
radius float
visitor Action<Collider>
layerMask int
queryTriggerInteraction QueryTriggerInteraction
PlaySound(SoundEvent, Vector3, float, SoundMixerType)
public static void PlaySound(this SoundEvent soundEvent, Vector3 position, float volumeFactor = 1, SoundManager.SoundMixerType soundMixerType = SoundMixerType.SFX)
Parameters
soundEvent SoundEvent
position Vector3
volumeFactor float
soundMixerType SoundManager.SoundMixerType
ReleaseJointRestrains(ConfigurableJoint)
public static void ReleaseJointRestrains(ConfigurableJoint cJoint)
Parameters
cJoint ConfigurableJoint
RequiresActiveOrNull<T>(T)
public static T RequiresActiveOrNull<T>(this T obj) where T : MonoBehaviour
Parameters
obj T
Returns
- T
Type Parameters
T
RotY(Quaternion)
public static Quaternion RotY(this Quaternion rot)
Parameters
rot Quaternion
Returns
- Quaternion
SetCullingLayerEnable(Camera, int, bool)
public static void SetCullingLayerEnable(Camera camera, int layer, bool enable)
Parameters
camera Camera
layer int
enable bool
SetIgnoreCollisionsBetweenGroups(Collider[], Collider[], bool)
public static void SetIgnoreCollisionsBetweenGroups(Collider[] group1, Collider[] group2, bool ignore)
Parameters
group1 Collider[]
group2 Collider[]
ignore bool
SetJointAngularMotion(ConfigurableJoint, ConfigurableJointMotion)
public static void SetJointAngularMotion(this ConfigurableJoint joint, ConfigurableJointMotion motion)
Parameters
joint ConfigurableJoint
motion ConfigurableJointMotion
SetJointLinearMotion(ConfigurableJoint, ConfigurableJointMotion)
public static void SetJointLinearMotion(this ConfigurableJoint joint, ConfigurableJointMotion motion)
Parameters
joint ConfigurableJoint
motion ConfigurableJointMotion
SetJointMotionFree(ConfigurableJoint)
public static void SetJointMotionFree(ConfigurableJoint joint)
Parameters
joint ConfigurableJoint
SetJointMotionLimited(ConfigurableJoint)
public static void SetJointMotionLimited(ConfigurableJoint joint)
Parameters
joint ConfigurableJoint
SetLayerRecursively(GameObject, int)
public static void SetLayerRecursively(GameObject go, int layer)
Parameters
go GameObject
layer int
SetRigidbodiesDetectCollision(GameObject, bool)
public static void SetRigidbodiesDetectCollision(GameObject obj, bool detect)
Parameters
obj GameObject
detect bool
public static void SetUiHeight(this RectTransform rect, float w)
Parameters
rect RectTransform
w float
SetUiNormalColor(Selectable, Color)
public static void SetUiNormalColor(this Selectable ui, Color normalColor)
Parameters
ui Selectable
normalColor Color
SetUiNormalSelectedColor(Selectable, Color)
public static void SetUiNormalSelectedColor(this Selectable ui, Color color)
Parameters
ui Selectable
color Color
public static void SetUiSize(RectTransform rect, float size, float sizeY = -1)
Parameters
rect RectTransform
size float
sizeY float
public static void SetUiSize(this RectTransform rect, Vector2 size)
Parameters
rect RectTransform
size Vector2
public static void SetUiSize(Transform rect, float size, float sizeY = -1)
Parameters
rect Transform
size float
sizeY float
public static void SetUiWidth(this RectTransform rect, float w)
Parameters
rect RectTransform
w float
public static void SetUiWidthToParentPercentage(this RectTransform rect, float percentage)
Parameters
rect RectTransform
percentage float
Snap(float, float)
public static float Snap(this float val, float unit)
Parameters
val float
unit float
Returns
- float
SnapPosition(Vector3, float)
public static Vector3 SnapPosition(this Vector3 pos, float unit)
Parameters
pos Vector3
unit float
Returns
- Vector3
SnapRotation(Quaternion, float)
public static Quaternion SnapRotation(this Quaternion rotation, float deg = 90)
Parameters
rotation Quaternion
deg float
Returns
- Quaternion
public static void StopSound(this SoundEvent soundEvent, Transform owner = null)
Parameters
soundEvent SoundEvent
owner Transform
Toggle(ref bool)
public static void Toggle(this ref bool val)
Parameters
val bool
ToVec3(int3)
public static Vector3 ToVec3(this int3 v)
Parameters
v int3
Returns
- Vector3
TrackEvent(string, GameObject, object, Dictionary<string, object>, bool?, GameObject, string)
public static void TrackEvent(string eventName, GameObject obj = null, object value = null, Dictionary<string, object> props = null, bool? active = null, GameObject targetObj = null, string valueKey = null)
Parameters
eventName string
obj GameObject
value object
props Dictionary<string, object>
active bool?
targetObj GameObject
valueKey string
public static Vector3 TransformPointYawUnscaled(this Transform trans, Vector3 pos)
Parameters
trans Transform
pos Vector3
Returns
- Vector3
TryDestroy(Object)
public static void TryDestroy(this Object obj)
Parameters
obj Object
TrySetActive(GameObject, bool)
public static void TrySetActive(this GameObject obj, bool to)
Parameters
obj GameObject
to bool
Volume(Vector3)
public static float Volume(this Vector3 v)
Parameters
v Vector3
Returns
- float