Ejemplo n.º 1
0
        /// <summary>
        /// <para>Replaces, builds a new electrical connection, and consumes
        /// cables from the hand.</para>
        /// <para>Destroys the electrical connection (if we're given one) and
        /// then adds a new electrical connection by adding an electrical
        /// node. We then calculate and consume a number of cables from the
        /// hand.</para>
        /// </summary>
        /// <param name="position">Position of the electrical connection.</param>
        /// <param name="eConn">Electrical connection we're replacing.</param>
        /// <param name="wireEndA">Connection direction of one end.</param>
        /// <param name="wireEndB">Connection direction of the other end.</param>
        private void ReplaceEConn(Vector3 position, IntrinsicElectronicData eConn, Connection wireEndA,
                                  Connection wireEndB, ConnectionApply interaction)
        {
            // Cost of cable coils to construct the original cable tile. Assume
            // 0 until we verify whether or not we are given an electrical
            // connection.
            int oldTileCost = 0;

            // Get the cost of the old tile. Then destroy the current
            // electrical connection only if we were given a connection.
            if (eConn != null)
            {
                oldTileCost = eConn.MetaDataPresent.RelatedTile.SpawnAmountOnDeconstruct;
                eConn.DestroyThisPlease();
            }

            // Get the electrical cable tile with the wire connection direction.
            ElectricalCableTile tile =
                ElectricityFunctions.RetrieveElectricalTile(wireEndA, wireEndB, powerTypeCategory);

            // Then, add an electrical node at the tile.
            interaction.Performer.GetComponentInParent <Matrix>().AddElectricalNode(position.RoundToInt(), tile, true);

            // We only want to consume the difference needed to build the new
            // cable.
            int newTileCost = tile.SpawnAmountOnDeconstruct;
            int finalCost   = newTileCost - oldTileCost;

            // Finally, consume the cables in the hands using the final cost
            // we found.
            Inventory.ServerConsume(interaction.HandSlot, finalCost);
        }
Ejemplo n.º 2
0
    private void UnderFloorElectricalSetTile(Connection WireEndA, Connection WireEndB,
                                             PowerTypeCategory powerTypeCategory, Vector3Int position, ElectricalMetaData newdata = null)
    {
        ElectricalCableTile Tile = ElectricityFunctions.RetrieveElectricalTile(WireEndA, WireEndB, powerTypeCategory);

        if (newdata != null)
        {
            newdata.RelatedTile = Tile;
        }

        if (Tile != null)
        {
            AddUnderFloorTile(position, Tile, Matrix4x4.identity, Color.white);
        }
    }
Ejemplo n.º 3
0
    private void UnderFloorElectricalSetTile(Connection WireEndA, Connection WireEndB, PowerTypeCategory powerTypeCategory, Vector3Int position, ElectricalMetaData newdata = null)
    {
        ElectricalCableTile Tile = ElectricityFunctions.RetrieveElectricalTile(WireEndA, WireEndB, powerTypeCategory);

        if (newdata != null)
        {
            newdata.RelatedTile = Tile;
        }
        if (Tile != null)
        {
            if (UnderFloorLayer == null)
            {
                underFloorLayer = GetComponentInChildren <UnderFloorLayer>();
            }
            if (UnderFloorLayer != null)
            {
                UnderFloorLayer.SetTile(position, Tile, Matrix4x4.identity);
            }
        }
    }
Ejemplo n.º 4
0
    public void FindOverlapsAndCombine(Vector3 position, Connection WireEndA, Connection WireEndB,
                                       ConnectionApply interaction)
    {
        if (WireEndA == Connection.Overlap | WireEndB == Connection.Overlap)
        {
            bool isA;
            if (WireEndA == Connection.Overlap)
            {
                isA = true;
            }
            else
            {
                isA = false;
            }

            List <IntrinsicElectronicData> Econns = new List <IntrinsicElectronicData>();
            var IEnumerableEconns = interaction.Performer.GetComponentInParent <Matrix>()
                                    .GetElectricalConnections(position.RoundToInt());
            foreach (var T in IEnumerableEconns)
            {
                Econns.Add(T);
            }

            IEnumerableEconns.Clear();
            ElectricalPool.PooledFPCList.Add(IEnumerableEconns);
            int i = 0;
            if (Econns != null)
            {
                while (!(i >= Econns.Count))
                {
                    if (powerTypeCategory == Econns[i].Categorytype)
                    {
                        if (Econns[i].WireEndA == Connection.Overlap)
                        {
                            if (isA)
                            {
                                WireEndA = Econns[i].WireEndB;
                            }
                            else
                            {
                                WireEndB = Econns[i].WireEndB;
                            }
                            Econns[i].DestroyThisPlease();
                            var tile = ElectricityFunctions.RetrieveElectricalTile(WireEndA, WireEndB,
                                                                                   powerTypeCategory);
                            interaction.Performer.GetComponentInParent <Matrix>().AddElectricalNode(position.RoundToInt(), tile, true);

                            return;
                        }
                        else if (Econns[i].WireEndB == Connection.Overlap)
                        {
                            if (isA)
                            {
                                WireEndA = Econns[i].WireEndA;
                            }
                            else
                            {
                                WireEndB = Econns[i].WireEndA;
                            }
                            Econns[i].DestroyThisPlease();
                            var tile = ElectricityFunctions.RetrieveElectricalTile(WireEndA, WireEndB,
                                                                                   powerTypeCategory);
                            interaction.Performer.GetComponentInParent <Matrix>().AddElectricalNode(position.RoundToInt(), tile, true);

                            return;
                        }
                    }

                    i++;
                }
            }
        }
        var _tile = ElectricityFunctions.RetrieveElectricalTile(WireEndA, WireEndB,
                                                                powerTypeCategory);

        interaction.Performer.GetComponentInParent <Matrix>().AddElectricalNode(position.RoundToInt(), _tile, true);
    }