Show / Hide Table of Contents

Class UniversalIDs

Management of objects with a universal id. Tracks them and allows finding by ID.

Inheritance
System.Object
UniversalIDs
Namespace: Eco.Core.Systems
Assembly: Eco.Core.dll
Syntax
public static class UniversalIDs : Object

Properties

AllObjects

Declaration
public static IEnumerable<IHasUniversalID> AllObjects { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<IHasUniversalID>

Methods

ClaimID(IHasUniversalID, Int32)

Claims id for obj. Can only be used when serialized IDs loaded and if object doesn't yet have an ID.

Declaration
public static void ClaimID(this IHasUniversalID obj, int id)
Parameters
Type Name Description
IHasUniversalID obj
System.Int32 id

Clean()

Remove entries whose weak-references no longer point to anything.

Declaration
public static void Clean()

GetOrCreateID(IHasUniversalID)

Get the ID, assigning a new one if none is set yet.

Declaration
public static int GetOrCreateID(this IHasUniversalID obj)
Parameters
Type Name Description
IHasUniversalID obj
Returns
Type Description
System.Int32

GetOrNull(Int32)

Return the IHasUniversalID with the given ID, or null if it's not found.

Declaration
public static IHasUniversalID GetOrNull(int id)
Parameters
Type Name Description
System.Int32 id
Returns
Type Description
IHasUniversalID

GetOrNull<T>(Int32)

Return the object with the given ID, cast to expected Type T. Returns null if not found or different type than expected.

Declaration
public static T GetOrNull<T>(int id)
    where T : class, IHasUniversalID
Parameters
Type Name Description
System.Int32 id
Returns
Type Description
T
Type Parameters
Name Description
T

Load(IEnumerable<IHasUniversalID>)

Loads objects to UniversalIDs storage.

Declaration
public static void Load(IEnumerable<IHasUniversalID> objs)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<IHasUniversalID> objs

Remove(IHasUniversalID)

Declaration
public static void Remove(IHasUniversalID obj)
Parameters
Type Name Description
IHasUniversalID obj

TryGetByID(Int32, out IHasUniversalID)

Get the object of the given ID. It may fail if the weak reference has expired on a deleted object, in which case false is returned.

Declaration
public static bool TryGetByID(int id, out IHasUniversalID val)
Parameters
Type Name Description
System.Int32 id
IHasUniversalID val
Returns
Type Description
System.Boolean
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾