protected override MechPowerPath[] GetMechPowerExits(MechPowerPath pathDir)
        {
            BlockFacing   face  = pathDir.OutFacing;
            BELargeGear3m beg   = Blockentity as BELargeGear3m;
            int           index = 0;

            if (face == BlockFacing.UP || face == BlockFacing.DOWN)
            {
                MechPowerPath[] paths = new MechPowerPath[2 + beg.CountGears(Api)];
                paths[index]   = pathDir;
                paths[++index] = new MechPowerPath(pathDir.OutFacing.Opposite, pathDir.gearingRatio, null, !pathDir.invert);
                bool sideInvert = face == BlockFacing.DOWN ^ pathDir.invert;
                for (int i = 0; i < 4; i++)
                {
                    BlockFacing horizFace = BlockFacing.HORIZONTALS[i];
                    if (beg.HasGearAt(Api, Position.AddCopy(horizFace)))
                    {
                        paths[++index] = new MechPowerPath(horizFace, pathDir.gearingRatio * ratio, null, sideInvert);                                                   //invert all horizontal output paths
                    }
                }
                return(paths);
            }

            MechPowerPath[] pathss = new MechPowerPath[2 + beg.CountGears(Api)];
            bool            invert = pathDir.IsInvertedTowards(Position);

            pathss[0] = new MechPowerPath(BlockFacing.DOWN, pathDir.gearingRatio / ratio, null, invert);
            pathss[1] = new MechPowerPath(BlockFacing.UP, pathDir.gearingRatio / ratio, null, !invert);
            index     = 1;
            bool sidesInvert = face == BlockFacing.DOWN ^ !invert;  //invert power in the opposite sense if power fed in from one of the sides instead of through up/down axle

            for (int i = 0; i < 4; i++)
            {
                BlockFacing horizFace = BlockFacing.HORIZONTALS[i];
                if (beg.HasGearAt(Api, Position.AddCopy(horizFace)))
                {
                    pathss[++index] = new MechPowerPath(horizFace, pathDir.gearingRatio, null, sidesInvert);                                                   //horizontals match the gearing ratio of the input horizontal
                }
            }
            return(pathss);
        }
Esempio n. 2
0
        protected override MechPowerPath[] GetMechPowerExits(MechPowerPath pathDir)
        {
            BlockFacing   face  = pathDir.OutFacing;
            BELargeGear3m beg   = Blockentity as BELargeGear3m;
            int           index = 0;

            if (face == BlockFacing.UP || face == BlockFacing.DOWN)
            {
                MechPowerPath[] paths = new MechPowerPath[2 + beg.CountGears(Api)];
                paths[index]   = pathDir;
                paths[++index] = new MechPowerPath(pathDir.OutFacing.Opposite, pathDir.gearingRatio, null, !pathDir.invert);
                for (int i = 0; i < 4; i++)
                {
                    BlockFacing horizFace = BlockFacing.HORIZONTALS[i];
                    if (beg.HasGearAt(Api, Position.AddCopy(horizFace)))
                    {
                        paths[++index] = new MechPowerPath(horizFace, pathDir.gearingRatio * ratio, null, face == BlockFacing.DOWN ^ pathDir.invert);                                                   //invert all horizontal output paths
                    }
                }
                return(paths);
            }

            MechPowerPath[] pathss = new MechPowerPath[2 + beg.CountGears(Api)];
            bool            invert = pathDir.IsInvertedTowards(Position);

            pathss[0] = new MechPowerPath(BlockFacing.DOWN, pathDir.gearingRatio / ratio, null, invert);
            pathss[1] = new MechPowerPath(BlockFacing.UP, pathDir.gearingRatio / ratio, null, !invert);
            index     = 1;
            for (int i = 0; i < 4; i++)
            {
                BlockFacing horizFace = BlockFacing.HORIZONTALS[i];
                if (beg.HasGearAt(Api, Position.AddCopy(horizFace)))
                {
                    pathss[++index] = new MechPowerPath(horizFace, pathDir.gearingRatio, null, (face.Opposite == horizFace || face == BlockFacing.DOWN) ^ !invert);                                                   //horizontals match the gearing ratio of the input horizontal; invert unless its the input side
                }
            }
            return(pathss);
        }
        public override void SetPropagationDirection(MechPowerPath path)
        {
            BlockFacing turnDir = path.NetworkDir();

            if (turnDir != BlockFacing.UP && turnDir != BlockFacing.DOWN)
            {
                turnDir          = path.IsInvertedTowards(Position) ? BlockFacing.UP : BlockFacing.DOWN; //network coming in (clockwise) from any of the 4 sides should then propagate (clockwise) in the down direction
                this.GearedRatio = path.gearingRatio / ratio;
            }
            else
            {
                this.GearedRatio = path.gearingRatio;
            }
            if (this.propagationDir == turnDir.Opposite && this.network != null)
            {
                if (!network.DirectionHasReversed)
                {
                    network.TurnDir = network.TurnDir == EnumRotDirection.Clockwise ? EnumRotDirection.Counterclockwise : EnumRotDirection.Clockwise;
                }
                network.DirectionHasReversed = true;
            }
            this.propagationDir = turnDir;
        }