Skip to main content

EntityIOValue

Typed accessor for the variant value carried by an entity I/O input or output hook.

public readonly struct EntityIOValue

Namespace: DeadworksManaged.Api
Source: Events/EntityIOValue.cs#L13

Notes​

Holds a pointer to the native variant_t for the duration of the hook callback. Do not retain an EntityIOValue past the callback's return — the native pointer becomes invalid. If you need to retain the value, call the typed accessor (e.g. AsString) immediately and store the result.

Properties​

EntityIOValue.Type​

The Source 2 field type of the underlying variant. FieldType.Void for null variants.

Signature

public FieldType Type { get; }

Source: Events/EntityIOValue.cs#L21

EntityIOValue.IsNull​

True if the variant is null or holds no value.

Signature

public bool IsNull { get; }

Source: Events/EntityIOValue.cs#L24

EntityIOValue.Empty​

Empty/null variant value (no underlying native pointer).

Signature

public static EntityIOValue Empty { get; }

Source: Events/EntityIOValue.cs#L94

Methods​

EntityIOValue.AsString()​

Returns the value as a string using Source 2's built-in formatter. Works for any variant type.

Signature

public string AsString()

Source: Events/EntityIOValue.cs#L27

EntityIOValue.AsInt()​

Converts the variant to a 32-bit signed integer. Returns 0 if the conversion is not supported.

Signature

public int AsInt()

Source: Events/EntityIOValue.cs#L34

EntityIOValue.AsInt64()​

Converts the variant to a 64-bit signed integer. Returns 0 if the conversion is not supported.

Signature

public long AsInt64()

Source: Events/EntityIOValue.cs#L37

EntityIOValue.AsUInt()​

Converts the variant to a 32-bit unsigned integer.

Signature

public uint AsUInt()

Source: Events/EntityIOValue.cs#L40

EntityIOValue.AsFloat()​

Converts the variant to a 32-bit float. Returns 0 if the conversion is not supported.

Signature

public float AsFloat()

Source: Events/EntityIOValue.cs#L43

EntityIOValue.AsDouble()​

Converts the variant to a 64-bit float. Returns 0 if the conversion is not supported.

Signature

public double AsDouble()

Source: Events/EntityIOValue.cs#L46

EntityIOValue.AsBool()​

Converts the variant to a boolean.

Signature

public bool AsBool()

Source: Events/EntityIOValue.cs#L49

EntityIOValue.AsVector3()​

Reads the variant as a 3D vector (Vector, QAngle, PositionVector). Returns zero for other types.

Signature

public Vector3 AsVector3()

Source: Events/EntityIOValue.cs#L52

EntityIOValue.AsVector2()​

Reads the variant as a 2D vector. Returns zero for other types.

Signature

public Vector2 AsVector2()

Source: Events/EntityIOValue.cs#L60

EntityIOValue.AsVector4()​

Reads the variant as a 4D vector or quaternion. Returns zero for other types.

Signature

public Vector4 AsVector4()

Source: Events/EntityIOValue.cs#L68

EntityIOValue.AsColor()​

Reads the variant as an RGBA color. Returns transparent black for non-color variants.

Signature

public Color AsColor()

Source: Events/EntityIOValue.cs#L76

EntityIOValue.AsEntity()​

Resolves the variant as a CBaseEntity. Returns null for non-ehandle variants or invalid handles.

Signature

public CBaseEntity? AsEntity()

Source: Events/EntityIOValue.cs#L87