Vector
Struct Vector
Namespace: SwiftlyS2.Shared.Natives
Assembly: SwiftlyS2.CS2.dll
3-Dimensional vector for source 2.
No more cssharp chaos.
public struct VectorInherited Members
- object.Equals(object?)
- object.Equals(object?, object?)
- object.GetHashCode()
- object.GetType()
- object.ReferenceEquals(object?, object?)
- object.ToString()
Constructors
Vector(float, float, float)
public Vector(float x, float y, float z)Parameters
Vector(Vector)
public Vector(Vector other)Parameters
- other Vector
Fields
X
public float XField Value
Y
public float YField Value
Z
public float ZField Value
Properties
One
public static Vector One { get; }Property Value
Zero
public static Vector Zero { get; }Property Value
Methods
Cross(Vector)
public readonly Vector Cross(Vector other)Parameters
- other Vector
Returns
Deconstruct(out float, out float, out float)
public readonly void Deconstruct(out float x, out float y, out float z)Parameters
Deserialize(string, IFormatProvider?)
Deserializes the vector from a string. Example input: "100 200 300"
public static Vector Deserialize(string input, IFormatProvider? formatProvider = null)Parameters
- input string — Serialized vector in string.
- formatProvider IFormatProvider? — Format provider to use for the string. Null for default provider.
Returns
- Vector — Deserialized vector.
Exceptions
- FormatException — Thrown when the input string is not in the correct format.
Distance(Vector)
public readonly float Distance(Vector other)Parameters
- other Vector
Returns
Distance2D(Vector)
public readonly float Distance2D(Vector other)Parameters
- other Vector
Returns
Distance2DSquared(Vector)
public readonly float Distance2DSquared(Vector other)Parameters
- other Vector
Returns
DistanceSquared(Vector)
public readonly float DistanceSquared(Vector other)Parameters
- other Vector
Returns
Dot(Vector)
public readonly float Dot(Vector other)Parameters
- other Vector
Returns
Dot(Vector, Vector)
public static float Dot(Vector a, Vector b)Parameters
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object? obj)Parameters
- obj object? — The object to compare with the current instance.
Returns
- bool — true if
objand this instance are the same type and represent the same value; otherwise, false.
FromBuiltin(Vector3)
public static Vector FromBuiltin(Vector3 vector)Parameters
- vector Vector3
Returns
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()Returns
- int — A 32-bit signed integer that is the hash code for this instance.
Length()
public readonly float Length()Returns
Length2D()
public readonly float Length2D()Returns
Length2DSquared()
public readonly float Length2DSquared()Returns
LengthSquared()
public readonly float LengthSquared()Returns
Normalize()
public void Normalize()Normalize2D()
public void Normalize2D()Normalized()
public readonly Vector Normalized()Returns
Normalized2D()
public readonly Vector Normalized2D()Returns
Serialize(IFormatProvider?)
Serializes the vector to a string. Example return: "100 200 300"
public readonly string Serialize(IFormatProvider? formatProvider = null)Parameters
- formatProvider IFormatProvider? — Format provider to use for the string. Null for default provider.
Returns
- string — Serialized vector in string.
ToBuiltin()
public readonly Vector3 ToBuiltin()Returns
ToQAngles()
Converts this forward vector into Euler QAngles (pitch, yaw, roll).
Usage: forward.ToQAngles(out var angles);
public readonly QAngle ToQAngles()Returns
- QAngle — Resulting SwiftlyS2.Shared.Natives.QAngle.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()Returns
- string — The fully qualified type name.
TryDeserialize(string?, out Vector)
Tries to deserialize the vector from a string. Example input: "100 200 300"
public static bool TryDeserialize(string? input, out Vector vector)Parameters
Returns
- bool — True if the deserialization was successful, false otherwise.
TryDeserialize(string?, IFormatProvider?, out Vector)
Tries to deserialize the vector from a string. Example input: "100 200 300"
public static bool TryDeserialize(string? input, IFormatProvider? formatProvider, out Vector vector)Parameters
- input string? — Serialized vector in string.
- formatProvider IFormatProvider? — Format provider to use for the string. Null for default provider.
- vector Vector — Deserialized vector.
Returns
- bool — True if the deserialization was successful, false otherwise.
Operators
operator +(Vector, Vector)
public static Vector operator +(Vector a, Vector b)Parameters
Returns
operator /(Vector, Vector)
public static Vector operator /(Vector a, Vector b)Parameters
Returns
operator /(Vector, float)
public static Vector operator /(Vector a, float b)Parameters
Returns
operator ==(Vector, Vector)
public static bool operator ==(Vector a, Vector b)Parameters
Returns
operator !=(Vector, Vector)
public static bool operator !=(Vector a, Vector b)Parameters
Returns
operator *(Vector, Vector)
public static Vector operator *(Vector a, Vector b)Parameters
Returns
operator *(Vector, float)
public static Vector operator *(Vector a, float b)Parameters
Returns
operator *(float, Vector)
public static Vector operator *(float b, Vector a)Parameters
Returns
operator -(Vector, Vector)
public static Vector operator -(Vector a, Vector b)Parameters
Returns
operator -(Vector)
public static Vector operator -(Vector a)Parameters
- a Vector
Returns