Exemple #1
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            CalculatedStyle dimensions = GetDimensions();

            long delta = energy.GetEnergy() - oldEnergy;

            oldEnergy = energy.GetEnergy();
            float progress = energy.GetEnergy() / (float)energy.GetCapacity();

            DrawBar(spriteBatch, bgColor);

            spriteBatch.End();

            RasterizerState state = new RasterizerState {
                ScissorTestEnable = true
            };

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, state);

            Rectangle prevRect = spriteBatch.GraphicsDevice.ScissorRectangle;

            spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle((int)dimensions.X, (int)(dimensions.Y + dimensions.Height - dimensions.Height * progress), (int)dimensions.Width, (int)(dimensions.Height * progress));

            DrawBar(spriteBatch, barColor);

            spriteBatch.GraphicsDevice.ScissorRectangle = prevRect;
            spriteBatch.End();
            spriteBatch.Begin();

            if (IsMouseHovering)
            {
                Main.LocalPlayer.showItemIcon = false;
                Main.ItemIconCacheUpdate(0);
                Main.instance.MouseTextHackZoom($"{energy}\n{(delta > 0 ? "+" : "") + delta.AsPower(true)}");
                Main.mouseText = true;
            }
        }
 public long GetEnergy() => energyStorage.GetEnergy();
Exemple #3
0
 public long GetEnergy() => energy.GetEnergy();
Exemple #4
0
 public static long CalculateGeneration(long energy, EnergyStorage storage) => Math.Min(energy, storage.GetCapacity() - storage.GetEnergy());
Exemple #5
0
 public long GetEnergySharePerNode() => energy.GetEnergy() / tiles.Count;
Exemple #6
0
 public float GetEnergySharePerNode() => (float)energy.GetEnergy() / tiles.Count;