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 BlobAssetReference <NodeBlob> GetBlobAsset() { var isPrefab = Root.gameObject.IsPrefab(); if (!isPrefab && !Root.GetComponent <StopConvertToEntity>()) { Root.gameObject.AddComponent <StopConvertToEntity>(); } var blob = Root.ToBlob(); if (!isPrefab && AutoDestroy) { UnityEngine.Object.Destroy(Root.gameObject); } return(blob); }
public Task <BlobAssetReference <NodeBlob> > GetBlobAsset() { var isPrefab = Root.gameObject.IsPrefab(); if (!isPrefab && !Root.GetComponent <StopConvertToEntity>()) { Root.gameObject.AddComponent <StopConvertToEntity>(); } var task = Task.FromResult(Root.ToBlob()); if (!isPrefab && AutoDestroy) { Object.Destroy(Root.gameObject); } return(task); }
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); } } } }