/// <summary> /// Constructor for a ReconfigurationRequest for a given space, with instructions for /// Area and Connectivity reconfiguration. /// [+1] = Increase /// [-1] = Decrese /// [0] = Don't change /// </summary> /// <param name="space">The space that should be reconfigured</param> /// <param name="areaDirection">The direction for the area reconfiguration</param> /// <param name="connectivityDirection"></param> public ReconfigurationRequest(PPSpace space, int areaDirection, int connectivityDirection) { space.ValidateSpace(); SpaceId = space.SpaceId; SpaceName = space.Name; _spaceCenter = new Vector3Int((int)space.GetCenter().x, 0, (int)space.GetCenter().z); CurrentIndices = space.Indices.ToArray(); //Area defined by the Voxel count int currentArea = space.VoxelCount; //Conectivity defined by the number of connections [voxels] int currentConnectivity = space.NumberOfConnections; space.ArtificialReconfigureRequest(areaDirection, connectivityDirection); //Set the target area if (areaDirection == 1) { TargetArea = currentArea + _areaModifier; } else if (areaDirection == -1) { TargetArea = currentArea - _areaModifier; } else if (areaDirection == 0) { TargetArea = 0; } //Set the target connections if (connectivityDirection == 1) { TargetConnections = currentConnectivity + _connectivityModifier; } else if (connectivityDirection == -1) { TargetConnections = currentConnectivity - _connectivityModifier; } else if (connectivityDirection == 0) { TargetConnections = 0; } _agents2Reconfigure = space.BoundaryParts.Select(p => p.CPAgent).ToArray(); foreach (var part in _agents2Reconfigure) { part.ClearRequest(); part.SetRequest(this); } //UnfreezeRandomAgent(); UnfreezeAgents(); }
public void SetSpace(PPSpace space, VoxelGrid grid) { _space = space; transform.position = _space.GetCenter() + (new Vector3(0, 1.5f, 0) * grid.VoxelSize); }