internal unsafe void UpdateFBO() { if (Shortcuts.renderer.GraphicsDevice.Textures[0] == fbo) { Shortcuts.renderer.GraphicsDevice.Textures[0] = null; } Components.Logics.AccumulatorLogics l = (Components.Logics.AccumulatorLogics)parent.Logics; int w = (int)(l.Charge / l.MaxCharge * fbo.Width); fixed(Color *a = fboarr) { for (int x = 0; x < w; x++) { *(a + x) = Color.Red; } for (int x = w; x < fbo.Width; x++) { *(a + x) = Color.Transparent; } } fbo.SetData <Color>(fboarr); }
public override void Draw(MicroWorld.Graphics.Renderer renderer) { if (texture0cw == null) { return; } if (!CanDraw()) { return; } Components.Logics.AccumulatorLogics l = (Components.Logics.AccumulatorLogics)parent.Logics; UpdateFBO(); switch (parent.ComponentRotation) { case Component.Rotation.cw0: renderer.Draw(texture0cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); renderer.Draw(fbo, new Rectangle((int)Position.X + 8, (int)Position.Y + 4, 48, 16), null, Color.White); renderer.Draw(arrow0cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); break; case Component.Rotation.cw90: renderer.Draw(texture90cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); renderer.Draw(fbo, new Rectangle((int)Position.X + 20, (int)Position.Y + 8, 48, 16), null, Color.White, (float)Math.PI / 2, Vector2.Zero); renderer.Draw(arrow90cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); break; case Component.Rotation.cw180: renderer.Draw(texture180cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); renderer.Draw(fbo, new Rectangle((int)Position.X + 56, (int)Position.Y + 20, 48, 16), null, Color.White, (float)Math.PI, Vector2.Zero); renderer.Draw(arrow180cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); break; case Component.Rotation.cw270: renderer.Draw(texture270cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); renderer.Draw(fbo, new Rectangle((int)Position.X + 4, (int)Position.Y + 56, 48, 16), null, Color.White, 3 * (float)Math.PI / 2, Vector2.Zero); renderer.Draw(arrow270cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); break; default: break; } }