reckfellENGINE

Rid

A server resource handle value; neither an owner nor a resource-existence check.

On this page
struct RidReckfellSharpInherits ValueType

Rid is a struct containing an Id value. default(Rid) has Id = 0. Copying the value does not extend server-object lifetime. IsValid checks only Id != 0; FreeRid does not clear saved copies.

Release only server objects you created, using the appropriate server. A Rid obtained from Resource.GetRid() is borrowed: do not call FreeRid on it yourself. A saved RID does not keep the Resource itself alive either.

The complete synchronous example below creates a temporary PhysicsServer2D space. Use takes Action<Rid>, releases its space in finally and propagates callback exceptions to its caller. The callback borrows the handle only until it returns: do not free or retain it, and do not pass an async lambda.

C#
using System;
using Reckfell;

public static class TemporaryPhysicsSpace
{
    // The callback borrows the handle until it returns; it must not free or retain it.
    public static void Use(Action<Rid> action)
    {
        ArgumentNullException.ThrowIfNull(action);
        Rid owned = PhysicsServer2D.SpaceCreate();
        if (!owned.IsValid)
            throw new InvalidOperationException("Could not create a physics space.");
        try
        {
            action(owned);
        }
        finally
        {
            PhysicsServer2D.FreeRid(owned);
            owned = default;
        }
    }
}

Working with servers.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

RidConstructor
# Rid
C#
public Rid(ReckfellObject from);

For a Resource, reads its existing handle through GetRid(). For another object type, including null at runtime, produces a zero RID. Does not create a server resource, duplicate the Resource or transfer ownership. Not every Resource supplies a nonzero RID.

Parameters
NameTypeDefault
fromReckfellObject—
from

Resource whose GetRid() is read. An ordinary Entity is not converted to its server object by this constructor.

Properties2

IdProperty
# Id
C#
public ulong Id { get; }

Opaque 64-bit identifier; default(Rid) has value 0. This number is not an asset path, Entity ID or proof that a resource exists. Do not persist it as a reference between runs.

IsValidProperty
# IsValid
C#
public bool IsValid { get; }

Returns Id != 0. Does not query the server or check object existence, type or ownership. A saved copy can still return true after FreeRid; reset your own variable to default after release.

Methods6

Equals2 overloads
# Equals · 1/2
C#
public bool Equals(Rid other);

Compares the numeric Id values. Two zero RIDs are equal; equal nonzero values do not establish that the corresponding object still exists.

Parameters
NameTypeDefault
otherRid—
other

RID value to compare; no server query is made.

Returns bool

true when the Id values match; otherwise false.

# Equals · 2/2
C#
public override bool Equals(object? obj);

Returns true only when obj is a boxed Rid with the same Id. Null, a ulong with the same number and a string containing the RID representation are not equal to this value.

Parameters
NameTypeDefault
objobject—
obj

Object to check for Rid type and value.

Returns bool

true for a Rid with the same Id; false for another Id, another type or null.

GetHashCodeint
# GetHashCode
C#
public override int GetHashCode();

Computes HashCode.Combine(Id) for C# collections. Equal values have equal hashes within the current process; different values can collide. Do not use it as a persistent identifier or a resource-existence check.

Returns int

32-bit hash of Id; stability between runs is not guaranteed.

ToStringstring
# ToString
C#
public override string ToString();

Creates RID(<Id>) with the decimal Id formatted using invariant culture; the zero value is RID(0). This is a diagnostic representation, not resource serialization or a way to restore the resource.

Returns string

Diagnostic string such as RID(123); the current culture does not change the Id format.

op_Equalitybool
# op_Equality
C#
public static bool operator ==(Rid left, Rid right);

Checks equality of the numeric Id values without querying the server. Comparison neither checks resource existence nor transfers ownership.

Parameters
NameTypeDefault
leftRid—
rightRid—
left

Left RID value.

right

Right RID value.

Returns bool

true when the Id values match; otherwise false.

op_Inequalitybool
# op_Inequality
C#
public static bool operator !=(Rid left, Rid right);

Checks inequality of the numeric Id values without querying the server. Comparison neither checks resource existence nor transfers ownership.

Parameters
NameTypeDefault
leftRid—
rightRid—
left

Left RID value.

right

Right RID value.

Returns bool

true when the Id values differ; otherwise false.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.