Exemplo n.º 1
0
        private VisualPartRuntime Instantiate()
        {
            string newName = string.Format("New Visual Part {0}", _internalCounter);

            _internalCounter++;
            return(VisualPartRuntime.Create(transform, newName));
        }
Exemplo n.º 2
0
        public void GenerateRuntimeMesh()
        {
            HUtils.log();

//		    Debug.Log("GenerateRuntimeMesh");
            if (!isLegal)
            {
                Debug.LogWarning("Illegal Runtime Volume. Base points likely intersect");
                for (int p = 0; p < numberOfPoints; p++)
                {
                    Debug.Log(this[p].position.vector3XY);
                }
            }
            if (visualPart == null)
            {
                _visualPart = VisualPartRuntime.GetPoolItem();
            }
            _visualPart.GenerateFromDynamicMesh();
            for (int f = 0; f < _interiorFloorplans.Count; f++)
            {
                _interiorFloorplans[f].GenerateRuntimeMesh();
                _interiorFloorplans[f].transform.parent        = transform;
                _interiorFloorplans[f].transform.localPosition = Vector3.zero;
            }
        }
Exemplo n.º 3
0
 public void GenerateRuntimeMesh()
 {
     if (visualPart == null)
     {
         _visualPart = VisualPartRuntime.GetPoolItem();
     }
     _visualPart.GenerateFromDynamicMesh();
 }
Exemplo n.º 4
0
 public void Clear()
 {
     if (_visualPart != null)
     {
         _visualPart.Deactivate();
         VisualPartRuntimePool.Instance.Push(_visualPart);
     }
     _visualPart = null;
 }
Exemplo n.º 5
0
 public void Push(VisualPartRuntime item)
 {
     if (!_initialised)
     {
         Init();
     }
     item.transform.parent = transform;
     _pool.Add(item);
 }
Exemplo n.º 6
0
        public VisualPartRuntime Pull()
        {
            if (!_initialised)
            {
                Init();
            }
            VisualPartRuntime output = GetPoolItem();

            output.Activate();
            return(output);
        }
Exemplo n.º 7
0
        public void GenerateFromDynamicMesh(BuildRMesh overflow = null)
        {
            HUtils.log();

            if (_dynamicMesh.vertexCount == 0)
            {
                return;
            }
            if (_mesh == null)
            {
                _mesh = new Mesh();
            }
            if (_filter == null)
            {
                _filter = gameObject.AddComponent <MeshFilter>();
            }
            if (_renderer == null)
            {
                _renderer = gameObject.AddComponent <MeshRenderer>();
            }
            if (overflow != null)
            {
                _dynamicMesh = overflow;
            }
            _dynamicMesh.Build(_mesh);
            _filter.sharedMesh        = _mesh;
            _renderer.sharedMaterials = _dynamicMesh.materials.ToArray();


            if (_dynamicMesh.hasOverflowed)
            {
                if (_sibling == null)
                {
                    _sibling = GetPoolItem();
                }
                _sibling.GenerateFromDynamicMesh(_dynamicMesh.overflow);
            }
            else
            {
                if (_sibling != null)
                {
                    _sibling.Deactivate();
                    VisualPartRuntimePool.Instance.Push(_sibling);
                }
                _sibling = null;
            }

            if (_colliderPart == null)
            {
                _colliderPart = ColliderPartRuntime.GetPoolItem();
                _colliderPart.GenerateFromColliderMesh(_colliderMesh);
            }
        }
Exemplo n.º 8
0
 private VisualPartRuntime GetPoolItem()
 {
     if (_pool.Count > 0)
     {
         VisualPartRuntime output = _pool[0];
         _pool.RemoveAt(0);
         return(output);
     }
     else
     {
         return(Instantiate());               //there was nothing suitable in the pool - make a new one!
     }
 }
Exemplo n.º 9
0
        public void Clear()
        {
            if (_visualPart != null)
            {
                _visualPart.Deactivate();
                VisualPartRuntimePool.Instance.Push(_visualPart);
            }
            _visualPart = null;

            for (int f = 0; f < _interiorFloorplans.Count; f++)
            {
                _interiorFloorplans[f].Clear();
            }

            _interiorFloorplans.Clear();
        }
Exemplo n.º 10
0
        public static VisualPartRuntime Create(Transform parent = null, string name = "visual part")
        {
            HUtils.log();

            GameObject go = new GameObject(name);

            if (parent != null)
            {
                go.transform.parent = parent;
            }
            VisualPartRuntime output = go.AddComponent <VisualPartRuntime>();

            output.Init();
            output.Deactivate();
            return(output);
        }
Exemplo n.º 11
0
        public void Deactivate()
        {
            HUtils.log();

            _filter.sharedMesh        = null;
            _renderer.sharedMaterials = new Material[0];
            _renderer.enabled         = false;

            _mesh.Clear(false);
            _mesh = null;

            if (_sibling != null)
            {
                _sibling.Deactivate();
                VisualPartRuntimePool.Instance.Push(_sibling);
                _sibling = null;
            }
        }