/// <summary> /// Constructs a new Cube struct. /// </summary> /// <param name="_parent">Parent of this cube</param> /// <param name="_type">Type of this cube</param> /// <param name="_x">X Coordinate of this cube's position</param> /// <param name="_y">Y Coordinate of this cube's position</param> /// <param name="_z">Z Coordinate of this cube's position</param> public Cube(CubeTracker _parent, ItemBase.tOreType _type, int _x, int _y, int _z) : this() { Parent = _parent; Type = _type; X = _x; Y = _y; Z = _z; }
void LoadCamCubes() { Debug.Log(String.Format("Cube: ({0},{1},{2})", cubeCamPos.X, cubeCamPos.Y, cubeCamPos.Z)); var cubeCamVector = new Vector3(cubeCamPos.X + 0.5f, cubeCamPos.Y + 0.5f, cubeCamPos.Z + 0.5f); var minVector = cubeCamVector - Vector3.one; var maxVector = cubeCamVector + Vector3.one; //minVector.z = 0f; // HACK: Hit the ground to see reference var octIntCubes = pyriteLevel.Octree.AllIntersections(new BoundingBox(minVector, maxVector)); int cubeCounter = 0; foreach (var i in octIntCubes) { cubeCounter++; var pCube = CreateCubeFromCubeBounds(i.Object); var cubePos = pyriteLevel.GetWorldCoordinatesForCube(pCube); // Setup object at cube location if(cubeDict.ContainsKey(pCube.GetKey())) { var cube = cubeDict[pCube.GetKey()]; cubeList.Remove(cube); cubeList.AddFirst(cube); if (!cube.Active) { cube.Active = true; // TODO: Re-activate cube } } else { CubeTracker ct; // TODO: Create GameObject var gObj = Instantiate(LocatorCube, cubePos, Quaternion.identity) as GameObject; if(cubeList.Count < MaxListCount) { ct = new CubeTracker(pCube.GetKey(), null); } else { // Reuse Last CubeTracker Debug.Log("Reusing Cube"); ct = cubeList.Last.Value; cubeList.RemoveLast(); cubeDict.Remove(ct.DictKey); ct.DictKey = pCube.GetKey(); // TODO: Reassign GameObject Content instead of destroying Destroy(ct.gameObject); if(ct.Active) { Debug.Log("ALERT: Active Object in List Tail"); } } gObj.transform.parent = gameObject.transform; ct.gameObject = gObj; ct.Active = true; cubeList.AddFirst(ct); cubeDict.Add(ct.DictKey, ct); } } Debug.Log(String.Format("CubeCounter: {0} CubeList/Dict: {1}/{2}", cubeCounter, cubeList.Count, cubeDict.Count)); foreach (var q in cubeList.Skip(cubeCounter).TakeWhile(q => q.Active)) { q.Active = false; } }