Exemple #1
0
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            if (_rootNode != null && _rootNode.GetComponent <StopConvertToEntity>() == null)
            {
                _rootNode.gameObject.AddComponent <StopConvertToEntity>();
            }

            var blob = _file != null?_file.ToBlob() : _rootNode.ToBlob();

            entity.AddBehaviorTree(dstManager, blob, _thread);

            if (_autoAddBehaviorTreeComponents)
            {
                var accessTypes = dstManager.HasComponent <BlackboardDataQuery>(entity)
                    ? dstManager.GetSharedComponentData <BlackboardDataQuery>(entity).Value
                    : blob.GetAccessTypes()
                ;

                foreach (var componentType in accessTypes)
                {
                    if (dstManager.HasComponent(entity, componentType))
                    {
                        continue;
                    }
                    var type      = TypeManager.GetType(componentType.TypeIndex);
                    var attribute = type?.GetCustomAttribute <BehaviorTreeComponentAttribute>();
                    if (attribute == null)
                    {
                        continue;
                    }
                    dstManager.AddComponent(entity, componentType);
                }
            }
        }
        public async void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            if (!enabled)
            {
                return;
            }

            var blob = await _source.GetBlobAsset();

            var blobRef = new NodeBlobRef(blob);

            entity.AddBehaviorTree(dstManager, blobRef, _order, _autoCreateTypes, _thread, _debugName);
        }
Exemple #3
0
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            if (!enabled)
            {
                return;
            }

            if (_rootNode != null && _rootNode.GetComponent <StopConvertToEntity>() == null)
            {
                _rootNode.gameObject.AddComponent <StopConvertToEntity>();
            }

            var blob = _file != null?_file.ToBlob() : _rootNode.ToBlob();

            var blobRef = new NodeBlobRef {
                BlobRef = blob
            };

            entity.AddBehaviorTree(dstManager, blobRef, _thread);

            if (_autoCreateTypes != 0)
            {
                var accessTypes = dstManager.HasComponent <BlackboardDataQuery>(entity)
                    ? dstManager.GetSharedComponentData <BlackboardDataQuery>(entity).Set
                    : blobRef.GetAccessTypes()
                ;

                foreach (var componentType in accessTypes)
                {
                    if (dstManager.HasComponent(entity, componentType))
                    {
                        continue;
                    }
                    var shouldCreate =
                        HasFlag(AutoCreateType.ReadOnly) && componentType.AccessModeType == ComponentType.AccessMode.ReadOnly ||
                        HasFlag(AutoCreateType.ReadWrite) && componentType.AccessModeType == ComponentType.AccessMode.ReadWrite ||
                        HasFlag(AutoCreateType.BehaviorTreeComponent) && TypeManager.GetType(componentType.TypeIndex)?.GetCustomAttribute <BehaviorTreeComponentAttribute>() != null
                    ;
                    if (shouldCreate)
                    {
                        dstManager.AddComponent(entity, componentType);
                    }
                }
            }
        }