Files
RobustToolbox/Robust.Shared/ViewVariables/ViewVariablesManagerShared.cs
T
SilverandGitHub 25926a17b7 Renames SS14.* to Robust.* (#793)
RobustToolbox projects should be named Robust.* 

This PR changes the RobustToolbox projects from SS14.* to Robust.*

Updates SS14.* prefixes/namespaces to Robust.*
Updates SpaceStation14.sln to RobustToolbox.sln
Updates MSBUILD/SS14.* to MSBUILD/Robust.*
Updates CSProject and MSBuild references for the above
Updates git_helper.py
Removes Runserver and Runclient as they are unusable
2019-04-15 20:24:59 -06:00

42 lines
1.3 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Robust.Shared.Interfaces.GameObjects;
namespace Robust.Shared.ViewVariables
{
internal class ViewVariablesManagerShared
{
private readonly Dictionary<Type, HashSet<object>> _cachedTraits = new Dictionary<Type, HashSet<object>>();
/// <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;
}
}
}