Skip to content

Commit

Permalink
Better component registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
genaray committed Nov 26, 2023
1 parent 7a9bad5 commit 3480086
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Arch/Core/Utils/CompileTimeStatics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,21 @@ private static ComponentType Add(Type type, int typeSize)
}

/// <summary>
/// Adds a new <see cref="ComponentType"/> manually and registers it.
/// <remarks>You should only be using this when you exactly know what you are doing.</remarks>
/// Adds a new <see cref="ComponentType"/> by its <see cref="Type"/> manually and registers it.
/// <remarks>Dangerous, does not check if the <see cref="Type"/> and <see cref="ComponentType"/> was registered yet.</remarks>
/// </summary>
/// <param name="type">Its <see cref="Type"/>.</param>
/// <param name="componentType">The <see cref="ComponentType"/>.</param>
/// <returns>Its <see cref="ComponentType"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ComponentType Add(ComponentType type)
public static ComponentType Add(Type type, ComponentType componentType)
{
// Register and assign component id
_typeToComponentType.Add(type, type);
_types = _types.Add(type.Id, type.Type);
_typeToComponentType.TryAdd(type, componentType);
_types = _types.Add(componentType.Id, type);

Size++;
return type;
return componentType;
}

/// <summary>
Expand Down

0 comments on commit 3480086

Please sign in to comment.