Files
crystall-punk-14/Content.Shared/Chemistry/SolutionVisuals.cs
2022-01-31 03:34:48 +11:00

49 lines
1.4 KiB
C#

using System;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
namespace Content.Shared.Chemistry
{
[Serializable, NetSerializable]
public enum SolutionContainerVisuals : byte
{
VisualState
}
[Serializable, NetSerializable]
public class SolutionContainerVisualState : ICloneable
{
public readonly Color Color;
/// <summary>
/// Represents how full the container is, as a fraction equivalent to <see cref="FilledVolumeFraction"/>/<see cref="byte.MaxValue"/>.
/// </summary>
public readonly byte FilledVolumeFraction;
// do we really need this just to save three bytes?
public float FilledVolumePercent => (float) FilledVolumeFraction / byte.MaxValue;
/// <summary>
/// Sets the solution state of a container.
/// </summary>
/// <param name="color"></param>
/// <param name="filledVolumeFraction">The fraction of the container's volume that is filled.</param>
public SolutionContainerVisualState(Color color, float filledVolumeFraction)
{
Color = color;
FilledVolumeFraction = (byte) (byte.MaxValue * filledVolumeFraction);
}
public object Clone()
{
return new SolutionContainerVisualState(Color, FilledVolumeFraction);
}
}
public enum SolutionContainerLayers : byte
{
Fill,
Base
}
}