public void UpdateDebugObject(VoxelVisualComponent component)
    {
        if (debugObjects.ContainsKey(component))
        {
            debugObjects[component].mesh            = component.Contents.Mesh;
            debugObjects[component].gameObject.name = GetObjName(component);
            component.SetComponentTransform(debugObjects[component].GetComponent <MeshRenderer>().material);
        }
        else
        {
            if (component.Contents == null || component.Contents.Mesh == null)
            {
                return;
            }
            GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
            obj.name = GetObjName(component);
            GameObject.Destroy(obj.GetComponent <BoxCollider>());
            MeshFilter   filter   = obj.GetComponent <MeshFilter>();
            MeshRenderer renderer = obj.GetComponent <MeshRenderer>();
            Material     mat      = new Material(voxelDisplayMat);
            component.SetComponentTransform(mat);
            renderer.material = mat;
            debugMats.Add(new Tuple <Material, VoxelVisualComponent>(mat, component));

            filter.mesh            = component.Contents.Mesh;
            obj.transform.position = component.ContentPosition;
            debugObjects.Add(component, filter);
            obj.transform.SetParent(piecesRoot, false);
        }
    }
        public SolverState GetWithModification(VoxelVisualComponent component, VoxelVisualOption option)
        {
            Dictionary <VoxelVisualComponent, VoxelVisualOption> newState = new Dictionary <VoxelVisualComponent, VoxelVisualOption>(state);

            newState.Add(component, option);
            return(new SolverState(newState));
        }
    public NeighborComponents(
        VoxelVisualComponent up,
        VoxelVisualComponent down,
        VoxelVisualComponent forward,
        VoxelVisualComponent backward,
        VoxelVisualComponent left,
        VoxelVisualComponent right)
    {
        Up       = new CellConnection(up, ConnectsUp);
        Down     = new CellConnection(down, ConnectsDown);
        Forward  = new CellConnection(forward, ConnectsForward);
        Backward = new CellConnection(backward, ConnectsBack);
        Left     = new CellConnection(left, ConnectsLeft);
        Right    = new CellConnection(right, ConnectsRight);

        cellConnections = new CellConnection[]
        {
            Up,
            Down,
            Forward,
            Backward,
            Left,
            Right
        }.Where(item => item.Cell != null).ToList();
    }
Example #4
0
 internal CellState GetCellState(VoxelVisualComponent component)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     return(cellStateLookup[component]);
 }
    public VoxelOptionSolver(VoxelVisualComponent startingComponent, MainGrid grid, OptionsByDesignation optionsSource)
    {
        SolverState       initialState = new SolverState();
        VoxelOptionSolver solver       = new VoxelOptionSolver(startingComponent, initialState);

        this.grid          = grid;
        this.optionsSource = optionsSource;
    }
Example #6
0
    public void InitializeNeighbors()
    {
        VoxelVisualsLayer    layer   = OnTopHalf ? topLayer : bottomLayer;
        VoxelVisualComponent up      = GetUpNeighbor();
        VoxelVisualComponent down    = GetDownNeighbor();
        VoxelVisualComponent left    = layer.AdjacentCellA.Visuals.GetComponent(Quad, OnTopHalf);
        VoxelVisualComponent right   = GetHorizontalNeighbor(layer.AdjacentCellA.GroundPoint, layer.AdjacentCellB.GroundPoint);
        VoxelVisualComponent forward = layer.AdjacentCellB.Visuals.GetComponent(Quad, OnTopHalf);
        VoxelVisualComponent back    = GetHorizontalNeighbor(layer.AdjacentCellB.GroundPoint, layer.AdjacentCellA.GroundPoint);

        Neighbors = new NeighborComponents(up, down, forward, back, left, right);
    }
Example #7
0
    public VoxelVisuals(VoxelCell cell)
    {
        Cell = cell;
        Dictionary <GroundQuad, VoxelVisualComponent> bottoms = new Dictionary <GroundQuad, VoxelVisualComponent>();
        Dictionary <GroundQuad, VoxelVisualComponent> tops    = new Dictionary <GroundQuad, VoxelVisualComponent>();

        foreach (GroundQuad quad in cell.GroundPoint.PolyConnections)
        {
            VoxelVisualComponent bottom = new VoxelVisualComponent(Cell, quad, false);
            VoxelVisualComponent top    = new VoxelVisualComponent(Cell, quad, true);
            bottoms.Add(quad, bottom);
            tops.Add(quad, top);
        }
        bottomComponents = bottoms;
        topComponents    = tops;
        Components       = bottomComponents.Values.Concat(topComponents.Values).ToArray();
    }
    private string GetObjName(VoxelVisualComponent component)
    {
        string ret = component.Core.ToString();

        if (component.Contents == null || component.Contents.Mesh == null)
        {
            return(ret + " (empty)");
        }
        ret += component.Contents.Mesh.name;
        if (component.Contents.Flipped)
        {
            ret += " flipped";
        }
        if (component.Contents.Rotations > 0)
        {
            ret += " " + component.Contents.Rotations.ToString() + " rotations";
        }
        return(ret);
    }
Example #9
0
 public CellConnection(VoxelVisualComponent cell, Func <VoxelVisualOption, VoxelVisualOption, bool> comparisonFunction)
 {
     Cell = cell;
     this.comparisonFunction = comparisonFunction;
 }
 public bool GetIsPotentiallyValid(VoxelVisualComponent component, VoxelVisualOption option)
 {
     //TODO: figure out validity checking for components
     throw new NotImplementedException();
 }
 private VoxelOptionSolver(VoxelVisualComponent component, SolverState state)
 {
 }
Example #12
0
 public CellState(IEnumerable <VoxelVisualOption> remainingOptions, VoxelVisualComponent component)
 {
     Component        = component;
     RemainingOptions = remainingOptions.ToList().AsReadOnly();
     CurrentChoice    = RemainingOptions[0];
 }