public void CheckEngaged(IBlockAccessor access, bool updateNetwork)
        {
            BlockFacing side          = orients[0] == BlockFacing.NORTH ? BlockFacing.EAST : BlockFacing.NORTH;
            bool        clutchEngaged = false;
            BEClutch    bec           = access.GetBlockEntity(Position.AddCopy(side)) as BEClutch;

            if (bec?.Facing == side.Opposite)
            {
                clutchEngaged = bec.Engaged;
            }
            if (!clutchEngaged)
            {
                bec = access.GetBlockEntity(Position.AddCopy(side.Opposite)) as BEClutch;
                if (bec?.Facing == side)
                {
                    clutchEngaged = bec.Engaged;
                }
            }
            if (clutchEngaged != this.engaged)
            {
                this.engaged = clutchEngaged;
                if (updateNetwork)
                {
                    this.ChangeState(clutchEngaged);
                }
            }
        }
Exemplo n.º 2
0
        public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            BEClutch be = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BEClutch;

            if (be != null)
            {
                return(be.OnInteract(byPlayer));
            }

            return(base.OnBlockInteractStart(world, byPlayer, blockSel));
        }
Exemplo n.º 3
0
        protected override void UpdateLightAndTransformMatrix(int index, Vec3f distToCamera, float rotation, IMechanicalPowerRenderable dev)
        {
            BEClutch clutch = dev as BEClutch;

            if (clutch == null)
            {
                return;
            }
            float rot1 = clutch.AngleRad;
            float rot2 = clutch.RotationNeighbour();

            float rotX = rot1 * dev.AxisSign[0];
            float rotY = rot1 * dev.AxisSign[1];
            float rotZ = rot1 * dev.AxisSign[2];

            UpdateLightAndTransformMatrix(matrixAndLightFloats1.Values, index, distToCamera, dev.LightRgba, rotX, rotY, rotZ, clutch.hinge, null);

            Vec3f axis = new Vec3f(0.5f - dev.AxisSign[2] * 0.125f, 0.625f, 0.5f + dev.AxisSign[0] * 0.125f);

            rotX = rot2 * dev.AxisSign[0];
            rotY = rot2 * dev.AxisSign[1];
            rotZ = rot2 * dev.AxisSign[2];
            UpdateLightAndTransformMatrix(matrixAndLightFloats2.Values, index, distToCamera, dev.LightRgba, rotX, rotY, rotZ, axis, (float[])tmpMat.Clone());
        }
Exemplo n.º 4
0
        public override void OnNeighbourBlockChange(IWorldAccessor world, BlockPos pos, BlockPos neibpos)
        {
            BEClutch be = world.BlockAccessor.GetBlockEntity(pos) as BEClutch;

            be?.onNeighbourChange(neibpos);
        }