#1046·Entitas

Add TryGet to entities code generator to get components

Author: pereviader-popcoreCreated Nov 9, 2022Updated Jul 7, 2023

Is your feature request related to a problem? Please describe. Internally the entity.potato calls entity.hasPotato , so this would make it a tad faster by avoiding some branching and getting the component directly.

Describe the solution you'd like From:

csharp
if(entity.hasPotato)
{
   var potato = entity.potato;
   ...
}

To:

csharp
if(entity.TryGetPotato(out var potato))
{
    ...
}