コード例 #1
0
ファイル: UIEnergyBar.cs プロジェクト: DRKV333/TheOneLibrary
        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;
            }
        }
コード例 #2
0
 public long GetCapacity() => energyStorage.GetCapacity();
コード例 #3
0
ファイル: TESpawner.cs プロジェクト: Eternal-Team/MobUtils
 public long GetCapacity() => energy.GetCapacity();
コード例 #4
0
 public static long CalculateGeneration(long energy, EnergyStorage storage) => Math.Min(energy, storage.GetCapacity() - storage.GetEnergy());
コード例 #5
0
 public long GetCapacitySharePerNode() => energy.GetCapacity() / tiles.Count;