static SentinelNativeStrategy()
 {
     if (TypeType.isUnmanaged <T>() == false)
     {
         throw new DBC.Common.PreconditionException("Only unmanaged data can be stored natively");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Note: static constructors are NOT compiled by burst as long as there are no static fields in the struct
        /// </summary>
        static NB()
        {
#if ENABLE_DEBUG_CHECKS
            if (TypeType.isUnmanaged <T>() == false)
            {
                throw new Exception("NativeBuffer (NB) supports only unmanaged types");
            }
#endif
        }
Beispiel #3
0
        static ComponentBuilder()
        {
            ENTITY_COMPONENT_TYPE    = typeof(T);
            DEFAULT_IT               = default;
            IS_ENTITY_VIEW_COMPONENT = typeof(IEntityViewComponent).IsAssignableFrom(ENTITY_COMPONENT_TYPE);
#if SLOW_SVELTO_SUBMISSION
            HAS_EGID      = typeof(INeedEGID).IsAssignableFrom(ENTITY_COMPONENT_TYPE);
            HAS_REFERENCE = typeof(INeedEntityReference).IsAssignableFrom(ENTITY_COMPONENT_TYPE);

            SetEGIDWithoutBoxing <T> .Warmup();
#endif
            ComponentID <T> .Init();

            ENTITY_COMPONENT_NAME = ENTITY_COMPONENT_TYPE.ToString();
            IS_UNMANAGED          = TypeType.isUnmanaged <T>(); //attention this is important as it serves as warm up for Type<T>
#if UNITY_NATIVE
            if (IS_UNMANAGED)
            {
                EntityComponentIDMap.Register <T>(new Filler <T>());
            }
#endif

            ComponentBuilderUtilities.CheckFields(ENTITY_COMPONENT_TYPE, IS_ENTITY_VIEW_COMPONENT);

            if (IS_ENTITY_VIEW_COMPONENT)
            {
                EntityViewComponentCache.InitCache();
            }
            else
            {
                if (ENTITY_COMPONENT_TYPE != ComponentBuilderUtilities.ENTITY_INFO_COMPONENT &&
                    ENTITY_COMPONENT_TYPE.IsUnmanagedEx() == false)
                {
                    throw new Exception(
                              $"Entity Component check failed, unexpected struct type (must be unmanaged) {ENTITY_COMPONENT_TYPE}");
                }
            }
        }
Beispiel #4
0
 static Filler()
 {
     DBC.ECS.Check.Require(TypeType.isUnmanaged <T>() == true, "invalid type used");
 }