mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-07 02:08:17 +02:00
* Removed the Interfaces folder. * All objects inside the GameObjects subfolders are now in the GameObjects namespace. * Added a Resharper DotSettings file to mark the GameObjects subfolders as not providing namespaces. * Simplified Robust.client.Graphics namespace. * Automated remove redundant using statements.
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Robust.Shared.ViewVariables
|
|
{
|
|
internal class ViewVariablesManagerShared
|
|
{
|
|
private readonly Dictionary<Type, HashSet<object>> _cachedTraits = new();
|
|
|
|
/// <summary>
|
|
/// Figures out which VV traits an object type has. This method is in shared so the client and server agree on this mess.
|
|
/// </summary>
|
|
/// <seealso cref="ViewVariablesBlobMetadata.Traits"/>
|
|
public ICollection<object> TraitIdsFor(Type type)
|
|
{
|
|
if (!_cachedTraits.TryGetValue(type, out var traits))
|
|
{
|
|
traits = new HashSet<object>();
|
|
_cachedTraits.Add(type, traits);
|
|
if (ViewVariablesUtility.TypeHasVisibleMembers(type))
|
|
{
|
|
traits.Add(ViewVariablesTraits.Members);
|
|
}
|
|
|
|
if (typeof(IEnumerable).IsAssignableFrom(type))
|
|
{
|
|
traits.Add(ViewVariablesTraits.Enumerable);
|
|
}
|
|
|
|
if (typeof(IEntity).IsAssignableFrom(type))
|
|
{
|
|
traits.Add(ViewVariablesTraits.Entity);
|
|
}
|
|
}
|
|
|
|
return traits;
|
|
}
|
|
}
|
|
}
|