APC & SMES appearances. (#78)

* CEV-Eris SMES sprite as RSI.

Has been modified so that the light overlay states use alpha blending.

* Add tiny glow to SMES display sprite.

* Appearances work v2

* More WiP

* RoundToLevels works correctly on even level counts now.

* SMES -> Smes because MS guidelines.

* CEV-Eris APC sprite.

* APC visuals.

* Reduce SMES scale again to normal levels.

* Update submodule
This commit is contained in:
Pieter-Jan Briers
2018-07-17 11:39:55 +02:00
committed by GitHub
parent 7629d447aa
commit ad5c82fec9
69 changed files with 1253 additions and 29 deletions

View File

@@ -67,6 +67,7 @@
<Compile Include="GameObjects\Components\Inventory\EquipmentSlotDefinitions.cs" />
<Compile Include="GameObjects\Components\Inventory\InventoryTemplates.cs" />
<Compile Include="GameObjects\Components\Inventory\SharedInventoryComponent.cs" />
<Compile Include="GameObjects\Components\Power\PowerShared.cs" />
<Compile Include="GameObjects\Components\Storage\SharedStorageComponent.cs" />
<Compile Include="GameObjects\ContentNetIDs.cs" />
<Compile Include="GameObjects\PhysicalConstants.cs" />
@@ -100,6 +101,9 @@
<None Include="app.config" />
<None Include="packages.config" />
<Compile Include="Input\ContentKeyFunctions.cs" />
<Compile Include="Utility\ContentHelpers.cs" />
<Compile Include="GameObjects\Components\Power\SharedSmesComponent.cs" />
<Compile Include="GameObjects\Components\Power\SharedApcComponent.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SS14.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Power
{
[Serializable, NetSerializable]
public enum ChargeState
{
Still,
Charging,
Discharging,
}
}

View File

@@ -0,0 +1,30 @@
using System;
using SS14.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Power
{
[Serializable, NetSerializable]
public enum ApcVisuals
{
ChargeState
}
[Serializable, NetSerializable]
public enum ApcChargeState
{
/// <summary>
/// APC does not have enough power to charge cell (if necessary) and keep powering the area.
/// </summary>
Lack,
/// <summary>
/// APC is not full but has enough power.
/// </summary>
Charging,
/// <summary>
/// APC battery is full and has enough power.
/// </summary>
Full,
}
}

View File

@@ -0,0 +1,16 @@
using SS14.Shared.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Content.Shared.GameObjects.Components.Power
{
[Serializable, NetSerializable]
public enum SmesVisuals
{
LastChargeState,
LastChargeLevel,
}
}

View File

@@ -0,0 +1,60 @@
using System;
namespace Content.Shared.Utility
{
public static class ContentHelpers
{
/// <summary>
/// Assigns the value <paramref name="actual" /> going from 0 to <paramref name="max" />
/// such that it is divided into a set of (amount <paramref name="levels" />) "levels".
/// Rounding is performed to the "middle" so that the highest and lowest levels are only assigned
/// if <paramref name="actual" /> is exactly <paramref name="max" /> or 0.
/// </summary>
/// <example>
/// Say you have a progress bar going from 0 -> 100 inclusive and you want to map this to 6 sprite states (0, 4 intermediates and full).
/// This method allows you to easily map this progress bar to the sprite states.
/// </example>
/// <param name="levels">The amount of levels to subdivide into.</param>
/// <returns>An integer from 0 to <paramref name="levels" />-1.</returns>
/// <exception cref="ArgumentException">
/// Thrown if levels is less than 1.
/// </exception>
public static int RoundToLevels(double actual, double max, int levels)
{
if (levels <= 0)
{
throw new ArgumentException("Levels must be greater than 0.", nameof(levels));
}
if (actual >= max)
{
return levels - 1;
}
if (actual <= 0)
{
return 0;
}
var toOne = actual / max;
double threshold;
if (levels % 2 == 0)
{
// Basically, if we have an even count of levels, there's no exact "mid point".
// Thus, I nominate the first one below the 50% mark.
threshold = ((levels / 2f) - 1) / (levels - 1);
}
else
{
threshold = 0.5f;
}
var preround = toOne * (levels - 1);
if (toOne <= threshold)
{
return (int)Math.Ceiling(preround);
}
else
{
return (int)Math.Floor(preround);
}
}
}
}