示例#1
0
 private void Awake()
 {
     SetUpDirectories();
     TextureFinder.AssignAllTextureDetails();
     RegionCollection.regionCollectionPrefab = (GameObject)Resources.Load("Region Collection");
     RegionCollection.CreateRegionCollection(new Vector3(-20, 20, -20), Vector3.zero, new IntVec3(3, 3, 3), "Test Region 1");
 }
示例#2
0
        public static RegionCollection CreateRegionCollection(Vector3 position, Vector3 eularAngles, IntVec3 dimensions, string name)
        {
            GameObject       regionCollectionObj = (GameObject)Instantiate(regionCollectionPrefab);
            RegionCollection regionCollection    = regionCollectionObj.GetComponent <RegionCollection>();

            regionCollection.Initialise(position, eularAngles, dimensions, name);
            return(regionCollection);
        }
示例#3
0
 public void Initialise(IntVec3 dataPosition, RegionCollection regionCollection)
 {
     gameObject.name         = (string)dataPosition + " Concave Collider";
     gameObject.layer        = LayerMask.NameToLayer("Region Collection");
     _regionCollection       = regionCollection;
     transform.parent        = regionCollection.transform.GetChild(0);
     transform.localRotation = new Quaternion();
     transform.localPosition = (Vector3)dataPosition * VoxelData.SIZE;
     _collider = GetComponent <MeshCollider>();
 }
示例#4
0
        public void Initialise(IntVec3 dataPosition, RegionCollection regionCollection)
        {
            gameObject.name = (string)dataPosition;
            renderer.material.mainTexture = TextureFinder.regionTexture;
            _voxelData      = new VoxelData(dataPosition, regionCollection.collectionDirectory);
            _meshGenerator  = new MeshGenerator();
            _mesh           = GetComponent <MeshFilter>().mesh;
            _convexCollider = GetComponent <MeshCollider>();

            _regionCollection       = regionCollection;
            transform.parent        = regionCollection.transform.GetChild(1);
            transform.localRotation = new Quaternion();
            transform.localPosition = (Vector3)dataPosition * VoxelData.SIZE;

            _concaveCollider = ((GameObject)Instantiate(_concaveColliderPrefab)).GetComponent <ConcaveCollider>();
            _concaveCollider.Initialise(dataPosition, regionCollection);
        }
示例#5
0
 private void LateUpdate()
 {
     lock (_dataPositionArrays)
     {
         while (_dataPositionArrays.Count > 0)
         {
             IntVec3[] positions = _dataPositionArrays.Dequeue();
             Block[]   data      = _dataArrays.Dequeue();
             _breakOffs++;
             RegionCollection regionCollection = RegionCollection.CreateRegionCollection(_convexShapes.position, _convexShapes.eulerAngles, _dimensions, string.Format("{0} Break Off {1}", name, _breakOffs));
             for (int i = 0; i < positions.Length; i++)
             {
                 VoxelEdit.SetAt(regionCollection, positions[i], data[i]);
             }
             Rigidbody newRigidbody = regionCollection.transform.GetChild(1).rigidbody;
             newRigidbody.centerOfMass = _convexShapes.rigidbody.centerOfMass;
             newRigidbody.velocity     = _convexShapes.rigidbody.velocity;
             newRigidbody.rigidbody.angularVelocity = _convexShapes.rigidbody.angularVelocity;
         }
     }
 }
示例#6
0
        private void ChangeAtCursor()
        {
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Region Collection")))
            {
                RegionCollection regionCollection = hit.collider.GetComponent <ConcaveCollider>().GetRegionCollection();
                Vector3          position         = hit.point + (hit.normal * -0.5f) + regionCollection.transform.GetChild(0).up;
                IntVec3          changePosition   = VoxelEdit.WorldToDataPosition(regionCollection, position);
                VoxelEdit.SetAt(regionCollection, changePosition, new Block());

                List <IntVec3> points = new List <IntVec3>(6)
                {
                    changePosition + IntVec3.right,
                    changePosition + IntVec3.left,
                    changePosition + IntVec3.forward,
                    changePosition + IntVec3.back,
                    changePosition + IntVec3.up,
                    changePosition + IntVec3.down
                };
                VoxelEdit.CheckCollectionSplit(regionCollection, points);
            }
        }