public override void Initialize(ICoreAPI api) { Facing = BlockFacing.FromCode(Block.Variant["side"]); if (Facing == null) { Facing = BlockFacing.NORTH; } switch (Facing.Index) { case 0: rotateY = 180; break; case 1: rotateY = 90; break; case 3: rotateY = 270; break; default: break; } mat.Translate(0.5f, 0.5f, 0.5f); mat.RotateYDeg(rotateY); mat.Translate(-0.5f, -0.5f, -0.5f); base.Initialize(api); inv.LateInitialize(InventoryClassName + "-" + Pos, api); if (api.World.Side == EnumAppSide.Server) { RegisterGameTickListener(OnServerTick, 200); } pvBh = GetBehavior <BEBehaviorMPPulverizer>(); }
protected override void UpdateLightAndTransformMatrix(int index, Vec3f distToCamera, float rotation, IMechanicalPowerRenderable dev) { BEBehaviorMPPulverizer bhpu = dev as BEBehaviorMPPulverizer; float rot = bhpu.bepu.hasAxle ? dev.AngleRad : 0; float axX = -Math.Abs(dev.AxisSign[0]); float axZ = -Math.Abs(dev.AxisSign[2]); // Axle if (bhpu.bepu.hasAxle) { float rotX = rot * axX; float rotZ = rot * axZ; UpdateLightAndTransformMatrix(matrixAndLightFloatsAxle.Values, quantityAxles, distToCamera, dev.LightRgba, rotX, rotZ, axisCentre, 0f); quantityAxles++; } if ((dev.Block as BlockPulverizer).InvertPoundersOnRender) { rot = -rot; } // Pounder-left if (bhpu.bepu.hasLPounder) { bool leftEmpty = bhpu.bepu.Inventory[1].Empty; int metalIndexLeft = bhpu.bepu.CapMetalIndexL; float progress = GetProgress(bhpu.bepu.hasAxle ? rot - 0.45f + GameMath.PIHALF / 2f : 0f, 0f); UpdateLightAndTransformMatrix(matrixAndLightFloatsLPounder[metalIndexLeft].Values, quantityLPounders[metalIndexLeft], distToCamera, dev.LightRgba, 0f, 0f, axisCentre, Math.Max(progress / 6f + 0.0071f, leftEmpty ? -1 : 1 / 32f)); if (progress < bhpu.prevProgressLeft && progress < 0.25f) { if (bhpu.leftDir == 1) { bhpu.OnClientSideImpact(false); } bhpu.leftDir = -1; } else { bhpu.leftDir = 1; } bhpu.prevProgressLeft = progress; quantityLPounders[metalIndexLeft]++; } // Pounder-right if (bhpu.bepu.hasRPounder) { bool rightEmpty = bhpu.bepu.Inventory[0].Empty; int metalIndexRight = bhpu.bepu.CapMetalIndexR; float progress = GetProgress(bhpu.bepu.hasAxle ? rot - 0.45f : 0f, 0f); UpdateLightAndTransformMatrix(matrixAndLightFloatsRPounder[metalIndexRight].Values, quantityRPounders[metalIndexRight], distToCamera, dev.LightRgba, 0f, 0f, axisCentre, Math.Max(progress / 6f + 0.0071f, rightEmpty ? -1 : 1 / 32f)); if (progress < bhpu.prevProgressRight && progress < 0.25f) { if (bhpu.rightDir == 1) { bhpu.OnClientSideImpact(true); } bhpu.rightDir = -1; } else { bhpu.rightDir = 1; } bhpu.prevProgressRight = progress; quantityRPounders[metalIndexRight]++; } }