/// <summary>
    /// Gets the options of the normal cube.
    /// </summary>
    /// <value>
    /// The options of commands of the chosen cube.
    /// </value>
    public virtual Command[] GetOptions()
    {
        if (transform.forward != Vector3.down && !Level.Singleton.ContainsSensor(new Vector3Int(transform.position).ToVector3))
        {
            setMood(Mood.Happy);
        }
        List <Command> options = new List <Command>();
        Vector3Int     pos;

        if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.forward, out pos, jumpHeight))
        {
            options.Add(new Move(this, pos));
        }
        if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.back, out pos, jumpHeight))
        {
            options.Add(new Move(this, pos));
        }
        if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.right, out pos, jumpHeight))
        {
            options.Add(new Move(this, pos));
        }
        if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.left, out pos, jumpHeight))
        {
            options.Add(new Move(this, pos));
        }
        return(options.ToArray());
    }
Exemple #2
0
        private void UpdateFaces(Byte flags)
        {
            Byte topDirection   = Utils.CalcTopDirection(flags);
            Byte leftDirection  = Utils.CalcLeftDirection(flags);
            Byte frontDirection = Utils.CalcFrontDirection(flags);

            _direction = Utils.CalcOppositeDirection(frontDirection); // The back direction

            Vector3 topVector = CubeHelper.GetDirectionVector(topDirection);

            _targetDirections[0] = Utils.CalcOppositeDirection(topDirection);
            _targetDirections[1] = topDirection;
            _xOffsets[0]         = (SByte)topVector.x;
            _yOffsets[0]         = (SByte)(-topVector.y); // Get direction vector returns incorrectly negative y and z values
            _zOffsets[0]         = (SByte)(-topVector.z);

            Vector3 leftVector = CubeHelper.GetDirectionVector(leftDirection);

            _targetDirections[2] = Utils.CalcOppositeDirection(leftDirection);
            _targetDirections[3] = leftDirection;
            _xOffsets[1]         = (SByte)leftVector.x;
            _yOffsets[1]         = (SByte)(-leftVector.y);
            _zOffsets[1]         = (SByte)(-leftVector.z);

            Vector3 frontVector = CubeHelper.GetDirectionVector(frontDirection);

            _targetDirections[4] = Utils.CalcOppositeDirection(frontDirection);
            _targetDirections[5] = frontDirection;
            _xOffsets[2]         = (SByte)frontVector.x;
            _yOffsets[2]         = (SByte)(-frontVector.y);
            _zOffsets[2]         = (SByte)(-frontVector.z);
        }
Exemple #3
0
        private void ProcessConnectedStorage(Vector3 side, ref List <SegmentEntity> segments, List <SegmentEntity> adjacentSegments)
        {
            PositionUtils.GetSegmentPos(side, mnX, mnY, mnZ, out long segmentX, out long segmentY,
                                        out long segmentZ);
            Segment adjacentSegment = AttemptGetSegment(segmentX, segmentY, segmentZ);

            if (adjacentSegment != null &&
                CubeHelper.HasEntity(adjacentSegment.GetCube(segmentX, segmentY, segmentZ)))
            {
                var segmentEntity = adjacentSegment.SearchEntity(segmentX, segmentY, segmentZ);
                if (segmentEntity is IQuantumStorage quantumStorageEntity)
                {
                    adjacentSegments.Add(segmentEntity);
                    if (!segments.Contains(segmentEntity))
                    {
                        segments.Add(segmentEntity);
                        quantumStorageEntity.GetConnectedSegments(ref segments);
                    }
                }
                else if (segmentEntity is IQuantumIo || segmentEntity is QuantumStorageControllerMachine)
                {
                    if (!segments.Contains(segmentEntity))
                    {
                        segments.Add(segmentEntity);
                    }
                }
            }
        }
Exemple #4
0
    private void JumpRecursive(Vector3 currentPosition, List <Command> commands, List <Vector3> jumpPositions, Vector3 direction)
    {
        Vector3 nextPosition = currentPosition + direction;

        if (Level.Singleton.ContainsElement(nextPosition + Vector3.down))
        {
            // exite piso osea que salte por ultima vez
            if (!Level.Singleton.ContainsElement(nextPosition))
            {
                commands.Add(new Bounce(this, nextPosition, jumpPositions));
            }
            else if (!Level.Singleton.ContainsElement(nextPosition + Vector3.up))
            {
                commands.Add(new Bounce(this, nextPosition + Vector3.up, jumpPositions));
            }
        }
        else
        {
            // Sigue la recursividad
            int jumpSize = CubeHelper.GetDifferenceInDirection(nextPosition, Vector3.down) - 1;
            if (jumpSize >= 0)
            {
                Vector3 jumpPosition = nextPosition + Vector3.down * jumpSize;                 // changed multiply

                jumpPositions.Add(jumpPosition);
                JumpRecursive(jumpPosition, commands, jumpPositions, direction);
            }
        }
    }
        private void UpdateEntity(Boolean forceReset)
        {
            Int64   targetX = mnX + TargetXOffset;
            Int64   targetY = mnY + TargetYOffset;
            Int64   targetZ = mnZ + TargetZOffset;
            Segment segment = AttemptGetSegment(targetX, targetY, targetZ);

            if (segment == null)
            {
                return;
            }

            UInt16 cubeType = segment.GetCube(targetX, targetY, targetZ);

            if (CubeHelper.HasEntity(cubeType))
            {
                SegmentEntity entity = segment.SearchEntity(targetX, targetY, targetZ);

                Boolean reset = _node.ActiveInputCount == 0; // Reset the entity to defaults if the node can't be set
                if (entity != null)
                {
                    UpdateTarget(entity, _node.InputValues, reset || forceReset);
                }
            }
        }
Exemple #6
0
    public Vector3 FindNextTwinPosition(Vector3 direction)
    {
        if (simAxis == "x")
        {
            if (direction == Vector3.forward || direction == Vector3.forward * -1)
            {
                direction = CubeHelper.GetTopPosition(transform.position + direction);
            }
            else
            {
                direction = CubeHelper.GetTopPosition(transform.position + direction * -1);
            }
        }
        else if (direction == Vector3.right || direction == Vector3.right * -1)
        {
            direction = CubeHelper.GetTopPosition(transform.position + direction);
        }
        else
        {
            direction = CubeHelper.GetTopPosition(transform.position + direction * -1);
        }

        if (direction.y - transform.position.y > 1)
        {
            direction = transform.position;
        }
        return(direction);
    }
        private ItemEquipmentCube MapCube(ItemId itemId, ItemEquipmentSlot slot)
        {
            if (!CubeHelper.IsCube(itemId))
            {
                return(ItemEquipmentCube.None);
            }
            switch (slot)
            {
            case ItemEquipmentSlot.Head:
            case ItemEquipmentSlot.Shoulders:
            case ItemEquipmentSlot.Hands:
            case ItemEquipmentSlot.Wrists:
            case ItemEquipmentSlot.Waist:
            case ItemEquipmentSlot.Legs:
            case ItemEquipmentSlot.Feet:
            case ItemEquipmentSlot.Torso:
                return(ItemEquipmentCube.Armor);

            case ItemEquipmentSlot.Neck:
            case ItemEquipmentSlot.LeftFinger:
            case ItemEquipmentSlot.RightFinger:
                return(ItemEquipmentCube.Jewelery);

            case ItemEquipmentSlot.Mainhand:
            case ItemEquipmentSlot.Offhand:
                return(ItemEquipmentCube.Weapon);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #8
0
        public SceneViewModel()
        {
            Colors         = NamedColorCollection.GetNamedColors();
            _selectedColor = Colors.Random();

            Grid = new Grid
            {
                Length  = 5.0D,
                Segment = 6.0D
            };

            Position = new Point3D(50, 50, 50);
            for (var x = 0; x < 6; x++)
            {
                for (var z = 0; z < 6; z++)
                {
                    Grid.Place(x, 0, z, new Cube(_selectedColor.Color));
                }
            }

            Selection = new SelectionViewModel(Grid, CubeHelper.CreateSelection());
            Selection.PropertyChanged += (sender, args) => { RaisePropertyChangedEvent(nameof(SelectionTransform)); };

            GridView = new GridViewModel();
            GridView.PropertyChanged += (sender, args) => { RaisePropertyChangedEvent(nameof(Model)); };

            Render();
        }
Exemple #9
0
    protected void findMk4AndMk5Bats()
    {
        VicisMod.log(getPrefix(), "Looking for T4 and T5 batteries");
        long[] coords = new long[3];
        for (int i = 0; i < 3; ++i)
        {
            for (int j = -1; j <= 1; j += 2)
            {
                Array.Clear(coords, 0, 3);
                coords[i] = j;

                long x = mnX + coords[0];
                long y = mnY + coords[1];
                long z = mnZ + coords[2];

                Segment segment = base.AttemptGetSegment(x, y, z);
                // Check if segment was generated (skip this point if it doesn't
                if (segment == null)
                {
                    continue;
                }
                ushort cube = segment.GetCube(x, y, z);
                // If this isn't an entity, skip it
                if (!CubeHelper.HasEntity((int)cube))
                {
                    continue;
                }
                PowerConsumerInterface pci = segment.SearchEntity(x, y, z) as PowerConsumerInterface;
                if (pci == null)
                {
                    continue;
                }
                // We're only looking for T4 and T5 batteries
                if (!(pci is T4_Battery) && !(pci is T5_Battery))
                {
                    continue;
                }
                VicisMod.log(getPrefix(), "Found one: " + pci.ToString());
                // Let's only keep track of PCIs that will accept power from the PowWow
                if (!pci.WantsPowerFromEntity(this))
                {
                    continue;
                }
                for (int l = mk4AndMk5Bats.Count - 1; l >= 0 && pci != null; --l)
                {
                    PowerConsumerInterface pci2 = mk4AndMk5Bats[l];
                    if (pci2 != null && !(pci2 as SegmentEntity).mbDelete && pci2 == pci)
                    {
                        pci = null;
                    }
                }
                VicisMod.log(getPrefix(), "End, checking " + pci);
                if (pci != null)
                {
                    mk4AndMk5Bats.Add(pci);
                }
            }
        }
    }
Exemple #10
0
    public override Command[] GetOptions()
    {
        if (transform.forward != Vector3.down && (!Level.Singleton.ContainsElement(transform.position + Vector3.down) || !Level.Singleton.getEntity(transform.position + Vector3.down) is BasicSensor))
        {
            setMood(Mood.Happy);
        }
        List <Command> commands = new List <Command>();

        if (!stuck || !CubeHelper.IsFree(new Vector3Int(transform.position + Vector3.down)))
        {
            commands = CubeHelper.GetListOptions(base.GetOptions());
            Vector3Int pos;
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.forward, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.forward);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.back, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.back);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.right, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.right);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.left, out pos, GetJumpHeight()))
            {
                if (new Vector3Int(transform.position).y - pos.y > 1)
                {
                    pos = new Vector3Int(transform.position + Vector3.left);
                    pos.y--;
                    commands.Add(new Move(this, pos));
                }
            }
        }
        else
        {
            Vector3Int pos;
            if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.down, out pos, GetJumpHeight()))
            {
                commands.Add(new Move(this, pos));
            }
        }
        return(commands.ToArray());
    }
 public static bool isCubeGlassForRoom(ushort blockID, RoomController rc)
 {
     if (blockID == eCubeTypes.EnergyGrommet || blockID == eCubeTypes.LogisticsGrommet)
     {
         return(false);
     }
     return(CubeHelper.IsCubeGlass((int)blockID));
 }
 private bool isAvailable(Vector3 direction)
 {
     if (PositionOutOfLimits(direction))
     {
         return(false);
     }
     return(CubeHelper.IsFree(new Vector3Int(Position + direction)));
 }
Exemple #13
0
 private void CanvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
 {
     CubeHelper helper = new CubeHelper(GetLength());
     foreach (Tuple<Vector2, Vector2> edge in helper.GetEdges(currentTransformation))
     {
         ColorValue colorValue = ColorComboBox.SelectedValue as ColorValue;
         Color color = (colorValue == null ? Colors.Black : colorValue.Color);
         args.DrawingSession.DrawLine(edge.Item1, edge.Item2, color);
     }
 }
Exemple #14
0
    public override void EndExecution()
    {
        Entity hit = CubeHelper.GetEntityInPosition(EndPosition + direction.normalized);

        if (hit is RockCube || hit is MetalCube)
        {
            ((IceCube)Cube).Break();
        }
        base.EndExecution();
    }
 public void Duplicate(Vector3 newPosition)
 {
     if (duplicateTimes > 0 && CubeHelper.IsFree(transform.position + Vector3.up))
     {
         GameObject newClone = (GameObject)Instantiate(clone, newPosition, transform.rotation);
         CubeAnimations.AnimateDuplication(newClone);
         EndExecution();
         duplicateTimes--;
     }
 }
Exemple #16
0
 private Vector3 HasFloorAround(Vector3 v)
 {
     Entity[] around = CubeHelper.GetEntitiesAround(v);
     foreach (Entity e in around)
     {
         if (e.transform.position != this.transform.position && IsWalkable(e))
         {
             return((e.transform.position - this.transform.position).normalized);
         }
     }
     return(Vector3.zero);
 }
Exemple #17
0
    public void Slide(Vector3 endPosition, Vector3 direction)
    {
        Level.Singleton.Entities.Remove(transform.position);
        transform.position = endPosition;
        Level.Singleton.Entities.Add(transform.position, this);
        Entity hit = CubeHelper.GetEntityInPosition(transform.position + direction.normalized);

        if (hit is RockCube) //Agregar cubo metal
        {
            Break();
        }
    }
 /**
  * Puede hacerse un metodo recursivo que verifique si todas las piezas estan conectadas
  * */
 public override bool CheckPressed()
 {
     Entity[] around = CubeHelper.GetEntitiesAround(this.transform.position);
     foreach (Entity e in around)
     {
         if (e is DigitalCube)
         {
             return(true);
         }
     }
     return(false);
 }
        private void UpdateTarget()
        {
            Int64   targetX = mnX - _sourceXOffset;
            Int64   targetY = mnY - _sourceYOffset;
            Int64   targetZ = mnZ - _sourceZOffset;
            Segment segment = AttemptGetSegment(targetX, targetY, targetZ);

            if (segment == null)
            {
                return;
            }
            UInt16 cubeType = segment.GetCube(targetX, targetY, targetZ);

            ILogicReceiver logicReciever;
            Int32          inputIndex;

            if (CubeHelper.HasEntity(cubeType) &&
                (logicReciever = segment.SearchEntity(targetX, targetY, targetZ) as ILogicReceiver) != null &&
                (inputIndex = logicReciever.FindFaceInputIndex(_targetDirection)) != -1)
            {
                // There is a connectable logic node at the target location
                var targetNode = logicReciever.GetLogicNode();
                if (_node.OutNodes[OutIndex] == targetNode)
                {
                    return;
                }

                // The node is not the same, so remove the old node and connect to the new one.
                _node.DisconnectFromHead(OutIndex);

                if (!targetNode.IsInputActive(inputIndex))
                {
                    try
                    {
                        _node.ConnectToHead(OutIndex, targetNode, inputIndex);
                    }
                    catch (InputEdgeAlreadyActiveException ex)
                    {
                        Debug.LogWarning(
                            "Sensor attempted to connect to index that was already in use!\n" +
                            $"\nTarget type: {targetNode.GetType()} inindex: {inputIndex} Active input count: {targetNode.ActiveInputCount}" +
                            "\nException: " + ex);
                    }
                }

                // Else, the current node is the same, no changes needed
            }
            else
            {
                // No connectable logic node at the target location, make sure we're disconnected
                _node.DisconnectFromHead(OutIndex);
            }
        }
        private void GetAdjacentBattery(long segmentX, long segmentY, long segmentZ,
                                        ref List <PowerStorageInterface> powerStoages)
        {
            Segment adjacentBattery = _quantumStorageController.AttemptGetSegment(segmentX, segmentY, segmentZ);

            if (adjacentBattery != null && CubeHelper.HasEntity(adjacentBattery.GetCube(segmentX, segmentY, segmentZ)))
            {
                if (adjacentBattery.SearchEntity(segmentX, segmentY, segmentZ) is PowerStorageInterface powerStorage)
                {
                    powerStoages.Add(powerStorage);
                }
            }
        }
Exemple #21
0
        public Mesh CreateMesh(float scale = 1)
        {
            List <Vertex> vertices = new();

            Vector3 size = new Vector3(scale);

            for (int z = 0; z < Size.Z; z++)
            {
                for (int y = 0; y < Size.Y; y++)
                {
                    for (int x = 0; x < Size.X; x++)
                    {
                        QubicleVoxel voxel = this[x, y, z];

                        Vector3 pos = new Vector3(x, y, z) * scale;

                        if (voxel.LeftVisible)
                        {
                            vertices.AddRange(CubeHelper.GetLeftVertices(pos, size, voxel.Color, Vector2.Zero, Vector2.One));
                        }

                        if (voxel.RightVisible)
                        {
                            vertices.AddRange(CubeHelper.GetRightVertices(pos, size, voxel.Color, Vector2.Zero, Vector2.One));
                        }

                        if (voxel.BottomVisible)
                        {
                            vertices.AddRange(CubeHelper.GetBottomVertices(pos, size, voxel.Color, Vector2.Zero, Vector2.One));
                        }

                        if (voxel.TopVisible)
                        {
                            vertices.AddRange(CubeHelper.GetTopVertices(pos, size, voxel.Color, Vector2.Zero, Vector2.One));
                        }

                        if (voxel.BackVisible)
                        {
                            vertices.AddRange(CubeHelper.GetBackVertices(pos, size, voxel.Color, Vector2.Zero, Vector2.One));
                        }

                        if (voxel.FrontVisible)
                        {
                            vertices.AddRange(CubeHelper.GetFrontVertices(pos, size, voxel.Color, Vector2.Zero, Vector2.One));
                        }
                    }
                }
            }

            return(new Mesh(vertices.ToArray()));
        }
Exemple #22
0
    private void SideOptions(List <Command> commands, Vector3 direction)
    {
        Vector3 currentPosition = transform.position + direction;

        if (Level.Singleton.ContainsElement(currentPosition))
        {
            Entity entity = Level.Singleton.getEntity(currentPosition);
            // Check if cubes exists on top of me
            if (!Level.Singleton.ContainsElement(currentPosition + Vector3.up))
            {
                commands.Add(new Move(this, currentPosition + Vector3.up));
            }
        }
        else
        {
            if (Level.Singleton.ContainsElement(currentPosition + Vector3.down))
            {
                commands.Add(new Move(this, currentPosition));
            }
            else
            {
                int            jumpSize      = CubeHelper.GetDifferenceInDirection(currentPosition, Vector3.down) - 1;
                Vector3        jumpPosition  = currentPosition + (jumpSize * Vector3.down);
                List <Vector3> jumpPositions = new List <Vector3>();
                jumpPositions.Add(jumpPosition);

                if (Level.Singleton.ContainsElement(currentPosition + direction))
                {
                    //Cae en el mismo lugar donde salto por su primera vez
                    commands.Add(new Bounce(this, jumpPosition, jumpPositions));
                }
                else
                {
                    int jumpSizeNext = CubeHelper.GetDifferenceInDirection(currentPosition + direction, Vector3.down) - 1;

                    //print ("jp" + jumpSize + "," + jumpSizeNext);

                    if (jumpSizeNext < jumpSize)
                    {
                        commands.Add(new Bounce(this, currentPosition + direction + (Vector3.down * jumpSizeNext), jumpPositions));
                    }
                    else
                    {
                        //Puede seguir reborando
                        JumpRecursive(jumpPosition, commands, jumpPositions, direction);
                    }
                }
            }
        }
    }
 /// <summary>
 /// Make the cube, with position currentPosition, fall.
 /// </summary>
 /// <param name='currentPosition'>
 /// Last.
 /// </param>
 public virtual void Gravity(Vector3Int currentPosition)
 {
     Level.Singleton.RemoveEntity(currentPosition);
     if (CubeHelper.IsFree(new Vector3Int(currentPosition.ToVector3 + Vector3.down)) && currentPosition.y > 1)
     {
         currentPosition.y = currentPosition.y - 1;
         Level.Singleton.AddEntity(this, currentPosition);
         Gravity(currentPosition);
     }
     else
     {
         Level.Singleton.AddEntity(this, currentPosition);
         CubeAnimations.AnimateMove(gameObject, Vector3.down, currentPosition.ToVector3);
     }
 }
 public static bool canCubeBeMouseClicked(ushort ID, ref CubeData data) //hydroponics bays are the same ID as canopies
 {
     if (ID == eCubeTypes.TNTButNowGrass)
     {
         return(false);
     }
     if (ID == eCubeTypes.Hydroponics && data.mValue == 1)
     {
         return(false);
     }
     if (CubeHelper.IsCustom(ID) || CubeHelper.HasObject(ID) || CubeHelper.HasEmbeddedObject(ID))
     {
         return(true);
     }
     return(CubeHelper.IsCubeSolid(ID));
 }
    void Update()
    {
        Vector3EqualityComparer comparer = new Vector3EqualityComparer();

        if (isClone && Vector3.Equals(transform.position, imitated.transform.position))
        {
            if (CubeHelper.GetEntityInPosition(imitated.transform.position + Vector3.down) is Cube)
            {
                Clone(CubeHelper.GetEntityInPosition(imitated.transform.position + Vector3.down));
            }
            else
            {
                UnClone();
            }
        }
    }
Exemple #26
0
    public override void MoveTo(Vector3Int nextPosition)
    {
        Vector3Int below = new Vector3Int(nextPosition.x, nextPosition.y, nextPosition.z);

        below.y--;
        if (stuck)
        {
            stuck = false;
        }
        if (CubeHelper.IsFree(below) && below.y > 0)
        {
            stuck = true;
        }

        base.MoveTo(nextPosition);
    }
Exemple #27
0
        // ## Neighbor Add ##
        // This method is a handler for the NeighborAdd event. It is triggered when
        // two cubes are placed side by side.
        //
        // Cube1 and cube2 are the two cubes that are involved in this neighboring.
        // The two cube arguments can be in any order; if your logic depends on
        // cubes being in specific positions or roles, you need to add logic to
        // this handler to sort the two cubes out.
        //
        // Side1 and side2 are the sides that the cubes neighbored on.
        private void OnNeighborAdd(Cube cube1, Cube.Side side1, Cube cube2, Cube.Side side2)
        {
            Log.Debug("Neighbor add: {0}.{1} <-> {2}.{3}", cube1.UniqueId, side1, cube2.UniqueId, side2);

            CubeWrapper wrapper = (CubeWrapper)cube1.userData;

            if (wrapper != null)
            {
                // Here we set our wrapper's rotation value so that the image gets
                // drawn with its top side pointing towards the neighbor cube.
                //
                // Cube.Side is an enumeration (TOP, LEFT, BOTTOM, RIGHT, NONE). The
                // values of the enumeration can be cast to integers by counting
                // counterclockwise:
                //
                // * TOP = 0
                // * LEFT = 1
                // * BOTTOM = 2
                // * RIGHT = 3
                // * NONE = 4
                //wrapper.mRotation = (int)side1;
                wrapper.mNeedDraw = true;
            }

            wrapper = (CubeWrapper)cube2.userData;
            if (wrapper != null)
            {
                //wrapper.mRotation = (int)side2;
                wrapper.mNeedDraw = true;
            }


            //TODO: Siegüberprüfung:
            Cube[] row = CubeHelper.FindRow(CubeSet);
            if (row.Length == totalCubes)
            {
                Log.Debug("6 connected");
                //found = true;
                //int lastId = -1;
                //foreach (Cube cube in row) {
                //					CubeWrapper wrapper = (CubeWrapper)cube.userData;
                //					if (wrapper.mIndex < lastId)
                //						found = false;
                //					lastId = wrapper.mIndex;
                //				}
            }
        }
Exemple #28
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         if (context != null && context.Instance != null && !String.IsNullOrEmpty((string)value))
         {
             ComponentBase c      = context.Instance as ComponentBase;
             Report        report = c.Report;
             if (report != null)
             {
                 return(CubeHelper.GetCubeSource(report.Dictionary, (string)value));
             }
         }
         return(null);
     }
     return(base.ConvertFrom(context, culture, value));
 }
Exemple #29
0
        public ItemConsumerInterface GetItemConsumer()
        {
            PositionUtils.GetSegmentPos(_machineSides.Back, _machine.mnX, _machine.mnY, _machine.mnZ, out long segmentX, out long segmentY,
                                        out long segmentZ);
            Segment adjacentSegment = _machine.AttemptGetSegment(segmentX, segmentY, segmentZ);

            if (adjacentSegment != null &&
                CubeHelper.HasEntity(adjacentSegment.GetCube(segmentX, segmentY, segmentZ)) &&
                adjacentSegment.SearchEntity(segmentX, segmentY, segmentZ) is ItemConsumerInterface adjacentItemConsumer)
            {
                return(adjacentItemConsumer);
            }
            else
            {
                return(null);
            }
        }
Exemple #30
0
        public QuantumStorageControllerMachine GetStorageController()
        {
            Segment segment =
                _machine.AttemptGetSegment(_machine.GetControllerPos()[0], _machine.GetControllerPos()[1],
                                           _machine.GetControllerPos()[2]);

            if (segment != null &&
                CubeHelper.HasEntity(segment.GetCube(_machine.GetControllerPos()[0],
                                                     _machine.GetControllerPos()[1], _machine.GetControllerPos()[2])) &&
                segment.SearchEntity(_machine.GetControllerPos()[0], _machine.GetControllerPos()[1],
                                     _machine.GetControllerPos()[2]) is QuantumStorageControllerMachine storageController)
            {
                return(storageController);
            }

            return(null);
        }
 public override void MoveTo(Vector3 nextPosition)
 {
     if (CubeHelper.GetEntityInPosition(nextPosition + Vector3.down) is Cube)
     {
         Debug.Log("Clone!");
         collider.enabled = false;
         renderer.enabled = false;
         Debug.Log(renderer.enabled);
         transform.position = nextPosition;
         Clone(CubeHelper.GetEntityInPosition(nextPosition + Vector3.down));
         Command.EndExecution();
     }
     else
     {
         base.MoveTo(nextPosition);
     }
 }